This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: sorting product descriptions


Tobias Reif wrote:
> 
> Hi Francis;
> 
> > You have a solution at
> > http://redrice.com/xml/sortfunction.zip
> 
> Awesome! It works *very* well so far.
> 
There is now a new version at
http://redrice.com/xml/sortfunction_0_1.zip which implements a
mix-and-match architecture.

You can now import and call either the simplesort or mergesort template
with exactly the same parameters including one which specifies which of
your project-specific compare templates you want used.

Both sort templates return their result in the same way, as an ordered
list of node-ids, eg

	"[1:cr423][2:cd342]..."

which can be de-referenced very conveniently within for-each loops or
even XPath expressions.

The demo can be run from the command line:

---
C:\test>saxon sort.xml sortcall.xslt
<?xml version="1.0" encoding="UTF-8"?>
<product id="a_a_00_01">                2       </product>
<product id="a_a_00_03">                1       </product>
<product id="a_a_00_05">                4       </product>
<product id="a_a_00_9">                 w       </product>
<product id="a_a_00_9">                 x       </product>
<product id="a_a_00_b">                 y       </product>
<product id="a_a_00_b">                 z       </product>
<product id="a_b_00_02">                3       </product>
<product id="a_a_30_50">                5       </product>
<product id="a_a_60_20">                6       </product>
<product id="a_a_30_20">                7       </product>
<product id="a_a_100_30">               8       </product>
C:\test>
---

To switch sortcall.xslt from using mergesort to simplesort, change line
19 from

			<xsl:call-template name="mergesort">

to 

			<xsl:call-template name="simplesort">

Very much in beta at the moment but I will put more work in if there is
demand.

Francis.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]