Package net.sf.saxon.trans
Class CompoundMode
- java.lang.Object
-
- net.sf.saxon.expr.instruct.Actor
-
- net.sf.saxon.trans.Mode
-
- net.sf.saxon.trans.CompoundMode
-
- All Implemented Interfaces:
javax.xml.transform.SourceLocator
,ExpressionOwner
,Location
,org.xml.sax.Locator
public class CompoundMode extends Mode
A CompoundMode is a mode representing the templates contained within an xsl:override element in a using package together with the rules in the corresponding mode of the base package.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.saxon.trans.Mode
Mode.RuleAction, Mode.RuleFilter
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.trans.Mode
DEFAULT_MODE_NAME, modeName, mustBeTyped, mustBeUntyped, OMNI_MODE, RECOVER_WITH_WARNINGS, UNNAMED_MODE_NAME
-
-
Constructor Summary
Constructors Constructor Description CompoundMode(Mode base, SimpleMode overrides)
Create a compound Mode
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allocateAllBindingSlots(StylesheetPackage pack)
Allocate slot numbers to all the external component references in this componentvoid
computeRankings(int start)
Compute a rank for each rule, as a combination of the precedence and priority, to allow rapid comparison.void
explainTemplateRules(ExpressionPresenter presenter)
Explain expression structure.void
exportTemplateRules(ExpressionPresenter presenter)
Export expression structure.SimpleMode
getActivePart()
Get the active component of this mode.BuiltInRuleSet
getBuiltInRuleSet()
Get the built-in template rules to be used with this Mode in the case where there is no explicit template rulejava.util.Set<java.lang.String>
getExplicitNamespaces(NamePool pool)
Get the "explicit namespaces" matched by this mode.int
getMaxPrecedence()
Get the maximum precedence of the rules in this modeint
getMaxRank()
Get the highest rank of the rules in this modeRule
getRule(Item item, XPathContext context)
Get the rule corresponding to a given item, by finding the best pattern match.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.int
getStackFrameSlotsNeeded()
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(Mode.RuleAction action)
Walk over all the rules, applying a specified action to each one.-
Methods inherited from class net.sf.saxon.trans.Mode
applyTemplates, explain, export, exportUseAccumulators, getAccumulators, getBuiltInRuleSetForCode, getCodeForBuiltInRuleSet, getDeclaringComponent, getDefaultResultType, getModeName, getModeTitle, getNextMatchRule, getObjectName, getRecoveryPolicy, getRule, getSymbolicName, isDeclaredStreamable, isModeTracing, isMustBeTyped, isUnnamedMode, makeNewContext, setAccumulators, setDefaultResultType, setHasRules, setModeTracing, setRecoveryPolicy, setStreamable
-
Methods inherited from class net.sf.saxon.expr.instruct.Actor
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
-
-
-
-
Constructor Detail
-
CompoundMode
public CompoundMode(Mode base, SimpleMode overrides)
Create a compound Mode- Parameters:
base
- the mode from the base (used) packageoverrides
- the mode containing (only) the overriding template rules from the using package
-
-
Method Detail
-
getBuiltInRuleSet
public BuiltInRuleSet getBuiltInRuleSet()
Get the built-in template rules to be used with this Mode in the case where there is no explicit template rule- Specified by:
getBuiltInRuleSet
in classMode
- Returns:
- the built-in rule set, defaulting to the TextOnlyCopyRuleSet if no other rule set has been supplied
-
getActivePart
public SimpleMode getActivePart()
Get the active component of this mode. For a simple mode this is the mode itself; for a compound mode it is the "overriding" part- Specified by:
getActivePart
in classMode
-
isEmpty
public boolean isEmpty()
Ask whether there are any template rules in this mode (a mode could exist merely because it is referenced in apply-templates)
-
getMaxPrecedence
public int getMaxPrecedence()
Get the maximum precedence of the rules in this mode- Specified by:
getMaxPrecedence
in classMode
-
getMaxRank
public int getMaxRank()
Get the highest rank of the rules in this mode- Specified by:
getMaxRank
in classMode
- Returns:
- the highest rank
-
computeRankings
public void computeRankings(int start) throws XPathException
Compute a rank for each rule, as a combination of the precedence and priority, to allow rapid comparison. This method also checks that there are no conflicts for property values in different xsl:mode declarations- Specified by:
computeRankings
in classMode
- Parameters:
start
- the lowest rank to use- Throws:
XPathException
- if an error occurs processing the rules
-
processRules
public void processRules(Mode.RuleAction action) throws XPathException
Walk over all the rules, applying a specified action to each one.- Specified by:
processRules
in classMode
- Parameters:
action
- an action that is to be applied to all the rules in this Mode- Throws:
XPathException
- if an error occurs processing any of the rules
-
getExplicitNamespaces
public java.util.Set<java.lang.String> getExplicitNamespaces(NamePool pool)
Get the "explicit namespaces" matched by this mode. Returns a set containing all the namespaces matched by specific template rules in this mode- Specified by:
getExplicitNamespaces
in classMode
- Parameters:
pool
- the NamePool for the configuration- Returns:
- the set of all namespace URIs of names explicitly matched by rules in this mode
-
allocateAllBindingSlots
public void allocateAllBindingSlots(StylesheetPackage pack)
Allocate slot numbers to all the external component references in this component- Overrides:
allocateAllBindingSlots
in classActor
- Parameters:
pack
- the containing package
-
getRule
public Rule getRule(Item item, XPathContext context) throws XPathException
Get the rule corresponding to a given item, by finding the best pattern match.- Specified by:
getRule
in classMode
- Parameters:
item
- the item to be matchedcontext
- the XPath dynamic evaluation context- Returns:
- the best matching rule, if any (otherwise null).
- Throws:
XPathException
- if an error occurs matching a pattern
-
getStackFrameSlotsNeeded
public int getStackFrameSlotsNeeded()
- Specified by:
getStackFrameSlotsNeeded
in classMode
-
getRule
public Rule getRule(Item item, XPathContext context, java.util.function.Predicate<Rule> filter) throws XPathException
Get the rule corresponding to a given item, by finding the best Pattern match.- Specified by:
getRule
in classMode
- Parameters:
item
- the item to be matchedcontext
- the XPath dynamic evaluation contextfilter
- a filter to select which rules should be considered- Returns:
- the best matching rule, if any (otherwise null).
- Throws:
XPathException
- if an error occurs
-
exportTemplateRules
public void exportTemplateRules(ExpressionPresenter presenter) throws XPathException
Export expression structure. The abstract expression tree is written to the supplied outputstream.- Specified by:
exportTemplateRules
in classMode
- Parameters:
presenter
- the expression presenter used to generate the XML representation of the structure- Throws:
XPathException
-
explainTemplateRules
public void explainTemplateRules(ExpressionPresenter presenter) throws XPathException
Explain expression structure. The abstract expression tree is written to the supplied outputstream.- Specified by:
explainTemplateRules
in classMode
- Parameters:
presenter
- the expression presenter used to generate the XML representation of the structure- Throws:
XPathException
-
-