com.werken.xpath

Class XPath


public class XPath
extends java.lang.Object

Main run-time interface into the XPath functionality

The XPath object embodies a textual XPath as described by the W3C XPath specification. It can be applied against a context node (or nodeset) along with context-helpers to produce the result of walking the XPath.

Example usage:

  

      // Create a new XPath
      XPath xpath = new XPath("a/b/c/../d/.[@name="foo"]);

      // Create the ContextSupport
      ContextSupport helper = new ContextSupport();

      // Use the XPathFunctionContext instance as the implement
      // for function resolution.
      helper.setFunctionContext( XPathFunctionContext.getInstance() );

      // Apply the XPath to your root context.
      Object results = xpath.applyTo(helper, myContext);

  
  

Author:
bob mcwhirter (bob @ werken.com)

See Also:
ContextSupport, NamespaceContext, VariableContext, FunctionContext, XPathFunctionContext

Constructor Summary

XPath(String xpath)
Construct an XPath

Method Summary

List
applyTo(Document doc)
List
applyTo(Element node)
List
applyTo(List nodes)
List
applyTo(ContextSupport contextSupport, Document doc)
List
applyTo(ContextSupport contextSupport, Element node)
Apply this XPath to a single root node
List
applyTo(ContextSupport contextSupport, List nodes)
Apply this XPath to a list of nodes
String
getString()
Retrieve the textual XPath string used to initialize this Object
String
toString()

Constructor Details

XPath

public XPath(String xpath)
Construct an XPath

Method Details

applyTo

public List applyTo(Document doc)


applyTo

public List applyTo(Element node)


applyTo

public List applyTo(List nodes)


applyTo

public List applyTo(ContextSupport contextSupport,
                    Document doc)


applyTo

public List applyTo(ContextSupport contextSupport,
                    Element node)
Apply this XPath to a single root node

Parameters:
contextSupport - Walk-assisting state
node - The root context node


applyTo

public List applyTo(ContextSupport contextSupport,
                    List nodes)
Apply this XPath to a list of nodes

Parameters:
contextSupport - Walk-assisting state
nodes - Root NodeSet context


getString

public String getString()
Retrieve the textual XPath string used to initialize this Object

Returns:
The XPath string


toString

public String toString()


Copyright B) 2000 bob mcwhirter and The Werken & Sons Company. All Rights Reserved.