[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Reading value of passed variable

Subject: RE: Reading value of passed variable
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 17 Jun 2004 07:58:09 +0100
dynamic form name
Wow, that's the fourth time this question has been asked in two days. Does
no-one lurk before posting questions nowadays?

Standard XSLT doesn't allow you to access variables in this way any more
than C or Java do. It's not an introspective language.

Some products (Saxon, Xalan) have an xx:evaluate extension that lets you do
it.

However, it's usually the wrong thing to do. If you have three variables a,
b and c and you don't know statically which one you want, then you should
probably have a single variable X whose value is an XML tree containing a,
b, and c as elements. You can then access the elements using standard path
expressions - including the dynamic form //*[name()=$var].

Michael Kay 

> -----Original Message-----
> From: Mayo [mailto:mayo@xxxxxxx] 
> Sent: 16 June 2004 23:32
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Reading value of passed variable
> 
> Hello,
> 
> I'm trying to read value of a variable who's name is passed 
> to the xslt 
> processor as argument.
> 
> My source file has something like:
> <var name="$somevar"/>
> 
> The variable $xsltvar will be defined at the processor's 
> runtime, so it 
> has some value ("test" just for the sake of example - as if 
> <xsl:variable name="somevar" select="'test'"/> was used). Now 
> what I'm 
> trying to do is to have xslt output the value of this variable.
> 
> I've tried using <value-of select=""> with selecting the name 
> attribute 
> from the var node, but to no avail.
> 
> <xsl:template match="var">
>      <xsl:value-of select="@name"/>
> </xsl:template>
> 
> This, naturally, prints out the name of the variable 
> ("$somevar"), but 
> I can't get the actual value of the variable.
> 
> any ideas?
> 
> Thanks,
> Mayo
> 
> 
> --+------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
> 
> 


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.