xsl-list
[Top] [All Lists]

RE: xsl:element in XSLT 1.0

2005-06-22 15:06:39

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/




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>