public abstract class Mode extends Actor
Modifier and Type | Class and Description |
---|---|
static interface |
Mode.RuleAction
Interface for helper classes used to process all the rules in the Mode
|
protected static interface |
Mode.RuleFilter
Interface for helper classes used to filter a chain of rules
|
Modifier and Type | Field and Description |
---|---|
static StructuredQName |
DEFAULT_MODE_NAME |
protected StructuredQName |
modeName |
boolean |
mustBeTyped |
boolean |
mustBeUntyped |
static StructuredQName |
OMNI_MODE |
static StructuredQName |
UNNAMED_MODE_NAME |
Constructor and Description |
---|
Mode(StructuredQName modeName) |
Modifier and Type | Method and Description |
---|---|
TailCall |
applyTemplates(ParameterSet parameters,
ParameterSet tunnelParameters,
XPathContextMajor context,
Location locationId)
Process selected nodes using the template rules registered for this mode.
|
abstract void |
computeRankings(int start)
Compute a rank for each rule, as a combination of the precedence and priority, to allow
rapid comparison.
|
void |
explain(ExpressionPresenter presenter) |
abstract void |
explainTemplateRules(ExpressionPresenter out)
Explain all template rules in this mode in a form that can be re-imported.
|
void |
export(ExpressionPresenter presenter)
Export expression structure.
|
abstract void |
exportTemplateRules(ExpressionPresenter out)
Export all template rules in this mode in a form that can be re-imported.
|
protected void |
exportUseAccumulators(ExpressionPresenter presenter) |
java.util.Set<? extends Accumulator> |
getAccumulators()
Get the list of accumulators declared on the xsl:mode/@use-accumulators attribute
|
abstract SimpleMode |
getActivePart()
Get the active component of this mode.
|
abstract BuiltInRuleSet |
getBuiltInRuleSet()
Get the built-in template rules to be used with this Mode in the case where there is no
explicit template rule
|
BuiltInRuleSet |
getBuiltInRuleSetForCode(java.lang.String code)
Return a built-in rule set for a code string.
|
java.lang.String |
getCodeForBuiltInRuleSet(BuiltInRuleSet builtInRuleSet)
Return a code string for a built-in rule set.
|
int |
getComponentKind()
Get the kind of component that this represents, using integer constants such as
StandardNames.XSL_FUNCTION |
int |
getConstructType()
Get the type of construct.
|
Component.M |
getDeclaringComponent() |
abstract java.util.Set<java.lang.String> |
getExplicitNamespaces(NamePool pool)
Get the "explicit namespaces" matched by this mode.
|
abstract int |
getMaxPrecedence()
Get the maximum precedence of the rules in this mode
|
abstract int |
getMaxRank()
Get the highest rank of the rules in this mode
|
StructuredQName |
getModeName()
Get the name of the mode (for diagnostics only)
|
java.lang.String |
getModeTitle()
Get a title for the mode: either "Mode mode-name" or "The unnamed mode" as appropriate
|
Rule |
getNextMatchRule(Item item,
Rule currentRule,
XPathContext context)
Get the rule corresponding to a given Node, by finding the next-best Pattern match
after the specified object.
|
StructuredQName |
getObjectName()
Get a name identifying the object of the expression, for example a function name, template name,
variable name, key name, element name, etc.
|
int |
getRecoveryPolicy()
Get the policy for handling recoverable errors.
|
Rule |
getRule(Item item,
int min,
int max,
XPathContext context)
Get the rule corresponding to a given Node, by finding the best Pattern match, subject to a minimum
and maximum precedence.
|
abstract Rule |
getRule(Item item,
XPathContext context)
Get the rule corresponding to a given item, by finding the best pattern match.
|
abstract Rule |
getRule(Item item,
XPathContext context,
Mode.RuleFilter filter)
Get the rule corresponding to a given item, by finding the best Pattern match.
|
abstract int |
getStackFrameSlotsNeeded() |
SymbolicName |
getSymbolicName()
Get the symbolic name of the component
|
boolean |
isDeclaredStreamable()
Ask whether this mode is declared to be streamable
|
abstract boolean |
isEmpty()
Ask whether there are any template rules in this mode
(a mode could exist merely because it is referenced in apply-templates)
|
boolean |
isModeTracing() |
boolean |
isMustBeTyped() |
boolean |
isUnnamedMode()
Determine if this is the unnamed mode
|
XPathContext |
makeNewContext(XPathContext context)
Make a new XPath context for evaluating patterns if there is any possibility that the
pattern uses local variables
|
abstract void |
processRules(Mode.RuleAction action)
Walk over all the rules, applying a specified action to each one.
|
void |
setAccumulators(java.util.Set<? extends Accumulator> accumulators)
Set the list of accumulators declared on the xsl:mode/@use-accumulators attribute
|
void |
setHasRules(boolean hasRules) |
void |
setModeTracing(boolean tracing)
Switch tracing on or off
|
void |
setRecoveryPolicy(int policy)
Set the policy for handling recoverable errors.
|
void |
setStreamable(boolean streamable)
Say that this mode is (or is not) streamable
|
allocateAllBindingSlots, allocateBindingSlotsRecursive, getBody, getColumnNumber, getDeclaredVisibility, getLineNumber, getLocation, getPackageData, getProperties, getProperty, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, isExportable, makeDeclaringComponent, obtainDeclaringComponent, saveLocation, setBody, setChildExpression, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId
public static final StructuredQName OMNI_MODE
public static final StructuredQName UNNAMED_MODE_NAME
public static final StructuredQName DEFAULT_MODE_NAME
protected StructuredQName modeName
public boolean mustBeTyped
public boolean mustBeUntyped
public Mode(StructuredQName modeName)
public Component.M getDeclaringComponent()
getDeclaringComponent
in class Actor
public abstract BuiltInRuleSet getBuiltInRuleSet()
public boolean isUnnamedMode()
public StructuredQName getModeName()
public abstract SimpleMode getActivePart()
public abstract int getMaxPrecedence()
public abstract int getMaxRank()
public abstract void computeRankings(int start) throws XPathException
start
- the lowest rank to useXPathException
- if an error occurs processing the rulespublic java.lang.String getModeTitle()
public void setModeTracing(boolean tracing)
public boolean isModeTracing()
public java.util.Set<? extends Accumulator> getAccumulators()
public void setAccumulators(java.util.Set<? extends Accumulator> accumulators)
accumulators
- the list of accumulators applicable when this is the initial modepublic int getComponentKind()
Actor
StandardNames.XSL_FUNCTION
getComponentKind
in class Actor
public SymbolicName getSymbolicName()
Actor
getSymbolicName
in class Actor
public int getConstructType()
InstructionInfo
StandardNames
: all less than 1024)
or it will be a constant in class LocationKind
.public StructuredQName getObjectName()
InstructionInfo
public abstract boolean isEmpty()
public void setRecoveryPolicy(int policy)
policy
- the recovery policy to be used. The options are Configuration.RECOVER_SILENTLY
,
Configuration.RECOVER_WITH_WARNINGS
, or Configuration.DO_NOT_RECOVER
.public void setHasRules(boolean hasRules)
public int getRecoveryPolicy()
public void setStreamable(boolean streamable)
streamable
- true if this mode is a streamable modepublic boolean isDeclaredStreamable()
public abstract java.util.Set<java.lang.String> getExplicitNamespaces(NamePool pool)
pool
- the NamePool for the configurationpublic abstract void processRules(Mode.RuleAction action) throws XPathException
action
- an action that is to be applied to all the rules in this ModeXPathException
- if an error occurs processing any of the rulespublic XPathContext makeNewContext(XPathContext context)
context
- The existing XPath contextpublic abstract Rule getRule(Item item, XPathContext context) throws XPathException
item
- the item to be matchedcontext
- the XPath dynamic evaluation contextXPathException
- if an error occurs matching a patternpublic abstract Rule getRule(Item item, XPathContext context, Mode.RuleFilter filter) throws XPathException
item
- the item to be matchedcontext
- the XPath dynamic evaluation contextfilter
- a filter to select which rules should be consideredXPathException
- if an error occurspublic Rule getRule(Item item, int min, int max, XPathContext context) throws XPathException
item
- the item to be matchedmin
- the minimum import precedencemax
- the maximum import precedencecontext
- the XPath dynamic evaluation contextXPathException
- if an error occurs evaluating match patternspublic Rule getNextMatchRule(Item item, Rule currentRule, XPathContext context) throws XPathException
item
- the NodeInfo referring to the node to be matchedcurrentRule
- the current rule; we are looking for the next match after the current rulecontext
- the XPath dynamic evaluation contextXPathException
- if an error occurs matching a patternpublic abstract void exportTemplateRules(ExpressionPresenter out) throws XPathException
out
- used to display the expression treeXPathException
public abstract void explainTemplateRules(ExpressionPresenter out) throws XPathException
out
- used to display the expression treeXPathException
public TailCall applyTemplates(ParameterSet parameters, ParameterSet tunnelParameters, XPathContextMajor context, Location locationId) throws XPathException
parameters
- A ParameterSet containing the parameters to
the handler/template being invoked. Specify null if there are no
parameters.tunnelParameters
- A ParameterSet containing the parameters to
the handler/template being invoked. Specify null if there are no
parameters.context
- A newly-created context object (this must be freshly created by the caller,
as it will be modified by this method). The nodes to be processed are those
selected by the currentIterator in this context object. There is also a precondition
that this mode must be the current mode in this context object.locationId
- location of this apply-templates instruction in the stylesheetXPathException
- if any dynamic error occurspublic abstract int getStackFrameSlotsNeeded()
public java.lang.String getCodeForBuiltInRuleSet(BuiltInRuleSet builtInRuleSet)
builtInRuleSet
- the rule set to get a codepublic BuiltInRuleSet getBuiltInRuleSetForCode(java.lang.String code)
code
- the code used in exportpublic final void export(ExpressionPresenter presenter) throws XPathException
Actor
export
in class Actor
presenter
- the expression presenter used to generate the XML representation of the structureXPathException
protected void exportUseAccumulators(ExpressionPresenter presenter)
public boolean isMustBeTyped()
public void explain(ExpressionPresenter presenter) throws XPathException
XPathException
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.