[XSLT] Accessing contents of variable with computed name

Discussion in 'XML' started by Christian Roth, Dec 8, 2003.

  1. 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, Dec 8, 2003
    #1
    1. Advertising

  2. Christian Roth <> 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.
     
    Christian Roth, Dec 16, 2003
    #2
    1. Advertising

  3. "Christian Roth" <> wrote in message
    news:1g61z15.gr6trbtp4olqN%...
    > Christian Roth <> 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
     
    Dimitre Novatchev, Dec 16, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Hillsley
    Replies:
    3
    Views:
    1,752
    Dimitre Novatchev
    Sep 25, 2003
  2. Mohanasundaram
    Replies:
    44
    Views:
    1,111
    Keith Thompson
    Aug 24, 2004
  3. Bobby Chamness
    Replies:
    2
    Views:
    2,449
    Joe Smith
    Apr 22, 2007
  4. mfglinux
    Replies:
    11
    Views:
    754
    Roberto Bonvallet
    Sep 12, 2007
  5. Rob Kerfia
    Replies:
    4
    Views:
    112
    Sy Ali
    Jul 15, 2007
Loading...

Share This Page