Class CompoundMode

  • All Implemented Interfaces:
    javax.xml.transform.SourceLocator, ExpressionOwner, Location, org.xml.sax.Locator

    public class CompoundMode
    extends Mode
    A CompoundMode is a mode representing the templates contained within an xsl:override element in a using package together with the rules in the corresponding mode of the base package.
    • Constructor Detail

      • CompoundMode

        public CompoundMode​(Mode base,
                            SimpleMode overrides)
        Create a compound Mode
        Parameters:
        base - the mode from the base (used) package
        overrides - the mode containing (only) the overriding template rules from the using package
    • Method Detail

      • getBuiltInRuleSet

        public BuiltInRuleSet getBuiltInRuleSet()
        Get the built-in template rules to be used with this Mode in the case where there is no explicit template rule
        Specified by:
        getBuiltInRuleSet in class Mode
        Returns:
        the built-in rule set, defaulting to the TextOnlyCopyRuleSet if no other rule set has been supplied
      • getActivePart

        public SimpleMode getActivePart()
        Get the active component of this mode. For a simple mode this is the mode itself; for a compound mode it is the "overriding" part
        Specified by:
        getActivePart in class 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)
        Specified by:
        isEmpty in class Mode
        Returns:
        true if no template rules exist in this mode
      • getMaxPrecedence

        public int getMaxPrecedence()
        Get the maximum precedence of the rules in this mode
        Specified by:
        getMaxPrecedence in class Mode
      • getMaxRank

        public int getMaxRank()
        Get the highest rank of the rules in this mode
        Specified by:
        getMaxRank in class Mode
        Returns:
        the highest rank
      • computeRankings

        public void computeRankings​(int start)
                             throws XPathException
        Compute a rank for each rule, as a combination of the precedence and priority, to allow rapid comparison. This method also checks that there are no conflicts for property values in different xsl:mode declarations
        Specified by:
        computeRankings in class Mode
        Parameters:
        start - the lowest rank to use
        Throws:
        XPathException - if an error occurs processing the rules
      • processRules

        public void processRules​(Mode.RuleAction action)
                          throws XPathException
        Walk over all the rules, applying a specified action to each one.
        Specified by:
        processRules in class Mode
        Parameters:
        action - an action that is to be applied to all the rules in this Mode
        Throws:
        XPathException - if an error occurs processing any of the rules
      • getExplicitNamespaces

        public java.util.Set<NamespaceUri> getExplicitNamespaces​(NamePool pool)
        Get the "explicit namespaces" matched by this mode. Returns a set containing all the namespaces matched by specific template rules in this mode
        Specified by:
        getExplicitNamespaces in class Mode
        Parameters:
        pool - the NamePool for the configuration
        Returns:
        the set of all namespace URIs of names explicitly matched by rules in this mode
      • allocateAllBindingSlots

        public void allocateAllBindingSlots​(StylesheetPackage pack)
        Allocate slot numbers to all the external component references in this component
        Overrides:
        allocateAllBindingSlots in class Actor
        Parameters:
        pack - the containing package
      • getRule

        public Rule getRule​(Item item,
                            XPathContext context)
                     throws XPathException
        Get the rule corresponding to a given item, by finding the best pattern match.
        Specified by:
        getRule in class Mode
        Parameters:
        item - the item to be matched
        context - the XPath dynamic evaluation context
        Returns:
        the best matching rule, if any (otherwise null).
        Throws:
        XPathException - if an error occurs matching a pattern
      • getRule

        public Rule getRule​(Item item,
                            XPathContext context,
                            java.util.function.Predicate<Rule> filter)
                     throws XPathException
        Get the rule corresponding to a given item, by finding the best Pattern match.
        Specified by:
        getRule in class Mode
        Parameters:
        item - the item to be matched
        context - the XPath dynamic evaluation context
        filter - a filter to select which rules should be considered
        Returns:
        the best matching rule, if any (otherwise null).
        Throws:
        XPathException - if an error occurs
      • exportTemplateRules

        public void exportTemplateRules​(ExpressionPresenter presenter)
                                 throws XPathException
        Export expression structure. The abstract expression tree is written to the supplied outputstream.
        Specified by:
        exportTemplateRules in class Mode
        Parameters:
        presenter - the expression presenter used to generate the XML representation of the structure
        Throws:
        XPathException
      • explainTemplateRules

        public void explainTemplateRules​(ExpressionPresenter presenter)
                                  throws XPathException
        Explain expression structure. The abstract expression tree is written to the supplied outputstream.
        Specified by:
        explainTemplateRules in class Mode
        Parameters:
        presenter - the expression presenter used to generate the XML representation of the structure
        Throws:
        XPathException