com.saxonica.stream.watch
Class IterateWatch

java.lang.Object
  extended by com.saxonica.validate.AbstractWatch
      extended by com.saxonica.stream.watch.EventPushingWatch
          extended by com.saxonica.stream.watch.IterateWatch
All Implemented Interfaces:
Watch

public class IterateWatch
extends EventPushingWatch

This watch implements xsl:iterate in streaming mode. It watches for the nodes selected by the xsl:iterate instruction; when such a node is encountered, it locates the relevant (inverted) template, and activates it. The watch is capable of handling a select expression that selects non-peer nodes (that is, one selected node that is a descendant of another). A top-level selected node is processed directly to the output receiver; a nested node is processed to create a temporary result tree, which is then appended to the output sequence when the processing of the outer selected node is complete.


Constructor Summary
IterateWatch(Expression expression, SequenceReceiver result, Stack<XPathContext> contextStack)
           
 
Method Summary
 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.
protected  XPathContext getLocalContext()
           
 void notifySelectedLeafNode(FleetingNode node, int locationId)
          Signal that a node (other than an element) that matches the selection has been found.
 void open()
          Open the watch.
 void setBody(InvertedExpression body)
           
 void setWatchManager(WatchManager watchManager)
           
 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.EventPushingWatch
getContext, getContextStack, getExpression, getResult, setParentExpressionFeed, setResult
 
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

IterateWatch

public IterateWatch(Expression expression,
                    SequenceReceiver result,
                    Stack<XPathContext> contextStack)
Method Detail

getLocalContext

protected XPathContext getLocalContext()

setBody

public void setBody(InvertedExpression body)

setWatchManager

public void setWatchManager(WatchManager watchManager)

open

public void open()
          throws XPathException
Description copied from class: AbstractWatch
Open the watch. This is done at the point where it first starts watching for nodes that match the selection.

Specified by:
open in interface Watch
Overrides:
open in class EventPushingWatch
Throws:
XPathException

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 WatchManager 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 - the element or document node whose start event has been matched
locationId - the location associated with the element or document node (may be the location of the instruction that created it)
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.
Throws:
ValidationException - May be raised if the constraint implemented by this Watch is violated @param locationId
XPathException

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

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

close

public void close()
           throws XPathException
Description copied from class: AbstractWatch
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. The default implementation does nothing.

Specified by:
close in interface Watch
Overrides:
close in class EventPushingWatch
Throws:
XPathException


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