Я пытаюсь добавить некоторый текст в абзац на основе атрибута «производительность» его родителя «шаг».
Если шаг помечен как «performance = «необязательный», я бы хотел, чтобы результирующий текст (для второго шага ниже) выглядел так:
"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(), чтобы попытаться добавить мой необязательный текст, но я потерял бы ссылку xref (возможно, потому, что concat() не учитывает дочерние элементы и атрибуты?)
Я приблизился к тому, что хочу, используя следующую настройку xsl, но (необязательный) текст находится за пределами абзаца, и это опускает текст шага вниз по строке и иногда разрывается с содержимым страницы. Я действительно хочу, чтобы сгенерированный текст находился внутри первого абзаца.
У кого-нибудь есть предложение?
<!-- 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>
para
элементам? - person Tim C   schedule 09.04.2013