Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   [XSLT] Accessing contents of variable with computed name (http://www.velocityreviews.com/forums/t166207-xslt-accessing-contents-of-variable-with-computed-name.html)

Christian Roth 12-08-2003 01:21 PM

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

Christian Roth 12-16-2003 08:16 AM

Re: [XSLT] Accessing contents of variable with computed name
 
Christian Roth <roth-news01@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.

Dimitre Novatchev 12-16-2003 09:24 AM

Re: [XSLT] Accessing contents of variable with computed name
 

"Christian Roth" <roth-news01@visualclick.de> wrote in message
news:1g61z15.gr6trbtp4olqN%roth-news01@visualclick.de...
> Christian Roth <roth-news01@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




All times are GMT. The time now is 12:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.