xsl-list
[Top] [All Lists]

Re: [xsl] XPath preceding

2012-04-09 13:27:57
Hi Rick,

http://www.w3.org/TR/xpath/#axes

the preceding axis contains all nodes in the same document as the context 
node that are before the context node in document order, excluding any 
ancestors and excluding attribute nodes and namespace nodes

If you have access to XPath 2 you could use he new << and >> operators, but I 
guess you have not. So if I read on in the spec:

NOTE: The ancestor, descendant, following, preceding and self axes partition 
a document (ignoring attribute and namespace nodes): they do not overlap and 
together they contain all the nodes in the document.


I would assume you have to built something like this:

preceding::case-cite or ancestor::*//case-cite

as ancestors (and their descendants) are also before the current node in 
document order but not part of the preceding:: axis.

- Michael


Am 09.04.2012 um 17:09 schrieb Rick Quatro:

Hello,

I am trying to find a particular element that is anywhere before the current
element like this:

preceding::case-cite

This works if the two elements have the same parent, but I want to match an
element anywhere before the current element. For example, if the context is
the <case-cite-2nd> element, I want to find a <case-cite> element anywhere
in the structure previous to the <case-cite-2nd> element.

<root>
 <section>
   <para>
     <case-cite/>
   </para>
   <para>
     <case-cite-2nd/>
   </para>
 </section>
</root>

Thanks in advance.

Rick Quatro


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