Re: Re-ordering elements

Subject: Re: Re-ordering elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 20 Jan 2000 19:58:39 GMT
Could I do this for the non-continquous example:

    <xsl:for-each select="mantra" >
                <xsl:sort select="[@id='rv1.84.10a']" />
                <xsl:sort select="[@id='rv3.62.10c']" />
                <xsl:sort select="[@id='rv1.164.1a']" />
                <xsl:sort select="[@id='rv1.164.1e']" />
                <xsl:sort select="[@id='rv1.14.1a']" />
                </xsl:for-each>
                

NO!

the way sort works is this.

You have two nodes, you want to decide if one is greater than the other
so you evaluate the expression specified in xsl:sort on each
node, and compare those values. If they are equal, and a second xsl:sort
is specified then use that expression, and so on until you get two
different values, once you get different values sort those two nodes
so the computed values are in the right order, and then start comparing
two more nodes....

But look at your sort expression,  select="[@id='rv1.84.10a']"
for _every_ node you evaluate that on, you will _always_ get the SAME
answer, namely the string value of the node with id rv1.84.10a.
So your entire sort is a complete no op. Every comparison will
compare two equal strings.

> In other words, is "sort" the only way? 
No the simpler and more direct way is just to step through the two sets
of verses taking one mantra at a time, that was my first posting, but
you didn't like it. (No one ever likes my postings, I fear)

David


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread