com.saxonica.stream.watch

## Class SimpleContentWatch

- java.lang.Object
- - com.saxonica.validate.AbstractWatch
  - - com.saxonica.stream.watch.ComposingWatch
    - - com.saxonica.stream.watch.SimpleContentWatch

- All Implemented Interfaces:
    Watch

      public class SimpleContentWatch
      extends ComposingWatch

  This class is used when a streaming template requests evaluation of a simple content constructor in streaming mode (that is, when it constructs a text, attribute, comment, or PI node based on the contents of the streamed document). The result of this Watch is a single string, constructed using the rules of "Constructing Simple Content" in the XSLT specification.

  The AdjacentTextNodeMergerFeed is used when the node is constructed as a result of a computation on the streamed data, for example `xsl:value-of select="distinct-values(.//@price)"`. By contrast, a SimpleContentWatch is used when the streamed nodes are selected directly, for example `xsl:value-of select=".//@price"`.

  Both a Feed and a Watch are needed because a simple content constructor operates on a sequence of nodes without simply atomizing the sequence.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleContentWatch(Feed result, Stack<XPathContext> contextStack)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` The close() method is called immediately before the Watch is destroyed, that is, when the element whose declaration scopes the constraint implemented by this Watch goes out of scope.
    `void` | `endSelectedParentNode(int locationId)` Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.
    `void` | `notifySelectedLeafNode(FleetingNode node, int locationId)` Signal that a node (other than an element) that matches the selection has been found.
    `Receiver` | `startSelectedParentNode(FleetingNode node, int locationId)` Signal that an element has been found that matches the selection that this Watch is looking for.

    - ### Methods inherited from class com.saxonica.stream.watch.ComposingWatch

      `getContext, getContextStack, getResult, open`

    - ### Methods inherited from class com.saxonica.validate.AbstractWatch

      `getAnchorNode, getNamespaceResolver, getPipelineConfiguration, getSelection, setAnchorNode, setNamespaceResolver, setPipelineConfiguration, setSelection`

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

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

- - ### Constructor Detail

    - #### SimpleContentWatch

          public SimpleContentWatch(Feed result,
                            Stack<XPathContext> contextStack)

  - ### Method Detail

    - #### startSelectedParentNode

          public Receiver startSelectedParentNode(FleetingNode node,
                                         int locationId)
                                           throws XPathException

      Signal that an element has been found that matches the selection that this Watch is looking for. This method is called by the ConstraintChecker while processing the startElement event that matches the selection. For this purpose, any attributes selected by the last step in the selection are ignored
      Parameters:
        `node` -
        `locationId` - @throws net.sf.saxon.type.ValidationException May be raised if the constraint implemented by this Watch is violated
      Returns:
        a Receiver to be notified of all events starting with the startElement/startDocument event for the matched element, and ending with the endElement event for that element; or null if this feature is not required.
      Throws:
        `XPathException` - May be raised if a dynamic error occurs

    - #### endSelectedParentNode

          public void endSelectedParentNode(int locationId)
                                     throws XPathException

      Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.
      Parameters:
        `locationId` - the location of the element
      Throws:
        `ValidationException` - May be raised if the constraint implemented by this Watch is violated @param locationId
        `XPathException` - May be raised if a constraint implemented by this Watch is violated

    - #### notifySelectedLeafNode

          public void notifySelectedLeafNode(FleetingNode node,
                                    int locationId)
                                      throws XPathException

      Signal that a node (other than an element) that matches the selection has been found.
      Specified by:
        `notifySelectedLeafNode` in interface `Watch`
      Overrides:
        `notifySelectedLeafNode` in class `AbstractWatch`
      Parameters:
        `node` - the node that was matched.
        `locationId` -
      Throws:
        `XPathException`

    - #### close

          public final void close()
                           throws XPathException

      The close() method is called immediately before the Watch is destroyed, that is, when the element whose declaration scopes the constraint implemented by this Watch goes out of scope.
      Specified by:
        `close` in interface `Watch`
      Overrides:
        `close` in class `ComposingWatch`
      Throws:
        `XPathException`

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