Package com.saxonica.ee.validate

## Class ValidationStack

- java.lang.Object
- - net.sf.saxon.event.SequenceReceiver
  - - net.sf.saxon.event.ProxyReceiver
    - - com.saxonica.ee.validate.ValidatingFilter
      - - com.saxonica.ee.validate.ValidationStack

- All Implemented Interfaces:
    `javax.xml.transform.Result`, `Receiver`

      public class ValidationStack
      extends ValidatingFilter

  This class manages the receivers that do element content validation. It maintains a stack of Validators, each of which does local element validation of the contents of a single element, adding a new validator to the stack to handle each layer of nesting.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.event.ProxyReceiver

      `nextReceiver`

    - ### Fields inherited from class net.sf.saxon.event.SequenceReceiver

      `pipelineConfiguration, previousAtomic, systemId`

    - ### Fields inherited from interface javax.xml.transform.Result

      `PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ValidationStack​(Receiver next, int initialValidationMode, SchemaType initialType)` | Create a validation stack

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `characters​(java.lang.CharSequence chars, Location locationId, int properties)` | Character data
    `void` | `endDocument()` | Notify the end of a document node
    `void` | `endElement()` | End of element
    `java.util.Map<SchemaComponent,​java.lang.Integer>` | `getCoverageStatistics()` | Get the statistics showing the usage of individual schema components during a validation episode
    `NodeName` | `getTopLevelElement()` | Get the name of the required top-level element (if any)
    `void` | `setInitialValidator​(ContentValidator validator)` | Set the initial validator to be used for the outermost element
    `void` | `setIsNilled​(boolean nilled)` | Indicate whether the current element is nilled
    `void` | `setKeepStatistics​(boolean keep)` | Ask that statistics be maintained for the duration of the validation episode.
    `void` | `setPipelineConfiguration​(PipelineConfiguration pipe)` | Set the pipeline configuration
    `void` | `setTopLevelElement​(NodeName name)` | Set the name of the required top-level element (if any)
    `void` | `setUnparsedEntity​(java.lang.String name, java.lang.String uri, java.lang.String publicId)` | Set the URI for an unparsed entity in the document.
    `void` | `setXsiValidationErrors​(java.util.List<ValidationFailure> errors)` | Supply a list of errors found in attributes in the XSI namespace.
    `void` | `startElement​(NodeName elemName, SchemaType typeCode, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties)` | Process element start tag

    - ### Methods inherited from class com.saxonica.ee.validate.ValidatingFilter

      `append, getAttributeInheritor, getConstraintChecker, getValidationContext, reportIfInvalid, reportValidationError, setConstraintChecker, setStartTagBuffer, setValidationContext, usesTypeAnnotations`

    - ### Methods inherited from class net.sf.saxon.event.ProxyReceiver

      `close, comment, getNamePool, getNextReceiver, open, processingInstruction, setSystemId, setUnderlyingReceiver, startDocument`

    - ### Methods inherited from class net.sf.saxon.event.SequenceReceiver

      `append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getPipelineConfiguration, getSystemId, handlesAppend`

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

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

