Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL / XML Sort Problem !

Reply
Thread Tools

XSL / XML Sort Problem !

 
 
Marco
Guest
Posts: n/a
 
      10-08-2004
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
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      10-08-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:sort using an xsl:variable as the sort key jobooker@gmail.com XML 2 09-05-2006 03:51 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
xsl:sort lang="es" modern vs. tradidional Spanish sort order nobody XML 0 06-01-2004 06:25 AM
sort data in xsl file ->problem tsirman XML 0 04-29-2004 01:53 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57