org.apache.muse.util.xml
Class XPathUtils

java.lang.Object
  extended by org.apache.muse.util.xml.XPathUtils

public class XPathUtils
extends Object

XPathUtils is a collection of utility methods related to XPath 1.0. It depends on Apache Xalan.

Author:
Dan Jemiolo (danj)

Field Summary
static String NAMESPACE_URI
          The XPath 1.0 namespace URI.
 
Constructor Summary
XPathUtils()
           
 
Method Summary
static boolean isMatch(Node context, String xpath)
          Evaluates the given XPath as a Boolean expression against the given XML.
static Node[] select(Node context, String xpath)
          Returns the first Node that matches the given XPath expression.
static Node[] selectNodeList(Node context, String xpath)
          Returns a set of all Nodes that match the given XPath expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE_URI

public static final String NAMESPACE_URI
The XPath 1.0 namespace URI.

See Also:
Constant Field Values
Constructor Detail

XPathUtils

public XPathUtils()
Method Detail

isMatch

public static boolean isMatch(Node context,
                              String xpath)
                       throws TransformerException
Evaluates the given XPath as a Boolean expression against the given XML.

Parameters:
context - The node from which to start all XPath evaluations. This node becomes irrelevant if the expression is an absolute path.
xpath - The XPath expression to evaluate.
Returns:
True if the XPath evaluates to "true" or a collection of Nodes.
Throws:
TransformerException -
  • If the XPath expression is invalid.

select

public static Node[] select(Node context,
                            String xpath)
                     throws TransformerException
Returns the first Node that matches the given XPath expression. The expression is evaluated in the context of the first parameter.

Parameters:
context - The node from which to start all XPath evaluations. This node becomes irrelevant if the expression is an absolute path.
xpath - The XPath expression to evaluate.
Returns:
The set of Nodes that match the expression. If there are no matches, the method returns null. If the expression evaluates to a Boolean, string, or number, the Node is a DOM Text with the appropriate value.
Throws:
TransformerException -
  • If the XPath expression is invalid.

selectNodeList

public static Node[] selectNodeList(Node context,
                                    String xpath)
                             throws TransformerException
Returns a set of all Nodes that match the given XPath expression. The expression is evaluated in the context of the first parameter.

Parameters:
context - The node from which to start all XPath evaluations. This node becomes irrelevant if the expression is an absolute path.
xpath - The XPath expression to evaluate.
Returns:
The set of Nodes that match the expression. If there are no matches, the method returns null.
Throws:
TransformerException -
  • If the XPath expression is invalid.


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.