Package com.saxonica.ee.trans
Class ModeEE
- java.lang.Object
-
- net.sf.saxon.expr.instruct.Actor
-
- net.sf.saxon.trans.Mode
-
- net.sf.saxon.trans.SimpleMode
-
- com.saxonica.trans.ModePE
-
- com.saxonica.ee.trans.ModeEE
-
- All Implemented Interfaces:
javax.xml.transform.SourceLocator
,ExpressionOwner
,Location
,org.xml.sax.Locator
public class ModeEE extends ModePE
A version of class Mode that optimizes various aspects of the template patterns, most notably supporting rule preconditions and indexation of unnamed elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ModeEE.RuleChainOptimizationData
-
Nested classes/interfaces inherited from class net.sf.saxon.trans.SimpleMode
SimpleMode.RuleGroupAction
-
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.SimpleMode
atomicValueRuleChain, commentRuleChain, documentRuleChain, functionItemRuleChain, genericRuleChain, namedAttributeRuleChains, namedElementRuleChains, namespaceRuleChain, processingInstructionRuleChain, qNamedAttributeRuleChains, qNamedElementRuleChains, textRuleChain, unnamedAttributeRuleChain, unnamedElementRuleChain
-
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 ModeEE(StructuredQName modeName, CompilerInfo compilerInfo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
computeStreamability()
Compute the streamability of all template rulesvoid
explainTemplateRules(ExpressionPresenter out)
Explain all template rules in this mode by showing their expression tree represented in XML.protected void
exportUseAccumulators(ExpressionPresenter presenter)
RuleChain
getNamedNodeChain(NodeInfo node, XPathContext context)
Find the named node rule chain for a given nodeRuleChain
getUnnamedNodeChain(NodeInfo node)
Find the unnamed node rule chain for a given nodevoid
invertStreamableTemplates()
For a streamable mode, invert all the templates to generate streamable codestatic java.util.List<Rule>
listRules(RuleChain chain)
Work with a rule chain as a list of rulesRule
makeRule(Pattern pattern, RuleTarget action, int precedence, int minImportPrecedence, double priority, int sequence, int part)
Generate a new rule - so it can be overridden to make more specialist rulesprotected PreconditionMatcher
makeRuleSearchState(RuleChain chain, XPathContext context)
Generate a search state for processing a given nodevoid
optimizeRuleChain(RuleChain chain)
Perform optimization on a chain of rules.void
optimizeRules()
Perform optimization on the complete set of rules comprising this Mode.static java.util.List<Rule>
orderRules(java.util.List<Rule> r1, java.util.List<Rule> r2)
Combine two rule lists in rank orderstatic java.util.List<Rule>
orderRules(RuleChain chain1, RuleChain chain2)
Combine two rule chains into a rank-ordered combined listprotected void
reportAmbiguity(Item item, Rule r1, Rule r2, XPathContext c)
Report an ambiguity, that is, the situation where two rules of the same precedence and priority match the same nodeprotected boolean
ruleMatches(Rule r, Item item, XPathContextMajor context, RuleSearchState ruleSearchState)
Does this rule match the given item? Can be overriddenstatic java.lang.String
typeName(int type)
Find the name for a node typeprotected static boolean
useFirst(Rule chain1, Rule chain2)
-
Methods inherited from class com.saxonica.trans.ModePE
prepareStreamability
-
Methods inherited from class net.sf.saxon.trans.SimpleMode
addRule, addRule, addRuleToNamedOrUnnamedChain, allocateAllBindingSlots, allocateAllPatternSlots, allocatePatternSlots, computeRankings, copyRules, exportTemplateRules, forceAllocateAllBindingSlots, getActivePart, getBuiltInRuleSet, getExplicitNamespaces, getLabel, getMaxPrecedence, getMaxRank, getNamedRuleChain, getPropertyValue, getRule, getRule, getStackFrameSlotsNeeded, isEmpty, processRuleChain, processRuleChain, processRuleChains, processRules, processRules, resolveProperties, searchRuleChain, searchRuleChain, setBuiltInRuleSet, setExplicitProperty, setGroup, setStackFrameSlotsNeeded
-
Methods inherited from class net.sf.saxon.trans.Mode
applyTemplates, explain, export, 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
-
ModeEE
public ModeEE(StructuredQName modeName, CompilerInfo compilerInfo)
-
-
Method Detail
-
exportUseAccumulators
protected void exportUseAccumulators(ExpressionPresenter presenter)
- Overrides:
exportUseAccumulators
in classMode
-
makeRule
public Rule makeRule(Pattern pattern, RuleTarget action, int precedence, int minImportPrecedence, double priority, int sequence, int part)
Description copied from class:SimpleMode
Generate a new rule - so it can be overridden to make more specialist rules- Overrides:
makeRule
in classSimpleMode
- Parameters:
pattern
- the pattern that this rule matchesaction
- the object invoked by this rule (usually a Template)precedence
- the precedence of the ruleminImportPrecedence
- the minimum import precedence for xsl:apply-importspriority
- the priority of the rulesequence
- a sequence number for ordering of rulespart
- distinguishes rules formed by splitting a rule on a union pattern- Returns:
- the newly created rule
-
makeRuleSearchState
protected PreconditionMatcher makeRuleSearchState(RuleChain chain, XPathContext context)
Description copied from class:SimpleMode
Generate a search state for processing a given node- Overrides:
makeRuleSearchState
in classSimpleMode
- Returns:
- a new object capable of holding the state of a search for a rule
-
getNamedNodeChain
public RuleChain getNamedNodeChain(NodeInfo node, XPathContext context)
Find the named node rule chain for a given node- Parameters:
node
- the node to be matchedcontext
- local context- Returns:
- the rule chain for nodes with this name, or null if none
-
getUnnamedNodeChain
public RuleChain getUnnamedNodeChain(NodeInfo node)
Find the unnamed node rule chain for a given node- Parameters:
node
- the node to be matched- Returns:
- the rule chain for nodes of this type,or XPath error if illegal type
-
ruleMatches
protected boolean ruleMatches(Rule r, Item item, XPathContextMajor context, RuleSearchState ruleSearchState) throws XPathException
Does this rule match the given item? Can be overridden- Overrides:
ruleMatches
in classSimpleMode
- Parameters:
r
- the rule to checkitem
- the context itemcontext
- the static context for evaluationruleSearchState
- An appropriate matcher for preconditions in this mode- Returns:
- true if this rule does match
- Throws:
XPathException
- if a dynamic error occurs while matching the pattern
-
computeStreamability
public void computeStreamability() throws XPathException
Compute the streamability of all template rules- Overrides:
computeStreamability
in classSimpleMode
- Throws:
XPathException
-
invertStreamableTemplates
public void invertStreamableTemplates() throws XPathException
For a streamable mode, invert all the templates to generate streamable code- Overrides:
invertStreamableTemplates
in classSimpleMode
- Throws:
XPathException
- if there is a non-streamable template in the mode
-
optimizeRules
public void optimizeRules()
Perform optimization on the complete set of rules comprising this Mode. This is done by optimizing each rule chain in turn.- Overrides:
optimizeRules
in classSimpleMode
-
optimizeRuleChain
public void optimizeRuleChain(RuleChain chain)
Perform optimization on a chain of rules. This is done by examining the rules in the chain to see if there are common subexpressions (preconditions) that apply to more than one rule; once a precondition has been evaluated for one rule, it can be used to eliminate other rules quickly without full evaluation of the pattern- Parameters:
chain
- the chain of rules
-
listRules
public static java.util.List<Rule> listRules(RuleChain chain)
Work with a rule chain as a list of rules- Parameters:
chain
- the chained set of rules- Returns:
- the rules as an ordered list, in the same order as the chain
-
orderRules
public static java.util.List<Rule> orderRules(java.util.List<Rule> r1, java.util.List<Rule> r2)
Combine two rule lists in rank orderThis does not detect duplicates within the list
- Parameters:
r1
- one list of rules, assumed in rank orderr2
- the other list of rules, assumed in rank order- Returns:
- the combined list of rules
-
orderRules
public static java.util.List<Rule> orderRules(RuleChain chain1, RuleChain chain2)
Combine two rule chains into a rank-ordered combined listThis could be simplified as orderRules(listRules(chain1),listRules(chain2))
- Parameters:
chain1
- the first rule chainchain2
- the second rule chain- Returns:
- a list containing all the rules in the two chains, ordered by rank
-
explainTemplateRules
public void explainTemplateRules(ExpressionPresenter out) throws XPathException
Description copied from class:SimpleMode
Explain all template rules in this mode by showing their expression tree represented in XML. Note that this produces more information than the simpler exportTemplateRules() method: this method is intended for the human reader wanting diagnostic explanations, whereas exportTemplateRules() is designed to produce a package that can be re-imported.- Overrides:
explainTemplateRules
in classSimpleMode
- Parameters:
out
- used to display the expression tree- Throws:
XPathException
-
reportAmbiguity
protected void reportAmbiguity(Item item, Rule r1, Rule r2, XPathContext c) throws XPathException
Description copied from class:SimpleMode
Report an ambiguity, that is, the situation where two rules of the same precedence and priority match the same node- Overrides:
reportAmbiguity
in classSimpleMode
- Parameters:
item
- The item that matches two or more rulesr1
- The first rule that the node matchesr2
- The second rule that the node matchesc
- The context for the transformation- Throws:
XPathException
- if the system is configured to treat ambiguous template matching as a non-recoverable error
-
typeName
public static java.lang.String typeName(int type)
Find the name for a node type- Parameters:
type
- the code for the type- Returns:
- a suitable string or the empty string if unknown
-
-