|
BEA Systems, Inc. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weblogic.xml.xpath.DOMXPath
Evaluates an XPath against a DOM representation of an XML document.
IMPORTANT: Each of the evaluateAs...() methods can take either a DOM Document or DOM Node. You should only pass a DOM Node if you really mean to evaluate the xpath in relation to a DOM subtree. Do not use the document element (Document.getDocumentElement()) if your intention is to evaluate the xpath against the whole document - these are not the same thing.To illustrate the difference, consider matching a simple
relative location path 'foo' against a document containing a single
element
Field Summary | |
static int |
BOOLEAN
Returned by getType() to indicate that this XPath evaluates to a boolean. |
static int |
NAMESPACE_NODE_TYPE
Type for synthesized namespace nodes. |
static int |
NODESET
Returned by getType() to indicate that this XPath evaluates to a node-set. |
static int |
NUMBER
Returned by getType() to indicate that this XPath evaluates to a floating point number. |
static int |
OTHER
Returned by getType() to indicate that this XPath evaluates to an extension-defined object. |
static int |
STRING
Returned by getType() to indicate that this XPath evaluates to a string. |
Constructor Summary | |
DOMXPath(java.lang.String xpath)
Constructs an object for evaluating the XPath expression contained in the given String. |
Method Summary | |
boolean |
evaluateAsBoolean(org.w3c.dom.Document document)
Evaluates this XPath in the context of the given document and returns the result as a boolean. |
boolean |
evaluateAsBoolean(org.w3c.dom.Node contextNode)
Evaluates this XPath in the context of the given Node and returns the result as a boolean. |
java.util.Set |
evaluateAsNodeset(org.w3c.dom.Document document)
Evaluates this XPath in the context of the given document and returns the result as a node-set. |
java.util.Set |
evaluateAsNodeset(org.w3c.dom.Node contextNode)
Evaluates this XPath in the context of the given Node and returns the result as a node-set. |
double |
evaluateAsNumber(org.w3c.dom.Document document)
Evaluates this XPath in the context of the given document and returns the result as a number. |
double |
evaluateAsNumber(org.w3c.dom.Node contextNode)
Evaluates this XPath in the context of the given Node and returns the result as a number. |
java.lang.String |
evaluateAsString(org.w3c.dom.Document document)
Evaluates this XPath in the context of the given document and returns the result as a String. |
java.lang.String |
evaluateAsString(org.w3c.dom.Node contextNode)
Evaluates this XPath in the context of the given Node and returns the result as a String. |
int |
getType()
Returns one of the integer constants declared above to indicate what type of value this XPath returns. |
static void |
main(java.lang.String[] args)
This method allows an expression to be evaluated from the command line. |
void |
setVariableBindings(java.util.Map bindings)
Sets the variable bindings for the evaluation process. |
java.lang.String |
toString()
Returns the string used to construct thie XPath. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int NODESET
public static final int BOOLEAN
public static final int NUMBER
public static final int STRING
public static final int OTHER
public static final int NAMESPACE_NODE_TYPE
Constructor Detail |
public DOMXPath(java.lang.String xpath) throws XPathException
xpath
- The XPath to be evaluated.xpath
is not a valid xpath
or contains xpath constructs which are not supported.Method Detail |
public int getType() throws XPathException
public java.util.Set evaluateAsNodeset(org.w3c.dom.Document document) throws XPathException
Evaluates this XPath in the context of the given document and returns the result as a node-set. The node-set is represented as a Set of org.w3c.dom.Nodes.
Some effort is made to ensure that Iterators retrived from such a Set will traverse the matched nodes in document order. This guarantee is not made for XPaths which make use of the union or composition operators.
Because the specification does not define conversions to node-set from other types, this method will return null if the XPath naturally evaluates to a type other than node-set.
public java.lang.String evaluateAsString(org.w3c.dom.Document document) throws XPathException
Evaluates this XPath in the context of the given document and returns the result as a String. If this XPath naturally evaluates to a type other than String, the necessary type conversion will be performed as described in the XPath specification.
public boolean evaluateAsBoolean(org.w3c.dom.Document document) throws XPathException
Evaluates this XPath in the context of the given document and returns the result as a boolean. If this XPath naturally evaluates to a type other than boolean, the necessary type conversion will be performed as described in the XPath specification.
public double evaluateAsNumber(org.w3c.dom.Document document) throws XPathException
Evaluates this XPath in the context of the given document and returns the result as a number. If this XPath naturally evaluates to a type other than number, the necessary type conversion will be performed as described in the XPath specification.
public java.util.Set evaluateAsNodeset(org.w3c.dom.Node contextNode) throws XPathException
Evaluates this XPath in the context of the given Node and returns the result as a node-set. The node-set is represented as a Set of org.w3c.dom.Nodes.
Some effort is made to ensure that Iterators retrived from such a Set will traverse the matched nodes in document order. This guarantee is not made for XPaths which make use of the union or composition operators.
Because the specification does not define conversions to node-set from other types, this method will return null if the XPath naturally evaluates to a type other than node-set.
public java.lang.String evaluateAsString(org.w3c.dom.Node contextNode) throws XPathException
Evaluates this XPath in the context of the given Node and returns the result as a String. If this XPath naturally evaluates to a type other than String, the necessary type conversion will be performed as described in the XPath specification.
public boolean evaluateAsBoolean(org.w3c.dom.Node contextNode) throws XPathException
Evaluates this XPath in the context of the given Node and returns the result as a boolean. If this XPath naturally evaluates to a type other than boolean, the necessary type conversion will be performed as described in the XPath specification.
public double evaluateAsNumber(org.w3c.dom.Node contextNode) throws XPathException
Evaluates this XPath in the context of the given Node and returns the result as a number. If this XPath naturally evaluates to a type other than number, the necessary type conversion will be performed as described in the XPath specification.
public void setVariableBindings(java.util.Map bindings)
variableBindings
- Provides a mapping for resolving variable
names which may appear in the XPath. Values in the map which are
instances of java.lang.String
,
java.lang.Boolean
, or java.lang.Number
will be used as values of the corresponding XPath types. Values
which are instances of java.util.List
are assumed to
be node-lists. Values of other types are not currently
recognized.public java.lang.String toString()
public static void main(java.lang.String[] args) throws java.lang.Exception
|
Documentation is available at http://download.oracle.com/docs/cd/E13222_01/wls/docs81 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |