How to find ancestors more than one level above

89 views Asked by At

I need to check for condition in XSLT where parent_of 'c' should be 'b' but ancestor of 'c' should not be 'a'? How can i achieve this ?

<a1>
 <a>
  <b>
   <c> </c> 
  </b>  
 </a>
<a1>
1

There are 1 answers

0
JLRishe On

To check whether the current node matches your description:

self::c[parent::b and not(ancestor::a)]

To select all elements in the document that match your description (or check whether there are any):

//b/c[not(ancestor::a)]

Given a more clearly explained use case, there may be a path that's better suited to your situation, and if so, please let us know. Hopefully the above sets you on the right track.