ValidatorHandler


ValidatorHandler javax.xml.validation

Java 5.0

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( ) .

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  name  )  throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException;        public Object  getProperty  (String  name  )  throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException;        public abstract org.w3c.dom.ls.LSResourceResolver  getResourceResolver  ( );        public abstract TypeInfoProvider  getTypeInfoProvider  ( );        public abstract void  setContentHandler  (org.xml.sax.ContentHandler  receiver  );        public abstract void  setErrorHandler  (org.xml.sax.ErrorHandler  errorHandler  );        public void  setFeature  (String  name  , boolean  value  )  throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException;        public void  setProperty  (String  name  , Object  object  )  throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException;        public abstract void  setResourceResolver  (org.w3c.dom.ls.LSResourceResolver  resourceResolver  );   } 

Returned By

Schema.newValidatorHandler( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net