我有一些像这样的 XML:
<subsection number="5">
<p>
(5) The <link path="123">Secretary of State</link> shall appoint such as....
</p>
</subsection>
我无法更改 XML,我需要去掉段落开头的 (5),并使用父标记中的 number 属性创建一个带有适当标记的新段落编号:
<xsl:template match="subsection/p">
<xsl:variable name="number">
<xsl:text>(</xsl:text>
<xsl:value-of select="../@number"/>
<xsl:text>)</xsl:text>
</xsl:variable>
<xsl:variable name="copy">
<xsl:value-of select="."/>
</xsl:variable>
<p>
<span class="indent">
<xsl:value-of select="$number" />
</span>
<span class="copy">
<xsl:value-of select="substring-after($copy, $number)" />
</span>
</p>
</xsl:template>
问题是段落的其余部分可能包含更多需要转换的 XML,例如示例中的链接标记。
一旦我使用了 substring-after 函数,我不知道如何将模板应用于此。