ValidatorHandler

public abstract class ValidatorHandler extends Object
implements ContentHandler

Streaming validator that works on SAX stream.

A ValidatorHandler object is a thread-unsafe, non-reentrant object. In other words, it is the application's responsibility to make sure that one ValidatorHandler object is not used from more than one thread at any given time.

ValidatorHandler checks if the SAX events follow the set of constraints described in the associated Schema, and additionally it may modify the SAX events (for example by adding default values, etc.)

ValidatorHandler extends from ContentHandler, but it refines the underlying ContentHandler in the following way:

  1. startElement/endElement events must receive non-null String for uri, localName, and qname, even though SAX allows some of them to be null. Similarly, the user-specified ContentHandler will receive non-null Strings for all three parameters.
  2. Applications must ensure that ValidatorHandler's startPrefixMapping(String, String) and endPrefixMapping(String) are invoked properly. Similarly, the user-specified ContentHandler will receive startPrefixMapping/endPrefixMapping events. If the ValidatorHandler introduces additional namespace bindings, the user-specified ContentHandler will receive additional startPrefixMapping/endPrefixMapping events.
  3. Attributes for the startElement(String, String, String, Attributes) method may or may not include xmlns* attributes.

A ValidatorHandler is automatically reset every time the startDocument method is invoked.

Recognized Properties and Features

This spec defines the following feature that must be recognized by all ValidatorHandler implementations.

http://xml.org/sax/features/namespace-prefixes

This feature controls how a ValidatorHandler introduces namespace bindings that were not present in the original SAX event stream. When this feature is set to true, it must make sure that the user's ContentHandler will see the corresponding xmlns* attribute in the Attributes object of the startElement(String, String, String, Attributes) callback. Otherwise, xmlns* attributes must not be added to Attributes that's passed to the user-specified ContentHandler.

(Note that regardless of this switch, namespace bindings are always notified to applications through startPrefixMapping(String, String) and endPrefixMapping(String) methods of the ContentHandler specified by the user.)

Note that this feature does NOT affect the way a ValidatorHandler receives SAX events. It merely changes the way it augments SAX events.

This feature is set to false by default.

Protected Constructor Summary

ValidatorHandler()
Constructor for derived classes.

Public Method Summary

abstract ContentHandler
getContentHandler()
Gets the ContentHandler which receives the augmented validation result.
abstract ErrorHandler
getErrorHandler()
Gets the current ErrorHandler set to this ValidatorHandler.
boolean
getFeature(String name)
Look up the value of a feature flag.
Object
getProperty(String name)
Look up the value of a property.
abstract LSResourceResolver
getResourceResolver()
Gets the current LSResourceResolver set to this ValidatorHandler.
abstract TypeInfoProvider
getTypeInfoProvider()
Obtains the TypeInfoProvider implementation of this ValidatorHandler.
abstract void
setContentHandler(ContentHandler receiver)
Sets the ContentHandler which receives the augmented validation result.
abstract void
setErrorHandler(ErrorHandler errorHandler)
Sets the ErrorHandler to receive errors encountered during the validation.
void
setFeature(String name, boolean value)
Set the value of a feature flag.
void
setProperty(String name, Object object)
Set the value of a property.
abstract void
setResourceResolver(LSResourceResolver resourceResolver)
Sets the LSResourceResolver to customize resource resolution while in a validation episode.

Inherited Method Summary