Package com.helger.schematron.pure
Class SchematronResourcePure
java.lang.Object
com.helger.schematron.AbstractSchematronResource
com.helger.schematron.pure.SchematronResourcePure
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.schematron.ISchematronResource
@NotThreadSafe
public class SchematronResourcePure
extends com.helger.schematron.AbstractSchematronResource
A Schematron resource that is not XSLT based but using the pure (native Java)
implementation. This class itself is not thread safe, but the underlying
cache is thread safe. So once you configured this object fully (with all the
setter), it can be considered thread safe.
Important: This class can only handle XPath expressions but no XSLT functions in Schematron asserts and reports! If your Schematrons use XSLT functionality you're better off using the
Important: This class can only handle XPath expressions but no XSLT functions in Schematron asserts and reports! If your Schematrons use XSLT functionality you're better off using the
com.helger.schematron.sch.SchematronResourceSCH or
com.helger.schematron.xslt.SchematronResourceXSLT classes instead!- Author:
- Philip Helger
-
Nested Class Summary
Nested classes/interfaces inherited from class com.helger.schematron.AbstractSchematronResource
com.helger.schematron.AbstractSchematronResource.NodeAndBaseURI -
Field Summary
Fields inherited from class com.helger.schematron.AbstractSchematronResource
DEFAULT_USE_CACHE -
Constructor Summary
ConstructorsConstructorDescriptionSchematronResourcePure(com.helger.commons.io.resource.IReadableResource aResource) SchematronResourcePure(com.helger.commons.io.resource.IReadableResource aResource, boolean bLenient) SchematronResourcePure(com.helger.commons.io.resource.IReadableResource aResource, String sPhase, IPSErrorHandler aErrorHandler) SchematronResourcePure(com.helger.commons.io.resource.IReadableResource aResource, String sPhase, IPSErrorHandler aErrorHandler, boolean bLenient) -
Method Summary
Modifier and TypeMethodDescriptionapplySchematronValidation(Node aXMLNode, String sBaseURI) com.helger.schematron.svrl.jaxb.SchematronOutputTypeapplySchematronValidationToSVRL(Node aXMLNode, String sBaseURI) The main method to convert a node to an SVRL document.protected IPSBoundSchemastatic SchematronResourcePurefromByteArray(byte[] aSchematron) Create a newSchematronResourcePurefrom Schematron rules provided by an arbitrary byte array.
Important: in this case, no include resolution will be performed!!static SchematronResourcePurefromClassPath(String sSCHPath) Create a newSchematronResourcePurefrom a Classpath Schematron rulesstatic SchematronResourcePurefromClassPath(String sSCHPath, ClassLoader aClassLoader) Create a newSchematronResourcePurefrom a Classpath Schematron rulesstatic SchematronResourcePureCreate a newSchematronResourcePurefrom file system Schematron rulesstatic SchematronResourcePureCreate a newSchematronResourcePurefrom file system Schematron rulesstatic SchematronResourcePurefromInputStream(String sResourceID, InputStream aSchematronIS) Create a newSchematronResourcePurefrom Schematron rules provided by an arbitraryInputStream.
Important: in this case, no include resolution will be performed!!static SchematronResourcePurefromSchema(PSSchema aSchematron) Create a newSchematronResourcePurefrom Schematron rules provided by a domain model.
Important: in this case, no include resolution will be performed!!static SchematronResourcePurefromString(String sSchematron, Charset aCharset) Create a newSchematronResourcePurefrom Schematron rules provided by an arbitrary String.
Important: in this case, no include resolution will be performed!!static SchematronResourcePureCreate a newSchematronResourcePurefrom Schematron rules provided at a URLstatic SchematronResourcePureCreate a newSchematronResourcePurefrom Schematron rules provided at a URLfinal IPSValidationHandlerfinal IPSErrorHandlerfinal XPathFunctionResolverGet the cached bound schema or create a new one.final StringgetPhase()com.helger.commons.state.EValiditygetSchematronValidity(Node aXMLNode, String sBaseURI) final XPathVariableResolverbooleanfinal SchematronResourcePuresetCustomValidationHandler(IPSValidationHandler aCustomValidationHandler) Set the custom validation handler to be used during binding.setEntityResolver(EntityResolver aEntityResolver) Set the XML entity resolver to be used when reading the Schematron or the XML to be validated.final SchematronResourcePuresetErrorHandler(IPSErrorHandler aErrorHandler) Set the error handler to be used during binding.final SchematronResourcePureSet the Schematron phase to be evaluated.final SchematronResourcePuresetXPathConfig(IXPathConfig aXPathConfig) Set theXPathConfigto be used in the XPath statements.voidUse the internal error handler to validate all elements in the schematron.voidvalidateCompletely(IPSErrorHandler aErrorHandler) Use the provided error handler to validate all elements in the schematron.Methods inherited from class com.helger.schematron.AbstractSchematronResource
applySchematronValidation, applySchematronValidation, applySchematronValidationToSVRL, applySchematronValidationToSVRL, getAsNode, getAsNode, getEntityResolver, getID, getResource, getSchematronValidity, getSchematronValidity, internalCreateDOMReaderSettings, internalSetEntityResolver, isLenient, isUseCache, setLenient, setUseCache, toString
-
Constructor Details
-
SchematronResourcePure
-
SchematronResourcePure
public SchematronResourcePure(@Nonnull com.helger.commons.io.resource.IReadableResource aResource, boolean bLenient) -
SchematronResourcePure
public SchematronResourcePure(@Nonnull com.helger.commons.io.resource.IReadableResource aResource, @Nullable String sPhase, @Nullable IPSErrorHandler aErrorHandler) -
SchematronResourcePure
public SchematronResourcePure(@Nonnull com.helger.commons.io.resource.IReadableResource aResource, @Nullable String sPhase, @Nullable IPSErrorHandler aErrorHandler, boolean bLenient)
-
-
Method Details
-
getPhase
- Returns:
- The phase to be used. May be
null.
-
setPhase
Set the Schematron phase to be evaluated. Changing the phase will result in a newly bound schema!- Parameters:
sPhase- The name of the phase to use. May benullwhich means all phases.- Returns:
- this
-
getErrorHandler
- Returns:
- The error handler to be used to bind the schema. May be
null.
-
setErrorHandler
@Nonnull public final SchematronResourcePure setErrorHandler(@Nullable IPSErrorHandler aErrorHandler) Set the error handler to be used during binding.- Parameters:
aErrorHandler- The error handler. May benull.- Returns:
- this
-
getCustomValidationHandler
- Returns:
- The custom validation handler to be used to bind the schema. May be
null. - Since:
- 5.3.0
-
setCustomValidationHandler
@Nonnull public final SchematronResourcePure setCustomValidationHandler(@Nullable IPSValidationHandler aCustomValidationHandler) Set the custom validation handler to be used during binding.- Parameters:
aCustomValidationHandler- The validation handler. May benull.- Returns:
- this
- Since:
- 5.3.0
-
getVariableResolver
- Returns:
- The variable resolver to be used. May be
null.
-
getFunctionResolver
- Returns:
- The function resolver to be used. May be
null.
-
setXPathConfig
Set theXPathConfigto be used in the XPath statements. This can only be set before the Schematron is bound. If it is already bound an exception is thrown to indicate the unnecessity of the call.- Parameters:
aXPathConfig- The XPath config to set. May benull.- Returns:
- this
-
setEntityResolver
Set the XML entity resolver to be used when reading the Schematron or the XML to be validated. This can only be set before the Schematron is bound. If it is already bound an exception is thrown to indicate the unnecessity of the call.- Parameters:
aEntityResolver- The entity resolver to set. May benull.- Returns:
- this
- Since:
- 4.1.1
-
createBoundSchema
-
getOrCreateBoundSchema
Get the cached bound schema or create a new one.- Returns:
- The bound schema. Never
null.
-
isValidSchematron
public boolean isValidSchematron() -
validateCompletely
public void validateCompletely()Use the internal error handler to validate all elements in the schematron. It tries to catch as many errors as possible. -
validateCompletely
Use the provided error handler to validate all elements in the schematron. It tries to catch as many errors as possible.- Parameters:
aErrorHandler- The error handler to use. May not benull.
-
getSchematronValidity
@Nonnull public com.helger.commons.state.EValidity getSchematronValidity(@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws Exception - Throws:
Exception
-
applySchematronValidationToSVRL
@Nonnull public com.helger.schematron.svrl.jaxb.SchematronOutputType applySchematronValidationToSVRL(@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws com.helger.schematron.SchematronException The main method to convert a node to an SVRL document.- Parameters:
aXMLNode- The source node to be validated. May not benull.sBaseURI- Base URI of the XML document to be validated. May benull.- Returns:
- The SVRL document. Never
null. - Throws:
com.helger.schematron.SchematronException- in case of a sever error validating the schema
-
applySchematronValidation
@Nullable public Document applySchematronValidation(@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws Exception - Throws:
Exception
-
fromClassPath
Create a newSchematronResourcePurefrom a Classpath Schematron rules- Parameters:
sSCHPath- The classpath relative path to the Schematron rules.- Returns:
- Never
null.
-
fromClassPath
@Nonnull public static SchematronResourcePure fromClassPath(@Nonnull @Nonempty String sSCHPath, @Nullable ClassLoader aClassLoader) Create a newSchematronResourcePurefrom a Classpath Schematron rules- Parameters:
sSCHPath- The classpath relative path to the Schematron rules.aClassLoader- The class loader to be used to retrieve the classpath resource. May benull.- Returns:
- Never
null. - Since:
- 6.0.4
-
fromFile
Create a newSchematronResourcePurefrom file system Schematron rules- Parameters:
sSCHPath- The file system path to the Schematron rules.- Returns:
- Never
null.
-
fromFile
Create a newSchematronResourcePurefrom file system Schematron rules- Parameters:
aSCHFile- The file system path to the Schematron rules.- Returns:
- Never
null.
-
fromURL
@Nonnull public static SchematronResourcePure fromURL(@Nonnull @Nonempty String sSCHURL) throws MalformedURLException Create a newSchematronResourcePurefrom Schematron rules provided at a URL- Parameters:
sSCHURL- The URL to the Schematron rules. May neither benullnor empty.- Returns:
- Never
null. - Throws:
MalformedURLException- In case an invalid URL is provided
-
fromURL
Create a newSchematronResourcePurefrom Schematron rules provided at a URL- Parameters:
aSCHURL- The URL to the Schematron rules. May not benull.- Returns:
- Never
null.
-
fromInputStream
@Nonnull public static SchematronResourcePure fromInputStream(@Nonnull @Nonempty String sResourceID, @Nonnull InputStream aSchematronIS) Create a newSchematronResourcePurefrom Schematron rules provided by an arbitraryInputStream.
Important: in this case, no include resolution will be performed!!- Parameters:
sResourceID- Resource ID to be used as the cache key. Should neither benullnor empty.aSchematronIS- TheInputStreamto read the Schematron rules from. May not benull.- Returns:
- Never
null. - Since:
- 6.2.5
-
fromByteArray
Create a newSchematronResourcePurefrom Schematron rules provided by an arbitrary byte array.
Important: in this case, no include resolution will be performed!!- Parameters:
aSchematron- The byte array representing the Schematron. May not benull.- Returns:
- Never
null.
-
fromString
@Nonnull public static SchematronResourcePure fromString(@Nonnull String sSchematron, @Nonnull Charset aCharset) Create a newSchematronResourcePurefrom Schematron rules provided by an arbitrary String.
Important: in this case, no include resolution will be performed!!- Parameters:
sSchematron- The String representing the Schematron. May not benull.aCharset- The charset to be used to convert the String to a byte array.- Returns:
- Never
null.
-
fromSchema
Create a newSchematronResourcePurefrom Schematron rules provided by a domain model.
Important: in this case, no include resolution will be performed!!- Parameters:
aSchematron- The Schematron model to be used. May not benull.- Returns:
- Never
null.
-