[XSLT] Accessing contents of variable with computed name

Christian Roth

Usenet Archive
Joined
Aug 18, 2002
Messages
14
Reaction score
0
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

Usenet Archive
Joined
Aug 18, 2002
Messages
14
Reaction score
0
Christian Roth said:
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.
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
Christian Roth said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top