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

changing only one attribute of element copy

Subject: changing only one attribute of element copy
From: Garvin Riensche <g.riensche@xxxxxxx>
Date: Wed, 04 Jul 2007 19:39:36 +0200
 changing only one attribute of element copy
Hello,

It would be nice if someone could tell me the easiest way of changing just one (and keeping the other) attributes of an copied element.

I am using the following templates to copy elements from a source class to a target class:

<xsl:template match="node() | @*" mode="transform">
  <xsl:copy>
    <xsl:apply-templates select="node() | @*" mode="transform"/>
  </xsl:copy>
</xsl:template>
	
<xsl:template match="//class[@name=$TargetCName]" mode="transform">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:copy-of select="//class[@name=$SrcCName]/field">
    <xsl:apply-templates mode="transform"/>
  </xsl:copy>
</xsl:template>

Inside "class" are elements like
<field id="31" class="3" type="type(basic,int,0)" name="publ_int_j" init="null"/>
which are going to be copied.


What, if I want to change the "id" of the copied element? (Suppose, I don't know that the element name is "field") Do I have to create a completely new element using <xsl:element> and to write down every single attribute explicitely using <xsl:attribute>? Or is there a possibility to copy the old attributes und to create just one new attribute?
My problem is, that <xsl:copy-of> doesn't allow <xsl:attribute> inside and <xsl:copy> which allows it doesn't allow a "select" inside...


Regards,
Garvin

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.