I have the following root element of a big XML file:
<Interchange xmlns='http://www.e2b.no/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.e2b.no/XMLSchema Interchange'>
I need to get
<Interchange>
Please advise. Here is a minimal document with the template I'm trying (I won't include my full attempts because they're much longer):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Interchange/@xmlns|@xmlns:xsi|@xsi:schemaLocation"/>
</xsl:stylesheet>
Namespace declarations are not the same as attributes. That's why you cannot exclude them from your identity templates the way you tried it.
Instead, simply match the element and output another
Interchange
that is not "burdened" with the namespaces above:Make sure that you define the required namespace in your XSLT stylesheet as well:
It is irrelevant which prefix (
eb
in this case) is used. But this makes sure that theInterchange
element is found. This is crucial because<Interchange>
and<Interchange xmlns='http://www.e2b.no/XMLSchema'>
are different elements.