Package ml.options
Class SchemaValidator
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- 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
Constructors Constructor Description SchemaValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
error(org.xml.sax.SAXParseException ex)
A method required by theorg.xml.sax.ErrorHandler
interfacevoid
fatalError(org.xml.sax.SAXParseException ex)
A method required by theorg.xml.sax.ErrorHandler
interfacejava.lang.String
getError()
Retrieve the error message set by theorg.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 theorg.xml.sax.ErrorHandler
interface
-
-
-
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 thegetError()
method.- Parameters:
xmlReader
- The reader for the XML file to validate- Returns:
true
if the XML file could be validated against the XML schema, elsefalse
- Throws:
java.io.IOException
org.xml.sax.SAXException
-
getError
public java.lang.String getError()
Retrieve the error message set by theorg.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 theorg.xml.sax.ErrorHandler
interface- Specified by:
warning
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
warning
in classorg.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 theorg.xml.sax.ErrorHandler
interface- Specified by:
error
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
error
in classorg.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 theorg.xml.sax.ErrorHandler
interface- Specified by:
fatalError
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
fatalError
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
ex
- A parsing exception- Throws:
org.xml.sax.SAXException
-
-