Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > [XSLT] Accessing contents of variable with computed name

Reply
Thread Tools

[XSLT] Accessing contents of variable with computed name

 
 
Christian Roth
Guest
Posts: n/a
 
      12-08-2003
Hi,

how do I access the contents of a variable (or param) whose name is
computed?

Pseudo-code for demonstration, NOT WORKING:

....
<xslaram name="table.frame.void">border: none;</xslaram>
<xslaram name="table.frame.box">border: 1pt solid black;</xslaram>
....

<xsl:template match="table">
<table style="{$table.frame.{@frame}}"> <!-- ### -->
...
</xsl:template>


What I intend is to compute the name of the variable to be accessed
using some constant prefix ('table.frame.') and the contents of the
element's 'frame' attribute.

Nested {...}'s are not allowed, and some other attempts of mine did not
work (like "{$concat( 'table.frame.', @frame)}").

How can I achieve this?

--
Christian Roth
Email: roth (at) visualclick (dot) de
Mac.Java.Pasta.Sopranosax.Single.
 
Reply With Quote
 
 
 
 
Christian Roth
Guest
Posts: n/a
 
      12-16-2003
Christian Roth <(E-Mail Removed)> wrote:

> how do I access the contents of a variable (or param) whose name is
> computed?


Answering my own question for the archive: This is not possible in XSLT.
--
Christian Roth
Email: roth (at) visualclick (dot) de
Mac.Java.Pasta.Sopranosax.Single.
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      12-16-2003

"Christian Roth" <(E-Mail Removed)> wrote in message
news:1g61z15.gr6trbtp4olqN%(E-Mail Removed)...
> Christian Roth <(E-Mail Removed)> wrote:
>
> > how do I access the contents of a variable (or param) whose name is
> > computed?

>
> Answering my own question for the archive: This is not possible in XSLT.


Not exactly so:

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

accesses the value of the "select" attribute of the global xsl:variable,
whose name is the same as the value of the variable "computedName".

To select the children ("contents") of the same xsl:variable use the
following XPath expression:

document('')/*/xsl:variable[@name = $computedName]/node()


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Variable variable name" or "variable lvalue" mfglinux Python 11 09-12-2007 03:08 AM
Contents of variable as variable name Rob Kerfia Ruby 4 07-15-2007 10:16 PM
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
Accessing a global variable when there is a local variable in the same name Mohanasundaram C Programming 44 08-23-2004 11:17 PM
How do I scope a variable if the variable name contains a variable? David Filmer Perl Misc 19 05-21-2004 03:55 PM



Advertisments