RE: [xsl] Generating an XSD: namespace difficulty

Subject: RE: [xsl] Generating an XSD: namespace difficulty
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 25 Mar 2005 11:32:20 -0000
> I can't figure out how to get the declaration of such a 
> prefix into the
> xs:schema result element since both the prefix and the URI to which it
> refers are unknown until runtime.


The xsl:namespace instruction was added in XSLT 2.0 for this purpose. It
allows you to create a namespace node with a prefix and uri, just as you
would use xsl:attribute to create an attribute node.

The only way to achieve the same effect in XSLT 1.0 is a workaround: create
a result tree fragment containing an element in the relevant namespace, and
then copy the resulting namespace node:

<xsl:variable name="temp">
  <xsl:element name="{concat($prefix, ':dummy')}" namespace="{$uri}"/>
</xsl:variable>

<xsl:copy-of select="xx:node-set($temp)//namespace::*[name()=$prefix]"/>

Michael Kay
http://www.saxonica.com/

Current Thread