blob: f1a3838036c1e3230b41e3eec7058626b3326c32 [file] [log] [blame]
\u001B[1mSYNOPSIS\u001B[0m
${project.description}
Original Maven URL:
\u001B[33mmvn:${pkgGroupId}/${pkgArtifactId}/${pkgVersion}\u001B[0m
\u001B[1mDESCRIPTION\u001B[0m
The org.apache.commons.jxpath package defines a simple interpreter of an expression language called XPath.
JXPath applies XPath expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts,
DOM etc, including mixtures thereof.
Consider this example:
\u001B[32mAddress address = (Address)JXPathContext.newContext(vendor).\u001B[0m
\u001B[32mgetValue("locations[address/zipCode='90210']/address");\u001B[0m
This XPath expression is equivalent to the following Java code:
\u001B[32mAddress address = null;\u001B[0m
\u001B[32mCollection locations = vendor.getLocations();\u001B[0m
\u001B[32mIterator it = locations.iterator();\u001B[0m
\u001B[32mwhile (it.hasNext()){\u001B[0m
\u001B[32mLocation location = (Location)it.next();\u001B[0m
\u001B[32mString zipCode = location.getAddress().getZipCode();\u001B[0m
\u001B[32mif (zipCode.equals("90210")){\u001B[0m
\u001B[32maddress = location.getAddress();\u001B[0m
\u001B[32mbreak;\u001B[0m
\u001B[32m}\u001B[0m
\u001B[32m}\u001B[0m
XPath was standardized by W3C and is used in both XSLT and XPointer.
If you want to find out more about XPath, a good place to start is an excellent XPath Tutorial by W3Schools
The official definition of XPath by W3C can be found at XML Path Language (XPath) Version 1.0
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.
\u001B[1mSEE ALSO\u001B[0m
\u001B[36mhttp://commons.apache.org/jxpath/\u001B[0m