|
The new home
of JXPath is Apache
Jakarta Commons.
JXPath is an interpreter of
an expression language called XPath. JXPath applies
XPath expressions to graphs of Java objects.
XPath was standardized by W3C and
is used in both XSLT and XPointer.
JXPath supports JavaBeans,
Java Collections, Maps etc. It also works with DOM objects,
the same way XPath was originally intended. A DOM node
can be the root of the graph, or a property value,
collection element, variable value. XML files
can be loaded as needed during the traversal of JXPaths.
JXPath supports such operations
as:
-
Graph traversal:
-
Retrieving property values by name
-
Retrieving map elements by key
-
Retrieving collection elements by
the index or search criteria
-
Search in object graphs.
-
Basic logical, arithmetic, string and
collection manipulations
-
Java method calls and object construction
-
Pools of variables
-
Extension functions
Consider this example:
Address address = (Address)JXPath.getValue(vendor,
"locations[address/zipCode='90210']/address");
This XPath expression is equvalent
to the following Java code:
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;
}
}
Primary applications of
JXPath are in scripting: JSP and similar template/script
based technologies.
Plans for the future
release of JXPath include:
JXPath was
initially developed by Dmitri Plotnikov at PLOTNIX and then
contributed to the Apache Jakarta project. The new home of
JXPath is Jakarta
Commons
|