org.apache.xalan.xpath
Class XPath

java.lang.Object
  |
  +--org.apache.xalan.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 ELEMWILDCARD
          **For advanced use only** [ELEMWILDCARD] Means ELEMWILDCARD ("*"), used instead of string index in some places.
static int EMPTY
          [EMPTY] Empty slot to indicate NULL.
static int ENDOP
          **For advanced use only** [ENDOP] Some operators may like to have a terminator.
static int FROM_ANCESTORS
          **For advanced use only** [FROM_stepType] [length, including predicates] [length of just the step, without the predicates] {node test} {predicates}? returns: XBoolean
static int FROM_ANCESTORS_OR_SELF
           
static int FROM_ATTRIBUTES
           
static int FROM_CHILDREN
           
static int FROM_DESCENDANTS
           
static int FROM_DESCENDANTS_OR_SELF
           
static int FROM_FOLLOWING
           
static int FROM_FOLLOWING_SIBLINGS
           
static int FROM_NAMESPACE
           
static int FROM_PARENT
           
static int FROM_PRECEDING
           
static int FROM_PRECEDING_SIBLINGS
           
static int FROM_ROOT
           
static int FROM_SELF
           
static int FUNC_BOOLEAN
           
static int FUNC_CEILING
           
static int FUNC_CONCAT
           
static int FUNC_CONTAINS
           
static int FUNC_COUNT
           
static int FUNC_CURRENT
           
static int FUNC_DOCLOCATION
           
static int FUNC_EXT_ELEM_AVAILABLE
           
static int FUNC_EXT_FUNCTION_AVAILABLE
           
static int FUNC_FALSE
           
static int FUNC_FLOOR
           
static int FUNC_GENERATE_ID
           
static int FUNC_ID
           
static int FUNC_KEY
           
static int FUNC_LANG
           
static int FUNC_LAST
           
static int FUNC_LOCAL_PART
           
static int FUNC_NAMESPACE
           
static int FUNC_NORMALIZE_SPACE
           
static int FUNC_NOT
           
static int FUNC_NUMBER
           
static int FUNC_POSITION
           
static int FUNC_QNAME
           
static int FUNC_ROUND
           
static int FUNC_STARTS_WITH
           
static int FUNC_STRING
           
static int FUNC_STRING_LENGTH
           
static int FUNC_SUBSTRING
           
static int FUNC_SUBSTRING_AFTER
           
static int FUNC_SUBSTRING_BEFORE
           
static int FUNC_SUM
           
static int FUNC_SYSTEM_PROPERTY
           
static int FUNC_TRANSLATE
           
static int FUNC_TRUE
           
static int FUNC_UNPARSED_ENTITY_URI
           
static int LOCATIONPATHEX_ISSIMPLE
           
static int LOCATIONPATHEX_MASK
           
static int MAPINDEX_LENGTH
          **For advanced use only** The length is always the opcode position + 1.
static int MATCH_ANY_ANCESTOR
          **For advanced use only** For match patterns.
static int MATCH_ATTRIBUTE
          **For advanced use only** For match patterns.
static int MATCH_IMMEDIATE_ANCESTOR
          **For advanced use only** For match patterns.
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 NODENAME
          **For advanced use only** [NODENAME] [index to ns token or EMPTY] [index to name token] returns: XBoolean
static int NODETYPE_ANYELEMENT
          **For advanced use only** [NODETYPE_ANY] No size or arguments.
static int NODETYPE_COMMENT
          **For advanced use only** [NODETYPE_COMMENT] No size or arguments.
static int NODETYPE_NODE
          **For advanced use only** [NODETYPE_NODE] No size or arguments.
static int NODETYPE_PI
          **For advanced use only** [NODETYPE_PI] [index to token] Note: must not overlap function OP number! returns: XBoolean
static int NODETYPE_ROOT
          **For advanced use only** [NODETYPE_ROOT] No size or arguments.
static int NODETYPE_TEXT
          **For advanced use only** [NODETYPE_TEXT] No size or arguments.
static int OP_AND
          **For advanced use only** [OP_AND] [length] {boolean expression} {boolean expression} returns: XBoolean
static int OP_ARGUMENT
          **For advanced use only** [OP_ARGUMENT] (Function argument.) [length] {expression} returns: XNodeSet XNumber XString XBoolean XRTree XObject
