net.sf.saxon.instruct

Class AnalyzeString

public class AnalyzeString extends Instruction

An xsl:analyze-string elements in the stylesheet. New at XSLT 2.0
Constructor Summary
AnalyzeString(Expression select, Expression regex, Expression flags, Expression matching, Expression nonMatching, RegularExpression pattern)
Construct an AnalyzeString instruction
Method Summary
voidcheckPermittedContents(SchemaType parentType, StaticContext env, boolean whole)
Check that any elements and attributes constructed or returned by this expression are acceptable in the content model of a given complex type.
intcomputeDependencies()
Compute the dependencies of an expression, as the union of the dependencies of its subexpressions.
voiddisplay(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure.
intgetImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
intgetInstructionNameCode()
ItemTypegetItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction
ExpressiongetMatchingExpression()
Get the expression used to process matching substrings
ExpressiongetNonMatchingExpression()
Get the expression used to process non-matching substrings
SequenceIteratoriterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
IteratoriterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)
Expressionoptimize(Optimizer opt, StaticContext env, ItemType contextItemType)
TailCallprocessLeavingTail(XPathContext context)
protected voidpromoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.
Expressionsimplify(StaticContext env)
Simplify an expression.
ExpressiontypeCheck(StaticContext env, ItemType contextItemType)

Constructor Detail

AnalyzeString

public AnalyzeString(Expression select, Expression regex, Expression flags, Expression matching, Expression nonMatching, RegularExpression pattern)
Construct an AnalyzeString instruction

Parameters: select the expression containing the input string regex the regular expression flags the flags parameter matching actions to be applied to a matching substring nonMatching actions to be applied to a non-matching substring pattern the compiled regular expression, if it was known statically

Method Detail

checkPermittedContents

public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole)
Check that any elements and attributes constructed or returned by this expression are acceptable in the content model of a given complex type. It's always OK to say yes, since the check will be repeated at run-time. The process of checking element and attribute constructors against the content model of a complex type also registers the type of content expected of those constructors, so the static validation can continue recursively.

computeDependencies

public int computeDependencies()
Compute the dependencies of an expression, as the union of the dependencies of its subexpressions. (This is overridden for path expressions and filter expressions, where the dependencies of a subexpression are not all propogated). This method should be called only once, to compute the dependencies; after that, getDependencies should be used.

Returns: the depencies, as a bit-mask

display

public void display(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure. The expression is written to the System.err output stream

Parameters: level indentation level for this expression out

getImplementationMethod

public int getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is prefered.

getInstructionNameCode

public int getInstructionNameCode()

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction

Parameters: th

Returns: the static item type of the instruction

getMatchingExpression

public Expression getMatchingExpression()
Get the expression used to process matching substrings

getNonMatchingExpression

public Expression getNonMatchingExpression()
Get the expression used to process non-matching substrings

iterate

public SequenceIterator iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.

Parameters: context supplies the context for evaluation

Returns: a SequenceIterator that can be used to iterate over the result of the expression

Throws: net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the expression

iterateSubExpressions

public Iterator iterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)

optimize

public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)

processLeavingTail

public TailCall processLeavingTail(XPathContext context)

promoteInst

protected void promoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.

Parameters: offer The type of rewrite being offered

Throws: XPathException

simplify

public Expression simplify(StaticContext env)
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).

Returns: the simplified expression

Throws: XPathException if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)