From: Mukul Gandhi [mailto:gandhi(_dot_)mukul(_at_)gmail(_dot_)com]
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(_at_)saxonica(_dot_)com]
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--