dt1*_*000 7 xml xslt xml-namespaces
我见过类似的问题,但我还不清楚.我不希望"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>
Run Code Online (Sandbox Code Playgroud)
从OUTPUT XML文件中获取:
<object type="mytype2" xmlns:n1="http://www.spicefactory.org/parsley">
Run Code Online (Sandbox Code Playgroud)
jas*_*sso 16
exclude-result-prefixes在<xsl:stylesheet>元素上使用属性.
<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"
>
Run Code Online (Sandbox Code Playgroud)