This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hierarchy problem


--- DPawson at rnib dot org dot uk wrote:

> 
> With a structure such as
> 
> 
> <bodymatter>
>   <level1 id='l1'>
>    <h1>Level1</h1>
>    <level2 id='l2'>
>     <h2>Level2</h2>  <!-- bad navPoint 1 -->
>     <level3 id='l3'> <!-- good navPoint 2 -->
>      <h3>level3</h3>
>      <note id="noteId">  <!-- navLabel target -->
>       <p>Note content</p>
>      </note>
>     </level3>
>    </level2>
>   </level1>
> 
> ....
> 
> I need to check that the node with id=noteId
> is (or is not) a direct descendant of another node (e.g.
> level2[id='l2'])
> or if there are intervening levelX elements.
> 

Hi Dave,

The following XPath expression will return the direct ancestor of the
"note" element that is a "level2" element, or nothing, if the "note"
element does not have a "level2" direct ancestor:

$vNote/ancestor::*[starts-with(name(), 'level')][1][self::level2]

Do I understand correctly that by "direct ancestor" you mean the first
ancestor, whose name is levelX?



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]