I've seen similar questions, but it is still unclear to me. I don't want the "n1" namespace to appear in the attribute of the node in the output file. But I had to create the "n1" namespace in the xslt file in order to get xpath to work. Thank you.
我见过类似的问题,但我现在还不清楚。我不希望“n1”命名空间出现在输出文件中节点的属性中。但我必须在xslt文件中创建“n1”命名空间才能使xpath正常工作。谢谢。
XSLT:
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>
EXCERPT FROM OUTPUT XML FILE:
从OUTPUT XML文件中获取:
<object type="mytype2" xmlns:n1="http://www.spicefactory.org/parsley">
1 个解决方案
#1
14
Use exclude-result-prefixes
attribute on <xsl:stylesheet>
element.
在
<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"
exclude-result-prefixes="n1"
>
#1
14
Use exclude-result-prefixes
attribute on <xsl:stylesheet>
element.
在
<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"
exclude-result-prefixes="n1"
>