Class XSDValidator
java.lang.Object
net.ionite.docval.validation.validator.XSDValidator
- All Implemented Interfaces:
DocumentValidator
This class implements the DocumentValidor interface for XML Schema (XSD)
validation.
-
Constructor Summary
ConstructorDescriptionXSDValidator
(InputStream stream) Construct an XSD Validator with the XML Schema definition provided in the given input stream.XSDValidator
(String filename) Construct an XSD Validator with the given XML Schema definition (XSD) file. -
Method Summary
Modifier and TypeMethodDescriptionvoid
reload()
Reload the XSD file this validator was initialized with.validate
(byte[] source) Validate the given XML document, and return a new ValidationResult structure containing the validation results.validate
(byte[] source, ValidationResult result) Validate the given XML document, and add the validation results to the given ValidationResult structure
-
Constructor Details
-
XSDValidator
Construct an XSD Validator with the given XML Schema definition (XSD) file.- Parameters:
filename
- The file containing the XML schema definition- Throws:
ValidatorException
- if there is an error reasing the schema
-
XSDValidator
Construct an XSD Validator with the XML Schema definition provided in the given input stream. Note that the 'reload' method is disabled when this constructor is used.- Parameters:
stream
- the InputStream containing the XML schema definition- Throws:
ValidatorException
- if there is an error reasing the schema
-
-
Method Details
-
reload
Reload the XSD file this validator was initialized with.- Specified by:
reload
in interfaceDocumentValidator
- Throws:
ValidatorException
- If there is an error reloading the file, or if this validator was initialized with an input stream.
-
validate
Validate the given XML document, and return a new ValidationResult structure containing the validation results.- Specified by:
validate
in interfaceDocumentValidator
- Parameters:
source
- Byte-array containing the XML document to validate- Returns:
- A newly initialized ValidationResult containing the results of the validation
- Throws:
ValidatorException
- Thrown when there is an error performing the validation
-
validate
Validate the given XML document, and add the validation results to the given ValidationResult structure- Specified by:
validate
in interfaceDocumentValidator
- Parameters:
source
- Byte-array containing the XML document to validateresult
- The structure to add the validation results to- Returns:
- The modified ValidationResult instance
- Throws:
ValidatorException
- Thrown when there is an error performing the validation
-