Re: [xsl] Re: Forcing namespaces to root element of output XML

Subject: Re: [xsl] Re: Forcing namespaces to root element of output XML
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 20 Jul 2005 14:32:51 +0100
[removing xalan-j-users@xxxxxxxxxxxxxx from CC]

> Unfortunately XSLT 1.0 doesn't have anything like an <xsl:namespace>
> directive. The standard workarounds are to generate unnecessary attributes
> in the desired namespaces to force their declaration (not acceptable for
> many users), or to build a node in a Result Tree Fragment which uses the
> namespace, then xsl:copy the namespace node off that RTF to put it where
> you want it (obscure and a bit ugly, but pretty much a standardized
> solution). XSLT 2.0 has promised to make this easier.

You only need to do this though if the namespace is not known at the
time the stylesheet is written. If it is a fixed namespace known in the
stylesheet you don't need the (missing) xsl:namespace functionality,
just declare the namespace (eg on xsl: stylesheet) and then use a
literal result element rather than xsl:element to generate the top level
element. A common reason for wanting to use xsl:element rather than a
literal result element is to stop this namespace copying in cases where
you don't want the namespace in the result.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread