「ステップ」親の「パフォーマンス」属性に基づいて、段落にテキストを追加しようとしています。
ステップが 'performance="optional"' とマークされている場合、結果のテキスト (以下の 2 番目のステップ) は次のようになります。
「2. (オプション) これはステップ 2 です...」
<procedure>
<step id="step_lkq_c1l_5j">
<para>This is step 1, which is required.</para>
</step>
<step performance="optional">
<para>This is step 2, which is optional, unlike <xref linkend="step_lkq_c1l_5j"/>.
<note>
<para>I don't want to lose this note in my transformation.</para>
</note>
</para>
</step>
<step>
<para>This is step 3.</para>
</step>
</procedure>
Xpath を使用してノードを一致させ、それを変更しようとしました。<xsl:template match="step[@performance='optional']/child::para[position()=1]">
次に、concat() を使用して Optional テキストを追加しようとしましたが、xref リンクが失われます (おそらく、concat() が子と属性を尊重しないためですか?)
次の xsl カスタマイズを使用して、必要なものに少し近づいていますが、(オプションの) テキストが段落の外側にあるため、ステップ テキストが 1 行下にドロップされ、ページ コンテンツで中断されることがあります。私が本当に欲しいのは、生成されたテキストが最初の段落内にあることです。
誰か提案がありますか?
<!-- Add "(Optional) " to steps that have the performance="optional" attribute set -->
<xsl:template match="procedure/step|substeps/step">
<xsl:variable name="id">
<xsl:call-template name="object.id"/>
</xsl:variable>
<xsl:variable name="keep.together">
<xsl:call-template name="pi.dbfo_keep-together"/>
</xsl:variable>
<fo:list-item xsl:use-attribute-sets="list.item.spacing">
<xsl:if test="$keep.together != ''">
<xsl:attribute name="keep-together.within-column"><xsl:value-of
select="$keep.together"/></xsl:attribute>
</xsl:if>
<fo:list-item-label end-indent="label-end()">
<fo:block id="{$id}">
<!-- dwc: fix for one step procedures. Use a bullet if there's no step 2 -->
<xsl:choose>
<xsl:when test="count(../step) = 1">
<xsl:text>•</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="number">
<xsl:with-param name="recursive" select="0"/>
</xsl:apply-templates>.
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:list-item-label>
<xsl:choose>
<xsl:when test="@performance='optional'">
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:text>(Optional) </xsl:text>
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</xsl:when>
<xsl:otherwise>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</xsl:otherwise>
</xsl:choose>
</fo:list-item>
</xsl:template>