ml.options
Class SchemaValidator

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by ml.options.SchemaValidator
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class SchemaValidator
extends org.xml.sax.helpers.DefaultHandler

Validator for XML documents using XML schema. This is based on JDK 5.0 and requires no outside library.


Constructor Summary
SchemaValidator()
           
 
Method Summary
 void error(org.xml.sax.SAXParseException ex)
          A method required by the org.xml.sax.ErrorHandler interface
 void fatalError(org.xml.sax.SAXParseException ex)
          A method required by the org.xml.sax.ErrorHandler interface
 java.lang.String getError()
          Retrieve the error message set by the org.xml.sax.ErrorHandler methods.
 boolean validate(java.io.Reader xmlReader)
          The actual validation method.
 void warning(org.xml.sax.SAXParseException ex)
          A method required by the org.xml.sax.ErrorHandler interface
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaValidator

public SchemaValidator()
Method Detail

validate

public boolean validate(java.io.Reader xmlReader)
                 throws java.io.IOException,
                        org.xml.sax.SAXException
The actual validation method. If validation is not successful, the errors found can be retrieved using the getError() method.

Parameters:
xmlReader - The reader for the XML file to validate

Returns:
true if the XML file could be validated against the XML schema, else false
Throws:
java.io.IOException
org.xml.sax.SAXException

getError

public java.lang.String getError()
Retrieve the error message set by the org.xml.sax.ErrorHandler methods. If no error has been found, null is returned.

Returns:
A string describing the error encountered

warning

public void warning(org.xml.sax.SAXParseException ex)
             throws org.xml.sax.SAXException
A method required by the org.xml.sax.ErrorHandler interface

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
ex - A parsing exception
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException ex)
           throws org.xml.sax.SAXException
A method required by the org.xml.sax.ErrorHandler interface

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
ex - A parsing exception
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws org.xml.sax.SAXException
A method required by the org.xml.sax.ErrorHandler interface

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
ex - A parsing exception
Throws:
org.xml.sax.SAXException