A specialized implementation of the ExpressionEngine interface
that is able to evaluate XPATH expressions.
This class makes use of
Commons JXPath for handling XPath expressions and mapping them to the
nodes of a hierarchical configuration. This makes the rich and powerfull
XPATH syntax available for accessing properties from a configuration object.
For selecting properties arbitrary XPATH expressions can be used, which
select single or multiple configuration nodes. The associated
Configuration instance will directly pass the specified
property keys into this engine. If a key is not syntactically correct, an
exception will be thrown.
For adding new properties, this expression engine uses a specific syntax: the
"key" of a new property must consist of two parts that are
separated by whitespace:
- An XPATH expression selecting a single node, to which the new element(s)
are to be added. This can be an arbitrary complex expression, but it must
select exactly one node, otherwise an exception will be thrown.
- The name of the new element(s) to be added below this parent node. Here
either a single node name or a complete path of nodes (separated by the
"/" character) can be specified.
Some examples for valid keys that can be passed into the configuration's
addProperty() method follow:
"/tables/table[1] type"
This will add a new type node as a child of the first
table element.
"/tables/table[1] @type"
Similar to the example above, but this time a new attribute named
type will be added to the first table element.
"/tables table/fields/field/name"
This example shows how a complex path can be added. Parent node is the
tables element. Here a new branch consisting of the nodes
table , fields , field , and
name will be added.
since: 1.3 author: Oliver Heger version: $Id: XPathExpressionEngine.java 466413 2006-10-21 15:23:45Z oheger $ |