RE: [xsl] adding attributes to an existing element

Subject: RE: [xsl] adding attributes to an existing element
From: Nirmala R <nirmala.r@xxxxxxxxxx>
Date: Sat, 19 Oct 2002 13:10:13 +0530
Incase if you want to get the same xml just with a new attribute added, you
can just
add the following:

<xsl:template match="/db/*">
    <xsl:copy>
       <xsl:copy-of select="@*"/>
       <xsl:attribute name="newattribute">newAttributeValue</xsl:attribute>
	 <xsl:value-of select="."/>  <------- Added.
    </xsl:copy>
</xsl:template>

Regards,
Nirmala

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Joerg
Heinicke
Sent: Tuesday, October 15, 2002 9:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] adding attributes to an existing element


<xsl:template match="/db/*">
    <xsl:copy>
       <xsl:copy-of select="@*"/>
       <xsl:attribute name="newattribute">newAttributeValue</xsl:attribute>
    </xsl:copy>
</xsl:template>

Regards,

Joerg

Saverio Perugini wrote:
> On Tue, 15 Oct 2002, Jeni Tennison wrote:
>
>
>>Try copying the existing attributes with xsl:copy-of. Something like:
>>
>><xsl:template match="name">
>>  <name number="20">
>>    <xsl:copy-of select="@*" />
>>  </name>
>></xsl:template>
>
>
> Thanks.  However, can this solution be used if I do not know the
> element name (in this case, `name') a-priori?
>
> For example, if I'd like to do this in:
>
> <xsl:template match="/db/*">
>    ...
> </xsl:template>
>
> Best,
>
> S. Perugini

--

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@xxxxxxxxx
www.virbus.de

VIRBUS hat jetzt als erster deutscher Softwarehersteller die Zertifizierung
für den 3D Secure-Authentifizierungsstandard "Verified by Visa" erhalten.
Details unter
http://www.virbus.de/de/press/pressemitteilung/20020828_verified_by_VISA.


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

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


Current Thread