The jaxen
project is a Java XPath Engine.
jaxen
is a universal object model walker, capable of evaluating
XPath expressions across multiple models. Currently supported
are dom4j and JDOM.
We use an Apache-style open source license which is one of the least
restrictive licenses around, you can use jaxen
to create new products
without them having to be open source.
After implementing an XPath engine for both dom4j and
JDOM, and attempting to keep them both in sync, it was
decided that factoring out the commonality would be a Good Thing. Thus, jaxen
provides a single point for XPath expression evaluation, regardless of the target
object model, whether its dom4j, JDOM, DOM, JavaBeans,
or whatnot.
jaxen
is better than werken.xpath specifically because it better
handles XPath expressions, and syntax error reporting. Additionally, since
jaxen is a unified code-base, developer effort isn't split between maintaining
the dom4j version and the JDOM version. More hands working on
the same project reduces bug count.
jaxen
may be perceived to be better than other XPath technologies since it
provides a single cohesive API for evaluating XPaths against multiple object
models. Learn the jaxen
API, and apply it to dom4j, JDOM,
EXML or DOM trees in exactly the same way.
Also, since jaxen
works against an adaptor which provides InfoSet access
to arbitrary object models, it should be possible to build even larger
tools in terms of jaxen
, to work with multiple models. For example, an
XQL engine could be developed, which would automagically work with
all models already supported by jaxen
.
jaxen
itself is based upon SAXPath, which is
an event-based model for parsing XPath expressions.
jaxen
currently has navigators defined for dom4j
and JDOM, two popular and convenient object models
for representing XML documents. Additionally, The Mind Electric's
EXML embeds jaxen
, providing better XPath support within the GLUE platform.
Of course, W3C DOM is also supported.
The only thing required is an implementation of the interface
org.jaxen.Navigator
. Not all of the interface is required,
and a default implementation, in the form of org.jaxen.DefaultNavigator
is also provided.
Since many of the XPath axes can be defined in terms of each other (for example,
the ancestor
axis is merely a the parent
recursively
applied), only a few low-level axis iterators are required to initially get
started. Of course, you may implement them directly, instead of relying upon
jaxen
's composition ability.
No.
The DocumentNavigators
provided with jaxen
would be used
by themselves, without the XPath evaluation engine, to provide univeral
access to many object models for other technologies.
jaxen
has been embedded directly into dom4j to provide
easy XPath evaluation directly from your documents. Additionally, it's
being integrated into David Megginson's
NewsML Framework.