如何模仿 copy-namespaces="no"在 XSLT 1.0 中? [英] How to mimic copy-namespaces="no" in XSLT 1.0?
本文介绍了如何模仿 copy-namespaces="no"在 XSLT 1.0 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 XSLT 1.0 中重写这个 xslt 片段,它不支持复制命名空间".
I want to rewrite this xslt piece in XSLT 1.0, which does not support "copy-namespaces".
<xsl:copy-of copy-namespaces="no" select="maml:alertSet/maml:alert" />
怎么样?
推荐答案
以下内容模仿了 XSLT 2.0 结构:
The following mimics the XSLT 2.0 construct:
在没有命名空间的情况下重新构建节点的模式下创建模板:
Create templates in a mode that will re-construct your nodes without namespaces:
<!-- 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>
在该模式下为所需元素应用模板:
Apply-templates for the desired element(s) in that mode:
<xsl:apply-templates select="maml:alertSet/maml:alert" mode="copy-no-namespaces"/>
这篇关于如何模仿 copy-namespaces="no"在 XSLT 1.0 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文