| <?xml version="1.0"?> |
| <document> |
| <properties> |
| <title>Home</title> |
| <author email="commons-dev@jakarta.apache.org">Commons Documentation Team</author> |
| <author email="dmitri@apache.org">Dmitri Plotnikov</author> |
| <revision>$Id: index.xml,v 1.2 2002/04/28 04:37:01 dmitri Exp $</revision> |
| </properties> |
| |
| <body> |
| <section name="The JXPath Component"> |
| <p> |
| The <code>org.apache.commons.jxpath</code> package defines a simple |
| interpreter of an expression language called XPath. JXPath applies <em>XPath</em> |
| expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, |
| including mixtures thereof. |
| </p> |
| <p> |
| Consider this example: |
| </p> |
| <blockquote><pre> |
| Address address = (Address)JXPathContext.newContext(vendor). |
| getValue("locations[address/zipCode='90210']/address"); |
| </pre></blockquote> |
| <p> |
| This XPath expression is equvalent to the following Java code: |
| </p> |
| <blockquote><pre> |
| Address address = null; |
| Collection locations = vendor.getLocations(); |
| Iterator it = locations.iterator(); |
| while (it.hasNext()){ |
| Location location = (Location)it.next(); |
| String zipCode = location.getAddress().getZipCode(); |
| if (zipCode.equals("90210")){ |
| address = location.getAddress(); |
| break; |
| } |
| } |
| </pre></blockquote> |
| <p> |
| XPath was standardized by W3C and is used in both XSLT and XPointer. |
| </p> |
| <p> |
| If you want to find out more about XPath, a good place to start |
| is an excellent XPath Tutorial by <a href="http://www.w3schools.com/xpath">W3Schools</a> |
| </p> |
| <p> |
| The official definition of XPath by W3C can be found at |
| <a href="http://www.w3.org/TR/xpath">XML Path Language (XPath) Version 1.0</a> |
| </p> |
| <p> |
| Primary applications of JXPath are in scripting: JSP and similar template/script based technologies. |
| However, programmers who prefer XML-flavored APIs, should consider JXPath as |
| an alternative to other expression languages as well. JXPath is a must-have tool |
| for those who work with mixtures of Java objects and XML and need to frequently |
| traverse through graphs of those. |
| </p> |
| <p> |
| JXPath documentation currently contains: |
| <ul> |
| <li><a href="users-guide.html">User's Guide</a></li> |
| <li><a href="api/index.html">JavaDoc API Documentation</a></li> |
| <!-- <li><a href="design.html">JXPath Design</a>, which is a document |
| primarily intended for those who are interested in extending JXPath. |
| It could also be quite useful if you are debugging a tough problem. |
| </li> |
| --> |
| </ul> |
| </p> |
| </section> |
| </body> |
| </document> |