XSL / XML Sort Problem !

Discussion in 'XML' started by Marco, Oct 8, 2004.

  1. Marco

    Marco Guest

    Hi All,

    this is a sample of my XML doc:
    <nodo>
    <nodo1>
    <nodo11 aa="10">21</nodo11>
    <nodo12>41</nodo12>
    <nodo13>61</nodo13>
    <nodo14>71</nodo14>
    <nodo15>marco</nodo15>
    </nodo1>
    <nodo1>
    <nodo11 aa="10">21</nodo11>
    <nodo12>92</nodo12>
    <nodo13>12</nodo13>
    <nodo14>42</nodo14>
    <nodo15>carla</nodo15>
    </nodo1>
    <nodo1>
    <nodo11 aa="13">21</nodo11>
    <nodo12>43</nodo12>
    <nodo13>53</nodo13>
    <nodo14>3</nodo14>
    <nodo15>antonio</nodo15>
    </nodo1>
    <info>
    <ordinamento>ascending</ordinamento>
    <campo>nodo14</campo>
    </info>
    </nodo>

    and this my XSL.. that NOT work like I want !!! :-(

    <xsl:variable name="ordinamento">
    <xsl:value-of select="info/ordinamento"/>
    </xsl:variable>
    <xsl:variable name="campo">
    <xsl:value-of select="info/campo"/>
    </xsl:variable>

    <xsl:when test=" $campo = 'nodo12' ">
    <xsl:for-each select="nodo1">
    <xsl:sort select="X.??.X.??.X" order="{$ordinamento}" data-type="number" />
    <xsl:call-template name="writeData"/>
    </xsl:for-each>
    </xsl:when>

    My idea is to make DINAMIC order !
    I've two variable: ordinamento to take the type
    and campo to choose the node to SORT !!!
    Good. But there is a "little" problem...
    <xsl:sort select="$campo"... --> DON'T WORK
    <xsl:sort select="{$campo}" --> DON'T WORK
    but for the order.. I use order="{$ordinamento}"

    WHY ?!?!?!?

    Anyone can help ME !!!
    Thanks
    Bye
    Marco, Oct 8, 2004
    #1
    1. Advertising

  2. In article <>,
    Marco <> wrote:

    ><xsl:sort select="$campo"... --> DON'T WORK
    ><xsl:sort select="{$campo}" --> DON'T WORK


    The select attribute is XPath expression, and must be static - not
    something determined from the document. This is true of all XPath
    expressions in XSLT 1.0.

    But you can do something like this:

    select="*[name() = $campo]"

    -- Richard
    Richard Tobin, Oct 8, 2004
    #2
    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. tsirman
    Replies:
    0
    Views:
    365
    tsirman
    Apr 29, 2004
  2. nobody
    Replies:
    0
    Views:
    528
    nobody
    Jun 1, 2004
  3. Replies:
    1
    Views:
    3,583
    A. Bolmarcich
    May 27, 2005
  4. Replies:
    2
    Views:
    9,244
    Martin Honnen
    Sep 5, 2006
  5. Navin
    Replies:
    1
    Views:
    668
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page