XSLT - 从文本节点中删除某些字符串
XSLT - Remove certain strings from the text node
我有 xml 如下,
<doc>
<p type="para">.<t/>JMS<s/>
<style type="italic">Bambulla</style>
<s/>2012-13, s. 65 (ad § 3)
</p>
</doc>
我需要的是删除 <p type="para">
之后的 .
。请注意,每次 .
都位于 <p type="para">
和 <t/>
之间。
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[@type='para']">
<p type="para">
<xsl:apply-templates/>
</p>
</xsl:template>
我如何在 xsl 之上扩展以仅删除 .
字符串?
如果添加 <xsl:template match="p[@type='para']/node()[1][self::text() and . = '.' and following-sibling::node()[1][self::t[not(node())]]]"/>
,则 p[@type='para']
的第一个子节点是字符串值为 .
的文本节点,后跟空 t
元素将被删除。
我有 xml 如下,
<doc>
<p type="para">.<t/>JMS<s/>
<style type="italic">Bambulla</style>
<s/>2012-13, s. 65 (ad § 3)
</p>
</doc>
我需要的是删除 <p type="para">
之后的 .
。请注意,每次 .
都位于 <p type="para">
和 <t/>
之间。
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[@type='para']">
<p type="para">
<xsl:apply-templates/>
</p>
</xsl:template>
我如何在 xsl 之上扩展以仅删除 .
字符串?
如果添加 <xsl:template match="p[@type='para']/node()[1][self::text() and . = '.' and following-sibling::node()[1][self::t[not(node())]]]"/>
,则 p[@type='para']
的第一个子节点是字符串值为 .
的文本节点,后跟空 t
元素将被删除。