[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Finding deepest node

Subject: Re: Finding deepest node
From: marcus <m-lists@xxxxxxxxxx>
Date: Fri, 02 Dec 2005 21:37:21 +0100
. node 1 id
Jon Gorman wrote:
> Well......what do you mean by farthest away? I'm sure it's probably possible.



When I say farthest away I mean the node that has the most nodes between itself and the context node in a straight line (not counting siblings).


.//node[@a = 'avalue' and max(count(ancestor::*))]/@id

I know that isn't a valid expression but I hope you know what I mean

Example:

<nodes>
 <node a="1" id="1"/>
 <node a="2" id="2">
  <node a="1" id="3">
   <node a="1" id="3.1"/>
  </node>
  <node a="1" id="4"/>
 </node>
 <node a="2" id="5">
  <node a="1" id="6">
   <node a="1" id="7"/>
  </node>
 </node>
</nodes>

Say that a node must have @a=1 to be selectable.

In this example the nodes with @id=3.1 and @id=7 are furthest away from <nodes> and have a distance of 3. @id=3, @id=4, @id=6 have a distance of 2 and so on.

/Marcus

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.