xsl-list
[Top] [All Lists]

Re: Finding deepest node

2005-12-02 13:37:21
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[(_at_)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



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