xsl-list
[Top] [All Lists]

Re: [xsl] testing preceding sibling always evaluates true

2011-08-09 22:15:43
Thank you Michael.

I just received the 4th edition (it really is hardbound!)
so I could check if anything had changed, but on p. 602 :

 There are three kinds of expressions in XPath 2.0 whose result
 is guaranteed to be a sequence of nodes in document order...

  o Any axis step (even and axis step like <preceding-sibling::*> that
    uses a reverse axis delivers its results in forwards document order)

But, reading on... p. 618

 In effect, the predicate operator <[]> has a higher precedence (it
 binds more tightly) than the path operator </>

That's a bit subtle, but OK, now I know, XPath has an evaluation
precedence to consider.

--Hank


On 07/29/2011 11:19 AM, Michael Kay wrote:


I believe the issue is (and I would like some clarification), is that
axis steps always return nodes in document order so

preceding-sibling::w:p[1]

will always return the first paragraph with its TableCaption child.

I believe the work around for this, to collect the nodes in search
order, is to make them a set,

(preceding-sibling::w:p)[1]

No this is wrong. preceding-sibling::w:p[1] selects the most recent w:p
element (the last in document order), whereas
(preceding-sibling::w:p)[1] selects the first in document order.

Michael Kay
Saxonica

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--
Louis (Hank) Ratzesberger
sopac.ucsd.edu

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>