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

Subject: [xsl] Re: Forcing namespaces to root element of output XML
From: Joseph Kesselman <keshlam@xxxxxxxxxx>
Date: Wed, 20 Jul 2005 09:15:08 -0400
Xalan's serializer will normally not re-assert namespace declarations which
are already in scope -- so the simplest fix may be to manually generate
those declarations on your root element, which should then suppress the
lower-level ones.

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.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk

Current Thread