|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|

Cart








