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

Re: variable indirection

Subject: Re: variable indirection
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sun, 28 Dec 2003 18:26:52 +0100
variable indirection
<karim@xxxxxxxxxxxxxxxx> wrote in message
news:1072588445.3fee669d6e86e@xxxxxxxxxxxxxxx
>
> Hi,
>
> Here's what I want to do :
> In a template I've got a variable which value is a string, this string is
also
> the name of a variable and I want to access it
> For example :
> $var1="var2" and I want to get $var2...
> Is that possible with xsl?

Generally no.

Exceptions:

  1. A global xsl:variable with *static* content:

          document('')/*/xsl:variable[@name = $var1]/@select

  2. If the content of your variable is created dynamically, you can express
this with the following dynamically created xml:

     <varContainer:varContainer xmlns:varContainer="my:varContainer">
        <varName1>tree1</varName1>
        <varName2>tree2</varName2>
       .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
        <varNameN>treeN</varNameN>
     </varContainer:varContainer>

    Then, if the above is the contents of the xsl:variable named
"vContainer", what you want is:

           $vContainer/*[name() = $var1]/node()


There's little meaning in your question as originally formulated, as
typically compiled languages (e.g. C, C++, Java, C#, etc.) do not allow
referencing a variable with dynamically created name.

Some of them have a pre-processor for this, but its work is done even before
compile-time.

Dimitre Novatchev.
FXSL developer

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html





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


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.