Package ml.options
Class SchemaValidator
java.lang.Object
org.xml.sax.helpers.DefaultHandler
ml.options.SchemaValidator
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
Validator for XML documents using XML schema. This is based on JDK 5.0 and requires
no outside library.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidA method required by theorg.xml.sax.ErrorHandlerinterfacevoidA method required by theorg.xml.sax.ErrorHandlerinterfacegetError()Retrieve the error message set by theorg.xml.sax.ErrorHandlermethods.booleanThe actual validation method.voidA method required by theorg.xml.sax.ErrorHandlerinterfaceMethods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDeclMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
SchemaValidator
public SchemaValidator()
-
-
Method Details
-
validate
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:
trueif the XML file could be validated against the XML schema, elsefalse- Throws:
IOExceptionSAXException
-
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
A method required by theorg.xml.sax.ErrorHandlerinterface- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Parameters:
ex- A parsing exception- Throws:
SAXException
-
error
A method required by theorg.xml.sax.ErrorHandlerinterface- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Parameters:
ex- A parsing exception- Throws:
SAXException
-
fatalError
A method required by theorg.xml.sax.ErrorHandlerinterface- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Parameters:
ex- A parsing exception- Throws:
SAXException
-