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:
SourceLocator,ExpressionOwner,Location,Locator
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 ClassesNested classes/interfaces inherited from class net.sf.saxon.trans.SimpleMode
SimpleMode.RuleGroupActionNested 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, unnamedElementRuleChainFields inherited from class net.sf.saxon.trans.Mode
DEFAULT_MODE_NAME, modeName, mustBeTyped, mustBeUntyped, OMNI_MODE_NAME, RECOVER_WITH_WARNINGS, UNNAMED_MODE_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCompute the streamability of all template rulesvoidExplain all template rules in this mode by showing their expression tree represented in XML.protected voidexportUseAccumulators(ExpressionPresenter presenter) getNamedNodeChain(NodeInfo node, XPathContext context) Find the named node rule chain for a given nodegetUnnamedNodeChain(NodeInfo node) Find the unnamed node rule chain for a given nodevoidFor a streamable mode, invert all the templates to generate streamable codeWork with a rule chain as a list of rulesmakeRule(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 RuleSearchStatemakeRuleSearchState(RuleChain chain, XPathContext context) Generate a search state for processing a given nodevoidoptimizeRuleChain(RuleChain chain) Perform optimization on a chain of rules.voidPerform optimization on the complete set of rules comprising this Mode.orderRules(List<Rule> r1, List<Rule> r2) Combine two rule lists in rank orderorderRules(RuleChain chain1, RuleChain chain2) Combine two rule chains into a rank-ordered combined listprotected voidreportAmbiguity(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 booleanruleMatches(Rule r, Item item, XPathContextMajor context, RuleSearchState ruleSearchState) Does this rule match the given item? Can be overriddenstatic StringtypeName(int type) Find the name for a node typeprotected static booleanMethods inherited from class com.saxonica.trans.ModePE
prepareStreamabilityMethods inherited from class net.sf.saxon.trans.SimpleMode
addRule, addRule, addRuleToNamedOrUnnamedChain, allocateAllBindingSlots, allocateAllPatternSlots, allocatePatternSlots, computeRankings, 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, setStackFrameSlotsNeededMethods inherited from class net.sf.saxon.trans.Mode
applyTemplates, explain, export, getAccumulators, getBuiltInRuleSetForCode, getCodeForBuiltInRuleSet, getDeclaringComponent, getDefaultResultType, getModeName, getModeTitle, getNextMatchRule, getObjectName, getRecoveryPolicy, getRule, getSymbolicName, isDeclaredStreamable, isEnclosingMode, isModeTracing, isMustBeTyped, isUnnamedMode, makeNewContext, setAccumulators, setDefaultResultType, setEnclosingMode, setHasRules, setModeTracing, setRecoveryPolicy, setStreamableMethods 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, process, saveLocation, setBody, setChildExpression, setColumnNumber, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId
-
Constructor Details
-
ModeEE
-
-
Method Details
-
exportUseAccumulators
- Overrides:
exportUseAccumulatorsin classMode
-
makeRule
public Rule makeRule(Pattern pattern, RuleTarget action, int precedence, int minImportPrecedence, double priority, int sequence, int part) Description copied from class:SimpleModeGenerate a new rule - so it can be overridden to make more specialist rules- Overrides:
makeRulein 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
Description copied from class:SimpleModeGenerate a search state for processing a given node- Overrides:
makeRuleSearchStatein classSimpleMode- Returns:
- a new object capable of holding the state of a search for a rule
-
getNamedNodeChain
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
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:
ruleMatchesin 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
Compute the streamability of all template rules- Overrides:
computeStreamabilityin classSimpleMode- Throws:
XPathException
-
invertStreamableTemplates
For a streamable mode, invert all the templates to generate streamable code- Overrides:
invertStreamableTemplatesin 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:
optimizeRulesin classSimpleMode
-
optimizeRuleChain
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
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
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
-
useFirst
-
orderRules
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
Description copied from class:SimpleModeExplain 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:
explainTemplateRulesin classSimpleMode- Parameters:
out- used to display the expression tree- Throws:
XPathException
-
reportAmbiguity
Description copied from class:SimpleModeReport an ambiguity, that is, the situation where two rules of the same precedence and priority match the same node- Overrides:
reportAmbiguityin 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
Find the name for a node type- Parameters:
type- the code for the type- Returns:
- a suitable string or the empty string if unknown
-