[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl:sort order problems

Subject: RE: xsl:sort order problems
From: DPawson@xxxxxxxxxxx
Date: Mon, 29 Nov 1999 12:27:24 -0000
xsl sort preceding sibling
Many thanks David. That's been giving me heartache for about two weeks!

Your point about axis specifiers referring to document order
clarifies things greatly.

I am happier without using extensions :-)

regards, DaveP

>-----Original Message-----
>From: David Carlisle [mailto:davidc@xxxxxxxxx]
>Sent: 29 November 1999 11:08
>To: xsl-list@xxxxxxxxxxxxxxxx
>Subject: 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 "&#10;&#xD;"> 
>]>
>
>
> <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
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.