Class XSLTValidator
java.lang.Object
net.ionite.docval.validation.validator.XSLTValidator
- All Implemented Interfaces:
DocumentValidator
- Direct Known Subclasses:
SCHValidator
This class implements the DocumentValidor interface for Schematron- XSLT
validation files. These are XSLT files that transform an input document to a
document following the SVRL schema, and are generally distributed as the
'compiled' version of schematron files.
Using these files is much faster than using .SCH files with the SCHValidator
directly.
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The XSLT file created from a schematron definition, if this validator is initialized with a file.protected InputStream
The InputStream containing the XSLT created from a schematron definition, if this validator is initialized with an inputstream.protected org.slf4j.Logger
General Logger instance -
Constructor Summary
ConstructorDescriptionXSLTValidator
(InputStream stream) Construct an Schematron XSLT Validator with the given input streamXSLTValidator
(String filename) Construct an Schematron XSLT Validator with the given XSLT file. -
Method Summary
Modifier and TypeMethodDescriptionprotected Transformer
loadTransformer
(InputStream inputStream) Load the transformer in the given input stream.void
reload()
Reload the XSLT file this validator was initialized with.protected Transformer
Initialize the Saxon Transformervalidate
(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
-
Field Details
-
_filename
The XSLT file created from a schematron definition, if this validator is initialized with a file. Null otherwise. -
_stream
The InputStream containing the XSLT created from a schematron definition, if this validator is initialized with an inputstream. Null otherwise. -
logger
protected org.slf4j.Logger loggerGeneral Logger instance
-
-
Constructor Details
-
XSLTValidator
Construct an Schematron XSLT Validator with the given XSLT file.- Parameters:
filename
- The XSLT file created from a schematron definition
-
XSLTValidator
Construct an Schematron XSLT Validator with the given input stream- Parameters:
stream
- the InputStream containing the XSLT created from a schematron definition
-
-
Method Details
-
reload
public void reload()Reload the XSLT 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
-
setupTransformer
Initialize the Saxon Transformer -
loadTransformer
Load the transformer in the given input stream.- Parameters:
inputStream
- The input stream containing the XSLT- Throws:
ValidatorException
- if the transformer cannot be initialized from the given stream data
-