[XSLT] Accessing contents of variable with computed name

C

Christian Roth

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?
 
C

Christian Roth

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.
 
D

Dimitre Novatchev

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
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top