xsl-list
[Top] [All Lists]

RE: [xsl] XPath preceding

2012-04-09 13:35:58
Hi Michael,

As Wendell pointed out, this should work according to the XPath spec.
However, I am using it with FrameSLT (an XPath plugin for Adobe FrameMaker)
and apparently there is a bug where the preceding axis doesn't work if the
elements have different parents. It actually works like preceding-sibling. I
have to send Russ a bug report.

Wendell, a belated thanks for your quick reply.

Rick

-----Original Message-----
From: Michael Müller-Hillebrand [mailto:mmh(_at_)cap-studio(_dot_)de] 
Sent: Monday, April 09, 2012 2:28 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] XPath preceding

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>