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 TypeMethodDescriptionvoid
A method required by theorg.xml.sax.ErrorHandler
interfacevoid
A method required by theorg.xml.sax.ErrorHandler
interfacegetError()
Retrieve the error message set by theorg.xml.sax.ErrorHandler
methods.boolean
The actual validation method.void
A method required by theorg.xml.sax.ErrorHandler
interfaceMethods 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
Methods 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:
true
if the XML file could be validated against the XML schema, elsefalse
- Throws:
IOException
SAXException
-
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
A method required by theorg.xml.sax.ErrorHandler
interface- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Parameters:
ex
- A parsing exception- Throws:
SAXException
-
error
A method required by theorg.xml.sax.ErrorHandler
interface- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Parameters:
ex
- A parsing exception- Throws:
SAXException
-
fatalError
A method required by theorg.xml.sax.ErrorHandler
interface- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Parameters:
ex
- A parsing exception- Throws:
SAXException
-