【发布时间】:2012-12-31 06:52:36
【问题描述】:
我需要从信封中提取 XML。但我无法获得预期的输出。 我需要摆脱输出中的命名空间。
我的意见:
<ns1:input xmlns:ns1="http://mysapmle.org/" xmlns="http://othersample.org/">
<sample>
<inner tc="5">Test</inner>
<routine>Always</routine>
</sample>
</ns1:input>
我的预期输出:
<sample>
<inner tc="5">Test</inner>
<routine>Always</routine>
</sample>
我的实际输出:
<sample xmlns="http://othersample.org/">
<inner tc="5">Test</inner>
<routine>Always</routine>
</sample>
我的 XSLT:
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="//sample" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
请帮忙。
【问题讨论】:
-
这是剥离标签,而不仅仅是“删除命名空间”。
-
就是这样。我需要将此提取的 XML 作为另一个 XML 的一部分包含在内。这就是为什么我不能拥有命名空间。
标签: xslt namespaces transform xml-namespaces