[jdom-interest] getting xpath of modified jtree-view

Laurent Bihanic laurent.bihanic at atosorigin.com
Fri Mar 26 05:18:22 PST 2004


Daniel Purucker wrote:
> Now my proble is: i'd like to show the children of a specific node (the  
> one the user clicked) inside of a table. And - i think - for this task  
> i need the xpath-expression of the selected node - or to be more  
> precise - of the underlying jdom-model. Now the quetion is: How do i  
> get that xpath?

If you really think you need to build an XPath expression to select the 
current node, you could use the org.jdom.contrib.helpers.XPathHelper class 
from the jdom-contrib module (available from CVS). The any of 
getPathString(node) methods will return an XPath expression to select the 
specified node. As these XPath expressions are based on the document 
structure, it is recommended not to cache or store them; instead recompute 
them each time.

Otherwise, XPath expressions can be evaluated relatively to a node. For that, 
make sure your expressions do not start with a '/' character. Then, simply 
call XPath.selectNodes(currentNode).


                 (o o)
Laurent Bihanic                | Tel: +33 (0)1 (direct)
AtosOrigin Systems Integration |      +33 (0)1
Generic Solutions / SC         | Fax: +33 (0)1
Les Miroirs - Bat. C           |
18, avenue d'Alsace            |
F-92926 La Defense Cedex       | E-mail: laurent.bihanic at atosorigin.com

I love deadlines. I like the whooshing sound they make as they fly by.

The opinions expressed are entirely my own and may not necessarily be
those of my employer.  Also, I am not now nor have I ever been a
lawyer.  My opinions are provided as-is with absolutely no warrantee of
merchantability or fitness for any particular use.  Besides, you can't
prove I typed this.  No body saw me type this.  Who says I typed this?

More information about the jdom-interest mailing list