RE: [xsl] XSLT2.0 compatibility

Subject: RE: [xsl] XSLT2.0 compatibility
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 5 Sep 2006 17:59:38 +0100
> "Error at xsl:copy-of on line 13 of
> file:///C:/trex-dev/Trunk/Projects/BFW/bde.bfw.core/resources/
> trans3.xsl
> t:
>   XTDE0410: An attribute node (name) cannot be created after 
> the children of the containing element
> ** Transformation error"
> 
> 
> If I remove xml:space="preserve", everything is fine. Can you 
> tell me what's wrong?
> 

If you use xml:space="preserve" (either in the stylesheet or the source
document) then it's very easy unwittingly to copy a whitespace text node to
the result document before creating an attribute. For example

<x xml:space="preserve">
  <xsl:attribute name="x"/>
</x>

creates an element X with four nodes in its content sequence: an attribute
called xml:space, a whitespace text node, an attribute called x, and another
whitespace text node.

I can't think of any good reason to use xml:space="preserve" in a
stylesheet.

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

Current Thread