Class RuleManager


  • public final class RuleManager
    extends java.lang.Object
    RuleManager maintains a set of template rules, one set for each mode
    • Method Detail

      • 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 java.util.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)
      • existsOmniMode

        public boolean existsOmniMode()
      • 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:
        Pattern
      • getTemplateRule

        public Rule getTemplateRule​(Item item,
                                    Mode mode,
                                    int min,
                                    int max,
                                    XPathContext c)
                             throws XPathException
        Get the template rule matching a given item whose import precedence is in a particular range. This is used to support the xsl:apply-imports function
        Parameters:
        item - The item 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 - if an error occurs matching a pattern
      • 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