public class ValidationDriver
extends java.lang.Object
Constructor and Description |
---|
ValidationDriver()
Equivalent to ValidationDriver(PropertyMap.EMPTY, PropertyMap.EMPTY, null).
|
ValidationDriver(PropertyMap properties)
Equivalent to ValidationDriver(properties, properties, null).
|
ValidationDriver(PropertyMap schemaProperties,
PropertyMap instanceProperties)
Equivalent to ValidationDriver(schemaProperties, instanceProperties, null).
|
ValidationDriver(PropertyMap schemaProperties,
PropertyMap instanceProperties,
SchemaReader schemaReader)
Creates and initializes a ValidationDriver.
|
ValidationDriver(PropertyMap properties,
SchemaReader sr)
Equivalent to ValidationDriver(properties, properties, sr).
|
ValidationDriver(SchemaReader sr)
Equivalent to ValidationDriver(PropertyMap.EMPTY, PropertyMap.EMPTY, null).
|
Modifier and Type | Method and Description |
---|---|
static org.xml.sax.InputSource |
fileInputSource(java.io.File file)
Returns an
InputSource for a File . |
static org.xml.sax.InputSource |
fileInputSource(java.lang.String filename)
Returns an
InputSource for a filename. |
boolean |
loadSchema(org.xml.sax.InputSource in)
Loads a schema.
|
static org.xml.sax.InputSource |
uriOrFileInputSource(java.lang.String uriOrFile)
Returns an
InputSource for a string that represents either a file
or an absolute URI. |
boolean |
validate(org.xml.sax.InputSource in)
Validates a document against the currently loaded schema.
|
public ValidationDriver(PropertyMap schemaProperties, PropertyMap instanceProperties, SchemaReader schemaReader)
schemaProperties
- a PropertyMap specifying properties controlling schema creation;
must not be null
instanceProperties
- a PropertyMap specifying properties controlling validation;
must not be null
schemaReader
- the SchemaReader to use; if this is null
, then the schema
must be in XML, and the namespace URI of the root element will be used to determine what
the schema language ispublic ValidationDriver(PropertyMap schemaProperties, PropertyMap instanceProperties)
public ValidationDriver(PropertyMap properties, SchemaReader sr)
public ValidationDriver(PropertyMap properties)
public ValidationDriver(SchemaReader sr)
public ValidationDriver()
public boolean loadSchema(org.xml.sax.InputSource in) throws org.xml.sax.SAXException, java.io.IOException
validate
will validate with
respect the loaded schema. This can be called more than once to allow
multiple documents to be validated against different schemas.in
- the InputSource for the schematrue
if the schema was loaded successfully; false
otherwisejava.io.IOException
- if an I/O error occurredorg.xml.sax.SAXException
- if an XMLReader or ErrorHandler threw a SAXExceptionpublic boolean validate(org.xml.sax.InputSource in) throws org.xml.sax.SAXException, java.io.IOException
in
- the InputSource for the document to be validatedtrue
if the document is valid; false
otherwisejava.lang.IllegalStateException
- if there is no currently loaded schemajava.io.IOException
- if an I/O error occurredorg.xml.sax.SAXException
- if an XMLReader or ErrorHandler threw a SAXExceptionpublic static org.xml.sax.InputSource fileInputSource(java.lang.String filename) throws java.net.MalformedURLException
InputSource
for a filename.filename
- a String specifying the filenameInputSource
for the filenamejava.net.MalformedURLException
public static org.xml.sax.InputSource fileInputSource(java.io.File file) throws java.net.MalformedURLException
InputSource
for a File
.file
- the File
InputSource
for the filenamejava.net.MalformedURLException
public static org.xml.sax.InputSource uriOrFileInputSource(java.lang.String uriOrFile) throws java.net.MalformedURLException
InputSource
for a string that represents either a file
or an absolute URI. If the string looks like an absolute URI, it will be
treated as an absolute URI, otherwise it will be treated as a filename.uriOrFile
- a String
representing either a file or an absolute URIInputSource
for the file or absolute URIjava.net.MalformedURLException