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

Questions on sorting

Subject: Questions on sorting
From: Ian Brockbank <ian@xxxxxxxxxxxxxx>
Date: Thu, 26 Aug 1999 10:29:35 +0100
questions on sorting
Hi all,

I'm a bit confused by the interaction of xsl:sort and the various
axes.  I suppose basically my question is: does xsl:sort affect the
ordering of nodes for the purpose of reference within the stylesheet,
or just for the purpose of the output?

To try to get a grip on this, I took this XML

<?xml version="1.0"?>
<root>

<foo>D</foo>
<foo>C</foo>
<foo>A</foo>
<foo>B</foo>

</root>

and this stylesheet

<?xml version='1.0'?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    indent-result="yes">

<!-- The root of the document -->
<xsl:template match="/">
  <xsl:for-each select="//foo">
    <xsl:sort/>
    <xsl:value-of select="."/>:<xsl:for-each select="preceding-sibling">
      <xsl:value-of select="."/>
    </xsl:for-each>/<xsl:for-each select="following-sibling">
      <xsl:value-of select="."/>
    </xsl:for-each>
    <xsl:text>
</xsl:text>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

And I obviously don't understand preceding-sibling, because the
output (using the latest XT) was

A:/
B:/
C:/
D:/

So two questions:
1) When processing C what are:

preceding-sibling (A+B or D)?
following-sibling (D or A+B)?

and would this change if the xsl:sort came after the
xsl:apply-templates?

2) Why doesn't

<xsl:for-each select="preceding-sibling">
  <xsl:value-of select="."/>
</xsl:for-each>

print anything out?

Thanks,

Ian
--
Ian Brockbank, Indigo Active Vision Systems, The Edinburgh Technopole,
Bush Loan, Edinburgh EH26 0PJ   Tel: 0131-475-7234  Fax: 0131-475-7201
work: ian@xxxxxxxxxxxxxx           personal: Ian.Brockbank@xxxxxxxxxxx
web: ScottishDance@xxxxxxxxxxx           http://www.scottishdance.net/


 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.