9
我想在XSLT 1.0中重写这个xslt,它不支持“copy-namespaces”。如何在XSLT 1.0中模仿copy-namespaces =“no”?
<xsl:copy-of copy-namespaces="no" select="maml:alertSet/maml:alert" />
怎么样?
我想在XSLT 1.0中重写这个xslt,它不支持“copy-namespaces”。如何在XSLT 1.0中模仿copy-namespaces =“no”?
<xsl:copy-of copy-namespaces="no" select="maml:alertSet/maml:alert" />
怎么样?
以下模仿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"/>
您的递归模板无法正确运行属性。现在它将该属性复制到包含元素中,但它也将该属性的值作为文本复制。您需要将' '更改为' '(放下'@ *') –
2012-12-14 12:22:15