BEA Systems, Inc.

WebLogic Server 8.1 API Reference

weblogic.xml.xpath
Class XMLNodeXPath

java.lang.Object
  |
  +--weblogic.xml.xpath.XMLNodeXPath

public final class XMLNodeXPath
extends java.lang.Object

Evaluates an XPath against an XMLNode representation of an XML document.

XPath Support

Due to some limitations in the way XMLNode models an XML document, it is impossible for XMLNodeXPath to fully support the XPath specification. The XMLNodeXPath constructor will throw an XPathUnsupportedException if the given XPath contains any of the unsupported features or constructs described below:

Axes

The following axes cannot be supported by XMLNodeXPath: attribute, namespace, comment, processing-instruction, following, following-sibling, preceding, preceding-sibling.

Author:
Copyright © 2002 BEA Systems, Inc. All Rights Reserved.

Field Summary
static int BOOLEAN
          Returned by getType() to indicate that this XPath evaluates to a boolean.
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
XMLNodeXPath(java.lang.String xpath)
          Constructs an object for evaluating the XPath expression contained in the given String.
 
Method Summary
 boolean evaluateAsBoolean(weblogic.xml.xmlnode.XMLNode node)
          Evaluates this XPath in the context of the given XMLNode Node and returns the result as a boolean.
 java.util.List evaluateAsNodeset(weblogic.xml.xmlnode.XMLNode node)
          Evaluates this XPath in the context of the given Node and returns the result as a node-set.
 double evaluateAsNumber(weblogic.xml.xmlnode.XMLNode node)
          Evaluates this XPath in the context of the given XMLNode Node and returns the result as a number.
 java.lang.String evaluateAsString(weblogic.xml.xmlnode.XMLNode node)
          Evaluates this XPath in the context of the given XMLNode 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

NODESET

public static final int NODESET
Returned by getType() to indicate that this XPath evaluates to a node-set.

BOOLEAN

public static final int BOOLEAN
Returned by getType() to indicate that this XPath evaluates to a boolean.

NUMBER

public static final int NUMBER
Returned by getType() to indicate that this XPath evaluates to a floating point number.

STRING

public static final int STRING
Returned by getType() to indicate that this XPath evaluates to a string.

OTHER

public static final int OTHER
Returned by getType() to indicate that this XPath evaluates to an extension-defined object.
Constructor Detail

XMLNodeXPath

public XMLNodeXPath(java.lang.String xpath)
             throws XPathException
Constructs an object for evaluating the XPath expression contained in the given String.

Parameters:
xpath - The XPath to be evaluated.
Throws:
java.lang.IllegalArgumentException - if xpath is null.
XPathException - if xpath is not a valid xpath or contains xpath constructs which are not supported.
Method Detail

getType

public int getType()
            throws XPathException
Returns one of the integer constants declared above to indicate what type of value this XPath returns.

setVariableBindings

public void setVariableBindings(java.util.Map bindings)
Sets the variable bindings for the evaluation process. This method must not be called after one of the xpath's evaluate methods has been called.

Parameters:
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.
Throws:
java.lang.IllegalStateException - if processing has already begun.

evaluateAsString

public java.lang.String evaluateAsString(weblogic.xml.xmlnode.XMLNode node)
                                  throws XPathException
Evaluates this XPath in the context of the given XMLNode 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 sepcification.

evaluateAsBoolean

public boolean evaluateAsBoolean(weblogic.xml.xmlnode.XMLNode node)
                          throws XPathException
Evaluates this XPath in the context of the given XMLNode 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 sepcification.

evaluateAsNodeset

public java.util.List evaluateAsNodeset(weblogic.xml.xmlnode.XMLNode node)
                                 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 List of weblogic.xml.xmlnode.XMLNodes. 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.

evaluateAsNumber

public double evaluateAsNumber(weblogic.xml.xmlnode.XMLNode node)
                        throws XPathException
Evaluates this XPath in the context of the given XMLNode 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 sepcification.

toString

public java.lang.String toString()
Returns the string used to construct thie XPath.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
This method allows an expression to be evaluated from the command line. Simply pass a url or filename as the first argument and an xpath as the second argument.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs81b