public class Mode extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ACCUMULATOR |
static int |
NAMED_MODE |
static StructuredQName |
OMNI_MODE |
static int |
UNNAMED_MODE |
static StructuredQName |
UNNAMED_MODE_NAME |
Constructor and Description |
---|
Mode(int usage,
StructuredQName modeName)
Default constructor - creates a Mode containing no rules
|
Mode(Mode omniMode,
StructuredQName modeName)
Construct a new Mode, copying the contents of an existing Mode
|
Modifier and Type | Method and Description |
---|---|
void |
addRule(Pattern pattern,
RuleTarget action,
StylesheetModule module,
double priority,
boolean explicitMode)
Add a rule to the Mode.
|
void |
allocateAllPatternSlots()
Allocate slots for local variables in all patterns used by the rules in this mode.
|
void |
allocatePatternSlots(int slots)
Specify how many slots for local variables are required by a particular pattern
|
TailCall |
applyTemplates(ParameterSet parameters,
ParameterSet tunnelParameters,
XPathContextMajor context,
int locationId)
Process selected nodes using the handlers registered for this mode.
|
void |
computeRankings()
Compute a rank for each rule, as a combination of the precedence and priority, to allow
rapid comparison.
|
void |
explainTemplateRules(ExpressionPresenter presenter)
Explain all template rules in this mode by showing their
expression tree represented in XML.
|
BuiltInRuleSet |
getBuiltInRuleSet()
Get the built-in template rules to be used with this Mode in the case where there is no
explicit template rule
|
Set<String> |
getExplicitNamespaces(NamePool pool)
Get the "explicit namespaces" matched by this mode.
|
StructuredQName |
getModeName()
Get the name of the mode (for diagnostics only)
|
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.
|
String |
getPropertyValue(String name)
Get the value of a property of this mode, e.g.
|
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.
|
Rule |
getRule(Item item,
XPathContext context)
Get the rule corresponding to a given Node, by finding the best Pattern match.
|
Rule |
getRule(Item item,
XPathContext context,
net.sf.saxon.trans.Mode.RuleFilter filter)
Get the rule corresponding to a given item, by finding the best Pattern match.
|
int |
getStackFrameSlotsNeeded() |
void |
invertStreamableTemplates()
For a streamable mode, invert all the templates to generate streamable code
|
boolean |
isDeclaredStreamable()
Ask whether this mode is declared to be streamable
|
boolean |
isDefaultMode()
Determine if this is the default mode
|
boolean |
isEmpty()
Ask whether there are any template rules in this mode
(a mode could exist merely because it is referenced in apply-templates)
|
void |
processRules(net.sf.saxon.trans.Mode.RuleAction action)
Walk over all the rules, applying a specified action to each one.
|
void |
setBuiltInRuleSet(BuiltInRuleSet defaultRules)
Set the built-in template rules to be used with this Mode in the case where there is no
explicit template rule
|
void |
setExplicitProperty(String name,
String value,
int precedence)
Set an explicit property at a particular precedence.
|
void |
setRecoveryPolicy(int policy)
Set the policy for handling recoverable errrors.
|
void |
setStreamable(boolean streamable)
Say that this mode is (or is not) streamable
|
public static final int UNNAMED_MODE
public static final int NAMED_MODE
public static final int ACCUMULATOR
public static final StructuredQName OMNI_MODE
public static final StructuredQName UNNAMED_MODE_NAME
public Mode(int usage, StructuredQName modeName)
usage
- one of UNNAMED_MODE
, NAMED_MODE
modeName
- the name of the modepublic Mode(Mode omniMode, StructuredQName modeName)
omniMode
- the existing mode. May be null, in which case it is not copiedmodeName
- the name of the new mode to be createdpublic void setBuiltInRuleSet(BuiltInRuleSet defaultRules)
defaultRules
- the built-in rule setpublic BuiltInRuleSet getBuiltInRuleSet()
public boolean isDefaultMode()
public StructuredQName getModeName()
public String getModeTitle()
public 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 int getRecoveryPolicy()
public void setStreamable(boolean streamable)
streamable
- true if this mode is a streamable modepublic boolean isDeclaredStreamable()
public void setExplicitProperty(String name, String value, int precedence)
name
- the name of the propertyvalue
- the value of the propertyprecedence
- the import precedence of this property valuepublic String getPropertyValue(String name)
name
- the property name, e.g. "typed"public Set<String> getExplicitNamespaces(NamePool pool)
pool
- the NamePool for the configurationpublic void addRule(Pattern pattern, RuleTarget action, StylesheetModule module, double priority, boolean explicitMode)
pattern
- a Patternaction
- the Object to return from getRule() when the supplied node matches this Patternmodule
- the stylesheet module containing the rulepriority
- the priority of the ruleexplicitMode
- true if adding a template rule for a specific (default or named) mode;
false if adding a rule because it applies to all modespublic void allocatePatternSlots(int slots)
slots
- the number of slots neededpublic 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 Rule getRule(Item item, XPathContext context, net.sf.saxon.trans.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 void processRules(net.sf.saxon.trans.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 void invertStreamableTemplates() throws XPathException
XPathException
- if there is a non-streamable template in the modepublic void explainTemplateRules(ExpressionPresenter presenter)
presenter
- used to display the expression treepublic void computeRankings() throws XPathException
XPathException
- if an error occurs processing the rulespublic TailCall applyTemplates(ParameterSet parameters, ParameterSet tunnelParameters, XPathContextMajor context, int 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 void allocateAllPatternSlots() throws XPathException
XPathException
- if anything goes wrongpublic int getStackFrameSlotsNeeded()
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.