static int OP_BOOL
          **For advanced use only** [OP_BOOL] (cast operation) [length] {expression} returns: XBoolean
static int OP_DIV
          **For advanced use only** [OP_DIV] [length] {number expression} {number expression} returns: XNumber
static int OP_EQUALS
          **For advanced use only** [OP_EQUALS] [length] {expression} {expression} returns: XBoolean
static int OP_EXTFUNCTION
          **For advanced use only** [OP_EXTFUNCTION] (Extension function.) [length] [index to namespace token] [index to function name token] {OP_ARGUMENT}* returns: XNodeSet XNumber XString XBoolean XRTree XObject
static int OP_FUNCTION
          **For advanced use only** [OP_FUNCTION] [length] [FUNC_name] {OP_ARGUMENT}* [ENDOP] returns: XNodeSet XNumber XString XBoolean XRTree XObject
static int OP_GROUP
          **For advanced use only** [OP_GROUP] [length] {expression} returns: XNodeSet XNumber XString XBoolean XRTree XObject
static int OP_GT
          **For advanced use only** [OP_GT] (greater-than) [length] {number expression} {number expression} returns: XBoolean
static int OP_GTE
          **For advanced use only** [OP_GTE] (greater-than-or-equals) [length] {number expression} {number expression} returns: XBoolean
static int OP_LITERAL
          **For advanced use only** [OP_LITERAL] [3] [index to token] returns: XString
static int OP_LOCATIONPATH
          **For advanced use only** [OP_LOCATIONPATH] [length] {FROM_stepType} | {function}{predicate}* [ENDOP] (Note that element and attribute namespaces and names can be wildcarded '*'.) returns: XNodeSet
static int OP_LOCATIONPATH_EX
           
static int OP_LOCATIONPATHPATTERN
          **For advanced use only** [OP_UNION] [length] {PathExpr}+ returns: XNodeSet
static int OP_LT
          **For advanced use only** [OP_LT] (less-than) [length] {number expression} {number expression} returns: XBoolean
static int OP_LTE
          **For advanced use only** [OP_LTE] (less-than-or-equals) [length] {number expression} {number expression} returns: XBoolean
static int OP_MATCHPATTERN
          **For advanced use only** [OP_UNION] [length] {PathExpr}+ returns: XNodeSet
static int OP_MINUS
          **For advanced use only** [OP_MINUS] [length] {number expression} {number expression} returns: XNumber
static int OP_MOD
          **For advanced use only** [OP_MOD] [length] {number expression} {number expression} returns: XNumber
static int OP_MULT
          **For advanced use only** [OP_MULT] [length] {number expression} {number expression} returns: XNumber
static int OP_NEG
          **For advanced use only** [OP_NEG] [length] {number expression} returns: XNumber
static int OP_NOTEQUALS
          **For advanced use only** [OP_NOTEQUALS] [length] {expression} {expression} returns: XBoolean
static int OP_NUMBER
          **For advanced use only** [OP_NUMBER] (cast operation) [length] {expression} returns: XBoolean
static int OP_NUMBERLIT
          **For advanced use only** [OP_NUMBERLIT] (Number literal.) [3] [index to token] returns: XString
static int OP_OR
          **For advanced use only** [OP_OR] [length] {boolean expression} {boolean expression} returns: XBoolean
static int OP_PLUS
          **For advanced use only** [OP_PLUS] [length] {number expression} {number expression} returns: XNumber
static int OP_PREDICATE
          **For advanced use only** [OP_PREDICATE] [length] {expression} [ENDOP] (For safety) returns: XBoolean or XNumber
static int OP_QUO
          **For advanced use only** [OP_QUO] [length] {number expression} {number expression} returns: XNumber
static int OP_STRING
          **For advanced use only** [OP_STRING] (cast operation) [length] {expression} returns: XString
static int OP_UNION
          **For advanced use only** [OP_UNION] [length] {PathExpr}+ returns: XNodeSet
static int OP_VARIABLE
          **For advanced use only** [OP_VARIABLE] [3] [index to token] returns: XString
static int OP_XPATH
          **For advanced use only** [OP_XPATH] [length] {expression} returns: XNodeSet XNumber XString XBoolean XRTree XObject
