正如您在评论中被告知的那样,对于纯 XSLT,这主要在 XSLT 3 中使用
parse-xml
函数和 serialize
函数是可行的:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
exclude-result-prefixes="#all"
version="3.0">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:output cdata-section-elements="rule"/>
<xsl:template match="rule">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:variable name="transformed">
<xsl:apply-templates select="parse-xml(.)"/>
</xsl:variable>
<xsl:value-of select="serialize($transformed)"/>
</xsl:copy>
</xsl:template>
<xsl:template match="sch:rule[ends-with(@context, 'GenericFailureAnnouncementName')]"/>
</xsl:stylesheet>
使用早期版本的 XSLT,您需要检查处理器是否公开扩展函数或允许您调用底层平台以实现
parse-xml
和 serialize
功能。