我想用xslt 1.0重写这段XSLT,它不支持"copy-namespaces“。
<xsl:copy-of copy-namespaces="no" select="maml:alertSet/maml:alert" />多么?
发布于 2012-01-27 16:50:34
下面的代码模拟了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"/>https://stackoverflow.com/questions/9026224
复制相似问题