RE: [xsl] Problem: namespace declaration in output document

Subject: RE: [xsl] Problem: namespace declaration in output document
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 26 Sep 2001 12:32:49 +0100
> Now, I have
> the following problem with the namespace declaration:
> The wsdl document must look like this:
> <definitions name="xyz" targetNamespace="xyz" xmlns:tns="X">
> ...
> </definitions>
> where X is the name of the created wsdl document.

There are two ways to get a namespace declaration in the result document:
(a) output an element or attribute that relies on this namespace declaration
(b) copy a namespace node from the source document or the stylesheet

If you can put up with dummy attributes in the output, the simplest solution
is to rely on (a):

<xsl:attribute name="dummy" namespace="{-- your namespace here-- }"/>

If not, you have to fall back on (b), which relies on using <xsl:copy> on
namespace nodes, a feature which is defined only in the XSLT 1.0 errata and
may therefore not work with all processors. Also, if the namespace is
generated dynamically form the stylesheet, you need to use the xx:node-set()
extension function:

<xsl:variable name="rtf">
  <xsl:element name="my:dummy" namespace="{-- your namespace here-- }"/>

  <xsl:copy select="xx:node-set($rtf)/*/namespace::my"/>
  <xsl:attribute name="name">xyz</xsl:attribute>


Mike Kay

 XSL-List info and archive:

Current Thread