Package net.sf.saxon.trans.rules
Class RuleManager
- java.lang.Object
-
- net.sf.saxon.trans.rules.RuleManager
-
public final class RuleManager extends java.lang.Object
RuleManager maintains a set of template rules, one set for each mode
-
-
Constructor Summary
Constructors Constructor Description RuleManager(StylesheetPackage pack)
create a RuleManager and initialise variables.RuleManager(StylesheetPackage pack, CompilerInfo compilerInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
allocateSequenceNumber()
void
checkConsistency()
Check all modes for conflicts in property valuesvoid
computeRankings()
Allocate rankings to the rules within each mode.void
explainTemplateRules(ExpressionPresenter presenter)
Explain (that is, output the expression tree) for all template rulesjava.util.Collection<Mode>
getAllNamedModes()
Get all registered modesStylesheetPackage
getStylesheetPackage()
Get the stylesheet packageSimpleMode
getUnnamedMode()
Get the mode object for the unnamed modevoid
invertStreamableTemplates()
Invert streamable templates in all streamable modesboolean
isUnnamedModeExplicit()
Ask whether the unnamed mode has been explicitly declared in an xsl:mode declarationMode
obtainMode(StructuredQName modeName, boolean createIfAbsent)
Get the Mode object for a named mode.void
optimizeRules()
Optimization of template rules Only invoked when rule optimization has been turned on.void
registerMode(Mode mode)
int
registerRule(Pattern pattern, TemplateRule eh, Mode mode, StylesheetModule module, double priority, int position, int part)
Register a template for a particular pattern.void
setCompilerInfo(CompilerInfo compilerInfo)
Set the compiler information specifically.void
setUnnamedModeExplicit(boolean declared)
Say that the unnamed mode has been explicitly declared in an xsl:mode declaration
-
-
-
Constructor Detail
-
RuleManager
public RuleManager(StylesheetPackage pack)
create a RuleManager and initialise variables.
-
RuleManager
public RuleManager(StylesheetPackage pack, CompilerInfo compilerInfo)
-
-
Method Detail
-
setUnnamedModeExplicit
public void setUnnamedModeExplicit(boolean declared)
Say that the unnamed mode has been explicitly declared in an xsl:mode declaration- Parameters:
declared
- true if it has been explicitly declared
-
isUnnamedModeExplicit
public boolean isUnnamedModeExplicit()
Ask whether the unnamed mode has been explicitly declared in an xsl:mode declaration- Returns:
- true if it has been explicitly declared
-
setCompilerInfo
public void setCompilerInfo(CompilerInfo compilerInfo)
Set the compiler information specifically.- Parameters:
compilerInfo
- the compiler options in use
-
getStylesheetPackage
public StylesheetPackage getStylesheetPackage()
Get the stylesheet package- Returns:
- the stylesheet package
-
getAllNamedModes
public java.util.Collection<Mode> getAllNamedModes()
Get all registered modes- Returns:
- a collection containing all registered modes excluding the unnamed mode
-
getUnnamedMode
public SimpleMode getUnnamedMode()
Get the mode object for the unnamed mode- Returns:
- the unnamed mode
-
obtainMode
public Mode obtainMode(StructuredQName modeName, boolean createIfAbsent)
Get the Mode object for a named mode. If there is not one already registered. a new Mode is created. This uses a makeMode() method in the configuration- 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. But if the requested mode is the omnimode, it is considered to always exist, and is therefore created regardless.- Returns:
- the Mode with this name
-
registerMode
public void registerMode(Mode mode)
-
allocateSequenceNumber
public int allocateSequenceNumber()
-
registerRule
public int registerRule(Pattern pattern, TemplateRule eh, Mode mode, StylesheetModule module, double priority, int position, int part)
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. The value is NaN if no explicit priority was specifiedposition
- The relative position of the rule in declaration orderpart
- Zero for a "real" rule; an incremented integer for rules generated by splitting a real rule on a union pattern, in cases where no user-specified priority is supplied.- Returns:
- the number of (sub-)rules registered
- See Also:
Pattern
-
computeRankings
public void computeRankings() throws XPathException
Allocate rankings to the rules within each mode. This method must be called when all the rules in each mode are known. This method also checks that there are no conflicts for property values in different xsl:mode declarations- Throws:
XPathException
- if an error occurs
-
invertStreamableTemplates
public void invertStreamableTemplates() throws XPathException
Invert streamable templates in all streamable modes- Throws:
XPathException
- if the templates are not streamable
-
checkConsistency
public void checkConsistency() throws XPathException
Check all modes for conflicts in property values- Throws:
XPathException
- if a mode has conflicting property values
-
explainTemplateRules
public void explainTemplateRules(ExpressionPresenter presenter) throws XPathException
Explain (that is, output the expression tree) for all template rules- Parameters:
presenter
- the object used to present the output- Throws:
XPathException
-
optimizeRules
public void optimizeRules()
Optimization of template rules Only invoked when rule optimization has been turned on. In this case we know the modes are instances of at least ModeEE
-
-