net.sf.saxon.trans
Class RuleManager

java.lang.Object
  |
  +--net.sf.saxon.trans.RuleManager
All Implemented Interfaces:
java.io.Serializable

public class RuleManager
extends java.lang.Object
implements java.io.Serializable

RuleManager maintains a set of template rules, one set for each mode

See Also:
Serialized Form

Constructor Summary
RuleManager()
          create a RuleManager and initialise variables.
 
Method Summary
 Mode getMode(int modeNameCode)
          Get the Mode object for a named mode.
 Template getNextMatchHandler(NodeInfo node, Mode mode, Template currentHandler, XPathContext c)
          Get the next-match handler after the current one
 Template getTemplateRule(NodeInfo node, Mode mode, int min, int max, XPathContext c)
          Get a template rule whose import precedence is in a particular range.
 Template getTemplateRule(NodeInfo node, Mode mode, XPathContext c)
          Find the template rule registered for a particular node in a specific mode.
 void resetHandlers()
          Set up a new table of handlers.
 void setHandler(Pattern pattern, Template eh, Mode mode, int precedence)
          Register a handler for a particular pattern.
 void setHandler(Pattern pattern, Template eh, Mode mode, int precedence, double priority)
          Register a handler for a particular pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleManager

public RuleManager()
create a RuleManager and initialise variables.

Method Detail

resetHandlers

public void resetHandlers()
Set up a new table of handlers.


getMode

public Mode getMode(int modeNameCode)
Get the Mode object for a named mode. If there is not one already registered. a new Mode is created.

Parameters:
modeNameCode - The name code of the mode. Supply Mode.DEFAULT_MODE to get the default mode or Mode.ALL_MODES to get the Mode object containing "mode=all" rules
Returns:
the Mode with this name

setHandler

public void setHandler(Pattern pattern,
                       Template eh,
                       Mode mode,
                       int precedence)
Register a handler for a particular pattern. The priority of the rule is the default priority for the pattern, which depends on the syntax of the pattern suppllied.

Parameters:
pattern - A match pattern
eh - The ElementHandler to be used
mode - The processing mode
precedence - The import precedence (use 0 by default)

setHandler

public void setHandler(Pattern pattern,
                       Template eh,
                       Mode mode,
                       int precedence,
                       double priority)
Register a handler for a particular pattern.

Parameters:
pattern - Must be a valid Pattern.
eh - The Template to be used
mode - The processing mode to which this element handler applies
precedence - The import precedence of this rule
priority - The priority of the rule: if an element matches several patterns, the one with highest priority is used
See Also:
Pattern

getTemplateRule

public Template getTemplateRule(NodeInfo node,
                                Mode mode,
                                XPathContext c)
                         throws XPathException
Find the template rule registered for a particular node in a specific mode.

Parameters:
node - The NodeInfo for the relevant node
mode - The processing mode
c - The controller for this transformation
Returns:
The template rule that will process this node Returns null if there is no specific handler registered.
XPathException

getTemplateRule

public Template getTemplateRule(NodeInfo node,
                                Mode mode,
                                int min,
                                int max,
                                XPathContext c)
                         throws XPathException
Get a template rule whose import precedence is in a particular range. This is used to support the xsl:apply-imports function

Parameters:
node - The node to be matched
mode - The mode for which a rule is required
min - The minimum import precedence that the rule must have
max - The maximum import precedence that the rule must have
c - The Controller for the transformation
Returns:
The template rule to be invoked
Throws:
XPathException

getNextMatchHandler

public Template getNextMatchHandler(NodeInfo node,
                                    Mode mode,
                                    Template currentHandler,
                                    XPathContext c)
                             throws XPathException
Get the next-match handler after the current one

Parameters:
node - The node to be matched
mode - The processing mode
currentHandler - The current template rule
c - The dynamic context for the transformation
Returns:
The template rule to be executed
Throws:
XPathException