RE: [xep-support] xsl:sort in apply-templates

From: G. Ken Holman <>
Date: Fri Feb 25 2005 - 08:20:28 PST

At 2005-02-25 15:39 +0100, Henk Rutten wrote:
>What if you remove the forward slashes within your sort:attribute select
><xsl:sort select="editor | author[1] " /> instead of <xsl:sort
>select="//editor | //author[1] " />

Your <xsl:sort select="editor | author"/> suggestion would work as an
exclusive "one or the other" sort only if there were only one present.

Since <xsl:sort> bases the lexicographic ordering on the value of the XPath
expression, providing the union of two nodes in the expression will cause
only the value of the first in document order to be used, so if both are
present, it will do only the first.

This would be an improvement on my suggestion of:

    <xsl:sort select="editor"/>
    <xsl:sort select="author"/>

in that my suggestion would group all authors in order before all editors
in order, while your suggestion would interleave all the authors and
editors in the lexicographic ordering.

If, however, one wanted to ensure the editor had preference over the author
in the sort, and you don't know which is first or you know the author is
first, then your suggestion would need to be modified to be:

     <xsl:sort select="self::*[editor]/editor |

... so as to say: the use of editor when the editor child exists and the
use of author when the editor child does not exist.

Another way to say the same thing would be:

     <xsl:sort select="editor |

... so as to say: only use the author child if its parent has no editor

I hope this helps.

............................ Ken

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman       
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness
Legal business disclaimers:
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service
Received on Fri Feb 25 09:01:38 2005

This archive was generated by hypermail 2.1.8 : Fri Feb 25 2005 - 09:01:39 PST