Re: [xsl] Grouping while sorting

Subject: Re: [xsl] Grouping while sorting
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Sun, 21 Nov 2004 20:05:06 +0000
Hi David,

Thank you for your answer.

I was afraid I would have to do something like this. I was hoping that there was some way of retrieving the first element with a certain value of a sorted list using only XSL 1.0.

As I have not the time to go through EXSLT at the moment, I solved my problem with a two-pass solution, first sorting the elements in one go, then grouping them in the next go.

I am rather hoping that you will finish the .NET version of XSL 2.0 in a short time, so I won't have to learn EXSLT, and then XSL 2.0 :-)

Regards,
Ragulf Pickaxe :-)

----Original Message Follows----
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Grouping while sorting
Date: Sun, 21 Nov 2004 10:52:32 -0800

Your best bet is to take the problem and break it into two seperate processes.

In the first process create a variable and within the opening and closing brackets of that variable put the logic you are using to sort your elements as desired. This process is often refered to as creating a temporary tree. In strict XSLT 1.0 the problem with this method is that there is no way to tree the Result Tree Fragment (RTF) and a node-set and as such each vendor has implemented similar but just slightly different (just enough to make each implementation non-portable between processors) such that without knowing which processor you are using I can give you the specifics of the syntax for the node-set function particular to that processor. A while back Jeni Tennison and company started the EXSLT project which is an effort to bring further functionality to XSLT using standard function names within one particular namespace extension library. There are several processors that support the EXSLT extensions directly the most notable being Dr. Michael Kay's Saxon processor. You can learn more about EXSLT at EXSLT.org, continue your learning of XSLT through Jeni Tennisons XSL tutorials (http://www.jenitennison.com), and download the latest build of Saxon from Dr. Kay's company site (http://www.saxonica.com). All this aside you can look up the specifics to the variation on the node-set function implemented by your processor by simply looking inside the documentation.

With this variable you can then, via the node-set function, treat the resulting XML node-set just like any node-set. The document order for this node-set is now in sorted order based on your original sort criteria. As such you can expect that whatever sort process you place on this newly order node-set the result will be based on the new document order and not the original document order, which at this point in the transformation processor the processor will know nothing about as it sees a brand new node-set that has no direct relation to the originating node-set///

Hope this helps!

<M:D/>

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


Current Thread