我想在 XSLT 1.0 中重写这个 xslt 片段,它不支持“复制命名空间”。
<xsl:copy-of copy-namespaces="no" select="maml:alertSet/maml:alert" />
How?
以下模仿 XSLT 2.0 构造:
在无需命名空间的情况下重新构建节点的模式中创建模板:
<!-- generate a new element in the same namespace as the matched element,
copying its attributes, but without copying its unused namespace nodes,
then continue processing content in the "copy-no-namepaces" mode -->
<xsl:template match="*" mode="copy-no-namespaces">
<xsl:element name="{local-name()}" namespace="{namespace-uri()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()" mode="copy-no-namespaces"/>
</xsl:element>
</xsl:template>
<xsl:template match="comment()| processing-instruction()" mode="copy-no-namespaces">
<xsl:copy/>
</xsl:template>
在该模式下应用所需元素的模板:
<xsl:apply-templates select="maml:alertSet/maml:alert" mode="copy-no-namespaces"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)