Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] XSLT2.0 compatibility

From: "Lin, Jessica" <jlin@----------->
To:
Date: 9/5/2006 4:32:00 PM
>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
the
>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
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?


<?xml version="1.0" encoding="UTF-8"?>
<template>
  <boot_object name="bo1">
     <boot_object_header>
	  <object_id>1</object_id>
     </boot_object_header>
     <boot_object_body>
	  <source_id>100</source_id>
	  <reserved1>255</reserved1>
	  <reserved2>15</reserved2>
     </boot_object_body>
  </boot_object>
</template>



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

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

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

    </advanced_boot_object>
  </xsl:template>

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

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





Thanks,
Jessica


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent