[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] xsl:element


Subject: Re: [xsl] xsl:element
From: Mike Brown <mike@xxxxxxxx>
Date: Sun, 23 Sep 2001 00:29:43 -0600 (MDT)

Mark Nahabedian wrote:
> So the output element generated by xsl:element will only have those
> namespace attributes that are explicitly specified?

Specifying xmlns on xsl:element won't make a difference.

Remember, the xlmns attributes do not exist in the tree model;
namespace nodes do. You can't create an attribute node named xmlns.

So if you did something like 

<xsl:element name="foo" xmlns="blah">
  <bar/>
</xsl:element>

then you should get

<foo>
  <bar xmlns="blah"/>
</foo>

because all you did when you added the xmlns attribute to xsl:element
was you said that *in the stylesheet* for the *xsl:element* and its
contents, that this namespace was in effect. In the tree model it
looks like

element node: 'element' in ns 'http://www.w3.org/1999/XSL/Transform'
  |  \\___namespace node: 'blah' is the default namespace
  |   \___attribute node: 'name' has value 'foo'
  |
  |___element node: 'bar' in namespace 'blah'
           \___namespace node: 'blah' is the default namespace

which translates to:

(XSLT instruction to create an element named 'foo' in result tree)
  |
  |___(literal result element: copy it to the result tree,
       namespace nodes and all)

thereby causing the result tree to contain:

element node: 'foo'
  |
  |___element node: 'bar' in namespace 'blah'
           \___namespace node: 'blah' is the default namespace

which gets serialized as:

<foo>
  <bar xmlns="blah"/>
</foo>

Does that help?

   - Mike
____________________________________________________________________________
  mike j. brown, fourthought.com  |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  personal: http://hyperreal.org/~mike/

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



Current Thread