RE: [xsl] XSLT2.0 compatibility

Subject: RE: [xsl] XSLT2.0 compatibility
From: "Lin, Jessica" <jlin@xxxxxxxxxxx>
Date: Tue, 5 Sep 2006 09:31:39 -0700
>From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx]

>You must follow this pattern, while creating elements and attributes:

>Create element (a)
>   Create element a's attributes
>Create any child elements

>It is quite obvious, you cannot create child elements before creating
>parent element's (here a) attributes.

>From: Michael Kay [mailto:mike@xxxxxxxxxxxx]

>Can't help you find what's wrong with your stylesheet without seeing
>stylesheet, I'm afraid.

I do follow the pattern of creating parent node and attributes first and
creating child nodes next. Here is my xml and xslt files. My xml
transform will change names of boot_object, boot_object_header and
boot_object_body to names start with "advanced". (I also need to
transform name and values of children nodes of boot_object_header and
boot_object_body. That part I omit here to focus on the problem.) If I
define xml:space="preserve" in the template, the xslt processor will say
the attribute copy is wrong. The error message is like the following:

"Error at xsl:copy-of on line 13 of
  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?

<?xml version="1.0" encoding="UTF-8"?>
  <boot_object name="bo1">

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

  <xsl:template match="/ | node() | @* | comment() | processin
	 <xsl:apply-templates select="@* | node()"/>

  <xsl:template match="boot_object" xml:space="preserve">
	<!-- The error line is below-->
	<xsl:copy-of select="@*"/>
	<xsl:apply-templates select="boot_object_header"/>
	<xsl:apply-templates select="boot_object_body" />


  <xsl:template match="boot_object_header">
	  <xsl:apply-templates select="node()"/>

  <xsl:template match="boot_object_body">
	 <xsl:apply-templates select="node()"/>


Current Thread