[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: suprised by <xsl:copy-of select="@*"/>

Subject: RE: suprised by <xsl:copy-of select="@*"/>
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Tue, 7 Aug 2001 09:48:35 +0100
xsl copy of select
> I was suprised that this template:
>
> <xsl:template match="cell">
>     <td>
>         <xsl:copy-of select="@*"/>
>         <xsl:apply-templates/>
>     </td>
> </xsl:template>
>
> against this XML:
>
> <cell colspan="2" bgcolor="#CC0000">
>    some other stuff...
> </cell>
>
> produced this output:
>
> <td colspan="2" bgcolor="#CC0000">
>     result of transform on other stuff...
> </td>
>
> Why did I get
> <td colspan="2" bgcolor="#CC0000">
> instead of
> <td>colspan="2" bgcolor="#CC0000"

Basically, because <xsl:copy-of seelct="@*"/> creates attribute nodes onthe
result tree, and your the output [<td>colspan="2" bgcolor="#CC0000"] could
never be produced by serializing attribute nodes.

<td>.....</td>, after parsing, becomes an element node on the stylesheet
tree. This element node acts as a special kind of instruction, called a
literal result element. When a literal result element is "instantiated"
(i.e. executed) it creates an element node on the result tree, and then
instantiates the instructions that are children of the literal result
element in the stylesheet tree. The first such instruction is <xsl:copy-of>,
and this creates attribute nodes which are added to the "current" element
node on the result tree.

I spelt this out laboriously, because I suspect you aren't really thinking
of the process in terms of nodes on trees, but this is essential to
understanding the behavior.

Mike Kay
Software AG


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.