Package net.sf.saxon.pattern
Class AnchorPattern
java.lang.Object
net.sf.saxon.pattern.Pattern
net.sf.saxon.pattern.AnchorPattern
- All Implemented Interfaces:
Serializable,SourceLocator,Container,PatternFinder
This is a special pattern that matches the "anchor node"; it is not used for XSLT patterns,
but for the selectors that arise when evaluating XPath expressions in streaming mode; the anchor
node is the context node for the streamed XPath evaluation.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyze(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) Type-check the pattern.Get a NodeTest that all the nodes matching this pattern must satisfyprotected booleaninternalMatches(NodeInfo node, NodeInfo anchor, XPathContext context) Determine whether this Pattern matches the given Node.booleanmatches(Item item, XPathContext context) Determine whether this Pattern matches the given Node.booleanmatchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context) Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node.toString()Get the original pattern textMethods inherited from class net.sf.saxon.pattern.Pattern
allocateSlots, getColumnNumber, getContainerGranularity, getDefaultPriority, getDependencies, getExecutable, getFingerprint, getHostLanguage, getLineNumber, getLocationProvider, getNodeKind, getPublicId, getSystemId, iterateSubExpressions, make, promote, replaceSubExpression, resolveCurrent, selectNodes, setExecutable, setLineNumber, setOriginalText, setSystemId, setVariableBindingExpression, simplify
-
Constructor Details
-
AnchorPattern
public AnchorPattern()
-
-
Method Details
-
analyze
public Pattern analyze(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException Type-check the pattern.- Overrides:
analyzein classPattern- Parameters:
visitor- the expression visitorcontextItemType- the type of the context item at the point where the pattern is defined. Set to null if it is known that the context item is undefined.- Returns:
- the optimised Pattern
- Throws:
XPathException- if a static error is discovered
-
matchesBeneathAnchor
public boolean matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context) throws XPathException Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node. This method is used when the pattern is used for streaming.- Overrides:
matchesBeneathAnchorin classPattern- Parameters:
node- The NodeInfo representing the Element or other node to be tested against the Patternanchor- The anchor node, which must match any AnchorPattern subpatterncontext- The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().- Returns:
- true if the node matches the Pattern, false otherwise
- Throws:
XPathException- if a dynamic error occurs during pattern matching
-
matches
Determine whether this Pattern matches the given Node. This is the main external interface for matching patterns: it sets current() to the node being tested- Specified by:
matchesin classPattern- Parameters:
item- The NodeInfo representing the Element or other node to be tested against the Patterncontext- The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().- Returns:
- true if the node matches the Pattern, false otherwise
- Throws:
XPathException- if a dynamic error occurs during pattern matching
-
internalMatches
protected boolean internalMatches(NodeInfo node, NodeInfo anchor, XPathContext context) throws XPathException Determine whether this Pattern matches the given Node. This is an internal interface used for matching sub-patterns; it does not alter the value of current(). The default implementation is identical to matches().- Overrides:
internalMatchesin classPattern- Parameters:
node- The NodeInfo representing the Element or other node to be tested against the Patternanchor-context- The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().- Returns:
- true if the node matches the Pattern, false otherwise
- Throws:
XPathException- if a dynamic error occurs during pattern matching
-
getItemType
Get a NodeTest that all the nodes matching this pattern must satisfy- Specified by:
getItemTypein classPattern- Returns:
- a NodeTest, as specific as possible, which all the matching nodes satisfy
-
toString
Description copied from class:PatternGet the original pattern text
-