Save This Page
Home » dom4j-1.6.1 » org.dom4j » [javadoc | source]
org.dom4j
public interface: XPath [javadoc | source]

All Implemented Interfaces:
    NodeFilter

All Known Implementing Classes:
    DefaultXPath

XPath represents an XPath expression after it has been parsed from a String.

Method from org.dom4j.XPath Summary:
booleanValueOf,   evaluate,   getFunctionContext,   getNamespaceContext,   getText,   getVariableContext,   matches,   numberValueOf,   selectNodes,   selectNodes,   selectNodes,   selectObject,   selectSingleNode,   setFunctionContext,   setNamespaceContext,   setNamespaceURIs,   setVariableContext,   sort,   sort,   valueOf
Method from org.dom4j.XPath Detail:
 public boolean booleanValueOf(Object context)
    Retrieve a boolean-value interpretation of this XPath expression when evaluated against a given context.

    The boolean-value of the expression is determined per the boolean(..) core function as defined in the XPath specification. This means that an expression that selects zero nodes will return false, while an expression that selects one-or-more nodes will return true.

 public Object evaluate(Object context)

    evaluate evaluates an XPath expression and returns the result as an Object . The object returned can either be a List of Node instances, a Node instance, a String or a Number instance depending on the XPath expression.

 public FunctionContext getFunctionContext()
    DOCUMENT ME!
 public NamespaceContext getNamespaceContext()
    DOCUMENT ME!
 public String getText()

    getText will return the textual version of the XPath expression.

 public VariableContext getVariableContext()
    DOCUMENT ME!
 public boolean matches(Node node)

    matches returns true if the given node matches the XPath expression. To be more precise when evaluating this XPath expression on the given node the result set must include the node.

 public Number numberValueOf(Object context)

    numberValueOf evaluates an XPath expression and returns the numeric value of the XPath expression if the XPath expression results is a number, or null if the result is not a number.

 public List selectNodes(Object context)

    selectNodes performs this XPath expression on the given Node or List of Node s instances appending all the results together into a single list.

 public List selectNodes(Object context,
    XPath sortXPath)

    selectNodes evaluates the XPath expression on the given Node or List of Node s and returns the result as a List of Node s sorted by the sort XPath expression.

 public List selectNodes(Object context,
    XPath sortXPath,
    boolean distinct)

    selectNodes evaluates the XPath expression on the given Node or List of Node s and returns the result as a List of Node s sorted by the sort XPath expression.

 public Object selectObject(Object context)Deprecated! please -  use evaluate(Object) instead. WILL BE REMOVED IN
dom4j-1.6 !!

    selectObject evaluates an XPath expression and returns the result as an Object . The object returned can either be a List of Node instances, a Node instance, a String or a Number instance depending on the XPath expression.

 public Node selectSingleNode(Object context)

    selectSingleNode evaluates this XPath expression on the given Node or List of Node s and returns the result as a single Node instance.

 public  void setFunctionContext(FunctionContext functionContext)
    Sets the function context to be used when evaluating XPath expressions
 public  void setNamespaceContext(NamespaceContext namespaceContext)
    Sets the namespace context to be used when evaluating XPath expressions
 public  void setNamespaceURIs(Map map)

    Sets the current NamespaceContext from a Map where the keys are the String namespace prefixes and the values are the namespace URIs.

    For example:

    Map uris = new HashMap();
    uris.put("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
    uris.put("m", "urn:xmethodsBabelFish");
    XPath xpath = document
    .createXPath("SOAP-ENV:Envelope/SOAP-ENV:Body/m:BabelFish");
    xpath.setNamespaceURIs(uris);
    Node babelfish = xpath.selectSingleNode(document);
    

 public  void setVariableContext(VariableContext variableContext)
    Sets the variable context to be used when evaluating XPath expressions
 public  void sort(List list)
 public  void sort(List list,
    boolean distinct)

    sort sorts the given List of Nodes using this XPath expression as a java.util.Comparator and optionally removing duplicates.

 public String valueOf(Object context)

    valueOf evaluates this XPath expression and returns the textual representation of the results using the XPath string() function.