Package org.frankframework.validation
Class AbstractXmlValidator
java.lang.Object
org.frankframework.validation.AbstractXmlValidator
- All Implemented Interfaces:
IConfigurationAware
,IScopeProvider
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
JavaxXmlValidator
,XercesXmlValidator
baseclass for validating input message against a XML Schema.
N.B. noNamespaceSchemaLocation may contain spaces, but not if the schema is stored in a .jar or .zip file on the class path.
- Author:
- Johan Verrips IOS, Jaco de Groot
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected Boolean
protected static org.apache.logging.log4j.Logger
protected String
protected SchemasProvider
protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(IConfigurationAware owner) Configure the XmlValidatorcreateValidationContext
(PipeLineSession session, RootValidations rootValidations, Map<List<String>, List<String>> invalidRootNamespaces) finalizeValidation
(AbstractValidationContext context, PipeLineSession session, Throwable t) Evaluate the validation and set 'reason' session variables.org.springframework.context.ApplicationContext
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.protected InputSource
getInputSource
(Message input) protected String
getLogPrefix
(PipeLineSession session) getName()
getOwner()
abstract ValidatorHandler
getValidatorHandler
(PipeLineSession session, AbstractValidationContext context) abstract List<org.apache.xerces.xs.XSModel>
boolean
boolean
boolean
boolean
boolean
boolean
void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setCharset
(String string) Characterset used for reading file, only used whenvalidateFile
istrue
void
setFullSchemaChecking
(boolean fullSchemaChecking) Enable full schema grammar constraint checking, including checking which may be time-consuming or memory intensive.void
setIgnoreCaching
(boolean ignoreCaching) If settrue
, the number for caching validators in appConstants is ignored and no caching is done (for this validator only)void
Ignore namespaces in the input message which are unknownvoid
setReasonSessionKey
(String reasonSessionKey) If set: key of session variable to store reasons of mis-validation invoid
setSchemasProvider
(SchemasProvider schemasProvider) void
setThrowException
(boolean throwException) Should the XmlValidator throw a PipeRunexception on a validation error.void
setValidateFile
(boolean b) If settrue
, the input is assumed to be the name of the file to be validated.void
setWarn
(boolean warn) If settrue
, send warnings to logging and console about syntax problems in the configured schema('s).void
setXmlReasonSessionKey
(String xmlReasonSessionKey) LikereasonSessionKey
but stores reasons in xml format and more extensivevoid
setXmlSchemaVersion
(String xmlSchemaVersion) If set to1.0
, Xerces's previous XML Schema factory will be used, which would make all XSD 1.1 features illegal.void
start()
void
stop()
validate
(Object input, PipeLineSession session, ValidatorHandler validatorHandler, XMLFilterImpl filter, AbstractValidationContext context) validate
(Object input, PipeLineSession session, RootValidations rootValidations, Map<List<String>, List<String>> invalidRootNamespaces) validate
(InputSource inputSource, ValidatorHandler validatorHandler, PipeLineSession session, AbstractValidationContext context)
-
Field Details
-
log
protected static org.apache.logging.log4j.Logger log -
warn
protected boolean warn -
logPrefix
-
ignoreUnknownNamespaces
-
schemasProvider
-
-
Constructor Details
-
AbstractXmlValidator
public AbstractXmlValidator()
-
-
Method Details
-
configure
Configure the XmlValidator- Throws:
ConfigurationException
- when:- the schema cannot be found
- <
isThrowException()
is false and there is no forward defined for "failure" - when the parser does not accept setting the properties for validating
-
getName
- Specified by:
getName
in interfaceIConfigurationAware
-
start
- Throws:
ConfigurationException
-
stop
public void stop() -
createValidationContext
public AbstractValidationContext createValidationContext(PipeLineSession session, RootValidations rootValidations, Map<List<String>, List<String>> invalidRootNamespaces) throws ConfigurationException, PipeRunException -
finalizeValidation
public AbstractXmlValidator.ValidationResult finalizeValidation(AbstractValidationContext context, PipeLineSession session, Throwable t) throws XmlValidatorException Evaluate the validation and set 'reason' session variables.- Parameters:
context
- the validationContext of this attemptsession
- the PipeLineSessiont
- the exception thrown by the validation, or null- Returns:
- the result event, e.g. 'valid XML' or 'Invalid XML'
- Throws:
XmlValidatorException
-
getValidatorHandler
public abstract ValidatorHandler getValidatorHandler(PipeLineSession session, AbstractValidationContext context) throws ConfigurationException, PipeRunException -
getXSModels
-
validate
public AbstractXmlValidator.ValidationResult validate(Object input, PipeLineSession session, RootValidations rootValidations, Map<List<String>, List<String>> invalidRootNamespaces) throws XmlValidatorException, PipeRunException, ConfigurationException- Parameters:
input
- the XML string to validatesession
- apipeLineSession
- Returns:
- ValidationResult
- Throws:
XmlValidatorException
- whenisThrowException
is true and a validationerror occurred.PipeRunException
ConfigurationException
-
validate
public AbstractXmlValidator.ValidationResult validate(Object input, PipeLineSession session, ValidatorHandler validatorHandler, XMLFilterImpl filter, AbstractValidationContext context) throws XmlValidatorException - Throws:
XmlValidatorException
-
validate
public AbstractXmlValidator.ValidationResult validate(InputSource inputSource, ValidatorHandler validatorHandler, PipeLineSession session, AbstractValidationContext context) throws XmlValidatorException - Throws:
XmlValidatorException
-
getLogPrefix
-
getInputSource
- Throws:
XmlValidatorException
-
setFullSchemaChecking
public void setFullSchemaChecking(boolean fullSchemaChecking) Enable full schema grammar constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation restriction checking are controlled by this option.see property http://apache.org/xml/features/validation/schema-full-checking
- Default value
false
-
setThrowException
public void setThrowException(boolean throwException) Should the XmlValidator throw a PipeRunexception on a validation error. If not, a forward with name 'failure' must be defined.- Default value
- false
-
setReasonSessionKey
If set: key of session variable to store reasons of mis-validation in- Default value
- failureReason
-
setXmlReasonSessionKey
LikereasonSessionKey
but stores reasons in xml format and more extensive- Default value
- xmlFailureReason
-
setValidateFile
public void setValidateFile(boolean b) If settrue
, the input is assumed to be the name of the file to be validated. Otherwise the input itself is validated- Default value
- false
-
setCharset
Characterset used for reading file, only used whenvalidateFile
istrue
- Default value
- utf-8
-
setWarn
public void setWarn(boolean warn) If settrue
, send warnings to logging and console about syntax problems in the configured schema('s). Alternatively, warnings can be switched off using suppression properties , and- Default value
- true
-
setIgnoreUnknownNamespaces
Ignore namespaces in the input message which are unknown- Default value
- true when
schema
ornoNamespaceSchemaLocation
is used, false otherwise
-
setIgnoreCaching
public void setIgnoreCaching(boolean ignoreCaching) If settrue
, the number for caching validators in appConstants is ignored and no caching is done (for this validator only)- Default value
- false
-
setXmlSchemaVersion
If set to1.0
, Xerces's previous XML Schema factory will be used, which would make all XSD 1.1 features illegal. The default behaviour can also be set withxsd.processor.version
property.- Default value
1.1
-
isXmlSchema1_0
public boolean isXmlSchema1_0() -
getConfigurationClassLoader
Description copied from interface:IScopeProvider
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.- Specified by:
getConfigurationClassLoader
in interfaceIScopeProvider
- Returns:
- returns the ClassLoader created by the
ClassLoaderManager
.
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContext
in interfaceIConfigurationAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
getOwner
-
isThrowException
public boolean isThrowException() -
isFullSchemaChecking
public boolean isFullSchemaChecking() -
getReasonSessionKey
-
getXmlReasonSessionKey
-
isValidateFile
public boolean isValidateFile() -
getCharset
-
getIgnoreUnknownNamespaces
-
isIgnoreCaching
public boolean isIgnoreCaching() -
getXmlSchemaVersion
-
setSchemasProvider
-
isStarted
public boolean isStarted()
-