[xslt] Sorting with <xsl:sort>



  Hi,

  I have a xml like:

<person>
<name>firts name</name>
<name>second name</name>
<name>third name</name>
...
</person>

<person>
<name>another first name</name>
...
</person>

So every person could have several names (like "Arthur Charles" Clarke):

<person>
<name>Arthur</name>
<name>Charles</name>
</preson>

I need to sort all person -- sort through first name, all persons with the same first name sort through second name etc. There is no restriction on number of names per person. The way I find is something like:

<xsl:for-each select="person">
<xsl:sort select="name[1]"/>
<xsl:sort select="name[2]"/>
...
<xsl:sort select="name[n]"/>
</xsl:for-each>

But what if the person have more than n names? So this solution is not good. Another way I see is to make my own sorting, but it is not ellegant. I hope there is another way to solve this. Any suggestions?

Thanks

Vlastik



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]