Class AppSchemaValidator
Object
AppSchemaValidator
A class to perform XML schema validation against schemas found using an
SchemaResolver .- Author:
- Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering)
-
Method Summary
Modifier and TypeMethodDescriptionstatic AppSchemaValidatorConstruct anAppSchemaValidatorthat performs schema validation against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).static AppSchemaValidatorbuildValidator(SchemaCatalog catalog) Construct anAppSchemaValidatorthat performs schema validation against schemas found using anSchemaResolverwith aSchemaCatalog.static AppSchemaValidatorbuildValidator(SchemaResolver resolver) Construct anAppSchemaValidatorthat performs schema validation against schemas found using anSchemaResolver.voidThrow aRuntimeExceptionif the validator has found any failures.Return the list of failures found during parsing.booleanAre validation warnings considered failures?voidparse(InputStream input) Parse an XML instance document read from anInputStream, recording any validation failures failures.voidsetFailOnWarning(boolean failOnWarning) Should validation warnings be considered failures?static voidvalidate(InputStream input, SchemaCatalog catalog) Perform schema validation of an XML instance document read from an input stream against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).static voidvalidate(String xml, SchemaCatalog catalog) Perform schema validation of an XML instance document in a string against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).static voidvalidateResource(String name, SchemaCatalog catalog) Perform schema validation of an XML instance document read from a classpath resource against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).
-
Method Details
-
getFailures
Return the list of failures found during parsing. -
isFailOnWarning
public boolean isFailOnWarning()Are validation warnings considered failures? -
setFailOnWarning
public void setFailOnWarning(boolean failOnWarning) Should validation warnings be considered failures? -
parse
Parse an XML instance document read from anInputStream, recording any validation failures failures.- Parameters:
input- stream from which XML instance document is read
-
checkForFailures
public void checkForFailures()Throw aRuntimeExceptionif the validator has found any failures. The exception detail contains the failure messages. -
buildValidator
Construct anAppSchemaValidatorthat performs schema validation against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI). -
buildValidator
Construct anAppSchemaValidatorthat performs schema validation against schemas found using anSchemaResolver.- Parameters:
resolver- the resolver used to find schemas
-
buildValidator
Construct anAppSchemaValidatorthat performs schema validation against schemas found using anSchemaResolverwith aSchemaCatalog.- Parameters:
catalog- SchemaCatalog
-
validateResource
Perform schema validation of an XML instance document read from a classpath resource against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).If validation fails, a
RuntimeExceptionis thrown containing details of all failures.- Parameters:
name- resource name of XML instance documentcatalog- SchemaCatalog to aide local schema resolution or null- Throws:
IOException
-
validate
Perform schema validation of an XML instance document in a string against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).If validation fails, a
RuntimeExceptionis thrown containing details of all failures.- Parameters:
xml- string containing XML instance documentcatalog- SchemaCatalog to aide local schema resolution or null
-
validate
Perform schema validation of an XML instance document read from an input stream against schemas found on the classpath using the convention described inSchemaResolver.getSimpleHttpResourcePath(java.net.URI).If validation fails, a
RuntimeExceptionis thrown containing details of all failures.- Parameters:
input- stream providing XML instance documentcatalog- SchemaCatalog file to aide local schema resolution or null
-