Package com.saxonica.ee.validate
Class SelectorWatch
- java.lang.Object
-
- com.saxonica.ee.stream.watch.AbstractWatch
-
- com.saxonica.ee.stream.watch.PatternWatch
-
- com.saxonica.ee.validate.SelectorWatch
-
- All Implemented Interfaces:
Watch
- Direct Known Subclasses:
KeySelectorWatch
,RefSelectorWatch
public abstract class SelectorWatch extends PatternWatch
A Watch represents a class that is interested in looking at nodes for the purpose of evaluating uniqueness and key constraints. A SelectorWatch looks for the nodes that match the selector in a unique, key, or keyref constraint. There are two concrete subclasses: one for key/unique, the other for keyref
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkRow(AtomicSequence[] currentRow, boolean isTarget, Location locationId)
Method to check that a row (that is, the collection of fields corresponding to one selected node) is valid.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(Location locationId)
Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.protected void
reportValidationError(ValidationFailure err, Location locator)
Report a validation errorReceiver
startSelectedParentNode(FleetingParentNode node, Location locationId)
Signal that an element has been found that matches the selection that this Watch is looking for.-
Methods inherited from class com.saxonica.ee.stream.watch.PatternWatch
getAnchorNode, getSelection, matchesNode, matchesNodesOfKind, open, processItem, setAnchorNode, setSelection
-
Methods inherited from class com.saxonica.ee.stream.watch.AbstractWatch
getNamespaceResolver, getPipelineConfiguration, setNamespaceResolver, setPipelineConfiguration
-
-
-
-
Method Detail
-
startSelectedParentNode
public Receiver startSelectedParentNode(FleetingParentNode node, Location 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
- the element or document node whose start event has been matchedlocationId
- 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 events for the subtree rooted at the element matched by this Watch. A SelectorWatch does not require such notification, so it returns null. @param locationId the location of the node in the source, or of the instruction that created it
- Throws:
ValidationException
- May be raised if the constraint implemented by this Watch is violatedXPathException
- May be raised if a dynamic error occurs
-
endSelectedParentNode
public void endSelectedParentNode(Location 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 node in the source, or of the instruction that created it- Throws:
ValidationException
- May be raised if the constraint implemented by this Watch is violated @param locationId the location of the node in the source, or of the instruction that created itXPathException
- May be raised if a constraint implemented by this Watch is violated
-
close
public 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 interfaceWatch
- Overrides:
close
in classPatternWatch
- Throws:
XPathException
- May be raised if a dynamic error occurs
-
checkRow
protected void checkRow(AtomicSequence[] currentRow, boolean isTarget, Location locationId) throws XPathException
Method to check that a row (that is, the collection of fields corresponding to one selected node) is valid.- Parameters:
currentRow
- the values of the set of fieldsisTarget
- set to true if this is a value of the key referred to by a key reference, rather than a value for this constraint's own selected fields.locationId
- identifies the location of the selected node- Throws:
ValidationException
- is raised if the value of the row (that is, the combination of fields) violates the constraintXPathException
-
reportValidationError
protected void reportValidationError(ValidationFailure err, Location locator) throws XPathException
Report a validation error- Parameters:
err
- The validation exceptionlocator
- identifies the location in the source document or stylesheet/query where the validation error was detected- Throws:
ValidationException
- if the threshold on number of errors is exceededXPathException
-
-