xsl-list
[Top] [All Lists]

Re: [xsl] How to get page range within a group

2008-09-12 10:14:20
This isn't working for you since the expression //doc//pb[position()=1] does
not return what you think it does.

It may appear it should return the first 'pb' element appearing inside each
'doc' element in the document, but this isn't so. The semantics of "//" is
not (as it is commonly glossed) "all the nodes (or elements) all the way
down the tree". It is an abbreviation for "/descendant-or-self::node()/",
which in itself is not a complete XPath expression, but must be completed by
adding an axis and node test. In particular, when you say "//pb" you are
implicitly adding the child:: axis (as always when no axis is given
explicitly) along with the "pb" node test. That is, "//pb" is short for
"/descendant-or-self::node()/child::pb".

This is crucial since it means that //pb[1] does not mean "the first 'pb'
descendant" but "the first pb child of any descendant".

I might not have understood properly, but:

//doc//pb[1]

will return the first <pb> descendant of all <doc> elements

it sounds like you're suggesting it won't include <pb> children of <doc> ?



-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
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>
--~--