Groovy Documentation

org.jdesktop.xpath
[Java] Class XPathUtils

java.lang.Object
  org.jdesktop.xpath.XPathUtils

public class XPathUtils
extends Object

Various utilities for working with XPath. This class uses a static XPath object for most of it's work. This XPath object is preconfigured to use the extended XPath functions of the org.jdesktop.xpath.function package.

Authors:
rbair


Field Summary
private static XPathFunctionResolverImpl functionResolver

private static XPath xpath

 
Constructor Summary
private XPathUtils()

 
Method Summary
static XPathExpression compile(String expression)

Compiles the given expression, using the internal XPath instance of this class and returns the XPathExpression.

static org.w3c.dom.Node getElement(String expression, org.w3c.dom.Node node)

Returns a Node matching the given expression.

static org.w3c.dom.Node getElement(XPathExpression expression, org.w3c.dom.Node node)

Returns a Node matching the given expression.

static SimpleNodeList getElements(String expression, org.w3c.dom.Node node)

Returns a SimpleNodeList containing all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).

static SimpleNodeList getElements(XPathExpression expression, org.w3c.dom.Node node)

Returns a SimpleNodeList containing all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).

static String getString(String expression, org.w3c.dom.Node node)

Returns the text content of the Node matching the given expression.

static String getString(String expression, org.w3c.dom.Node node, String namespace, String namespacePrefix)

static String getString(XPathExpression expression, org.w3c.dom.Node node)

Returns the text content of the Node matching the given expression.

static String toXML(org.w3c.dom.Document dom)

Exports this DOM as a String

static String toXML(org.w3c.dom.Document dom, Properties outputProperties)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

functionResolver

private static final XPathFunctionResolverImpl functionResolver


xpath

private static final XPath xpath


 
Constructor Detail

XPathUtils

private XPathUtils()


 
Method Detail

compile

public static XPathExpression compile(String expression)
Compiles the given expression, using the internal XPath instance of this class and returns the XPathExpression.
throws:
XPathExpressionException for a malformed XPath expression
Parameters:
expression - The XPath expression to compile
Returns:
the compiled XPathExpression


getElement

public static org.w3c.dom.Node getElement(String expression, org.w3c.dom.Node node)
Returns a Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
Node. May be null.


getElement

public static org.w3c.dom.Node getElement(XPathExpression expression, org.w3c.dom.Node node)
Returns a Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
Node. May be null.


getElements

public static SimpleNodeList getElements(String expression, org.w3c.dom.Node node)
Returns a SimpleNodeList containing all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
SimpleNodeList containing the results from the expression. This will never be null, but may contain no results.


getElements

public static SimpleNodeList getElements(XPathExpression expression, org.w3c.dom.Node node)
Returns a SimpleNodeList containing all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
SimpleNodeList containing the results from the expression. This will never be null, but may contain no results.


getString

public static String getString(String expression, org.w3c.dom.Node node)
Returns the text content of the Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
text content of the selected Node. May be null.


getString

public static String getString(String expression, org.w3c.dom.Node node, String namespace, String namespacePrefix)


getString

public static String getString(XPathExpression expression, org.w3c.dom.Node node)
Returns the text content of the Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
text content of the selected Node. May be null.


toXML

public static String toXML(org.w3c.dom.Document dom)
Exports this DOM as a String


toXML

public static String toXML(org.w3c.dom.Document dom, Properties outputProperties)


 

Groovy Documentation