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
|
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 int |
RECOVER_WITH_WARNINGS |
static StructuredQName |
UNNAMED_MODE_NAME |
Constructor and Description |
---|
Mode(StructuredQName modeName) |
Modifier and Type | Method and Description |
---|---|
TailCall |
applyTemplates(ParameterSet parameters,
ParameterSet tunnelParameters,
NodeInfo separator,
Outputter output,
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.
|
Component.M |
getDeclaringComponent() |
SequenceType |
getDefaultResultType() |
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(boolean initialCaps)
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() |
RecoveryPolicy |
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,
java.util.function.Predicate<Rule> 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 |
setDefaultResultType(SequenceType type) |
void |
setHasRules(boolean hasRules) |
void |
setModeTracing(boolean tracing)
Switch tracing on or off
|
void |
setRecoveryPolicy(RecoveryPolicy policy)
Set the policy for handling recoverable errors.
|
void |
setStreamable(boolean streamable)
Say that this mode is (or is not) streamable
|
allocateAllBindingSlots, allocateBindingSlotsRecursive, getBody, getChildExpression, getColumnNumber, getComponentName, getDeclaredVisibility, getLineNumber, getLocation, getPackageData, getProperty, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, getTracingTag, isExportable, makeDeclaringComponent, obtainDeclaringComponent, saveLocation, setBody, setChildExpression, setColumnNumber, 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 static final int RECOVER_WITH_WARNINGS
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(boolean initialCaps)
initialCaps
- true if the first letter should be upper casepublic 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 SymbolicName getSymbolicName()
Actor
getSymbolicName
in class Actor
public StructuredQName getObjectName()
public abstract boolean isEmpty()
public void setRecoveryPolicy(RecoveryPolicy policy)
policy
- the recovery policy to be used.public void setHasRules(boolean hasRules)
public RecoveryPolicy 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 void setDefaultResultType(SequenceType type)
public SequenceType getDefaultResultType()
public 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, java.util.function.Predicate<Rule> 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, NodeInfo separator, Outputter output, 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.separator
- Text node to be inserted between the output of successive input items;
may be nulloutput
- The destination for the result of the selected templatescontext
- 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
- if things go wrong, for example an I/O failureprotected void exportUseAccumulators(ExpressionPresenter presenter)
public boolean isMustBeTyped()
public void explain(ExpressionPresenter presenter) throws XPathException
XPathException
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.