Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.saxonica.validate
Class ContentValidator

    java.lang.Object
      net.sf.saxon.event.SequenceReceiver
          net.sf.saxon.event.ProxyReceiver
              com.saxonica.validate.ContentValidator

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

Direct Known Subclasses:
  AttributeValidator, LaxValidator, StripValidator

public abstract class ContentValidator
extends ProxyReceiver

This class is an abstract superclass for all the validators. The class includes factory methods for constructing a validator.

Renamed from Validator to ContentValidator in Saxon 8.2, to avoid confusion with the JAXP 1.3 Validator class.

Field Summary
`protected boolean` | `invalid`
`protected java.util.List` | `pendingMessages`
`protected SchemaType` | `xsiType`

Fields inherited from class net.sf.saxon.event.ProxyReceiver
`nextReceiver, systemId`

Fields inherited from class net.sf.saxon.event.SequenceReceiver
`pipelineConfiguration, previousAtomic`

Fields inherited from interface javax.xml.transform.Result
`PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

Constructor Summary
`ContentValidator()`

Method Summary
`void` | `endDocument()` Notify the end of a document node
`protected int` | `getAnnotation()` Get the type annotation code to be used on elements validated by this validator
`protected abstract ContentValidator` | `getChildValidator()` Get a validator to handle the children of the current element.
`int` | `getContainingElement()` Get the fingerprint of the name of the element being validated (for diagnostics).
`int` | `getContainingElementLocationId()` Get the location ID of the element being validated
`protected java.lang.String` | `getContainingElementName()` Get the containing element name, for use in error messages.
`ElementDecl` | `getElementDeclaration()` Get the element declaration that this validator is validating against
`NamespaceResolver` | `getNamespaceResolver()` Get the namespace resolver
`boolean` | `isInvalid()` Determine if an error was found
`boolean` | `isNillable()` Determine whether this type permits xsi:nil = true
`boolean` | `isOutput()` Determine whether this validator is being used for an output document
`protected static ContentValidator` | `makeValidator(Configuration config, SchemaType type, SchemaType xsiType, ElementDecl decl)`
`static ContentValidator` | `makeValidator(ElementDecl elementDecl, SchemaType schemaType, PipelineConfiguration pipe)` Factory method to create a validator for elements of a given type
`static ContentValidator` | `makeValidator(int nameCode, int locationId, SchemaType xsiType, int validation, PipelineConfiguration pipe)` Factory method to make a validator for a particular element
`protected void` | `reportValidationError(java.lang.String message, boolean issueComment, int locationId)` Report a validation error
`protected void` | `setAnnotation(int annotation)` Set the type annotation code to be allocated by this validator
`void` | `setContainingElement(int fingerprint, int locationId)` Set the fingerprint identifying the name of the containing element (for diagnostics)
`void` | `setElementDeclaration(ElementDecl decl)` Set the element declaration that this validator is validating against
`void` | `setIsOutput(boolean output)` Indicate that this validator is being used for an output document.
`void` | `setNamespaceResolver(NamespaceResolver resolver)` Set the NamespaceResolver to be used for resolving QName-valued attributes
`void` | `setNillable(boolean nillable)` Set whether this type permits xsi:nil = true
`void` | `setXSIType(SchemaType xsiType)` Set the value of the xsi:type attribute.
`void` | `startElement(int nameCode, int typeCode, int locationId, int properties)` Handle the start tag for a child element of the element being validated

Methods inherited from class net.sf.saxon.event.ProxyReceiver
`attribute, characters, close, comment, endElement, getConfiguration, getDocumentLocator, getNamePool, getSystemId, getUnderlyingReceiver, namespace, open, processingInstruction, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, startContent, startDocument`

Methods inherited from class net.sf.saxon.event.SequenceReceiver
`append, getPipelineConfiguration`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### xsiType

    protected SchemaType xsiType

### invalid

    protected boolean invalid

### pendingMessages

    protected java.util.List pendingMessages

Constructor Detail

### ContentValidator

    public ContentValidator()

Method Detail

### setContainingElement

    public void setContainingElement(int fingerprint,
                                     int locationId)

  Set the fingerprint identifying the name of the containing element (for diagnostics)

  Parameters:
    `fingerprint` -

### setElementDeclaration

    public void setElementDeclaration(ElementDecl decl)

  Set the element declaration that this validator is validating against

### getElementDeclaration

    public ElementDecl getElementDeclaration()

  Get the element declaration that this validator is validating against

### getContainingElement

    public int getContainingElement()

  Get the fingerprint of the name of the element being validated (for diagnostics).

  Returns:
    the fingerprint, or -1 if not available.

### getContainingElementLocationId

    public int getContainingElementLocationId()

  Get the location ID of the element being validated

  Returns:
    the location ID, or 0 if not available

### getContainingElementName

    protected java.lang.String getContainingElementName()

  Get the containing element name, for use in error messages.

  Returns:
    the name of the containing element (plus surrounding punctuation), or the string "this element" if not available

### setAnnotation

    protected final void setAnnotation(int annotation)

  Set the type annotation code to be allocated by this validator

### getAnnotation

    protected final int getAnnotation()

  Get the type annotation code to be used on elements validated by this validator

### setXSIType

    public void setXSIType(SchemaType xsiType)

  Set the value of the xsi:type attribute. This is called immediately before the call of startElement on which the xsi:type attribute appears.

### setNamespaceResolver

    public void setNamespaceResolver(NamespaceResolver resolver)

  Set the NamespaceResolver to be used for resolving QName-valued attributes

### getNamespaceResolver

    public NamespaceResolver getNamespaceResolver()

  Get the namespace resolver

### setNillable

    public void setNillable(boolean nillable)

  Set whether this type permits xsi:nil = true

### isNillable

    public boolean isNillable()

  Determine whether this type permits xsi:nil = true

### setIsOutput

    public void setIsOutput(boolean output)

  Indicate that this validator is being used for an output document. This allows errors to be treated as warnings

### isOutput

    public boolean isOutput()

  Determine whether this validator is being used for an output document

### startElement

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

  Handle the start tag for a child element of the element being validated

  Specified by:
    `startElement` in interface `Receiver`
  Overrides:
    `startElement` in class `ProxyReceiver`
  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.
    `properties` - properties of the element node
  Throws:
    `XPathException`

### makeValidator

    public static ContentValidator makeValidator(int nameCode,
                                                 int locationId,
                                                 SchemaType xsiType,
                                                 int validation,
                                                 PipelineConfiguration pipe)
                                          throws XPathException

  Factory method to make a validator for a particular element

  Parameters:
    `nameCode` - the name of the element to be validated
    `locationId` - the location of the stylesheet instruction that generated this element (or zero)
    `xsiType` - the type identified by xsi:type, if specified; otherwise null
    `validation` - the validation mode (strict, lax, preserve, strip)
    `pipe` - the pipeline configuration
  Returns:
    a Validator suitable for validating the content of this element
  Throws:
    `XPathException`

### makeValidator

    protected static ContentValidator makeValidator(Configuration config,
                                                    SchemaType type,
                                                    SchemaType xsiType,
                                                    ElementDecl decl)
                                             throws XPathException

  Throws:
    `XPathException`

### getChildValidator

    protected abstract ContentValidator getChildValidator()

  Get a validator to handle the children of the current element. This is called immediately on return from the startElement call that starts this element.

### makeValidator

    public static ContentValidator makeValidator(ElementDecl elementDecl,
                                                 SchemaType schemaType,
                                                 PipelineConfiguration pipe)
                                          throws ValidationException

  Factory method to create a validator for elements of a given type

  Parameters:
    `elementDecl` - the element declaration if available, otherwise null (there will be no element declaration, for example, when doing lax validation against an xsi:type)
    `schemaType` - the simple or complex type against which the content of the element is to be validated
    `pipe` - the pipeline configuration
  Returns:
    a Validator that can sit in the event pipeline to perform local validation of elements declared to have this type
  Throws:
    `ValidationException`

### reportValidationError

    protected void reportValidationError(java.lang.String message,
                                         boolean issueComment,
                                         int locationId)
                                  throws XPathException

  Report a validation error

  Parameters:
    `message` - The validation error message
    `issueComment` - true if the validation error message is to be written as an XML comment to the result document
    `locationId` - identifies the location in the source document or stylesheet/query where the validation error was detected
  Throws:
    `XPathException`

### isInvalid

    public boolean isInvalid()

  Determine if an error was found

### 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`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD