469,332 Members | 6,612 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

[XSLT] Accessing contents of variable with computed name

Hi,

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

Pseudo-code for demonstration, NOT WORKING:

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

<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.
Jul 20 '05 #1
2 1795
Christian Roth <ro*********@visualclick.de> 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.
Jul 20 '05 #2

"Christian Roth" <ro*********@visualclick.de> wrote in message
news:1g61z15.gr6trbtp4olqN%ro*********@visualclick .de...
Christian Roth <ro*********@visualclick.de> 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
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sergio del Amo | last post: by
8 posts views Thread by Maciej Wegorkiewicz | last post: by
2 posts views Thread by Michael Hamm | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.