|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl: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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