static java.lang.String PSEUDONAME_ANY
          **For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
static java.lang.String PSEUDONAME_COMMENT
          **For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
static java.lang.String PSEUDONAME_OTHER
          **For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
static java.lang.String PSEUDONAME_PI
          **For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
static java.lang.String PSEUDONAME_ROOT
          **For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
static java.lang.String PSEUDONAME_TEXT
          **For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
 
Constructor Summary
XPath()
          Construct an XPath object.
XPath(ProblemListener problemListener)
          Construct a XPath, passing in a problem listener.
 
Method Summary
 XObject execute(XPathSupport execContext, org.w3c.dom.Node context, int opPos)
          **For advanced use only** Execute the XPath object from a given opcode position.
 XObject execute(XPathSupport execContext, org.w3c.dom.Node context, int opPos, NodeCallback callback, java.lang.Object callbackInfo, boolean stopAtFirst)
          **For advanced use only** Execute the XPath object from a given opcode position, calling back to a NodeCallback interface as the nodes are found.
 XObject execute(XPathSupport execContext, org.w3c.dom.Node contextNode, PrefixResolver namespaceContext)
          Given an expression and a context, evaluate the XPath and return the result.
 XObject execute(XPathSupport execContext, org.w3c.dom.Node contextNode, PrefixResolver namespaceContext, NodeCallback callback, java.lang.Object callbackInfo, boolean stopAtFirst)
          **Experimental** Given an expression and a context, evaluate the XPath and call the callback as nodes are found.
 int getArgLengthOfStep(int opPos)
          **For advanced use only** Go to the first child of a given operation.
static int getFirstChildPos(int opPos)
          **For advanced use only** Go to the first child of a given operation.
static int getFirstChildPosOfStep(int opPos)
          **For advanced use only** Go to the first child of a given operation.
 double getMatchScore(XPathSupport execContext, org.w3c.dom.Node context)
          Get the match score of the given node.
 int getNextOpPos(int opPos)
          **For advanced use only** Given an operation position, return the end position, i.e.
static int getNextOpPos(int[] opMap, int opPos)
          **For advanced use only** Given an operation position, return the end position, i.e.
 int getOp(int opPos)
          **For advanced use only** Given an operation position, return the current op.
 int[] getOpMap()
          **For advanced use only** Get the opcode list that describes the XPath operations.
 java.lang.String getPatternString()
          Get the pattern string.
 ProblemListener getProblemListener()
          Get the problem listener property.
 java.util.Vector getTargetElementStrings()
          **For advanced use only** This method is for building indexes of match patterns for fast lookup.
 java.lang.Object[] getTokenQueue()
          **For advanced use only** Get the XPath as a list of tokens.
 int getTokenQueueSize()
          **For advanced use only** Get size of the token queue.
static int installFunction(java.lang.String name, Function func)
          Install a built-in function.
 void installFunction(java.lang.String name, int funcIndex, Function func)
          Install a built-in function.
 XNodeSet locationPath(XPathSupport execContext, org.w3c.dom.Node context, int opPos, NodeCallback callback, java.lang.Object callbackInfo, boolean stopAtFirst)
          **For advanced use only** Execute a location path.
 XObject predicate(XPathSupport execContext, org.w3c.dom.Node context, int opPos)
          **For advanced use only** Evaluate a predicate.
 void setProblemListener(ProblemListener l)
          Set the problem listener property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAPINDEX_LENGTH

public static final int MAPINDEX_LENGTH
**For advanced use only** The length is always the opcode position + 1. Length is always expressed as the opcode+length bytes, so it is always 2 or greater.

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.

ENDOP

public static final int ENDOP
**For advanced use only** [ENDOP] Some operators may like to have a terminator.

EMPTY

public static final int EMPTY
[EMPTY] Empty slot to indicate NULL.

ELEMWILDCARD

public static final int ELEMWILDCARD
**For advanced use only** [ELEMWILDCARD] Means ELEMWILDCARD ("*"), used instead of string index in some places.

OP_XPATH

public static final int OP_XPATH
**For advanced use only** [OP_XPATH] [length] {expression} returns: XNodeSet XNumber XString XBoolean XRTree XObject

OP_OR

public static final int OP_OR
**For advanced use only** [OP_OR] [length] {boolean expression} {boolean expression} returns: XBoolean

