RE: [xsl] namespace declaration when generating a stylesheet

Subject: RE: [xsl] namespace declaration when generating a stylesheet
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 27 Jul 2001 12:55:51 +0100
> I am transforming the xml document into a stylesheet via
> another stylesheet.
>
>
> The result stylesheet needs any namespace declarations that
> were in the
> source (where they will be needed).
>
> How do I get them there (using XSLT)? I am stumped.
>

Namespace nodes from the source document will be copied into the result
document when you copy an element that owns such a namespace node; they will
also be generated if you create an element or attribute that refers to the
namespace.

Apart from that, the only way to get a namespace node into the result
document is to do an <xsl:copy[-of]> on a namespace node (and even then,
only if the XSLT processor implements the latest XSLT errata). One technique
is to create a result tree fragment containing the namespace node, and copy
it from there:

<xsl:variable name="rtf">
  <xsl:element name="dummy" namespace="{$required-namespace}"/>
</xsl:variable>
<xsl:copy-of
select="xx:node-set($rtf)/dummy/namespace::*[.=$required-namespace]"/>

Mike Kay
Software AG


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread