Re: [xsl] sorted for-each: preceding::sibling is not in sort order

Subject: Re: [xsl] sorted for-each: preceding::sibling is not in sort order
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sun, 13 Nov 2005 15:35:53 GMT
> It took me a long time to find out that while for-each will present the
> nodes in sort order, preceding::sibling will give me the
> results for a totally different node (probably document order).

all axes always refer to the input tree, not the current node list. The
siblings (and parent) of a node are, like its children, properties of
the node,not properties of the particular set of nodes currently
selected or the order in which they are processed.

> Is this intended behaviour (I'm working with Xalan)? 

yes

> And if so, what is the best way around this.

it depends what you are doing. Sometimes doing it in two passes as you
suggest, first sortung and then processing, is the best way, sometimes
you can do it in one pass. It all depends what it is that you want to
do.


> One big disadvantage being that I'm cutting off all the parent
> relationships when copying my node.

you can copy the parent, or potentially the whole document, first make a
copy of the document, with just the nodes re-ordered that you want to
reorder, then process the new document. But as I say sometimes two
passes are not necessary.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread