commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anand Narasimhan" <>
Subject New to JXPath. Please help
Date Fri, 22 Apr 2005 01:19:03 GMT
I am new to JXPath. I just read the user guide briefly. I have a few
questions. Please help.
The user guide says  "JXPath applies XPath expressions to graphs of objects
of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures
thereof. "
1. Can I use JXPath to select nodes from a tree containing arbitrary data by
applying XPath expressions. If so what do I need to do, what classes do I
need to extend. Or my understanding of JXPath is completely
wrong and JXPath cannot be used for this purpose?
2. If I want to package JXPath binaries with a commercial product, are there
any licensing restrictions. What are they?
A bit more information on my tree model. My tree mode is very much similar
to the javax.swing.tree.DefaultTreeModel and the nodes are similar to
public class Tree
    Node root;
   public Node getRoot();
public class Node 
    String nodeName;
    Node parent;
    List children;
    MyClass userData;
Implementation of MyClass does not follow the Java Bean conventions. It
basically contains a hash map of attribute/value pairs and has setAttribute
and getAttribute method. It also has a setter and getter for each attribute.

For eg.
public class MyClass
    protected HashMap attributes
    public void setAttribute( String key, Object value );
    public Object getAttribute( String key );
public class MyClass1 extends MyClass
    public static final String NAME = "Name";
    public static final String IP_ADDRESS = "IP Address";
    public String getName ()
        return (String) getAttribute( NAME );
    public String getIpAddress()
        return (String) getAttribute( IP_ADDRESS );
So, If have a tree instance like
    |                    |                                |                |
                         X                             X1
                         |                                |
                  -----------                ----------
                |                |                |                |
                Y            Y2          Z1            Z2
I want use XPath to select node /Root/X/Y2    or  /Root/X/Y[@Name = 'xyz'].
Is this possible with JXPath.
Anand Narasimhan

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message