xsl-list
[Top] [All Lists]

RE: adding attributes to an existing element

2002-10-19 00:40:13
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(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]On Behalf Of 
Joerg
Heinicke
Sent: Tuesday, October 15, 2002 9:24 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_dot_)heinicke(_at_)virbus(_dot_)de
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