Class SchematronValidator
java.lang.Object
org.projecthusky.validation.service.schematron.SchematronValidator
A Schematron validator for XML files.
The underlying Schematron validator is not thread-safe.
- Author:
- Quentin Ligier
-
Constructor Summary
ConstructorsConstructorDescriptionSchematronValidator
(byte[] xsltContent) Constructs a Schematron validator from the content of a XSLT file (.xsl
).SchematronValidator
(com.helger.commons.io.resource.IReadableResource xsltResource) Constructs a Schematron validator.SchematronValidator
(File xsltFile) Constructs a Schematron validator from a XSLT file (.xsl
). -
Method Summary
Modifier and TypeMethodDescriptionstatic SchematronValidator
fromSchematronContent
(byte[] schematronContent) Constructs a Schematron validator from a Schematron content (.sch
).static SchematronValidator
fromSchematronFile
(File schematronFile) Constructs a Schematron validator from a Schematron file (.sch
).@Nullable SchematronReport
Performs the Schematron validation of an XML content.
-
Constructor Details
-
SchematronValidator
public SchematronValidator(com.helger.commons.io.resource.IReadableResource xsltResource) Constructs a Schematron validator.Beware to only pass
IReadableResource
instances that have a unique resource ID or all instances of the validator will use the same XSLT resource (internals use the resource ID as a key for caching).- Parameters:
xsltResource
- The XSLT resource.- Throws:
IllegalArgumentException
- if the Schematron resource is invalid.
-
SchematronValidator
Constructs a Schematron validator from a XSLT file (.xsl
).- Parameters:
xsltFile
- The XSLT file.- Throws:
IllegalArgumentException
- if the Schematron resource is invalid.
-
SchematronValidator
public SchematronValidator(byte[] xsltContent) Constructs a Schematron validator from the content of a XSLT file (.xsl
).- Parameters:
xsltContent
- The XSLT file content.- Throws:
IllegalArgumentException
- if the Schematron resource is invalid.
-
-
Method Details
-
fromSchematronFile
public static SchematronValidator fromSchematronFile(File schematronFile) throws TransformerException Constructs a Schematron validator from a Schematron file (.sch
).If you are often using this method, you should consider transforming the Schematron file with the
SchematronTransformer
and storing the result as it is an expensive operation.- Parameters:
schematronFile
- The Schematron file.- Returns:
- the constructed Schematron validator.
- Throws:
TransformerException
- if the Schematron content transformation fails.IllegalArgumentException
- if the Schematron resource is invalid.
-
fromSchematronContent
public static SchematronValidator fromSchematronContent(byte[] schematronContent) throws TransformerException Constructs a Schematron validator from a Schematron content (.sch
).If you are often using this method, you should consider transforming the Schematron content with the
SchematronTransformer
and storing the result as it is an expensive operation.- Parameters:
schematronContent
- The Schematron content.- Returns:
- the constructed Schematron validator.
- Throws:
TransformerException
- if the Schematron content transformation fails.IllegalArgumentException
- if the Schematron resource is invalid.
-
validate
Performs the Schematron validation of an XML content.
-