Package com.helger.schematron
Class AbstractSchematronResource
java.lang.Object
com.helger.schematron.AbstractSchematronResource
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,ISchematronResource
- Direct Known Subclasses:
AbstractSchematronXSLTBasedResource
@NotThreadSafe
public abstract class AbstractSchematronResource
extends Object
implements ISchematronResource
Abstract implementation of the
ISchematronResource interface handling
the underlying resource and wrapping one method.- Author:
- Philip Helger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classHelper class to handle DOM Document and base URI for reference -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSchematronResource(com.helger.commons.io.resource.IReadableResource aResource) Constructor -
Method Summary
Modifier and TypeMethodDescriptionapplySchematronValidation(com.helger.commons.io.IHasInputStream aXMLResource) Apply the Schematron validation on the passed XML resource and return an SVRL XML DOM Document.applySchematronValidation(Source aXMLSource) Apply the Schematron validation on the passed XML source and return an SVRL XML DOM Document.applySchematronValidationToSVRL(com.helger.commons.io.IHasInputStream aXMLResource) Apply the Schematron validation on the passed XML resource and return aSchematronOutputTypeobject.applySchematronValidationToSVRL(Source aXMLSource) Apply the Schematron validation on the passed XML source and return aSchematronOutputTypeobject.getAsNode(com.helger.commons.io.IHasInputStream aXMLResource) protected Nodefinal EntityResolverfinal StringgetID()final com.helger.commons.io.resource.IReadableResourcecom.helger.commons.state.EValiditygetSchematronValidity(com.helger.commons.io.IHasInputStream aXMLResource) A method to check if the passed XML DOM node matches the Schematron rules or not.com.helger.commons.state.EValiditygetSchematronValidity(Source aXMLSource) A method to check if the passed XML DOM node matches the Schematron rules or not.protected com.helger.xml.serialize.read.DOMReaderSettingsprotected final voidinternalSetEntityResolver(EntityResolver aEntityResolver) Set the XML entity resolver to be used when reading the Schematron or the XML to be validated.final booleanThis is currently only supported for the "pure Schematron".final booleanfinal voidsetLenient(boolean bLenient) This is currently only supported for the "pure Schematron".final voidsetUseCache(boolean bUseCache) Enable or disable caching.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.schematron.ISchematronResource
applySchematronValidation, applySchematronValidationToSVRL, getSchematronValidity, isValidSchematron
-
Field Details
-
DEFAULT_USE_CACHE
public static final boolean DEFAULT_USE_CACHE- See Also:
-
-
Constructor Details
-
AbstractSchematronResource
public AbstractSchematronResource(@Nonnull com.helger.commons.io.resource.IReadableResource aResource) Constructor- Parameters:
aResource- The Schematron resource. May not benull.
-
-
Method Details
-
getID
- Specified by:
getIDin interfacecom.helger.commons.id.IHasID<String>
-
getResource
- Specified by:
getResourcein interfaceISchematronResource- Returns:
- The non-
nullresource from which to read the Schematron rules.
-
isUseCache
public final boolean isUseCache()- Specified by:
isUseCachein interfaceISchematronResource- Returns:
trueto use caching, if applicable.
-
setUseCache
public final void setUseCache(boolean bUseCache) Description copied from interface:ISchematronResourceEnable or disable caching.- Specified by:
setUseCachein interfaceISchematronResource- Parameters:
bUseCache-trueto use the cache,falseto not use it.
-
isLenient
public final boolean isLenient()Description copied from interface:ISchematronResourceThis is currently only supported for the "pure Schematron".- Specified by:
isLenientin interfaceISchematronResource- Returns:
trueif 'old' schematron NS is tolerated,falseif not. Default isfalse.
-
setLenient
public final void setLenient(boolean bLenient) Description copied from interface:ISchematronResourceThis is currently only supported for the "pure Schematron". Allow use of 'old' schematron NS.- Specified by:
setLenientin interfaceISchematronResource- Parameters:
bLenient-trueif 'old' schematron NS is tolerated,falseif not.
-
getEntityResolver
- Specified by:
getEntityResolverin interfaceISchematronResource- Returns:
- The XML entity resolver to be used to read the Schematron or XML to
be validated. May be
null.
-
internalSetEntityResolver
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.- Since:
- 4.2.3
-
internalCreateDOMReaderSettings
@Nonnull @ReturnsMutableCopy protected com.helger.xml.serialize.read.DOMReaderSettings internalCreateDOMReaderSettings()- Returns:
- The
DOMReaderSettingsto be used for reading the XML files to be validated. This includes theEntityResolverto be used. - See Also:
-
getAsNode
@Nullable @OverrideOnDemand protected AbstractSchematronResource.NodeAndBaseURI getAsNode(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception - Throws:
Exception
-
getAsNode
- Throws:
Exception
-
getSchematronValidity
@Nonnull public com.helger.commons.state.EValidity getSchematronValidity(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception Description copied from interface:ISchematronResourceA method to check if the passed XML DOM node matches the Schematron rules or not. This is the quick check method, as it breaks upon the first failed assertion or the first successful report, if the implementation supports it (as e.g. the native pure Schematron version).- Specified by:
getSchematronValidityin interfaceISchematronResource- Parameters:
aXMLResource- The source XML to read and validate against the Schematron. May not benull.- Returns:
EValidity.VALIDif the document is valid,EValidity.INVALIDif it is invalid.- Throws:
Exception- in case of a sever error validating the schema
-
getSchematronValidity
@Nonnull public com.helger.commons.state.EValidity getSchematronValidity(@Nonnull Source aXMLSource) throws Exception Description copied from interface:ISchematronResourceA method to check if the passed XML DOM node matches the Schematron rules or not. This is the quick check method, as it breaks upon the first failed assertion or the first successful report, if the implementation supports it (as e.g. the native pure Schematron version).- Specified by:
getSchematronValidityin interfaceISchematronResource- Parameters:
aXMLSource- The source XML to be validated against the Schematron. May not benull.- Returns:
EValidity.VALIDif the document is valid,EValidity.INVALIDif it is invalid.- Throws:
Exception- in case of a sever error validating the schema
-
applySchematronValidation
@Nullable public Document applySchematronValidation(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception Description copied from interface:ISchematronResourceApply the Schematron validation on the passed XML resource and return an SVRL XML DOM Document.- Specified by:
applySchematronValidationin interfaceISchematronResource- Parameters:
aXMLResource- The XML resource to be validated via Schematron. May not benull.- Returns:
nullif the passed resource does not exist or the non-nullSVRL document otherwise.- Throws:
Exception- In case the transformation somehow goes wrong.- See Also:
-
applySchematronValidation
Description copied from interface:ISchematronResourceApply the Schematron validation on the passed XML source and return an SVRL XML DOM Document.- Specified by:
applySchematronValidationin interfaceISchematronResource- Parameters:
aXMLSource- The XML source to be validated via Schematron. May not benull.- Returns:
- The SVRL XML document containing the result. May be
nullwhen interpreting the Schematron failed. - Throws:
Exception- In case the transformation somehow goes wrong.- See Also:
-
applySchematronValidationToSVRL
@Nullable public SchematronOutputType applySchematronValidationToSVRL(@Nonnull com.helger.commons.io.IHasInputStream aXMLResource) throws Exception Description copied from interface:ISchematronResourceApply the Schematron validation on the passed XML resource and return aSchematronOutputTypeobject.- Specified by:
applySchematronValidationToSVRLin interfaceISchematronResource- Parameters:
aXMLResource- The XML resource to be validated via Schematron. May not benull.- Returns:
- The SVRL object containing the result. May be
nullwhen interpreting the Schematron failed. - Throws:
Exception- In case the transformation somehow goes wrong.
-
applySchematronValidationToSVRL
@Nullable public SchematronOutputType applySchematronValidationToSVRL(@Nonnull Source aXMLSource) throws Exception Description copied from interface:ISchematronResourceApply the Schematron validation on the passed XML source and return aSchematronOutputTypeobject.- Specified by:
applySchematronValidationToSVRLin interfaceISchematronResource- Parameters:
aXMLSource- The XML source to be validated via Schematron. May not benull.- Returns:
- The SVRL object containing the result. May be
nullwhen interpreting the Schematron failed. - Throws:
Exception- In case the transformation somehow goes wrong.
-
toString
-