OP_AND

public static final int OP_AND
**For advanced use only** [OP_AND] [length] {boolean expression} {boolean expression} returns: XBoolean

OP_NOTEQUALS

public static final int OP_NOTEQUALS
**For advanced use only** [OP_NOTEQUALS] [length] {expression} {expression} returns: XBoolean

OP_EQUALS

public static final int OP_EQUALS
**For advanced use only** [OP_EQUALS] [length] {expression} {expression} returns: XBoolean

OP_LTE

public static final int OP_LTE
**For advanced use only** [OP_LTE] (less-than-or-equals) [length] {number expression} {number expression} returns: XBoolean

OP_LT

public static final int OP_LT
**For advanced use only** [OP_LT] (less-than) [length] {number expression} {number expression} returns: XBoolean

OP_GTE

public static final int OP_GTE
**For advanced use only** [OP_GTE] (greater-than-or-equals) [length] {number expression} {number expression} returns: XBoolean

OP_GT

public static final int OP_GT
**For advanced use only** [OP_GT] (greater-than) [length] {number expression} {number expression} returns: XBoolean

OP_PLUS

public static final int OP_PLUS
**For advanced use only** [OP_PLUS] [length] {number expression} {number expression} returns: XNumber

OP_MINUS

public static final int OP_MINUS
**For advanced use only** [OP_MINUS] [length] {number expression} {number expression} returns: XNumber

OP_MULT

public static final int OP_MULT
**For advanced use only** [OP_MULT] [length] {number expression} {number expression} returns: XNumber

OP_DIV

public static final int OP_DIV
**For advanced use only** [OP_DIV] [length] {number expression} {number expression} returns: XNumber

OP_MOD

public static final int OP_MOD
**For advanced use only** [OP_MOD] [length] {number expression} {number expression} returns: XNumber

OP_QUO

public static final int OP_QUO
**For advanced use only** [OP_QUO] [length] {number expression} {number expression} returns: XNumber

OP_NEG

public static final int OP_NEG
**For advanced use only** [OP_NEG] [length] {number expression} returns: XNumber

OP_STRING

public static final int OP_STRING
**For advanced use only** [OP_STRING] (cast operation) [length] {expression} returns: XString

OP_BOOL

public static final int OP_BOOL
**For advanced use only** [OP_BOOL] (cast operation) [length] {expression} returns: XBoolean

OP_NUMBER

public static final int OP_NUMBER
**For advanced use only** [OP_NUMBER] (cast operation) [length] {expression} returns: XBoolean

OP_UNION

public static final int OP_UNION
**For advanced use only** [OP_UNION] [length] {PathExpr}+ returns: XNodeSet

OP_LITERAL

public static final int OP_LITERAL
**For advanced use only** [OP_LITERAL] [3] [index to token] returns: XString

OP_VARIABLE

public static final int OP_VARIABLE
**For advanced use only** [OP_VARIABLE] [3] [index to token] returns: XString

OP_GROUP

public static final int OP_GROUP
**For advanced use only** [OP_GROUP] [length] {expression} returns: XNodeSet XNumber XString XBoolean XRTree XObject

OP_NUMBERLIT

public static final int OP_NUMBERLIT
**For advanced use only** [OP_NUMBERLIT] (Number literal.) [3] [index to token] returns: XString

OP_ARGUMENT

public static final int OP_ARGUMENT
**For advanced use only** [OP_ARGUMENT] (Function argument.) [length] {expression} returns: XNodeSet XNumber XString XBoolean XRTree XObject

OP_EXTFUNCTION

public static final int OP_EXTFUNCTION
**For advanced use only** [OP_EXTFUNCTION] (Extension function.) [length] [index to namespace token] [index to function name token] {OP_ARGUMENT}* returns: XNodeSet XNumber XString XBoolean XRTree XObject

OP_FUNCTION

public static final int OP_FUNCTION
**For advanced use only** [OP_FUNCTION] [length] [FUNC_name] {OP_ARGUMENT}* [ENDOP] returns: XNodeSet XNumber XString XBoolean XRTree XObject

OP_LOCATIONPATH

public static final int OP_LOCATIONPATH
**For advanced use only** [OP_LOCATIONPATH] [length] {FROM_stepType} | {function}{predicate}* [ENDOP] (Note that element and attribute namespaces and names can be wildcarded '*'.) returns: XNodeSet

