KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > xml > validation > ValidatorHandler

javax.xml.validation
Class ValidatorHandler

java.lang.Object
  extended by javax.xml.validation.ValidatorHandler
All Implemented Interfaces:
ContentHandler
See Also:
Top Examples, Source Code, ContentHandler.startElement(String,String,String,Attributes), Attributes, ContentHandler.endPrefixMapping(String), ContentHandler.startPrefixMapping(String,String), Schema, ValidatorHandler

public abstract ContentHandler getContentHandler()
See Also:
setContentHandler(ContentHandler)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract ErrorHandler getErrorHandler()
See Also:
setErrorHandler(ErrorHandler)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean getFeature(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
See Also:
setFeature(String, boolean), NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Object getProperty(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
See Also:
setProperty(String, Object), NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract LSResourceResolver getResourceResolver()
See Also:
setErrorHandler(ErrorHandler), setResourceResolver(LSResourceResolver)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract TypeInfoProvider getTypeInfoProvider()
See Also:
TypeInfo, ValidatorHandler
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract void setContentHandler(ContentHandler receiver)
See Also:
ErrorHandler, ValidatorHandler, ContentHandler.endDocument(), ContentHandler.startDocument(), ContentHandler.endElement(String, String, String), ContentHandler.startElement(String, String, String, Attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract void setErrorHandler(ErrorHandler errorHandler)
See Also:
ValidatorHandler, SAXException, SAXParseException, Throwable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setFeature(String name,
                       boolean value)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
See Also:
getFeature(String), NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setProperty(String name,
                        Object object)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
See Also:
NullPointerException, ValidatorHandler
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract void setResourceResolver(LSResourceResolver resourceResolver)
See Also:
ValidatorHandler, RuntimeException, LSInput
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected ValidatorHandler()
See Also:
LSResourceResolver, ErrorHandler, ValidatorHandler
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1920]Use ValidatorHandler to validate SAX events
By Anonymous on 2007/08/14 16:45:09  Rate
Create a specially-designed javax.xml.validation.ValidatorHandler to validate SAX events: 
  
  
    SAXParserFactory spf = SAXParserFactory.newInstance (  ) ; 
    spf.setNamespaceAware ( true ) ; 
    XMLReader reader = spf.newSAXParser (  ) .getXMLReader (  ) ; 
    ValidatorHandler vh = schema.newValidatorHandler (  ) ; 
    //key is to set "ValidatorHandler" as ContentHandler  
    //so that SAX event can be validated 
    reader.setContentHandler ( vh ) ; 
    reader.parse ( xml ) ;   
  
  
 Notice that to validate the SAX events, you need to set the ValidatorHandler as the ContentHandler. 
  
  
 Using a ValidatorHandler, you can also validate a JDOM document against the schema. In fact, any object model  ( such as XOM and DOM4J )  which can be built on top of a SAX stream or can produce SAX events can be used with the SVF to validate an XML document against a schema. This is possible because the ValidationHandler can validate a SAX stream. Here is a code snippet that illustrates how a JDOM document can be validated against a schema, it assumes that you obtained a ValidatorHandler as shown in the previous example: 
  
  
    SAXOutputter so = new SAXOutputter ( vh ) ; 
    so.output ( jdomDocument ) ; 
  
  
 The SAXOutputter object fires SAX events for the JDOM document. The SAX events are then validated by the ValidatorHandler.  
  
  
 

Popular Tags