Class XSDValidator
- java.lang.Object
-
- net.ionite.docval.validation.validator.XSDValidator
-
- All Implemented Interfaces:
DocumentValidator
public class XSDValidator extends Object implements DocumentValidator
This class implements the DocumentValidor interface for XML Schema (XSD) validation.
-
-
Constructor Summary
Constructors Constructor Description XSDValidator(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
reload()
Reload the XSD file this validator was initialized with.ValidationResult
validate(byte[] source)
Validate the given XML document, and return a new ValidationResult structure containing the validation results.ValidationResult
validate(byte[] source, ValidationResult result)
Validate the given XML document, and add the validation results to the given ValidationResult structure
-
-
-
Constructor Detail
-
XSDValidator
public XSDValidator(String filename) throws ValidatorException
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
public XSDValidator(InputStream stream) throws ValidatorException
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 Detail
-
reload
public void reload() throws ValidatorException
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
public ValidationResult validate(byte[] source) throws ValidatorException
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
public ValidationResult validate(byte[] source, ValidationResult result) throws ValidatorException
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
-
-