[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] xsl:variable


Subject: RE: [xsl] xsl:variable
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Wed, 20 Aug 2003 14:19:25 -0600

> From: Zarana Shah [mailto:zarana@xxxxxxxxxxxxx]
> Sent: Wednesday, August 20, 2003 1:45 PM
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] xsl:variable
> 
> 
> 
> how do i assign value to xsl:variable.

<xsl:variable name="some_var" select="'some value'"/>

The value of the select attribute may be an XPath expression, number or
literal string.  If you omit the select attribute:

<xsl:variable name="some_var">some value</xsl:variable>

then the contents of the xsl:variable element provide the value.  This is
invariably a string (or a result tree fragment, which in practice is the
same thing).

> i think this question must be
> answered on the group.

And the FAQ, among other places:
http://www.dpawson.co.uk/xsl/sect2/N8090.html

> is ther any other way round this. all i need to do is 
> maintain a counter
> actually.

Ah, now we're getting somewhere.  You can't do a counter in the procedural
sense, because XSLT variables can't be updated with new values once bound.
You can, however, implement a loop (as one example requiring a counter)
using recursive techniques: http://www.dpawson.co.uk/xsl/sect2/N5019.html

> but xsl:counter doesn't work either.

I'm not the first to say this, but you can't just invent syntax for a
language and expect it to work.  I recommend perusing the above-mentioned
FAQ or finding a good tutorial book for learning XSLT.

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.357.3548 |
| cheap tickets, part of trip network                fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400           englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

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



Current Thread
  • [xsl] xsl:variable
    • Zarana Shah - Wed, 20 Aug 2003 15:45:00 -0400 (EDT)
      • <Possible follow-ups>
      • Martinez, Brian - Wed, 20 Aug 2003 14:19:25 -0600 <=
      • cknell - Wed, 20 Aug 2003 16:21:37 -0400
Keywords