[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Sort list by a combination of elements
Hi. Consider some kind of bookshelf XML: <bookshelf> <series id="LoTR"> <author>Tolkien</author> </series> ... <book> <title>Two Towers</title> <belongs_to ref="LoTR"> </book> ... <book> <title>It</title> <author>King</author> </book> </bookshelf> 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. Solution: Normally one would write something like <xsl:sort select="//book/author" />. In this case, I found a solution by concatenating: <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: <choose> <when test="author"><sort select="author"> <otherwise><sort select="series/author"> </choose> Best Regards Manuel
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|