Package net.sf.saxon.pattern
Class AncestorQualifiedPattern
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.PseudoExpression
-
- net.sf.saxon.pattern.Pattern
-
- net.sf.saxon.pattern.AncestorQualifiedPattern
-
- All Implemented Interfaces:
ExportAgent,Locatable,IdentityComparable,Traceable
public final class AncestorQualifiedPattern extends Pattern
An AncestorQualifiedPattern represents a path of the form A/B or A//B, where nodes must match the pattern B and also have a parent/ancestor (respectively) that matches A.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
-
Constructor Summary
Constructors Constructor Description AncestorQualifiedPattern(Pattern base, Pattern upper, int axis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intallocateSlots(SlotManager slotManager, int nextFree)Allocate slots to any variables used within the patternvoidbindCurrent(LocalBinding binding)Replace any calls on current() by a variable reference bound to the supplied bindingintcomputeHashCode()hashcode supporting equals()PatternconvertToTypedPattern(java.lang.String val)Convert the pattern to a typed pattern, in which an element name is treated as schema-element(N)Patterncopy(RebindingMap rebindings)Copy a pattern.booleanequals(java.lang.Object other)Determine whether this pattern is the same as another patternvoidexport(ExpressionPresenter presenter)Diagnostic print of expression structure.PatterngetBasePattern()Get the base pattern, the pattern applying to the node itselfintgetDependencies()Get the dependencies of the pattern.intgetFingerprint()Determine the fingerprint of nodes to which this pattern applies.ItemTypegetItemType()Get a NodeTest that all the nodes matching this pattern must satisfyPatterngetUpperPattern()Get the pattern applying to the parent node, if there is oneintgetUpwardsAxis()Get the upwards axis, that is, the axis by which the upper pattern is reached.UTypegetUType()Get a UType indicating which kinds of items this Pattern can match.booleanisMotionless()Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream.booleanmatches(Item item, XPathContext context)Determine whether the pattern matches a given item.booleanmatchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context)Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node.booleanmatchesCurrentGroup()Ask whether the pattern is anchored on a call on current-group()java.lang.Iterable<Operand>operands()Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.java.lang.Stringreconstruct()Get the original pattern textPatternsimplify()Simplify the pattern: perform any context-independent optimisationsPatterntypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)Type-check the pattern, performing any type-dependent optimizations.-
Methods inherited from class net.sf.saxon.pattern.Pattern
effectiveBooleanValue, getDefaultPriority, getHostLanguage, getOriginalText, handleDynamicError, isLiftable, isRecoverable, make, optimize, patternContainsVariable, replaceCurrent, selectNodes, setOriginalText, setPriority, setRecoverable, toPattern, toShortString, toString
-
Methods inherited from class net.sf.saxon.expr.PseudoExpression
computeCardinality, evaluateAsString, evaluateItem, getImplementationMethod, iterate, process
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeSpecialProperties, computeStaticProperties, dynamicError, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getEvaluationMethod, getExpressionName, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Method Detail
-
operands
public java.lang.Iterable<Operand> operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Overrides:
operandsin classExpression- Returns:
- an iterator containing the sub-expressions of this expression
-
bindCurrent
public void bindCurrent(LocalBinding binding)
Replace any calls on current() by a variable reference bound to the supplied binding- Overrides:
bindCurrentin classPattern
-
getBasePattern
public Pattern getBasePattern()
Get the base pattern, the pattern applying to the node itself- Returns:
- the base pattern
-
getUpperPattern
public Pattern getUpperPattern()
Get the pattern applying to the parent node, if there is one- Returns:
- the parent pattern, for example if the pattern is a/b[1]/c then the parent pattern is a/b[1]
-
getUpwardsAxis
public int getUpwardsAxis()
Get the upwards axis, that is, the axis by which the upper pattern is reached. Typically Axis.PARENT or Axis.ANCESTOR- Returns:
- the relevant axis
-
isMotionless
public boolean isMotionless()
Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream. This is a necessary condition for patterns used as the match pattern of a streamed template rule.- Overrides:
isMotionlessin classPattern- Returns:
- true if the pattern is motionless, that is, if it can be evaluated against a streamed node without changing the position in the streamed input file
-
matchesCurrentGroup
public boolean matchesCurrentGroup()
Description copied from class:PatternAsk whether the pattern is anchored on a call on current-group()- Overrides:
matchesCurrentGroupin classPattern- Returns:
- true if calls on matchesBeneathAnchor should test with all nodes in the current group as anchor nodes. If false, only the first node in a group is treated as the anchor node
-
simplify
public Pattern simplify() throws XPathException
Simplify the pattern: perform any context-independent optimisations- Overrides:
simplifyin classPattern- Returns:
- the simplified expression (or the original if unchanged, or if modified in-situ)
- Throws:
XPathException- if an error is discovered during expression rewriting
-
typeCheck
public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
Type-check the pattern, performing any type-dependent optimizations.- Overrides:
typeCheckin classPattern- Parameters:
visitor- an expression visitorcontextItemType- the type of the context item at the point where the pattern appears- Returns:
- the optimised Pattern
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
getDependencies
public int getDependencies()
Get the dependencies of the pattern. The only possible dependency for a pattern is on local variables. This is analyzed in those patterns where local variables may appear.- Overrides:
getDependenciesin classPattern- Returns:
- the dependencies, as a bit-significant mask
-
allocateSlots
public int allocateSlots(SlotManager slotManager, int nextFree)
Allocate slots to any variables used within the pattern- Overrides:
allocateSlotsin classPattern- Parameters:
slotManager- keeps track of slotsnextFree- the next slot that is free to be allocated @return the next slot that is free to be allocated- Returns:
- the next slot that is free to be allocated
-
matches
public boolean matches(Item item, XPathContext context) throws XPathException
Determine whether the pattern matches a given item.- Specified by:
matchesin classPattern- Parameters:
item- the item to be testedcontext- The dynamic context.- Returns:
- true if the pattern matches, else false
- Throws:
XPathException- if an error occurs while matching the pattern (the caller will usually treat this the same as a false result)
-
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 an error occurs while matching the pattern (the caller will usually treat this the same as a false result)
-
getUType
public UType getUType()
Get a UType indicating which kinds of items this Pattern can match.
-
getFingerprint
public int getFingerprint()
Determine the fingerprint of nodes to which this pattern applies. Used for optimisation.- Overrides:
getFingerprintin classPattern- Returns:
- the fingerprint of nodes matched by this pattern.
-
getItemType
public ItemType getItemType()
Get a NodeTest that all the nodes matching this pattern must satisfy- Specified by:
getItemTypein classPattern- Returns:
- an ItemType, as specific as possible, which all the matching items satisfy
-
convertToTypedPattern
public Pattern convertToTypedPattern(java.lang.String val) throws XPathException
Convert the pattern to a typed pattern, in which an element name is treated as schema-element(N)- Overrides:
convertToTypedPatternin classPattern- Parameters:
val- either "strict" or "lax" depending on the value of xsl:mode/@typed- Returns:
- either the original pattern unchanged, or a new pattern as the result of the conversion
- Throws:
XPathException- if the pattern cannot be converted
-
reconstruct
public java.lang.String reconstruct()
Get the original pattern text- Overrides:
reconstructin classPattern
-
equals
public boolean equals(java.lang.Object other)
Determine whether this pattern is the same as another pattern- Overrides:
equalsin classExpression- Parameters:
other- the other object- Returns:
- true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
-
computeHashCode
public int computeHashCode()
hashcode supporting equals()- Overrides:
computeHashCodein classExpression- Returns:
- a computed hash code
-
export
public void export(ExpressionPresenter presenter) throws XPathException
Description copied from class:ExpressionDiagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin classPattern- Parameters:
presenter- the expression presenter used to display the structure- Throws:
XPathException- if the export fails, for example if an expression is found that won't work in the target environment.
-
copy
public Pattern copy(RebindingMap rebindings)
Copy a pattern. This makes a deep copy.
-
-