Hi Folks,
This XPath expression says: select all <section> element's <head> element:
//section/head
But that may not result in returning nodes in document order, as is the case
for this input:
<section>
<section>
<head/> <!-- A -->
</section>
<head/> <!-- B -->
</section>
"A" occurs first in the document, but is returned second. "B" occurs second in
the document, but is returned first.
To ensure that the <head> elements are selected in document order we can
rewrite the XPath expression to select all <head> elements that have a parent
<section> element:
/descendant::head[parent::section]
Now the first <head> element in the document is the first item returned. The
second <head> element in the document is the second item returned.
I am seeking a general rule for designing XPath expressions to return the
selected items in document order. Can you provide a general rule?
/Roger
--~------------------------------------------------------------------
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>
--~--