【发布时间】:2009-10-09 09:25:51
【问题描述】:
我有一个带有元素的段落的引用类型。
例子
输入文件:
<reference>
<emph type="bold">Antony</emph><emph type="bold">,</emph> <emph type="bold">R.</emph>
<emph type="bold">and</emph> <emph type="bold">Micheal</emph><emph type="bold">,</emph> <emph type="bold">V.</emph>
<emph type="italic">reference title</emph></reference>
现在收到的输出:
<p class="reference"><strong>Antony</strong><strong>,</strong> <strong>R.</strong>
<strong>and</strong> <strong>Micheal</strong><strong>,</emph>
<emph type="bold">V.</strong> <em>reference title></em></p>
所需的输出文件:
<p class="reference"><strong>Antony, R. and Micheal, V.</strong> <em>reference title</em></p>
我的 xslt 脚本:
<xsl:template match="reference">
<p class="reference"><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="emph">
<xsl:if test="@type='bold'">
<strong><xsl:apply-templates/></strong>
</xsl:if>
<xsl:if test="@type='italic'">
<em><xsl:apply-templates/></em>
</xsl:if>
</xsl:template>
需要在 xslt 中更正哪些内容才能像所需的输出文件一样一次性获得 <strong> 元素?
请给任何人建议..
由, 蚂蚁。
【问题讨论】:
-
您有幸使用 XSLT 2.0 吗?如果是这样,请使用
和 group-adjacent。否则,它会更棘手但可能。 -
我的问题是为什么输入文件通过多个
节点而不是一个 围绕你想要加粗的整个字符串?