【发布时间】:2011-02-11 20:16:28
【问题描述】:
我见过类似的问题,但我仍然不清楚。我不希望“n1”命名空间出现在输出文件中节点的属性中。但我必须在 xslt 文件中创建“n1”命名空间才能使 xpath 工作。谢谢。
XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:n1="http://www.spicefactory.org/parsley"
xmlns="http://www.spicefactory.org/parsley"
>
<xsl:output method="xml" indent="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="n1:object[@type='mytype1']">
<object type="mytype2">
<xsl:apply-templates select="node()"/>
</object>
</xsl:template>
输出 XML 文件的摘录:
<object type="mytype2" xmlns:n1="http://www.spicefactory.org/parsley">
【问题讨论】:
标签: xml xslt xml-namespaces