LOCATIONPATHEX_MASK

public static final int LOCATIONPATHEX_MASK

LOCATIONPATHEX_ISSIMPLE

public static final int LOCATIONPATHEX_ISSIMPLE

OP_LOCATIONPATH_EX

public static final int OP_LOCATIONPATH_EX

OP_PREDICATE

public static final int OP_PREDICATE
**For advanced use only** [OP_PREDICATE] [length] {expression} [ENDOP] (For safety) returns: XBoolean or XNumber

OP_MATCHPATTERN

public static final int OP_MATCHPATTERN
**For advanced use only** [OP_UNION] [length] {PathExpr}+ returns: XNodeSet

OP_LOCATIONPATHPATTERN

public static final int OP_LOCATIONPATHPATTERN
**For advanced use only** [OP_UNION] [length] {PathExpr}+ returns: XNodeSet

NODETYPE_COMMENT

public static final int NODETYPE_COMMENT
**For advanced use only** [NODETYPE_COMMENT] No size or arguments. Note: must not overlap function OP number! returns: XBoolean

NODETYPE_TEXT

public static final int NODETYPE_TEXT
**For advanced use only** [NODETYPE_TEXT] No size or arguments. Note: must not overlap function OP number! returns: XBoolean

NODETYPE_PI

public static final int NODETYPE_PI
**For advanced use only** [NODETYPE_PI] [index to token] Note: must not overlap function OP number! returns: XBoolean

NODETYPE_NODE

public static final int NODETYPE_NODE
**For advanced use only** [NODETYPE_NODE] No size or arguments. Note: must not overlap function OP number! returns: XBoolean

NODENAME

public static final int NODENAME
**For advanced use only** [NODENAME] [index to ns token or EMPTY] [index to name token] returns: XBoolean

NODETYPE_ROOT

public static final int NODETYPE_ROOT
**For advanced use only** [NODETYPE_ROOT] No size or arguments. returns: XBoolean

NODETYPE_ANYELEMENT

public static final int NODETYPE_ANYELEMENT
**For advanced use only** [NODETYPE_ANY] No size or arguments. returns: XBoolean

FROM_ANCESTORS

public static final int FROM_ANCESTORS
**For advanced use only** [FROM_stepType] [length, including predicates] [length of just the step, without the predicates] {node test} {predicates}? returns: XBoolean

FROM_ANCESTORS_OR_SELF

public static final int FROM_ANCESTORS_OR_SELF

FROM_ATTRIBUTES

public static final int FROM_ATTRIBUTES

FROM_CHILDREN

public static final int FROM_CHILDREN

FROM_DESCENDANTS

public static final int FROM_DESCENDANTS

FROM_DESCENDANTS_OR_SELF

public static final int FROM_DESCENDANTS_OR_SELF

FROM_FOLLOWING

public static final int FROM_FOLLOWING

FROM_FOLLOWING_SIBLINGS

public static final int FROM_FOLLOWING_SIBLINGS

FROM_PARENT

public static final int FROM_PARENT

FROM_PRECEDING

public static final int FROM_PRECEDING

FROM_PRECEDING_SIBLINGS

public static final int FROM_PRECEDING_SIBLINGS

FROM_SELF

public static final int FROM_SELF

FROM_NAMESPACE

public static final int FROM_NAMESPACE

FROM_ROOT

public static final int FROM_ROOT

FUNC_CURRENT

public static final int FUNC_CURRENT

FUNC_LAST

public static final int FUNC_LAST

FUNC_POSITION

public static final int FUNC_POSITION

FUNC_COUNT

public static final int FUNC_COUNT

FUNC_ID

public static final int FUNC_ID

FUNC_KEY

public static final int FUNC_KEY

FUNC_LOCAL_PART

public static final int FUNC_LOCAL_PART

FUNC_NAMESPACE

public static final int FUNC_NAMESPACE

FUNC_QNAME

public static final int FUNC_QNAME

FUNC_GENERATE_ID

public static final int FUNC_GENERATE_ID

FUNC_NOT

public static final int FUNC_NOT

FUNC_TRUE

public static final int FUNC_TRUE

FUNC_FALSE

public static final int FUNC_FALSE

FUNC_BOOLEAN

