|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] distance between elements and hierarchical orderDavid Carlisle davidc at nag.co.ukFri Dec 9 00:20:43 PST 2005
$x-ancestor at $x-ancestor-position in $x/ancestor-or-self::element()
would $x itself (always) be at position 1, or should it be last?
path expressions always return nodes in document order, so $x is always
last(). (it'll only be in position 1 if it's the top level element)
In the original problem I don't think you need to explictly iterate over
the ancestor lists then use count and min, you just walk up the
ancestors of x which are not ancestors of y , then up one level to the
nearest common ancestor then down the ancestors of y that are not
ancestors of x so the distance is
count($x-ancestors)+count($y-ancestors)+1-2*count($x-ancestors intersect $y-ancestors)
where x-ancestors is as in the posted code the ancestor-or-self:: axis
from $x
David
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