- - ### Constructor Detail

    - #### ValidationStack

          public ValidationStack​(Receiver next,
                                 int initialValidationMode,
                                 SchemaType initialType)

      Create a validation stack
      Parameters:
        `next` - the destination of events after passing through validation
        `initialValidationMode` - the initial validation mode, strict/lax
        `initialType` - the initial type to validate against, if any

  - ### Method Detail

    - #### setPipelineConfiguration

          public void setPipelineConfiguration​(PipelineConfiguration pipe)

      Description copied from interface: `Receiver`
      Set the pipeline configuration
      Specified by:
        `setPipelineConfiguration` in interface `Receiver`
      Overrides:
        `setPipelineConfiguration` in class `ProxyReceiver`
      Parameters:
        `pipe` - the pipeline configuration

    - #### setTopLevelElement

          public void setTopLevelElement​(NodeName name)

      Set the name of the required top-level element (if any)
      Parameters:
        `name` - the name of the element that must appear at the root of the subtree being validated

    - #### getTopLevelElement

          public NodeName getTopLevelElement()

      Get the name of the required top-level element (if any)
      Returns:
        the name of the element that must appear at the root of the subtree being validated, or null if none has been set

    - #### setUnparsedEntity

          public void setUnparsedEntity​(java.lang.String name,
                                        java.lang.String uri,
                                        java.lang.String publicId)
                                 throws XPathException

      Set the URI for an unparsed entity in the document.
      Specified by:
        `setUnparsedEntity` in interface `Receiver`
      Overrides:
        `setUnparsedEntity` in class `ProxyReceiver`
      Parameters:
        `name` - The name of the unparsed entity
        `uri` - The system identifier of the unparsed entity
        `publicId` - The public identifier of the unparsed entity
      Throws:
        `XPathException` - if an error occurs

    - #### setIsNilled

          public void setIsNilled​(boolean nilled)

      Indicate whether the current element is nilled
      Parameters:
        `nilled` - true if xsi:nil is set

    - #### setXsiValidationErrors

          public void setXsiValidationErrors​(java.util.List<ValidationFailure> errors)

      Supply a list of errors found in attributes in the XSI namespace. This is called immediately before calling startElement on the element containing these erroneous attributes
      Parameters:
        `errors` - the list of errors

    - #### startElement

          public void startElement​(NodeName elemName,
                                   SchemaType typeCode,
                                   AttributeMap attributes,
                                   NamespaceMap namespaces,
                                   Location location,
                                   int properties)
                            throws XPathException

      Process element start tag
      Specified by:
        `startElement` in interface `Receiver`
      Overrides:
        `startElement` in class `ProxyReceiver`
      Parameters:
        `elemName` - the name of the element.
        `typeCode` - the type annotation of the element.
        `attributes` - the attributes of this element
        `namespaces` - the in-scope namespaces of this element: generally this is all the in-scope namespaces, without relying on inheriting namespaces from parent elements
        `location` - an object providing information about the module, line, and column where the node originated
        `properties` - bit-significant properties of the element node. If there are no relevant properties, zero is supplied. The definitions of the bits are in class `ReceiverOption`
      Throws:
        `XPathException` - if an error occurs

    - #### setInitialValidator

          public void setInitialValidator​(ContentValidator validator)

      Set the initial validator to be used for the outermost element
      Parameters:
        `validator` - the validator to be used for the outermost element being validated

    - #### characters

          public void characters​(java.lang.CharSequence chars,
                                 Location locationId,
                                 int properties)
                          throws XPathException

      Description copied from class: `ProxyReceiver`
      Character data
      Specified by:
        `characters` in interface `Receiver`
      Overrides:
        `characters` in class `ProxyReceiver`
      Parameters:
        `chars` - The characters
        `locationId` - provides information such as line number and system ID.
        `properties` - Bit significant value. The following bits are defined:
        DISABLE_ESCAPING
          Disable escaping for this text node
        USE_CDATA
          Output as a CDATA section
      Throws:
        `XPathException` - if an error occurs

    - #### endElement

          public void endElement()
                          throws XPathException

      End of element
      Specified by:
        `endElement` in interface `Receiver`
      Overrides:
        `endElement` in class `ProxyReceiver`
      Throws:
        `XPathException` - if an error occurs

    - #### endDocument

          public void endDocument()
                           throws XPathException

      Notify the end of a document node
      Specified by:
        `endDocument` in interface `Receiver`
      Overrides:
        `endDocument` in class `ProxyReceiver`
      Throws:
        `XPathException` - if an error occurs

    - #### setKeepStatistics

          public void setKeepStatistics​(boolean keep)

      Ask that statistics be maintained for the duration of the validation episode. The statistics indicate how often particular schema components (currently, element declarations and types) have been used.
      Parameters:
        `keep` - true if statistics are to be kept, false if not

    - #### getCoverageStatistics

          public java.util.Map<SchemaComponent,​java.lang.Integer> getCoverageStatistics()

      Get the statistics showing the usage of individual schema components during a validation episode
      Returns:
        a table showing for each component that has been used, the number of times it has been used. If statistics are not being maintained, returns null.