|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.thaiopensource.relaxng.util.ValidationEngine
Provides a simplified API for validating XML documents against RELAX NG schemas. This class is neither reentrant nor safe for access from multiple threads.
SchemaFactory
Constructor Summary | |
ValidationEngine()
Default constructor. |
|
ValidationEngine(XMLReaderCreator xrc,
ErrorHandler eh,
boolean checkIdIdref)
Constructs a ValidationEngine . |
|
ValidationEngine(XMLReaderCreator xrc,
ErrorHandler eh,
boolean checkIdIdref,
boolean compactSyntax)
Constructs a ValidationEngine . |
|
ValidationEngine(XMLReaderCreator xrc,
ErrorHandler eh,
boolean checkIdIdref,
boolean compactSyntax,
boolean feasible)
|
Method Summary | |
static InputSource |
fileInputSource(File file)
Returns an InputSource for a File . |
static InputSource |
fileInputSource(String filename)
Returns an InputSource for a filename. |
boolean |
loadSchema(InputSource in)
Loads a schema. |
static InputSource |
uriOrFileInputSource(String uriOrFile)
Returns an InputSource for a string that represents either a file
or an absolute URI. |
boolean |
validate(InputSource in)
Validates a document against the currently loaded schema. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ValidationEngine()
ValidationEngine(null, null, true)
.
public ValidationEngine(XMLReaderCreator xrc, ErrorHandler eh, boolean checkIdIdref)
ValidationEngine
.
xrc
- the XMLReaderCreator
to be used for constructing XMLReader
s;
if null
uses Sax2XMLReaderCreator
eh
- the ErrorHandler
to be used for reporting errors; if null
uses DraconianErrorHandler
checkIdIdref
- true
if ID/IDREF/IDREFS should be checked; false
otherwise
NullPointerException
- if xrc
is null
DraconianErrorHandler
,
Sax2XMLReaderCreator
public ValidationEngine(XMLReaderCreator xrc, ErrorHandler eh, boolean checkIdIdref, boolean compactSyntax)
ValidationEngine
.
xrc
- the XMLReaderCreator
to be used for constructing XMLReader
s;
if null
uses Sax2XMLReaderCreator
eh
- the ErrorHandler
to be used for reporting errors; if null
uses DraconianErrorHandler
checkIdIdref
- true
if ID/IDREF/IDREFS should be checked; false
otherwisecompactSyntax
- true
if the compact syntax should be used to parse the schema;
false
if the XML syntax should be used
NullPointerException
- if xrc
is null
DraconianErrorHandler
,
Sax2XMLReaderCreator
public ValidationEngine(XMLReaderCreator xrc, ErrorHandler eh, boolean checkIdIdref, boolean compactSyntax, boolean feasible)
Method Detail |
public boolean loadSchema(InputSource in) throws SAXException, 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 schema
true
if the schema was loaded successfully; false
otherwise
IOException
- if an I/O error occurred
SAXException
- if an XMLReader or ErrorHandler threw a SAXExceptionpublic boolean validate(InputSource in) throws SAXException, IOException
in
- the InputSource for the document to be validated
true
if the document is valid; false
otherwise
IllegalStateException
- if there is no currently loaded schema
IOException
- if an I/O error occurred
SAXException
- if an XMLReader or ErrorHandler threw a SAXExceptionpublic static InputSource fileInputSource(String filename) throws MalformedURLException
InputSource
for a filename.
filename
- a String specifying the filename
InputSource
for the filename
MalformedURLException
public static InputSource fileInputSource(File file) throws MalformedURLException
InputSource
for a File
.
file
- the File
InputSource
for the filename
MalformedURLException
public static InputSource uriOrFileInputSource(String uriOrFile) throws 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 URI
InputSource
for the file or absolute URI
MalformedURLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |