com.saxonica.stream.adjunct

## Class ForEachGroupAdjunct

- java.lang.Object
- - com.saxonica.stream.adjunct.StreamingAdjunct
  - - com.saxonica.stream.adjunct.ForEachGroupAdjunct

-     public class ForEachGroupAdjunct
      extends StreamingAdjunct

  Handle streamed implementation of an xsl:for-each-group instruction.

  At present streamed grouping always starts by copying the selected nodes, so the memory required is limited by the maximum size of these nodes. (However, Saxon does not take advantage of the fact that the nodes are copied in doing the streamability analysis: for example, the grouping key for the streamed nodes must be a motionless expression). Hopefully this limitation will be removed at some stage.

  Grouping works only if the new 3.0 syntax for binding a grouping variable is used; it is not possible to use the 2.0 current-group() function, because of the impossibility of static analysis.

  The "streaming route" starts with a CopyOfWatch. This recognizes the elements selected in the select expression of the for-each-group instruction, and feeds these into a GroupingFeed. The GroupingFeed examines successive items and decides when to start and end groups. This is done by calling the open() and close() methods of the Feed for the xsl:for-each-group instruction itself.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ForEachGroupAdjunct()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `WatchMaker` | `getWatchMaker(Expression expression, List<String> reasonsForFailure)` Get a WatchMaker, a factory class that creates a Watch to evaluate this expression in streaming mode.

    - ### Methods inherited from class com.saxonica.stream.adjunct.StreamingAdjunct

      `getConfiguration, getFeedMaker, makeStreamingAdjunct, setConfiguration`

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

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

- - ### Constructor Detail

    - #### ForEachGroupAdjunct

          public ForEachGroupAdjunct()

  - ### Method Detail

    - #### getWatchMaker

          public WatchMaker getWatchMaker(Expression expression,
                                 List<String> reasonsForFailure)
                                   throws XPathException

      Description copied from class: `StreamingAdjunct`
      Get a WatchMaker, a factory class that creates a Watch to evaluate this expression in streaming mode. This method will only be called if the getImplementationMethod() method of the expression includes the value `Expression.WATCH_METHOD`
      Overrides:
        `getWatchMaker` in class `StreamingAdjunct`
      Parameters:
        `expression` - the expression to be evaluated in streaming mode
        `reasonsForFailure` - if non-null, this is a list supplied by the caller which will be populated by the callee with one or more messages indicating why it was not possible to allocate a WatchMaker. Normally if the list is non-empty on return, the return value from the method will be null.
      Returns:
        a Watchmaker to evaluate the expression, or null if it is not streamable with respect to the specificed argument.
      Throws:
        `XPathException` - in the event of a failure

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