Re: [xsl] Integrated sort using different elements

Subject: Re: [xsl] Integrated sort using different elements
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 Feb 2009 11:25:51 -0500
At 2009-02-19 10:13 -0600, Quinn Dombrowski wrote:
I'm using 2.0 (sorry, I should've mentioned that), so I'll try Michael's solution and let you know how it goes...

Before you do so, Quinn .....

At 2009-02-19 10:19 -0500, I wrote:
In XSLT 2.0, choose the first item in a sequence of many items, priority indicated by the order of your sequence:

<xsl:sort select="
 ( monogr/author, analytic/author, monogr/editor, monogr/title )[1]"/>

At 2009-02-19 15:47 +0000, Michael Kay wrote:
Would it work to sort on the concatenation? -

<xsl:sort select="concat(monogr/author, analytic/author, monogr/editor,

I think the sequence solution is safer than the concatenation solution because if more than one field is present, then the initial characters of a following field, tacked on to the final characters of a preceding field, will but the record out of order.

Consider the following:

<biblStruct id="b1">
<biblStruct id="b2">

Using the sequence approach would put "b1" before "b2" in the result because "abc" is before "abcdef", while using the concatenation approach would put "b2" before "b1" in the result because "abcdef" is before "abcxyz".

I hope this illustrates an important issue that was neglected in your decision.

. . . . . . . . . . Ken

Upcoming hands-on  XQuery, XSLT, UBL & code list training classes:
Brussels, BE 2009-03;  Prague, CZ 2009-03,
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread