public class ModeEE extends ModePE
Modifier and Type | Class and Description |
---|---|
static interface |
ModeEE.RuleTypeAction |
SimpleMode.RuleGroupAction
Mode.RuleAction, Mode.RuleFilter
Modifier and Type | Field and Description |
---|---|
protected PatternOptimizationEE |
patternOptimization |
protected PreconditionSet |
rulePreconditions |
atomicValueRuleChain, commentRuleChain, documentRuleChain, functionItemRuleChain, genericRuleChain, namedAttributeRuleChains, namedElementRuleChains, namespaceRuleChain, processingInstructionRuleChain, qNamedAttributeRuleChains, qNamedElementRuleChains, textRuleChain, unnamedAttributeRuleChain, unnamedElementRuleChain
DEFAULT_MODE_NAME, hasRules, modeName, mustBeTyped, mustBeUntyped, OMNI_MODE, UNNAMED_MODE_NAME
body
Constructor and Description |
---|
ModeEE(StructuredQName modeName,
CompilerInfo compilerInfo) |
Modifier and Type | Method and Description |
---|---|
void |
computePreconditions()
Compute the set of preconditions for all the rules
(of all types) within this mode
Then filter them according to usage and retain on rules only those retained on the mode.
|
void |
computeStreamability()
Compute the streamability of all template rules
|
static List<Rule> |
deduplicateRules(List<Rule> in)
Remove duplicate rules within a rule list - this can happen from rules with UnionPatterns which appear twice.
|
void |
explainTemplateRules(ExpressionPresenter out)
Explain all template rules in this mode by showing their
expression tree represented in XML.
|
Rule |
getNamedNodeChain(NodeInfo node,
XPathContext context)
Find the named node rule chain for a given node
|
Rule |
getUnnamedNodeChain(NodeInfo node)
Find the unnamed node rule chain for a given node
|
void |
invertStreamableTemplates()
For a streamable mode, invert all the templates to generate streamable code
|
static List<Rule> |
listRules(Rule chain)
Work with a rule chain as a list of rules
|
Rule |
makeRule(Pattern pattern,
RuleTarget action,
int precedence,
int minImportPrecedence,
double priority,
int sequence)
Generate a new rule - so it can be overridden to make more specialist rules
|
protected RuleSearchState |
makeRuleSearchState()
Generate a search state for processing a given node
|
void |
optimizeRules() |
void |
optimizeRules(IntHashMap<Rule> chains) |
void |
optimizeRules(Rule r,
int type) |
static List<Rule> |
orderRules(List<Rule> r1,
List<Rule> r2)
Combine two rule lists in rank order
|
static List<Rule> |
orderRules(Rule chain1,
Rule chain2)
Combine two rule chains into a rank-ordered combined list
|
void |
processRulesTyped(ModeEE.RuleTypeAction action)
Process all the chain of rules each with an indication of the type of rule being processed
|
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 node
|
protected boolean |
ruleMatches(Rule r,
Item item,
XPathContextMajor context,
RuleSearchState ruleSearchState)
Does this rule match the given item? Can be overridden
|
protected ModeEE.RuleTypeAction |
setType(ModeEE.RuleTypeAction action,
ItemType type) |
static String |
typeName(int type)
Find the name for a node type
|
getBuiltInRuleSetForCode, getCodeForBuiltInRuleSet, prepareStreamability
addRule, addRule, allocateAllBindingSlots, allocateAllPatternSlots, allocatePatternSlots, checkForConflictingProperties, computeRankings, copyRules, exportTemplateRules, forceAllocateAllBindingSlots, getActivePart, getBuiltInRuleSet, getExplicitNamespaces, getMaxPrecedence, getMaxRank, getNamedRuleChain, getPropertyValue, getRule, getRule, getStackFrameSlotsNeeded, isEmpty, processRuleChain, processRuleChain, processRuleChains, processRules, processRules, searchRuleChain, searchRuleChain, setBuiltInRuleSet, setExplicitProperty, setGroup, setStackFrameSlotsNeeded
applyTemplates, explain, export, getComponentKind, getConstructType, getModeName, getModeTitle, getNextMatchRule, getObjectName, getRecoveryPolicy, getRule, getSymbolicName, isDeclaredStreamable, isUnnamedMode, makeNewContext, makeNewContextIfNeeded, setRecoveryPolicy, setStreamable
allocateBindingSlotsRecursive, getBody, getColumnNumber, getDeclaredVisibility, getDeclaringComponent, getLineNumber, getLocation, getPackageData, getProperties, getProperty, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, makeDeclaringComponent, saveLocation, setBody, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId
protected PatternOptimizationEE patternOptimization
protected PreconditionSet rulePreconditions
public ModeEE(StructuredQName modeName, CompilerInfo compilerInfo)
public Rule makeRule(Pattern pattern, RuleTarget action, int precedence, int minImportPrecedence, double priority, int sequence)
SimpleMode
makeRule
in class SimpleMode
pattern
- the pattern that this rule matchesaction
- the object invoked by this rule (usually a Template)precedence
- the precedence of the ruleminImportPrecedence
- the minumum import precedence for xsl:apply-importspriority
- the priority of the rulesequence
- a sequence number for ordering of rulesprotected RuleSearchState makeRuleSearchState()
SimpleMode
makeRuleSearchState
in class SimpleMode
public Rule getNamedNodeChain(NodeInfo node, XPathContext context)
node
- the node to be matchedcontext
- local contextpublic Rule getUnnamedNodeChain(NodeInfo node)
node
- the node to be matchedpublic void computePreconditions()
protected boolean ruleMatches(Rule r, Item item, XPathContextMajor context, RuleSearchState ruleSearchState) throws XPathException
ruleMatches
in class SimpleMode
r
- the rule to checkitem
- the context itemcontext
- the static context for evaluationruleSearchState
- An appropriate matcher for preconditions in this modeXPathException
public void processRulesTyped(ModeEE.RuleTypeAction action) throws XPathException
action
- the action to executeXPathException
public void computeStreamability() throws XPathException
computeStreamability
in class SimpleMode
XPathException
public void invertStreamableTemplates() throws XPathException
invertStreamableTemplates
in class SimpleMode
XPathException
- if there is a non-streamable template in the modeprotected ModeEE.RuleTypeAction setType(ModeEE.RuleTypeAction action, ItemType type)
public void optimizeRules()
optimizeRules
in class SimpleMode
public void optimizeRules(Rule r, int type)
public void optimizeRules(IntHashMap<Rule> chains)
public static List<Rule> listRules(Rule chain)
chain
- the chained set of rulespublic static List<Rule> orderRules(List<Rule> r1, List<Rule> r2)
This does not detect duplicates within the list
r1
- one list of rules, assumed in rank orderr2
- the other list of rules, assumed in rank orderpublic static List<Rule> deduplicateRules(List<Rule> in)
Assumes the list is ordered, so duplicates should appear together.
TODO - look at sequence as well.in
- the list of rules from which duplicates arepublic static List<Rule> orderRules(Rule chain1, Rule chain2)
This could be simplified as orderRules(listRules(chain1),listRules(chain2))
chain1
- chain2
- public void explainTemplateRules(ExpressionPresenter out)
SimpleMode
explainTemplateRules
in class SimpleMode
out
- used to display the expression treepublic void reportAmbiguity(Item item, Rule r1, Rule r2, XPathContext c) throws XPathException
SimpleMode
reportAmbiguity
in class SimpleMode
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 transformationXPathException
- if the system is configured to treat ambiguous template matching as a
non-recoverable errorpublic static String typeName(int type)
type
- the code for the typeCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.