[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl templates, Removing spurious namespace declara

Subject: RE: xsl templates, Removing spurious namespace declarations in output elements
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 9 Apr 2003 20:42:05 +0100
xsl copy of remove namespace
> 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.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


, 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.