com.saxonica.validate

## Class SimpleContentValidator

- java.lang.Object
- - net.sf.saxon.event.SequenceReceiver
  - - net.sf.saxon.event.ProxyReceiver
    - - com.saxonica.validate.ValidatingFilter
      - - com.saxonica.validate.ContentValidator
        - - com.saxonica.validate.AttributeValidator
          - - com.saxonica.validate.SimpleContentValidator

- All Implemented Interfaces:
    Result, Receiver

      public class SimpleContentValidator
      extends AttributeValidator

  This class is a filter that is used to validate that an element has simple content conforming to a given simple type. This filter accumulates the character data in a buffer and invokes the validation method of the simple type at the time that endElement() is called. Child elements are rejected as invalid. This validator can handle simple types, or complex types with simple content: the attributes are validated by the superclass, Validator.

- - ### Field Summary

    - ### Fields inherited from class com.saxonica.validate.ContentValidator

      `childValidator, nil, NIL_ALLOWED, NIL_DISALLOWED, NIL_IGNORED, pendingMessages`

    - ### Fields inherited from class com.saxonica.validate.ValidatingFilter

      `locallyInvalid`

    - ### 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 and Description
    `SimpleContentValidator(ElementDecl declaration, SchemaType type, Receiver next)` Create a simple content validator

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `characters(CharSequence chars, int locationId, int properties)` Handle character data appearing as a child of the element being validated
    `void` | `endElement()` End of element being validated
    `protected ContentValidator` | `getChildValidator()` Return a validator to handle the children of the element just started.
    `SchemaType` | `getSchemaType()` Get the schema type against which we are validating
    `void` | `setSchemaType(SchemaType type)` Set the schema type against which this validator is to perform validation
    `void` | `startElement(NodeName nameCode, SchemaType typeCode, int locationId, int properties)` Output element start tag (for a child of the element being validated)

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

      `attribute, getMostRecentAttributeType, noCharactersWhenNil, processWildcardTerm, setAttributeGroup, startContent`

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

      `endDocument, getAnnotation, getContainingElement, getContainingElementLocationId, getContainingElementName, getElementDeclaration, getNamespaceResolver, getNillability, isNil, makeChildValidator, makeValidator, makeValidatorForType, setAnnotation, setContainingElement, setElementDeclaration, setNillability`

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

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

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

      `close, comment, getNamePool, getUnderlyingReceiver, namespace, open, processingInstruction, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, startDocument`

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

      `append, getConfiguration, getPipelineConfiguration, getSystemId`

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

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

- - ### Constructor Detail

    - #### SimpleContentValidator

          public SimpleContentValidator(ElementDecl declaration,
                                SchemaType type,
                                Receiver next)
                                 throws ValidationException

      Create a simple content validator
      Parameters:
        `declaration` - The element declaration (may be null). Used to check fixed/default values
        `type` - The schema type of the element
        `next` - The next receiver in the pipeline
      Throws:
        `ValidationException` - if any failure occurs

  - ### Method Detail

    - #### getSchemaType

          public SchemaType getSchemaType()

      Get the schema type against which we are validating
      Specified by:
        `getSchemaType` in class `ContentValidator`
      Returns:
        the schema type

    - #### setSchemaType

          public void setSchemaType(SchemaType type)
                             throws ValidationException

      Set the schema type against which this validator is to perform validation
      Parameters:
        `type` - the schema type
      Throws:
        `ValidationException` - indicates a problem with the schema

    - #### startElement

          public void startElement(NodeName nameCode,
                          SchemaType typeCode,
                          int locationId,
                          int properties)
                            throws XPathException

      Output element start tag (for a child of the element being validated)
      Specified by:
        `startElement` in interface `Receiver`
      Overrides:
        `startElement` in class `AttributeValidator`
      Parameters:
        `nameCode` - integer code identifying the name of the element within the name pool.
        `typeCode` - integer code identifying the element's type within the name pool.
        `locationId` - an integer which can be interpreted using a `LocationProvider` to return information such as line number and system ID. If no location information is available, the value zero is supplied.
        `properties` - properties of the element node
      Throws:
        `XPathException` - if an error occurs

    - #### getChildValidator

          protected ContentValidator getChildValidator()

      Return a validator to handle the children of the element just started. This will only be called during error recovery, because an exception would have been thrown when the element was started
      Specified by:
        `getChildValidator` in class `ContentValidator`
      Returns:
        the validator to be used to handle the children

    - #### characters

          public void characters(CharSequence chars,
                        int locationId,
                        int properties)
                          throws XPathException

      Handle character data appearing as a child of the element being validated
      Specified by:
        `characters` in interface `Receiver`
      Overrides:
        `characters` in class `AttributeValidator`
      Parameters:
        `chars` - The character content
        `properties` - Additional properties
        `locationId` - an integer which can be interpreted using a `LocationProvider` to return information such as line number and system ID. If no location information is available, the value zero is supplied.
      Throws:
        `XPathException` - If the character data is invalid

    - #### endElement

          public void endElement()
                          throws XPathException

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

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