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

From: Martin Holmes <mholmes@uvic.ca>
Date: Fri Feb 25 2005 - 10:05:35 PST

Hi there,

>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.

That's actually what I wanted to do. I need to sort the bibliographic items
on the basis of the first of either author or editor which appears. For
example, if there's a reference for a book chapter authored by X, in a book
edited by Y, I want to sort on the former (which is first in the structure
anyway); if it's just a book with an editor but no specified authors, then
I want to use the editor value as the sort key. As far as I can tell, with
the first suggestion I'm getting exactly what I want, because in all cases,
it happens that the value I need to sort on is the first occurrence of
either an author or an editor element in the structure.

Cheers,
Martin

At 08:20 AM 25/02/2005, you wrote:

>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 |
> self::*[not(editor)]/author"/>
>
>... 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 |
> author[not(../editor)]"/>
>
>... so as to say: only use the author child if its parent has no editor
>children.
>
>I hope this helps.
>
>............................ Ken
>
>--
>World-wide on-site corporate, govt. & user group XML/XSL training.
>G. Ken Holman mailto:gkholman@CraneSoftwrights.com
>Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
>Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
>Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
>Legal business disclaimers: http://www.CraneSoftwrights.com/legal
>
>-------------------
>(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
>in the body of the message to majordomo@renderx.com from the address
>you are subscribed from.
>(*) By using the Service, you expressly agree to these Terms of Service
>http://www.renderx.com/tos.html
>

______________________________________
Martin Holmes
University of Victoria Humanities Computing and Media Centre
mholmes@uvic.ca
martin@mholmes.com
mholmes@halfbakedsoftware.com
http://www.mholmes.com
http://web.uvic.ca/hcmc/
http://www.halfbakedsoftware.com

-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html
Received on Fri Feb 25 10:31:42 2005

This archive was generated by hypermail 2.1.8 : Fri Feb 25 2005 - 10:31:42 PST