[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:sort order problems
Even when the node list is in sorted order (so the values returned by position() reflect sorted order) the axis specifiers like preceding-sibling refer to _document_ order. So preceding-sibling::qna[1]/topic) doesn't do what you want. There are various postings on `grouping' in the archives that give wprkarounds for this, or alternatively you can use extensions eg the latest xt has a node-set function which means you can sort the thing once and then get the result-tree back as a node list on which the preceding-sibling works as you expect. See the unique sort example in the xt distrib for an example of this. If you want to do it without extension elements then: <?xml version="1.0" ?> <!DOCTYPE xsl:stylesheet [ <!ENTITY sp "<xsl:text> </xsl:text>"> <!ENTITY dot "<xsl:text>.</xsl:text>"> <!ENTITY nl " 
"> ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/">root <!-- match on parent of group --> <xsl:for-each select="doc/qna/topic[not(.=following::topic)]"> <xsl:sort select="."/> <!-- sort on topic --> <h2>TOPIC IS: <xsl:value-of select="."/> </h2> <xsl:for-each select="/doc/qna[topic=current()]"> <xsl:sort select="q"/> <p> <xsl:value-of select="q"/>(<xsl:value-of select="topic"/>) </p> </xsl:for-each> </xsl:for-each> </xsl:template> <xsl:template match="*" priority="-1"> ************ Default ************** </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|