struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Plotnikov" <>
Subject [JXPath] support for DOM and transparent containers
Date Mon, 03 Sep 2001 01:45:08 GMT
I checked in two important additions to JXPath.

1. JXPath now supports DOM Nodes in addition to JavaBeans, objects with
Dynamic Properties and collections.  The DOM object can be the context node
of JXPathContext or it can be a value of a property, element of a
collection, variable value etc.  Let's say we have a path "$foo/bar/baz". It
will work just fine if the value of the variable "foo" is a JavaBean, whose
property "bar" is a DOM Node, which has a child element named "baz".   The
intepretation of XPath over DOM structures is implemented in strict
accordance with the XPath specification (at least I did my best). For
instance, the "attribute" axis is supported for DOM objects, even though it
is not applicable to JavaBeans.

I believe the addition of DOM support brings a certain closure to the whole
idea of using the XPath language to traverse Java object graphs.

2. JXPath now also supports "transparent containers".  Such a Container is
an object with the getValue() and setValue() methods.  A container is
traversed by JXPath transparently.  In the example above, the property "bar"
could be a Container that returns a DOM Node for getValue().  I implemented
a sample Container, XMLDocumentContainer, which is initialized with a URL or
a transformer Source. The first time the getValue() method is called, it
loads and parses an XML file.  JXPath than transparently walks into the DOM
tree for that file.

This feature can be used can be used when you need to occasionally access
some reference files. You simply wrap them into XMLDocumentContainers and
then use XPaths to access their elements. This way you can avoid unnecessary

- Dmitri

View raw message