Subject: RE: [xsl] xsl:element in XSLT 1.0 From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 22 Jun 2005 23:06:39 +0100 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:element in XSLT 1.0, Jack Matheson | Thread | [xsl] XSLT2 grouping over multiple , Thomas J. Sebestyen |
RE: [xsl] Re: xsl-list Digest 22 Ju, Michael Kay | Date | Re: [xsl] xsl:element in XSLT 1.0, Jack Matheson |
Month |