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.DefaultHandlerValidator 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 voiderror(org.xml.sax.SAXParseException ex)A method required by theorg.xml.sax.ErrorHandlerinterfacevoidfatalError(org.xml.sax.SAXParseException ex)A method required by theorg.xml.sax.ErrorHandlerinterfacejava.lang.StringgetError()Retrieve the error message set by theorg.xml.sax.ErrorHandlermethods.booleanvalidate(java.io.Reader xmlReader)The actual validation method.voidwarning(org.xml.sax.SAXParseException ex)A method required by theorg.xml.sax.ErrorHandlerinterface
-
-
-
Method Detail
-
validate
public boolean validate(java.io.Reader xmlReader) throws java.io.IOException, org.xml.sax.SAXExceptionThe 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:
trueif the XML file could be validated against the XML schema, elsefalse- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
getError
public java.lang.String getError()
Retrieve the error message set by theorg.xml.sax.ErrorHandlermethods. If no error has been found,nullis returned.- Returns:
- A string describing the error encountered
-
warning
public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXExceptionA method required by theorg.xml.sax.ErrorHandlerinterface- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Overrides:
warningin 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.SAXExceptionA method required by theorg.xml.sax.ErrorHandlerinterface- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Overrides:
errorin 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.SAXExceptionA method required by theorg.xml.sax.ErrorHandlerinterface- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Overrides:
fatalErrorin classorg.xml.sax.helpers.DefaultHandler- Parameters:
ex- A parsing exception- Throws:
org.xml.sax.SAXException
-
-