Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT: Dynamic sorting with multiple keys

Reply
Thread Tools

XSLT: Dynamic sorting with multiple keys

 
 
Petr Vlcek
Guest
Posts: n/a
 
      07-19-2005
Hello,

I have a file with records storing information about people, something
like this:

<people>
<person>
<name>John</name>
<name>Fitzgerald</name>
<name>Kennedy</name>
</person>

<person>
<name>George</name>
<name>Walker</name>
<name>Bush</name>
</person>

<person>
<name>George</name>
<name>Washington</name>
</person>
</people>

I have tried to write XSLT template that would sort records by name. When
first names are the same, it would sort by second name, etc. The problem
is, that records can differ with number of names.

For fixed number of names (here it is 2) it is possible to use this
template:

<xsl:sort select="name[1]"/>
<xsl:sort select="name[2]"/>

Does anyone have an idea how to do it for dynamic number of names?

Thanks in advance, Petr Vlcek.
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      07-19-2005

"Petr Vlcek" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) uni.cz...
> Hello,
>
> I have a file with records storing information about people, something
> like this:
>
> <people>
> <person>
> <name>John</name>
> <name>Fitzgerald</name>
> <name>Kennedy</name>
> </person>
>
> <person>
> <name>George</name>
> <name>Walker</name>
> <name>Bush</name>
> </person>
>
> <person>
> <name>George</name>
> <name>Washington</name>
> </person>
> </people>
>
> I have tried to write XSLT template that would sort records by name. When
> first names are the same, it would sort by second name, etc. The problem
> is, that records can differ with number of names.
>
> For fixed number of names (here it is 2) it is possible to use this
> template:
>
> <xsl:sort select="name[1]"/>
> <xsl:sort select="name[2]"/>
>
> Does anyone have an idea how to do it for dynamic number of names?
>
> Thanks in advance, Petr Vlcek.


Yes, it has been done -- see it here:

http://www.biglist.com/lists/xsl-lis.../msg00007.html


Cheers,
Dimitre Novatchev


 
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
Sorting a multidimensional array by multiple keys Rehceb Rotkiv Python 16 04-02-2007 03:02 PM
How to link foreign keys & primary keys using python? Harry George Python 9 06-13-2006 06:29 AM
serial keys/validation keys sandeep Kanwal C++ 1 10-29-2004 06:36 PM
sorting by multiple criterias (sub-sorting) Tom Kirchner Perl Misc 3 10-11-2003 05:16 PM
keyboard keys replacing mouse keys? larry Computer Support 8 09-14-2003 07:32 PM



Advertisments