XSL / XML Sort Problem !

M

Marco

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
 
R

Richard Tobin

Marco said:
<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
 

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

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top