Package net.sf.saxon.trans
Class Mode
- java.lang.Object
-
- net.sf.saxon.trans.Mode
-
- All Implemented Interfaces:
java.io.Serializable
public class Mode extends java.lang.Object implements java.io.Serializable
A Mode is a collection of rules; the selection of a rule to apply to a given element is determined by a Pattern.- Author:
- Michael H. Kay
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StructuredQName
ALL_MODES
static int
DEFAULT_MODE
static StructuredQName
DEFAULT_MODE_NAME
static int
NAMED_MODE
static int
STRIPPER_MODE
-
Constructor Summary
Constructors Constructor Description Mode(int usage, StructuredQName modeName)
Default constructor - creates a Mode containing no rulesMode(Mode omniMode, StructuredQName modeName)
Construct a new Mode, copying the contents of an existing Mode
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRule(Pattern p, java.lang.Object action, int precedence, double priority, boolean explicitMode)
Add a rule to the Mode.void
explainTemplateRules(ExpressionPresenter presenter)
Explain all template rules in this mode by showing their expression tree represented in XML.int
getList(int fingerprint, int kind)
Determine which list to use for a given pattern (we must also search the generic list)StructuredQName
getModeName()
Get the name of the mode (for diagnostics only)Rule
getNextMatchRule(NodeInfo node, Rule currentRule, XPathContext context)
Get the rule corresponding to a given Node, by finding the next-best Pattern match after the specified object.Rule
getRule(NodeInfo node, int min, int max, XPathContext context)
Get the rule corresponding to a given Node, by finding the best Pattern match, subject to a minimum and maximum precedence.Rule
getRule(NodeInfo node, XPathContext context)
Get the rule corresponding to a given Node, by finding the best Pattern match.boolean
isDefaultMode()
Determine if this is the default modeboolean
isEmpty()
Ask whether there are any template rules in this mode (a mode could exist merely because it is referenced in apply-templates)
-
-
-
Field Detail
-
DEFAULT_MODE
public static final int DEFAULT_MODE
- See Also:
- Constant Field Values
-
NAMED_MODE
public static final int NAMED_MODE
- See Also:
- Constant Field Values
-
STRIPPER_MODE
public static final int STRIPPER_MODE
- See Also:
- Constant Field Values
-
ALL_MODES
public static final StructuredQName ALL_MODES
-
DEFAULT_MODE_NAME
public static final StructuredQName DEFAULT_MODE_NAME
-
-
Constructor Detail
-
Mode
public Mode(int usage, StructuredQName modeName)
Default constructor - creates a Mode containing no rules- Parameters:
usage
- one ofDEFAULT_MODE
,NAMED_MODE
,STRIPPER_MODE
modeName
- the name of the mode
-
Mode
public Mode(Mode omniMode, StructuredQName modeName)
Construct a new Mode, copying the contents of an existing Mode- Parameters:
omniMode
- the existing mode. May be null, in which case it is not copiedmodeName
- the name of the new mode to be created
-
-
Method Detail
-
isDefaultMode
public boolean isDefaultMode()
Determine if this is the default mode- Returns:
- true if this is the default (unnamed) mode
-
getModeName
public StructuredQName getModeName()
Get the name of the mode (for diagnostics only)- Returns:
- the mode name. Null for the default (unnamed) mode
-
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)- Returns:
- true if no template rules exist in this mode
-
addRule
public void addRule(Pattern p, java.lang.Object action, int precedence, double priority, boolean explicitMode)
Add a rule to the Mode.- Parameters:
p
- a Patternaction
- the Object to return from getRule() when the supplied node matches this Patternprecedence
- the import precedence of the rulepriority
- the explicit or implicit priority of the ruleexplicitMode
- true if adding a template rule for a specific (default or named) mode; false if adding a rule because it applies to all modes
-
getList
public int getList(int fingerprint, int kind)
Determine which list to use for a given pattern (we must also search the generic list)- Parameters:
fingerprint
- the name of the node being matchedkind
- the node kind of the node being matched- Returns:
- an index in the hash array for this node name and kind
-
getRule
public Rule getRule(NodeInfo node, XPathContext context) throws XPathException
Get the rule corresponding to a given Node, by finding the best Pattern match.- Parameters:
node
- the NodeInfo referring to the node to be matchedcontext
- the XPath dynamic evaluation context- Returns:
- the best matching rule, if any (otherwise null).
- Throws:
XPathException
-
getRule
public Rule getRule(NodeInfo node, int min, int max, XPathContext context) throws XPathException
Get the rule corresponding to a given Node, by finding the best Pattern match, subject to a minimum and maximum precedence. (This supports xsl:apply-imports)- Parameters:
node
- the NodeInfo referring to the node to be matchedmin
- the minimum import precedencemax
- the maximum import precedencecontext
- the XPath dynamic evaluation context- Returns:
- the Rule registered for that node, if any (otherwise null).
- Throws:
XPathException
-
getNextMatchRule
public Rule getNextMatchRule(NodeInfo node, Rule currentRule, XPathContext context) throws XPathException
Get the rule corresponding to a given Node, by finding the next-best Pattern match after the specified object.- Parameters:
node
- the NodeInfo referring to the node to be matchedcurrentRule
- the current rule; we are looking for the next match after the current rulecontext
- the XPath dynamic evaluation context- Returns:
- the object (e.g. a NodeHandler) registered for that element, if any (otherwise null).
- Throws:
XPathException
-
explainTemplateRules
public void explainTemplateRules(ExpressionPresenter presenter)
Explain all template rules in this mode by showing their expression tree represented in XML.- Parameters:
presenter
- used to display the expression tree
-
-