Package net.sf.saxon.trans
Class RuleManager
java.lang.Object
net.sf.saxon.trans.RuleManager
- All Implemented Interfaces:
Serializable
RuleManager maintains a set of template rules, one set for each mode
- Version:
- 10 December 1999: carved out of the old Controller class
- Author:
- Michael H. Kay
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Allocate rankings to the rules within each mode.void
explainTemplateRules
(ExpressionPresenter presenter) Explain (that is, output the expression tree) all template rulesgetMode
(StructuredQName modeName, boolean createIfAbsent) Get the Mode object for a named mode.getNextMatchHandler
(Item node, Mode mode, Rule currentRule, XPathContext c) Get the next-match handler after the current oneint
Get the policy for handling recoverable errors.getTemplateRule
(Item item, Mode mode, int min, int max, XPathContext c) Get the template rule matching a given item whose import precedence is in a particular range.Get the mode object for the unnamed modevoid
Invert streamable templates in all streamable modesvoid
Set up a new table of handlers.void
setRecoveryPolicy
(int policy) Set the policy for handling recoverable errrors.void
setTemplateRule
(Pattern pattern, Template eh, Mode mode, StylesheetModule module, double priority) Register a template for a particular pattern.
-
Constructor Details
-
RuleManager
public RuleManager()create a RuleManager and initialise variables.
-
-
Method Details
-
setRecoveryPolicy
public void setRecoveryPolicy(int policy) Set the policy for handling recoverable errrors. Note that for some errors the decision can be made at run-time, but for the "ambiguous template match" error, the decision is (since 9.2) fixed at compile time.- Parameters:
policy
- the recovery policy to be used. The options areConfiguration.RECOVER_SILENTLY
,Configuration.RECOVER_WITH_WARNINGS
, orConfiguration.DO_NOT_RECOVER
.- Since:
- 9.2
-
getRecoveryPolicy
public int getRecoveryPolicy()Get the policy for handling recoverable errors. Note that for some errors the decision can be made at run-time, but for the "ambiguous template match" error, the decision is (since 9.2) fixed at compile time.- Returns:
- the current policy.
- Since:
- 9.2
-
resetHandlers
public void resetHandlers()Set up a new table of handlers. -
getUnnamedMode
Get the mode object for the unnamed mode- Returns:
- the unnamed mode
-
getMode
Get the Mode object for a named mode. If there is not one already registered. a new Mode is created.- Parameters:
modeName
- The name of the mode. Supply null to get the default mode or Mode.ALL_MODES to get the Mode object containing "mode=all" rulescreateIfAbsent
- if true, then if the mode does not already exist it will be created. If false, then if the mode does not already exist the method returns null.- Returns:
- the Mode with this name
-
setTemplateRule
public void setTemplateRule(Pattern pattern, Template eh, Mode mode, StylesheetModule module, double priority) Register a template for a particular pattern.- Parameters:
pattern
- Must be a valid Pattern.eh
- The Template to be usedmode
- The processing mode to which this template appliesmodule
- The stylesheet module containing the template rulepriority
- The priority of the rule: if an element matches several patterns, the one with highest priority is used- See Also:
-
getTemplateRule
public Rule getTemplateRule(Item item, Mode mode, int min, int max, XPathContext c) throws XPathException Get the template rule matching a given item whose import precedence is in a particular range. This is used to support the xsl:apply-imports function- Parameters:
item
- The item to be matchedmode
- The mode for which a rule is requiredmin
- The minimum import precedence that the rule must havemax
- The maximum import precedence that the rule must havec
- The Controller for the transformation- Returns:
- The template rule to be invoked
- Throws:
XPathException
- if an error occurs matching a pattern
-
getNextMatchHandler
public Rule getNextMatchHandler(Item node, Mode mode, Rule currentRule, XPathContext c) throws XPathException Get the next-match handler after the current one- Parameters:
node
- The node to be matchedmode
- The processing modecurrentRule
- The current template rulec
- The dynamic context for the transformation- Returns:
- The template rule to be executed
- Throws:
XPathException
- if an error occurs while matching a pattern
-
computeRankings
Allocate rankings to the rules within each mode. This method must be called when all the rules in each mode are known- Throws:
XPathException
- if an error occurs
-
invertStreamableTemplates
Invert streamable templates in all streamable modes- Parameters:
opt
- the optimizer (Always a Saxon-EE optimizer)- Throws:
XPathException
- if the templates are not streamable
-
explainTemplateRules
Explain (that is, output the expression tree) all template rules- Parameters:
presenter
- the object used to present the output
-