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

RE: xsl:element in XSLT 1.0

Subject: RE: xsl:element in XSLT 1.0
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 22 Jun 2005 23:06:39 +0100
element in xslt 1.0
> 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.

Don't try to apply reasoning based on what seems "reasonable": you've got to
read what the spec says.

The spec says that in the result tree, <child> has a namespace node (a=bar),
and <foo> does not. However, the XSLT 1.0 spec gives the serializer free
rein to add namespace declarations anywhere it likes. So both outputs are
conformant.

In 2.0, the serializer has much less freedom of action, and the first output
would be wrong.

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

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.