|
Subject: Re: What does 'reverse document order' mean? From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 15 Nov 2000 09:25:01 GMT |
> Am I guilty of muddled thinking, or inadequate study of the spec? Or is
> there some subtlety that I am missing?
guilty of uuencoding an example that was small enough to inline:-)
> since preceding-sibling:: selects siblings in
> 'reverse document order', the first node in the set
Note that node sets are called sets (rather than lists) on purpose, not
by accident. They are intrinsically unordered.
[1] in a step selects the first node in the direction specified by the
axis used in the step, but anywhere else it refers to document order.
so
preceding-sibling::elt[1]
selects the immediately preceding elt sibling,
but
(preceding-sibling::elt)[1]
selects the first elt sibling in document order.
You did
<xsl:variable name="sibling-preceders" select="preceding-sibling::elt"/>
<xsl:for-each select="$sibling-preceders">
<xsl:value-of select="."/> <xsl:if test="position()<last()">
which is like
(preceding-sibling::elt)[position() < last()]
so position() and last() refer to document order here.
To see _why_ it has to be that way (other than because that was the will
of the w3c)
consider
<xsl:variable name="sibling-preceders"
select="preceding-sibling::elt|../*[@id]"/>
now the variable contains all the preceding elts (which were "collected
backwards" and all sibling elements with an id attribute (which were
collected forwards) note these two sets overlap but | is set union,
an elt with an id is selected by both clauses, but only appears in the
node set once. So a constructed node set is justa set of nodes, each
individual node doesn't "remember" what axis was used to select it.
So if you caome later to apply a position() construct to the node set,
at that point the set is considered in document order.
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| What does 'reverse document order' , Richard Light | Thread | Re: What does 'reverse document ord, Richard Light |
| RE: XPATH and XSL(T), DPawson | Date | RE: copying CData sections from the, R_KNOWLES |
| Month |