Name

ValidatorHandler

Synopsis

A ValidatorHandler is an org.xml.sax.ContentHandler that uses the streaming SAX API to validate an XML document against the Schema from which the ValidatorHandler was derived. The Validator class can be used to validate a SAXSource, but ValidatorHandler provides lower-level access to the SAX API.

If the document is not valid, one of the ContentHandler methods throws a SAXException that propagates up to your code. As with the Validator class, you can alter this by specifying a custom org.xml.sax.ErrorHandler class.

ValidatorHandler can be used as a filter for SAX parsing events. If you pass a ContentHandler to setContentHandler( ), the ValidatorHandler augments the source document with attribute defaults from the schema and invokes the appropriate callback methods on the ContentHandler you supply. If you are interested in attribute and element type information provided by the schema, your ContentHandler can use the TypeInfoProvider obtained from the ValidatorHandler getTypeInfoProvider( ).

javax.xml.validation.ValidatorHandler

Figure 20-18. javax.xml.validation.ValidatorHandler

public abstract class ValidatorHandler implements org.xml.sax.ContentHandler {
// Protected Constructors
     protected ValidatorHandler( );  
// Public Instance Methods
     public abstract org.xml.sax.ContentHandler getContentHandler( );  
     public abstract org.xml.sax.ErrorHandler getErrorHandler( );  
     public boolean getFeature(String ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.