XSL / XML Sort Problem !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marco

    #1

    XSL / XML Sort Problem !

    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>as cending</ordinamento>
    <campo>nodo14 </campo>
    </info>
    </nodo>

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

    <xsl:variable name="ordinamen to">
    <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="{$ordina mento}" 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="{$ordina mento}"

    WHY ?!?!?!?

    Anyone can help ME !!!
    Thanks
    Bye
  • Richard Tobin

    #2
    Re: XSL / XML Sort Problem !

    In article <96525338.04100 80124.5ea121d4@ posting.google. com>,
    Marco <nemo_79@tiscal i.it> wrote:
    [color=blue]
    ><xsl:sort select="$campo" ... --> DON'T WORK
    ><xsl:sort select="{$campo }" --> DON'T WORK[/color]

    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

    Comment

    Working...