xsl-list
[Top] [All Lists]

Re: Re: Forcing namespaces to root element of output XML

2005-07-20 06:32:51

[removing xalan-j-users(_at_)xml(_dot_)apache(_dot_)org 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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>