This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to replace the value for an attribute


A method for doing this is using <xsl:attribute> as follows:

=============================================
<xsl:template match="Message">
    <input type="hidden" name="id">
        <xsl:attribute name="value"><xsl:value-of select="@id"/></xsl:attribute>
    </input>
</xsl:template>
=============================================

A bit verbose, but I do this all the time.  Just think of XSLT as
an "assembly language" for tree-walking not a general-purpose
programming language.

-- jack

John R. Callahan, Ph.D.
CTO
Sphere Corporation - The Intelligence of XML
jcallahan@sphere.com
410-480-7301
509-352-1536 (eFax)


----- Original Message ----- 
From: <David_N_Bertoni@lotus.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Tuesday, May 29, 2001 10:27 AM
Subject: Re: [xsl] How to replace the value for an attribute


> 
> It's pretty difficult to guess what you're trying to do with incomplete and
> incorrect XML, but you probably want to use an attribute value template
> (AVT):
> 
> <?xml version="1.0"?>
> <Message id='10' value='one'/>
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version
> ="1.0">
> <xsl:output method="html"/>
> 
> <xsl:template match="Message">
>     <input type="hidden" name="id" value="{@id}"/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> If you need a more generic solution, you will need to use xsl:element and
> xsl:attribute.
> 
> Dave
> 
> 
> 
>                                                                                                                             
>                     "Sri ni"                                                                                                
>                     <srini75@hotmail.com>              To:     xsl-list@lists.mulberrytech.com                              
>                     Sent by:                           cc:     (bcc: David N Bertoni/CAM/Lotus)                             
>                     owner-xsl-list@lists.mulber        Subject:     [xsl] How to replace the value for an attribute         
>                     rytech.com                                                                                              
>                                                                                                                             
>                                                                                                                             
>                     05/29/2001 05:04 AM                                                                                     
>                     Please respond to xsl-list                                                                              
>                                                                                                                             
>                                                                                                                             
> 
> 
> 
> Team,
> 
> I have a xml file which is like this
> 
> <Message id='10' value='one'/>
> 
> i have a xsl file which has to take this value of this attribute id and to
> replace with it for an hidden value.
> 
> <input type='hidden' name='id' value='<xsl:value-of select="@id"'/>>
> 
> But i am getting a transform exception how shall i achieve the same??.
> 
> I want to replace the value 10 in my hidden attribute ( note this is just
> an
> example i will this id in the fly ONLY).
> 
> Can anyone please please help me out.
> 
> Thanks
> Srini
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]