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 SchematronValidatorfromSchematronContent(byte[] schematronContent) Constructs a Schematron validator from a Schematron content (.sch).static SchematronValidatorfromSchematronFile(File schematronFile) Constructs a Schematron validator from a Schematron file (.sch).@Nullable SchematronReportPerforms 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
IReadableResourceinstances 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
SchematronTransformerand 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
SchematronTransformerand 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.
-