RE: [xsl] Generating a namespace declaration

Subject: RE: [xsl] Generating a namespace declaration
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 1 Dec 2003 12:44:09 -0000
> using <xsl:element>, is it possible to declare a namespace 
> prefix. I tried specifying "xmlns:myns" as an attribute ( 
> <xsl:attribute> ), but the processor complained.
> 
> I d rather not use any extensions.
> 
> Do I have to resort to LREs for this.
> 

If the namespace you want to declare is actually used by the element
name or by one of its attributes, then you can use the namespace
attribute of <xsl:element> or <xsl:attribute> to create the node in the
right namespace, and the namespace declarations will be added
automatically by the serializer.

If you want to add a namespace node that isn't used in any element or
attribute name it's a bit trickier. XSLT 2.0 allows you to do it with an
xsl:namespace instruction. In XSLT 1.0, the only way is to copy a
namespace node (using <xsl:copy>) either from the source document or
from a temporary tree.

Michael Kay


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


Current Thread