[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl:element in XSLT 1.0

Subject: xsl:element in XSLT 1.0
From: Jack Matheson <jack@xxxxxxxxxxxxxx>
Date: Wed, 22 Jun 2005 15:42:17 -0500
jack matheson
This is sort of a fuzzy area in the spec, so any help would be appreciated.

When an xsl:element contains namespace declarations outside of the 'namespace' AVT, when should those namespace declarations be inserted into the result tree?

Here is an example of my problem:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="*">
<out>
<xsl:element name="foo" xmlns:a="bar">
<child/>
</xsl:element>
</out>
</xsl:template>
</xsl:stylesheet>


Xalan produces this:

<out><foo xmlns:a="bar"><child/></foo></out>

While Saxon produces this:

<out><foo><child xmlns:a="bar"/></foo></out>

Honestly, I can see both of these outputs being reasonable. In Xalan's defense, if 'foo' were simply a literal result element in the stylesheet, the declaration would be part of 'foo'. In Saxon's defense, the 'bar' namespace is declared on an element only used in the stylesheet, and therefore it does not apply to element results until 'child' is inserted into the result tree.

However, if I modify the stylesheet slightly...

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="*">
<out>
<xsl:element name="a:foo" xmlns:a="bar">
<child/>
</xsl:element>
</out>
</xsl:template>
</xsl:stylesheet>


Xalan and Saxon both produces this:

<out><a:foo xmlns:a="bar"><child/></a:foo></out>

Clearly the 'bar' namespace belongs on the 'a:foo' result element., but this begs the question: How can this namespace be in scope for 'foo' depending on whether it is used or not?

In any other situation, a namespace enters scope once it is defined, regardless of how it is used.

Can anyone help clear this up?

-Jack Matheson

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.