public static final int FUNC_BOOLEAN

FUNC_NUMBER

public static final int FUNC_NUMBER

FUNC_FLOOR

public static final int FUNC_FLOOR

FUNC_CEILING

public static final int FUNC_CEILING

FUNC_ROUND

public static final int FUNC_ROUND

FUNC_SUM

public static final int FUNC_SUM

FUNC_STRING

public static final int FUNC_STRING

FUNC_STARTS_WITH

public static final int FUNC_STARTS_WITH

FUNC_CONTAINS

public static final int FUNC_CONTAINS

FUNC_SUBSTRING_BEFORE

public static final int FUNC_SUBSTRING_BEFORE

FUNC_SUBSTRING_AFTER

public static final int FUNC_SUBSTRING_AFTER

FUNC_NORMALIZE_SPACE

public static final int FUNC_NORMALIZE_SPACE

FUNC_TRANSLATE

public static final int FUNC_TRANSLATE

FUNC_CONCAT

public static final int FUNC_CONCAT

FUNC_SUBSTRING

public static final int FUNC_SUBSTRING

FUNC_STRING_LENGTH

public static final int FUNC_STRING_LENGTH

FUNC_SYSTEM_PROPERTY

public static final int FUNC_SYSTEM_PROPERTY

FUNC_LANG

public static final int FUNC_LANG

FUNC_EXT_FUNCTION_AVAILABLE

public static final int FUNC_EXT_FUNCTION_AVAILABLE

FUNC_EXT_ELEM_AVAILABLE

public static final int FUNC_EXT_ELEM_AVAILABLE

FUNC_DOCLOCATION

public static final int FUNC_DOCLOCATION

FUNC_UNPARSED_ENTITY_URI

public static final int FUNC_UNPARSED_ENTITY_URI

MATCH_ATTRIBUTE

public static final int MATCH_ATTRIBUTE
**For advanced use only** For match patterns.

MATCH_ANY_ANCESTOR

public static final int MATCH_ANY_ANCESTOR
**For advanced use only** For match patterns.

MATCH_IMMEDIATE_ANCESTOR

public static final int MATCH_IMMEDIATE_ANCESTOR
**For advanced use only** For match patterns.

PSEUDONAME_ANY

public static final java.lang.String PSEUDONAME_ANY
**For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.

PSEUDONAME_ROOT

public static final java.lang.String PSEUDONAME_ROOT
**For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.

PSEUDONAME_TEXT

public static final java.lang.String PSEUDONAME_TEXT
**For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.

PSEUDONAME_COMMENT

public static final java.lang.String PSEUDONAME_COMMENT
**For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.

PSEUDONAME_PI

public static final java.lang.String PSEUDONAME_PI
**For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.

PSEUDONAME_OTHER

public static final java.lang.String PSEUDONAME_OTHER
**For advanced use only** used mainly for keys in the pattern lookup table, for those nodes that don't have unique lookup values.
Constructor Detail

XPath

public XPath(ProblemListener problemListener)
Construct a XPath, passing in a problem listener. The object must be initialized by the XPathProcessorImpl.initXPath method.
Parameters:
problemListener - An interface whereby the caller can listen for errors and warnings.

XPath

public XPath()
Construct an XPath object. The object must be initialized by the XPathProcessorImpl.initXPath method.
Method Detail

getPatternString

public java.lang.String getPatternString()
Get the pattern string.

getTokenQueue

public java.lang.Object[] getTokenQueue()
**For advanced use only** Get the XPath as a list of tokens.

getTokenQueueSize

public int getTokenQueueSize()
**For advanced use only** Get size of the token queue.

getOpMap

public int[] getOpMap()
**For advanced use only** Get the opcode list that describes the XPath operations. It contains operations codes and indexes into the m_tokenQueue. I use an array instead of a full parse tree in order to cut down on the number of objects created.

setProblemListener

public void setProblemListener(ProblemListener l)
Set the problem listener property. This class can have a single listener that can be informed of errors and warnings, and can normally control if an exception is thrown or not (or the problem listeners can throw their own RuntimeExceptions).
Parameters:
l - A ProblemListener interface.

getProblemListener

public ProblemListener getProblemListener()
Get the problem listener property. This class can have a single listener that can be informed of errors and warnings, and can normally control if an exception is thrown or not (or the problem listeners can throw their own RuntimeExceptions).
Returns:
A ProblemListener interface.

