Package net.sf.saxon.trans

## Class CompoundMode

- java.lang.Object
- - net.sf.saxon.expr.instruct.Actor
  - - net.sf.saxon.trans.Mode
    - - net.sf.saxon.trans.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.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class net.sf.saxon.trans.Mode

      `Mode.RuleAction, Mode.RuleFilter`

  - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.trans.Mode

      `DEFAULT_MODE_NAME, modeName, mustBeTyped, mustBeUntyped, OMNI_MODE, RECOVER_WITH_WARNINGS, UNNAMED_MODE_NAME`

    - ### Fields inherited from class net.sf.saxon.expr.instruct.Actor

      `body`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CompoundMode​(Mode base, SimpleMode overrides)` | Create a compound Mode

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `allocateAllBindingSlots​(StylesheetPackage pack)` | Allocate slot numbers to all the external component references in this component
    `void` | `computeRankings​(int start)` | Compute a rank for each rule, as a combination of the precedence and priority, to allow rapid comparison.
    `void` | `explainTemplateRules​(ExpressionPresenter presenter)` | Explain expression structure.
    `void` | `exportTemplateRules​(ExpressionPresenter presenter)` | Export expression structure.
    `SimpleMode` | `getActivePart()` | Get the active component of this mode.
    `BuiltInRuleSet` | `getBuiltInRuleSet()` | Get the built-in template rules to be used with this Mode in the case where there is no explicit template rule
    `java.util.Set<java.lang.String>` | `getExplicitNamespaces​(NamePool pool)` | Get the "explicit namespaces" matched by this mode.
    `int` | `getMaxPrecedence()` | Get the maximum precedence of the rules in this mode
    `int` | `getMaxRank()` | Get the highest rank of the rules in this mode
    `Rule` | `getRule​(Item item, XPathContext context)` | Get the rule corresponding to a given item, by finding the best pattern match.
    `Rule` | `getRule​(Item item, XPathContext context, Mode.RuleFilter filter)` | Get the rule corresponding to a given item, by finding the best Pattern match.
    `int` | `getStackFrameSlotsNeeded()` |
    `boolean` | `isEmpty()` | Ask whether there are any template rules in this mode (a mode could exist merely because it is referenced in apply-templates)
    `void` | `processRules​(Mode.RuleAction action)` | Walk over all the rules, applying a specified action to each one.

    - ### Methods inherited from class net.sf.saxon.trans.Mode

      `applyTemplates, explain, export, exportUseAccumulators, getAccumulators, getBuiltInRuleSetForCode, getCodeForBuiltInRuleSet, getDeclaringComponent, getDefaultResultType, getModeName, getModeTitle, getNextMatchRule, getObjectName, getRecoveryPolicy, getRule, getSymbolicName, isDeclaredStreamable, isModeTracing, isMustBeTyped, isUnnamedMode, makeNewContext, setAccumulators, setDefaultResultType, setHasRules, setModeTracing, setRecoveryPolicy, setStreamable`

    - ### Methods inherited from class net.sf.saxon.expr.instruct.Actor

      `allocateBindingSlotsRecursive, getBody, getChildExpression, getColumnNumber, getComponentName, getDeclaredVisibility, getLineNumber, getLocation, getPackageData, getProperties, getProperty, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, getTracingTag, isExportable, makeDeclaringComponent, obtainDeclaringComponent, saveLocation, setBody, setChildExpression, setColumnNumber, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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<java.lang.String> 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

    - #### getStackFrameSlotsNeeded

          public int getStackFrameSlotsNeeded()

      Specified by:
        `getStackFrameSlotsNeeded` in class `Mode`

    - #### getRule

          public Rule getRule​(Item item,
                              XPathContext context,
                              Mode.RuleFilter 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`