[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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:
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...
[xsl] changing only one attribute of element copy
Subject: [xsl] changing only one attribute of element copy From: Garvin Riensche <g.riensche@xxxxxxx> Date: Wed, 04 Jul 2007 19:39:36 +0200 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Cross-browser exsl:node-set, , M. David Peterson | Thread | Re: [xsl] changing only one attribu, David Carlisle |
[xsl] accessing a node-set in varia, Sam Carleton | Date | [xsl] Removing an XML Attribute, McDonald, Shaun |
Month |