Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xpath
Class XPath

    java.lang.Object
      |
      +--org.apache.xpath.XPath

public class XPath
extends java.lang.Object
implements java.io.Serializable

The XPath class represents the semantic parse tree of the XPath pattern. It is the representation of the grammar which filters out the choice for replacement order of the production rules. In order to conserve memory and reduce object creation, the tree is represented as an array of integers: [op code][length][...] where strings are represented within the array as indexes into the token tree.

See Also:
  Serialized Form

Field Summary
`static int` | `MATCH`
`static double` | `MATCH_SCORE_NODETEST` **For advanced use only** The match score if the pattern consists of just a NodeTest.
`static double` | `MATCH_SCORE_NONE` **For advanced use only** The match score if no match is made.
`static double` | `MATCH_SCORE_NSWILD` **For advanced use only** The match score if the pattern pattern has the form NCName:*.
`static double` | `MATCH_SCORE_OTHER` **For advanced use only** The match score if the pattern consists of something other than just a NodeTest or just a qname.
`static double` | `MATCH_SCORE_QNAME` **For advanced use only** The match score if the pattern has the form of a QName optionally preceded by an @ character.
`static int` | `SELECT`

Constructor Summary
`XPath(java.lang.String exprString, Locator locator, PrefixResolver prefixResolver, int type)` Construct an XPath object.

Method Summary
`void` | `assert(boolean b, java.lang.String msg)` Tell the user of an assertion error, and probably throw an exception.
`void` | `error(XPathContext xctxt, Node sourceNode, int msg, java.lang.Object[] args)` Tell the user of an error, and probably throw an exception.
`XObject` | `execute(XPathContext xctxt, Node contextNode, PrefixResolver namespaceContext)` **Experimental** Given an expression and a context, evaluate the XPath and call the callback as nodes are found.
`Expression` | `getExpression()`
`Locator` | `getLocator()`
`double` | `getMatchScore(XPathContext xctxt, Node context)` Get the match score of the given node.
`java.lang.String` | `getPatternString()`
`java.util.Vector` | `getTargetElementStrings()` **For advanced use only** This method is for building indexes of match patterns for fast lookup.
`void` | `installFunction(java.lang.String name, int funcIndex, Function func)` Install a built-in function.
`void` | `setExpression(Expression exp)`
`void` | `setLocator(Locator l)`
`void` | `warn(XPathContext xctxt, Node sourceNode, int msg, java.lang.Object[] args)` Warn the user of an problem.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SELECT

    public static final int SELECT

### MATCH

    public static final int MATCH

### MATCH_SCORE_NONE

    public static final double MATCH_SCORE_NONE

  **For advanced use only** The match score if no match is made.

### MATCH_SCORE_QNAME

    public static final double MATCH_SCORE_QNAME

  **For advanced use only** The match score if the pattern has the form of a QName optionally preceded by an @ character.

### MATCH_SCORE_NSWILD

    public static final double MATCH_SCORE_NSWILD

  **For advanced use only** The match score if the pattern pattern has the form NCName:*.

### MATCH_SCORE_NODETEST

    public static final double MATCH_SCORE_NODETEST

  **For advanced use only** The match score if the pattern consists of just a NodeTest.

### MATCH_SCORE_OTHER

    public static final double MATCH_SCORE_OTHER

  **For advanced use only** The match score if the pattern consists of something other than just a NodeTest or just a qname.

Constructor Detail

### XPath

    public XPath(java.lang.String exprString,
                 Locator locator,
                 PrefixResolver prefixResolver,
                 int type)
          throws SAXException

  Construct an XPath object. The object must be initialized by the XPathParser.initXPath method.

Method Detail

### getExpression

    public Expression getExpression()

### setExpression

    public void setExpression(Expression exp)

### getLocator

    public Locator getLocator()

### setLocator

    public void setLocator(Locator l)

### getPatternString

    public java.lang.String getPatternString()

### execute

    public XObject execute(XPathContext xctxt,
                           Node contextNode,
                           PrefixResolver namespaceContext)
                    throws SAXException

  **Experimental** Given an expression and a context, evaluate the XPath and call the callback as nodes are found. Only some simple types of expresions right now can call back, so if this method returns null, then the callbacks have been called, otherwise a valid XObject will be returned.
  Parameters:
    `xctxt` - The execution context.
    `contextNode` - The node that "." expresses.
    `namespaceContext` - The context in which namespaces in the XPath are supposed to be expanded.
    `callback` - Interface that implements the processLocatedNode method.
    `callbackInfo` - Object that will be passed to the processLocatedNode method.
    `stopAtFirst` - True if the search should stop once the first node in document order is found.
  Returns:
    The result of the XPath or null if callbacks are used.
  Throws:
    SAXException - thrown if the active ProblemListener decides the error condition is severe enough to halt processing.
    SAXException - thrown if the error condition is severe enough to halt processing.

### getMatchScore

    public double getMatchScore(XPathContext xctxt,
                                Node context)
                         throws SAXException

  Get the match score of the given node.
  Parameters:
    `context` - The current source tree context node.

### installFunction

    public void installFunction(java.lang.String name,
                                int funcIndex,
                                Function func)

  Install a built-in function.
  Parameters:
    `name` - The unqualified name of the function.
    `funcIndex` - The index of the function in the table.
    `func` - A Implementation of an XPath Function object.
  Returns:
    the position of the function in the internal index.

### getTargetElementStrings

    public java.util.Vector getTargetElementStrings()

  **For advanced use only** This method is for building indexes of match patterns for fast lookup. This allows a caller to get the name or type of a node, and quickly find the likely candidates that may match.

### warn

    public void warn(XPathContext xctxt,
                     Node sourceNode,
                     int msg,
                     java.lang.Object[] args)
              throws SAXException

  Warn the user of an problem.

### assert

    public void assert(boolean b,
                       java.lang.String msg)
                throws SAXException

  Tell the user of an assertion error, and probably throw an exception.

### error

    public void error(XPathContext xctxt,
                      Node sourceNode,
                      int msg,
                      java.lang.Object[] args)
               throws SAXException

  Tell the user of an error, and probably throw an exception.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 Apache XML Project. All Rights Reserved.