Class Pattern
java.lang.Object
com.icl.saxon.pattern.Pattern
- Direct Known Subclasses:
IDPattern, KeyPattern, LocationPathPattern, NodeTest, UnionPattern
A Pattern represents the result of parsing an XSLT pattern string.
Patterns are created by calling the static method Pattern.make(string).
The pattern is used to test a particular node by calling match().
Patterns are created by calling the static method Pattern.make(string).
The pattern is used to test a particular node by calling match().
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleDetermine the default priority to use if this pattern appears as a match pattern for a template with no explicit priority attribute.intDetermine the name fingerprint of nodes to which this pattern applies.intGet the line number on which the pattern was definedshortDetermine the types of nodes to which this pattern applies.Determine the static context used when the pattern was parsedGet the system id of the entity in which the pattern occurredstatic Patternmake(String pattern, StaticContext env) Static method to make a Pattern by parsing a String.abstract booleanDetermine whether this Pattern matches the given NodevoidsetOriginalText(String text) Set the original text of the pattern for use in diagnosticsfinal voidSet the static context used when the pattern was parsedsimplify()Simplify the pattern by applying any context-independent optimisations.toString()Get the original pattern text
-
Field Details
-
staticContext
-
originalText
-
-
Constructor Details
-
Pattern
public Pattern()
-
-
Method Details
-
make
Static method to make a Pattern by parsing a String.- Parameters:
pattern- The pattern text as a Stringenv- An object defining the compile-time context for the expression- Returns:
- The pattern object
- Throws:
XPathException
-
setOriginalText
Set the original text of the pattern for use in diagnostics -
simplify
Simplify the pattern by applying any context-independent optimisations. Default implementation does nothing.- Returns:
- the optimised Pattern
- Throws:
XPathException
-
setStaticContext
Set the static context used when the pattern was parsed -
getStaticContext
Determine the static context used when the pattern was parsed -
matches
Determine whether this Pattern matches the given Node- Parameters:
node- The NodeInfo representing the Element or other node to be tested against the Patterncontext- The context in which the match is to take place. Only relevant if the pattern uses variables.- Returns:
- true if the node matches the Pattern, false otherwise
- Throws:
XPathException
-
getNodeType
public short getNodeType()Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return NodeInfo.NODE- Returns:
- the type of node matched by this pattern. e.g. NodeInfo.ELEMENT or NodeInfo.TEXT
-
getFingerprint
public int getFingerprint()Determine the name fingerprint of nodes to which this pattern applies. Used for optimisation.- Returns:
- A fingerprint that the nodes must match, or null Otherwise return null.
-
getDefaultPriority
public double getDefaultPriority()Determine the default priority to use if this pattern appears as a match pattern for a template with no explicit priority attribute. -
getSystemId
Get the system id of the entity in which the pattern occurred -
getLineNumber
public int getLineNumber()Get the line number on which the pattern was defined -
toString
-