currently I have an XML document where the root node has 2 namespaces listed something like this
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns = "www.ns1.com"
xmlns:ns2 = "www.ns2.com">
<node1>
<node2 addy1="something">value</node2>
</node1>
</Document>
my current transformation looks like this
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()">
<xsl:copy>
<xsl:copy-of select="@addy1"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The resulting xml is almost perfect except I would like to exclude xmlns:ns2 from the Document element (xmlns is fine) What do i need to add to get copy just the default namespace with Document, but not xmlns2
答案 0 :(得分:3)
Use
<xsl:template match="node()">
<xsl:copy copy-namespaces="no">
<xsl:copy-of select="@addy1"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>