Class RuleManager

java.lang.Object
net.sf.saxon.trans.rules.RuleManager

public final class RuleManager extends Object
RuleManager maintains a set of template rules, one set for each mode
  • Constructor Details

  • Method Details

    • setUnnamedModeExplicit

      public void setUnnamedModeExplicit(boolean declared)
      Say that the unnamed mode has been explicitly declared in an xsl:mode declaration
      Parameters:
      declared - true if it has been explicitly declared
    • isUnnamedModeExplicit

      public boolean isUnnamedModeExplicit()
      Ask whether the unnamed mode has been explicitly declared in an xsl:mode declaration
      Returns:
      true if it has been explicitly declared
    • setCompilerInfo

      public void setCompilerInfo(CompilerInfo compilerInfo)
      Set the compiler information specifically.
      Parameters:
      compilerInfo - the compiler options in use
    • getStylesheetPackage

      public StylesheetPackage getStylesheetPackage()
      Get the stylesheet package
      Returns:
      the stylesheet package
    • getAllNamedModes

      public Collection<Mode> getAllNamedModes()
      Get all registered modes
      Returns:
      a collection containing all registered modes excluding the unnamed mode
    • getUnnamedMode

      public SimpleMode getUnnamedMode()
      Get the mode object for the unnamed mode
      Returns:
      the unnamed mode
    • obtainMode

      public Mode obtainMode(StructuredQName modeName, boolean createIfAbsent)
      Get the Mode object for a named mode. If there is not one already registered. a new Mode is created. This uses a makeMode() method in the configuration
      Parameters:
      modeName - The name of the mode. Supply null to get the default mode or Mode.ALL_MODES to get the Mode object containing "mode=all" rules
      createIfAbsent - if true, then if the mode does not already exist it will be created. If false, then if the mode does not already exist the method returns null. But if the requested mode is the omnimode, it is considered to always exist, and is therefore created regardless.
      Returns:
      the Mode with this name
    • registerMode

      public void registerMode(Mode mode)
    • allocateSequenceNumber

      public int allocateSequenceNumber()
    • registerRule

      public int registerRule(Pattern pattern, TemplateRule eh, Mode mode, StylesheetModule module, double priority, int position, int part)
      Register a template for a particular pattern.
      Parameters:
      pattern - Must be a valid Pattern.
      eh - The Template to be used
      mode - The processing mode to which this template applies
      module - The stylesheet module containing the template rule
      priority - The priority of the rule: if an element matches several patterns, the one with highest priority is used. The value is NaN if no explicit priority was specified
      position - The relative position of the rule in declaration order
      part - Zero for a "real" rule; an incremented integer for rules generated by splitting a real rule on a union pattern, in cases where no user-specified priority is supplied.
      Returns:
      the number of (sub-)rules registered
      See Also:
    • computeRankings

      public void computeRankings() throws XPathException
      Allocate rankings to the rules within each mode. This method must be called when all the rules in each mode are known. This method also checks that there are no conflicts for property values in different xsl:mode declarations
      Throws:
      XPathException - if an error occurs
    • invertStreamableTemplates

      public void invertStreamableTemplates() throws XPathException
      Invert streamable templates in all streamable modes
      Throws:
      XPathException - if the templates are not streamable
    • checkConsistency

      public void checkConsistency() throws XPathException
      Check all modes for conflicts in property values
      Throws:
      XPathException - if a mode has conflicting property values
    • explainTemplateRules

      public void explainTemplateRules(ExpressionPresenter presenter) throws XPathException
      Explain (that is, output the expression tree) for all template rules
      Parameters:
      presenter - the object used to present the output
      Throws:
      XPathException
    • optimizeRules

      public void optimizeRules()
      Optimization of template rules Only invoked when rule optimization has been turned on. In this case we know the modes are instances of at least ModeEE