com.saxonica.stream

## Class TemplateInversion

- java.lang.Object
- - com.saxonica.stream.TemplateInversion

- All Implemented Interfaces:
    Serializable, RuleTarget

      public class TemplateInversion
      extends Object
      implements RuleTarget

  This class represents the inversion of a template body
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TemplateInversion(Template originalTemplate, Configuration config)` Create the Jackson inversion of a template, allowing the template to execute on a streamed input source.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `explain(ExpressionPresenter presenter)` Output diagnostic explanation to an ExpressionPresenter
    `Template` | `getOriginalTemplate()` Get the original template of which this is an inversion
    `SlotManager` | `getStackFrame()` Get the stackframe identifying the slots used for local variables
    `Watch` | `getWatch(WatchManager wm, Stack<XPathContext> contextStack)` Get a Watch associated with this template, if any.
    `void` | `invert()` Invert the body of the template.
    `void` | `setStackFrame(SlotManager frame)` Set the stackframe identifying the slots used for local variables

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

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

- - ### Constructor Detail

    - #### TemplateInversion

          public TemplateInversion(Template originalTemplate,
                           Configuration config)

      Create the Jackson inversion of a template, allowing the template to execute on a streamed input source.
      Parameters:
        `originalTemplate` - the template to be inverted
        `config` - the Saxon configuration

  - ### Method Detail

    - #### getWatch

          public Watch getWatch(WatchManager wm,
                       Stack<XPathContext> contextStack)
                         throws XPathException

      Get a Watch associated with this template, if any. This creates a watch to implement the "drill-down" instruction of the inverted template, for example if the drill-down instruction is `CopyOfWatch` with that expression as its selection.
      Parameters:
        `wm` - the WatchManager which keeps track of all active Watches
        `contextStack` - the stack of dynamic context objects for the active Watches
      Returns:
        the Watch if there is one, or null otherwise.
      Throws:
        `XPathException` - if an error occurs

    - #### getOriginalTemplate

          public Template getOriginalTemplate()

      Get the original template of which this is an inversion
      Returns:
        the original template

    - #### invert

          public void invert()
                      throws XPathException

      Invert the body of the template.
      Throws:
        `XPathException` - if the template is non-streamable

    - #### setStackFrame

          public void setStackFrame(SlotManager frame)

      Set the stackframe identifying the slots used for local variables
      Parameters:
        `frame` - the stack frame skeleton

    - #### getStackFrame

          public SlotManager getStackFrame()

      Get the stackframe identifying the slots used for local variables
      Returns:
        the stack frame skeleton

    - #### explain

          public void explain(ExpressionPresenter presenter)

      Output diagnostic explanation to an ExpressionPresenter
      Specified by:
        `explain` in interface `RuleTarget`

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.