net.sf.saxon.pattern
public abstract class Pattern extends Object implements PatternFinder, Serializable, Container
Method Summary | |
---|---|
int | allocateSlots(StaticContext env, SlotManager slotManager, int nextFree)
Allocate slots to any variables used within the pattern |
Pattern | analyze(ExpressionVisitor visitor, ItemType contextItemType)
Type-check the pattern. |
int | getColumnNumber()
Get the column number (always -1) |
int | getContainerGranularity()
Get the granularity of the container. |
double | getDefaultPriority()
Determine the default priority to use if this pattern appears as a match pattern
for a template with no explicit priority attribute. |
int | getDependencies()
Get the dependencies of the pattern. |
Executable | getExecutable()
Get the executable containing this pattern |
int | getFingerprint()
Determine the name fingerprint of nodes to which this pattern applies. |
int | getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container |
int | getLineNumber()
Get the line number on which the pattern was defined |
LocationProvider | getLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved. |
int | getNodeKind()
Determine the types of nodes to which this pattern applies. |
abstract NodeTest | getNodeTest()
Get a NodeTest that all the nodes matching this pattern must satisfy |
String | getPublicId()
Get the public ID (always null) |
String | getSystemId()
Get the system id of the entity in which the pattern occurred |
protected boolean | internalMatches(NodeInfo node, XPathContext context)
Determine whether this Pattern matches the given Node. |
Iterator | iterateSubExpressions()
Iterate over the subexpressions within this pattern |
static Pattern | make(String pattern, StaticContext env, Executable exec)
Static method to make a Pattern by parsing a String. |
Expression | makeSearchExpression()
Make an expression whose effect is to select all the nodes that match this pattern
in a given document. |
abstract boolean | matches(NodeInfo node, XPathContext context)
Determine whether this Pattern matches the given Node. |
void | promote(PromotionOffer offer, Expression parent)
Offer promotion for subexpressions within this pattern. |
boolean | replaceSubExpression(Expression original, Expression replacement)
Replace a subexpression by a replacement subexpression |
SequenceIterator | selectNodes(DocumentInfo doc, XPathContext context)
Select nodes in a document using this PatternFinder. |
void | setExecutable(Executable executable)
Set the executable containing this pattern |
void | setLineNumber(int lineNumber)
Set the line number where the pattern occurred |
void | setOriginalText(String text)
Set the original text of the pattern for use in diagnostics |
void | setSystemId(String systemId)
Set the system ID where the pattern occurred |
Pattern | simplify(ExpressionVisitor visitor)
Simplify the pattern by applying any context-independent optimisations.
|
String | toString()
Get the original pattern text |
Parameters: env the static context in the XSLT stylesheet slotManager the slot manager representing the stack frame for local variables nextFree the next slot that is free to be allocated @return the next slot that is free to be allocated
Parameters: visitor the expression visitor contextItemType 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
Returns: 0 for a temporary container created during parsing; 1 for a container that operates at the level of an XPath expression; 2 for a container at the level of a global function or template
Returns: the default priority for the pattern
Returns: the dependencies, as a bit-significant mask
Returns: the executable
Returns: A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints
Returns: the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT
Returns: a NodeTest, as specific as possible, which all the matching nodes satisfy
Parameters: node The NodeInfo representing the Element or other node to be tested against the Pattern 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
Returns: an iterator over the subexpressions. Default implementation returns an empty sequence
Parameters: pattern The pattern text as a String env An object defining the compile-time context for the expression exec The executable containing this pattern
Returns: The pattern object
Parameters: node The NodeInfo representing the Element or other node to be tested against the Pattern 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
Unlike the corresponding method on Expression, this method does not return anything: it can make internal changes to the pattern, but cannot return a different pattern. Only certain kinds of promotion are applicable within a pattern: specifically, promotions affecting local variable references within the pattern.
Parameters: offer details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expression parent
Throws: net.sf.saxon.trans.XPathException if any error is detected
Parameters: original the expression to be replaced replacement the new expression to be inserted in its place
Returns: true if the replacement was carried out
Parameters: doc the document node at the root of a tree context the dynamic evaluation context
Returns: an iterator over the selected nodes in the document.
Parameters: executable the executable
Parameters: lineNumber the line number of the pattern in the source module
Parameters: text the original text of the pattern
Parameters: systemId the URI of the module containing the pattern
Parameters: visitor the expression visitor
Returns: the optimised Pattern