I require as final output an XML file without any use of
namespaces. The input data does make use of namespaces,
although this is part of a multiple pass operation and I have
elements which don't use namespaces by this stage. I wish to
copy some of these elements without changing them
But you just said you did want to change them - you want to remove the
namespaces! xsl:copy-of can only create an exact copy. For anything
else, you need to do a recursive application of a template rule that
makes the necessary changes to each element.
To copy an element without copying its namespaces, you need to use
xsl:element name="local-name()".
XSLT 2.0 has an option copy-namespaces on xsl:copy-of which may do what
you want.
The exclude-result-prefixes only suppresses copying of namespaces from
the stylesheet, not from the source document.
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
, and have
tried, for example
<xsl:template match="Attribute">
<xsl:copy-of select="current()"/>
</xsl:template>
The template copies the elements as required, except that I
get spurious namespace declarations such as
"xmlns:gml="http://www.opengis.net/gml" in the output (as
attributes on the "Attribute" output element), even though
the xsl:stylesheet specifically excludes them (using
exclude-result-prefixes). How do I get rid of them? My
guess is that, since I'm trying to copy an element without a
namespace it is assuming that any could apply, but in this
case none do (the output uses a DTD). I also get namespace
declarations from the input file, not mentioned by the style
sheet, and I wish to exclude these as well, without making
the stylesheet depend upon these.
Thank you,
Tim Wilkins
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list