execute

public XObject execute(XPathSupport execContext,
                       org.w3c.dom.Node contextNode,
                       PrefixResolver namespaceContext)
                throws org.xml.sax.SAXException
Given an expression and a context, evaluate the XPath and return the result.
Parameters:
execContext - The execution context.
contextNode - The node that "." expresses.
namespaceContext - The context in which namespaces in the XPath are supposed to be expanded.
Throws:
SAXException - thrown if the active ProblemListener decides the error condition is severe enough to halt processing.

execute

public XObject execute(XPathSupport execContext,
                       org.w3c.dom.Node contextNode,
                       PrefixResolver namespaceContext,
                       NodeCallback callback,
                       java.lang.Object callbackInfo,
                       boolean stopAtFirst)
                throws org.xml.sax.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:
execContext - 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(XPathSupport execContext,
                            org.w3c.dom.Node context)
                     throws org.xml.sax.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.

installFunction

public static int installFunction(java.lang.String name,
                                  Function func)
Install a built-in function.
Parameters:
name - The unqualified name of the function.
func - A Implementation of an XPath Function object.
Returns:
the position of the function in the internal index.

locationPath

public XNodeSet locationPath(XPathSupport execContext,
                             org.w3c.dom.Node context,
                             int opPos,
                             NodeCallback callback,
                             java.lang.Object callbackInfo,
                             boolean stopAtFirst)
                      throws org.xml.sax.SAXException
**For advanced use only** Execute a location path.
Parameters:
context - The current source tree context node.
opPos - The current position in the m_opMap array.
callback - Interface that implements the processLocatedNode method.
callbackInfo - Object that will be passed to the processLocatedNode method.

predicate

public XObject predicate(XPathSupport execContext,
                         org.w3c.dom.Node context,
                         int opPos)
                  throws org.xml.sax.SAXException
**For advanced use only** Evaluate a predicate.
Parameters:
context - The current source tree context node.
opPos - The current position in the m_opMap array.

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.

execute

public XObject execute(XPathSupport execContext,
                       org.w3c.dom.Node context,
                       int opPos)
                throws org.xml.sax.SAXException
**For advanced use only** Execute the XPath object from a given opcode position.
Parameters:
execContext - The execution context.
context - The current source tree context node.
opPos - The current position in the xpath.m_opMap array.
callback - Interface that implements the processLocatedNode method.
callbackInfo - Object that will be passed to the processLocatedNode method.
Returns:
The result of the XPath.

execute

public XObject execute(XPathSupport execContext,
                       org.w3c.dom.Node context,
                       int opPos,
                       NodeCallback callback,
                       java.lang.Object callbackInfo,
                       boolean stopAtFirst)
                throws org.xml.sax.SAXException
**For advanced use only** Execute the XPath object from a given opcode position, calling back to a NodeCallback interface as the nodes are found. This will return null if the path is simple enough for callbacks to be used, otherwise it will return an XObject.
Parameters:
execContext - The execution context.
context - The current source tree context node.
opPos - The current position in the xpath.m_opMap array.
callback - Interface that implements the processLocatedNode method.
callbackInfo - Object that will be passed to the processLocatedNode method.
Returns:
The result of the XPath or null if callbacks are used.

getOp

public int getOp(int opPos)
**For advanced use only** Given an operation position, return the current op.
Returns:
position of next operation in m_opMap.

getNextOpPos

public int getNextOpPos(int opPos)
**For advanced use only** Given an operation position, return the end position, i.e. the beginning of the next operation.
Returns:
position of next operation in m_opMap.

getNextOpPos

public static int getNextOpPos(int[] opMap,
                               int opPos)
**For advanced use only** Given an operation position, return the end position, i.e. the beginning of the next operation.
Returns:
position of next operation in m_opMap.

getFirstChildPos

public static int getFirstChildPos(int opPos)
**For advanced use only** Go to the first child of a given operation.

getArgLengthOfStep

public int getArgLengthOfStep(int opPos)
**For advanced use only** Go to the first child of a given operation.

getFirstChildPosOfStep

public static int getFirstChildPosOfStep(int opPos)
**For advanced use only** Go to the first child of a given operation.