Subject: Re: [xsl] Sort list by a combination of elements From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 21 Dec 2006 14:46:51 +0100 |
So we have <book>s with <author> elements and <book>s with a <belongs_to> referring to a series of some author.
Problem: Sort the list of books by the author.
<xsl:sort select="concat( //book/author, //series[ @id = current()/belongs_to/@ref ]/author )" />. This works, BUT it "feels like a hack", if you know, what I mean.
I would prefer a more XSLT-like solution, that determines, if there is an <author> element, sorts by this and uses the <series> author as a fallback. Does anyone know, if and how this could be done? Schematically:
Here's the sort with: a) by author, which can come from <series> or <book> b) by title (all authors together, than title)
I extended the input a bit, and with the following input: <bookshelf> <series id="LoTR"> <author>Tolkien</author> </series> <book> <title>Two Towers</title> <belongs_to ref="LoTR" /> </book> <book> <title>The hobbit</title> <belongs_to ref="LoTR" /> </book> <book> <title>Pygmalion</title> <belongs_to ref="LoTR" /> </book> <book> <title>It</title> <author>King</author> </book> <book> <title>Lisey's story</title> <author>King</author> </book> <book> <title>Sociology</title> <author>Giddens</author> </book> </bookshelf>
Giddens: Sociology King: It King: Lisey's story Tolkien: Pygmalion Tolkien: The hobbit Tolkien: Two Towers
Cheers, -- Abel Braaksma www.nuntia.nl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sort list by a combinatio, David Carlisle | Thread | Re: [xsl] Sort list by a combinatio, Manuel Strehl |
Re: [xsl] Sort list by a combinatio, David Carlisle | Date | [xsl] Why does '#' start a comment , Abel Braaksma |
Month |