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

Re: Copy element with attributes

Subject: Re: Copy element with attributes
From: "Diogo Vascocelos" <dgvascon@xxxxxxxxxxx>
Date: Tue, 29 Nov 2005 15:52:45 +0000
xsl copy element
Thanks, you pointed it out to me:

<xsl:template match="body/@text">
<xsl:attribute name="text">#000000</xsl:attribute>
</xsl:template>

<xsl:template match="body">
<xsl:copy>
<xsl:apply-templates select="@*"/><! -- this was failing me -->
Prepend
<xsl:apply-templates/>
Append
</xsl:copy>
</xsl:template>





From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Copy element with attributes
Date: Tue, 29 Nov 2005 14:25:13 +0100

Hi Diogo,

> The xslt I use:
>
> <xsl:template match="body">
> <xsl:copy>
> Prepend text
> <xsl:apply-templates/>
> Append text
> </xsl:copy>
> </xsl:template>
>
> removes body tag attributes. How can
> I copy the body tag attributes at the
> same time, so I can use something like:
>
> <xsl:template match="body/@text">
> <xsl:attribute name="text">#000000</xsl:attribute>
> </xsl:template>
>
> to change attributes.

I am not sure quite what you want.
If you want to copy the attributes as is, you should do something like:
<xsl:copy>
<xsl:copy-of select="@*"/>
Prepend text
<xsl:apply-templates/>
...

If you want to do something with the attributes, you should perhaps do
something like:
<xsl:copy>
<xsl:apply-templates select="@*"/>
...

Or you can do something like:
<xsl:copy>
<xsl:for-each select="@*">
<xsl:attribute name="name()"><!-- Do something here --></xsl:attribute>
</xsl:for-each>
Prepend text
...

I do not know if this is what you want.

Regards,
Ragulf Pickaxe :-)


_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


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.