Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Returning "nearest in document" matches using XPath

From: Manuel Collado <m.collado@---.--.--.---.-->
To: NULL
Date: 12/5/2008 5:48:00 PM
Nick Leverton escribió:
 > I have an application which attempts to describe a tree of TCP subnets,
 > which in essence are not fully accessible from each other.  I have a
 > description of the network in XML as shown in the excerpt below.
 > ...
 >
 > <?xml version="1.0"?>
 > <nodes>
 >   <node id="V9990" ip="1.1.1.1">
 >     <unit id="23" ip="10.10.10.10"/>
 >     <unit id="24" ip="10.10.10.11"/>
 >     <node id="V9991" ip="10.10.10.12">
 >       <unit id="26" ip="192.168.0.1"/>
 >       <unit id="27" ip="192.168.0.2"/>
 >     </node>
 >   </node>
 >   <node id="V9992" ip="2.2.2.2">
 >     <node id="V9993" ip="10.10.10.10">
 >       <unit id="21"/>
 >       <unit id="22"/>
 >     </node>
 >   </node>
 > </nodes>
 >
 > To simplify network maintenance I would like to use the same config file
 > on all the "nodes", and to modify the XPath query with extra terms on
 > the sub-nodes.  In other words, on the "root" machine a query for id=26
 > will return ip=1.1.1.1, but on node V9990 a query for id=26 will return
 > ip=10.10.10.12
 >
 > In summary, what I want to do is to retrieve the nearest ip attribute
 > in the document which has a given id attribute as a descendant.  I am
 > currently using the following XPath:
 >
Nick Leverton escribió:
> In article <4939431f$0$17068$6e1ede2f@r...>,
> Dimitre Novatchev <dnovatchev@c...> wrote:
>> What do you mean by "nearest"? Is this the geographical distance b/n two 
>> nodes? I dont see this reflected in the XML document.
> 
> No, sorry for being unclear.  I mean that from the set of ip attributes
> on the axis which contains both the root and the required id attribute:
> 
>   / ... @ip ... @ip ... @ip ... @id
> 
> I want to find the left-most one in the above diagram, nearest to the root
> (or to other selected starting node inbetween the root and the required @id).

So you mean: inside the context node, find the IP of the outermost 
"node" that contains the destination "unit". The XPath for this could be 
(untested):

     ./descendant::node[.//unit[@id="26"]]/@ip

Is that what you want?

-- 
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent