Package org.frankframework.pipes
Class XmlValidator
- All Implemented Interfaces:
HasSpecialDefaultValues
,HasTransactionAttribute
,IConfigurable
,IConfigurationAware
,IDualModeValidator
,IForwardTarget
,INamedObject
,IPipe
,IScopeProvider
,IValidator
,IWithParameters
,IXmlValidator
,EventThrowing
,HasStatistics
,SchemasProvider
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
Json2XmlValidator
@Category(BASIC)
public class XmlValidator
extends AbstractValidator
implements SchemasProvider, HasSpecialDefaultValues, IXmlValidator, org.springframework.beans.factory.InitializingBean
Pipe that validates the input message against an XML Schema.
- Author:
- Johan Verrips IOS, Jaco de Groot
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Wrapper for the XML response validator. -
Field Summary
Fields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUnique
Fields inherited from class org.frankframework.core.TransactionAttributes
log
Fields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addInvalidRootNamespaces
(List<String> path, List<String> invalidRootNamespaces) protected void
protected void
void
protected void
void
Configure the XmlValidatorprotected RootValidations
createRootValidation
(String messageRoot) protected PipeForward
determineForward
(AbstractXmlValidator.ValidationResult validationResult, PipeLineSession session, boolean responseMode) doPipe
(Message input, PipeLineSession session, boolean responseMode, String messageRoot) Provide additional generic documentation on the validation of the subsequent processing.protected PipeRunResult
getErrorResult
(String reason, PipeLineSession session, boolean responseMode) getMessageRoot
(boolean responseMode) protected RootValidations
protected RootValidations
getRootValidations
(boolean responseMode) getSchemas
(boolean checkRootValidations) getSchemas
(PipeLineSession session) getSchemasId
(PipeLineSession session) Deprecated.getXsds()
List<org.apache.xerces.xs.XSModel>
boolean
protected boolean
boolean
boolean
boolean
boolean
void
setAddNamespaceToSchema
(boolean addNamespaceToSchema) If settrue
, the namespace from schemalocation is added to the schema document as targetnamespacevoid
setCharset
(String string) void
setFullSchemaChecking
(boolean fullSchemaChecking) void
setIgnoreCaching
(boolean ignoreCaching) void
setIgnoreUnknownNamespaces
(Boolean ignoreUnknownNamespaces) void
setImplementation
(Class<? extends AbstractXmlValidator> clazz) void
setImportedNamespacesToIgnore
(String string) Comma separated list of namespaces which are excluded from an import or include in the schema documentvoid
Comma separated list of schemaLocations which are excluded from an import or include in the schema documentvoid
setNoNamespaceSchemaLocation
(String noNamespaceSchemaLocation) A uri reference as a hint as to the location of a schema document with no target namespace.void
setReasonSessionKey
(String reasonSessionKey) void
setResponseRoot
(String responseRoot) Name of the response root element, or a comma separated list of element names.void
Name of the root element, or a comma separated list of element names.void
setRootElementSessionKey
(String rootElementSessionKey) Key of session variable to store the name of the root elementvoid
setRootNamespaceSessionKey
(String rootNamespaceSessionKey) Key of session variable to store the namespace of the root elementvoid
The filename of the schema on the classpath.void
setSchemaLocation
(String schemaLocation) Pairs of URI references (one for the namespace name, and one for a hint as to the location of a schema document defining names for that namespace name).
The syntax is the same as for schemaLocation attributes in instance documents: e.g, "http://www.example.com file%20name.xsd".
The user can specify more than one XML Schema in the list.
Note that spaces are considered separators for this attributed.void
setSoapNamespace
(String string) Deprecated.void
setThrowException
(boolean throwException) void
setUseBaseImportedSchemaLocationsToIgnore
(boolean useBaseImportedSchemaLocationsToIgnore) If settrue
, the comparison for importedSchemaLocationsToIgnore is done on base filename without any pathvoid
setValidateFile
(boolean b) void
setWarn
(boolean warn) void
setXmlReasonSessionKey
(String xmlReasonSessionKey) void
setXmlSchemaVersion
(String xmlSchemaVersion) void
start()
Perform necessary action to start the pipe.void
stop()
Perform necessary actions to stop thePipe
.
For instance, closing JMS connections, DBMS connections etc.protected PipeForward
validate
(Message messageToValidate, PipeLineSession session, boolean responseMode, String messageRoot) Methods inherited from class org.frankframework.pipes.AbstractValidator
determineForward, doPipe, getResponseRoot, getRoot, getSchemaSessionKey, isForwardFailureToSuccess, setForwardFailureToSuccess, setSchemaSessionKey, validate, validate
Methods inherited from class org.frankframework.pipes.FixedForwardPipe
getIfParam, getIfValue, getOnlyIfSessionKey, getOnlyIfValue, getParameterValue, getSuccessForward, getUnlessSessionKey, getUnlessValue, isSkipOnEmptyInput, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipe
Methods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getApplicationContext, getChompCharSize, getConfigurationClassLoader, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getEventSourceName, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getName, getParameterList, getPipeLine, getSecLogSessionKeys, getStoreResultInSessionKey, hasRegisteredForward, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setEventPublisher, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, throwEvent
Methods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, getTransactionAttribute, getTransactionTimeout, getTxDef, isTransacted, isTransacted, setTransacted, setTransactionAttribute, setTransactionTimeout
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.IForwardTarget
getName
Methods inherited from interface org.frankframework.core.INamedObject
getName
Methods inherited from interface org.frankframework.core.IPipe
addForward, consumesSessionVariable, doPipe, getChompCharSize, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getSecLogSessionKeys, getStoreResultInSessionKey, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, throwEvent, throwEvent
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.IValidator
setName, validate
-
Field Details
-
validator
-
configurationException
-
-
Constructor Details
-
XmlValidator
public XmlValidator()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
configure
Configure the XmlValidator- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIPipe
- Overrides:
configure
in classAbstractValidator
- 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
-
start
Description copied from interface:IPipe
Perform necessary action to start the pipe. This method is executed after theIPipe.configure()
method, for each start and stop command of the adapter.- Specified by:
start
in interfaceIPipe
- Overrides:
start
in classAbstractPipe
- Throws:
PipeStartException
-
stop
public void stop()Description copied from interface:IPipe
Perform necessary actions to stop thePipe
.
For instance, closing JMS connections, DBMS connections etc.- Specified by:
stop
in interfaceIPipe
- Overrides:
stop
in classAbstractPipe
-
checkSchemaSpecified
- Throws:
ConfigurationException
-
getConfigurationException
- Specified by:
getConfigurationException
in interfaceIXmlValidator
-
getXSModels
-
doPipe
public PipeRunResult doPipe(Message input, PipeLineSession session, boolean responseMode, String messageRoot) throws PipeRunException - Overrides:
doPipe
in classAbstractValidator
- Throws:
PipeRunException
-
validate
protected PipeForward validate(Message messageToValidate, PipeLineSession session, boolean responseMode, String messageRoot) throws XmlValidatorException, PipeRunException, ConfigurationException - Specified by:
validate
in classAbstractValidator
- Throws:
XmlValidatorException
PipeRunException
ConfigurationException
-
createRootValidation
-
determineForward
protected PipeForward determineForward(AbstractXmlValidator.ValidationResult validationResult, PipeLineSession session, boolean responseMode) throws PipeRunException - Throws:
PipeRunException
-
getErrorResult
protected PipeRunResult getErrorResult(String reason, PipeLineSession session, boolean responseMode) throws PipeRunException - Throws:
PipeRunException
-
isConfiguredForMixedValidation
protected boolean isConfiguredForMixedValidation()- Overrides:
isConfiguredForMixedValidation
in classAbstractValidator
-
getMessageRoot
-
getSchemasId
- Specified by:
getSchemasId
in interfaceSchemasProvider
-
getXsds
- Specified by:
getXsds
in interfaceIXmlValidator
- Throws:
ConfigurationException
-
getSchemas
- Specified by:
getSchemas
in interfaceSchemasProvider
- Throws:
ConfigurationException
-
getSchemas
- Throws:
ConfigurationException
-
getResponseValidator
- Specified by:
getResponseValidator
in interfaceIDualModeValidator
- Overrides:
getResponseValidator
in classAbstractValidator
-
getRootValidations
-
getSchemasId
- Specified by:
getSchemasId
in interfaceSchemasProvider
- Throws:
PipeRunException
-
getSchemas
- Specified by:
getSchemas
in interfaceSchemasProvider
- Throws:
PipeRunException
-
getSpecialDefaultValue
public Object getSpecialDefaultValue(String attributeName, Object defaultValue, Map<String, String> attributes) - Specified by:
getSpecialDefaultValue
in interfaceHasSpecialDefaultValues
-
addRequestRootValidation
-
getRequestRootValidations
-
addResponseRootValidation
-
getResponseRootValidations
-
addInvalidRootNamespaces
- Parameters:
path
- to the element from where to start validating namespacesinvalidRootNamespaces
- XML namespace that is not allowed on the current element
-
getInvalidRootNamespaces
-
getDocumentation
Description copied from interface:IXmlValidator
Provide additional generic documentation on the validation of the subsequent processing. This documentation will be included in generated schema's like WSDL or OpenApi- Specified by:
getDocumentation
in interfaceIXmlValidator
-
setImplementation
public void setImplementation(Class<? extends AbstractXmlValidator> clazz) throws ReflectiveOperationException, SecurityException -
setSchema
The filename of the schema on the classpath. It is not possible to specify a namespace using this attribute. (effectively the same as noNamespaceSchemaLocation) An example value would be "xml/xsd/GetPartyDetail.xsd". The value of the schema attribute is only used if the schemaLocation attribute and the noNamespaceSchemaLocation are not set. -
getSchema
- Specified by:
getSchema
in interfaceIXmlValidator
- Returns:
- noNamespaceSchemalocation, if specified
-
setSchemaLocation
Pairs of URI references (one for the namespace name, and one for a hint as to the location of a schema document defining names for that namespace name).
The syntax is the same as for schemaLocation attributes in instance documents: e.g, "http://www.example.com file%20name.xsd".
The user can specify more than one XML Schema in the list.
Note that spaces are considered separators for this attributed. This means that, for example, spaces in filenames should be escaped to %20. -
setNoNamespaceSchemaLocation
A uri reference as a hint as to the location of a schema document with no target namespace. -
setRoot
Name of the root element, or a comma separated list of element names. The validation fails if the root element is not present in the list. N.B. for WSDL generation only the first element is used- Overrides:
setRoot
in classAbstractValidator
-
setResponseRoot
Name of the response root element, or a comma separated list of element names. The validation fails if the root element is not present in the list. N.B. for WSDL generation only the first element is used- Overrides:
setResponseRoot
in classAbstractValidator
-
getMessageRoot
- Specified by:
getMessageRoot
in interfaceIXmlValidator
-
setFullSchemaChecking
-
isFullSchemaChecking
public boolean isFullSchemaChecking() -
setThrowException
-
isThrowException
public boolean isThrowException()- Overrides:
isThrowException
in classAbstractValidator
-
setReasonSessionKey
-
getReasonSessionKey
-
setXmlReasonSessionKey
-
getXmlReasonSessionKey
-
setValidateFile
-
isValidateFile
public boolean isValidateFile() -
setCharset
-
getCharset
-
setAddNamespaceToSchema
public void setAddNamespaceToSchema(boolean addNamespaceToSchema) If settrue
, the namespace from schemalocation is added to the schema document as targetnamespace- Default value
- false
-
setImportedSchemaLocationsToIgnore
Comma separated list of schemaLocations which are excluded from an import or include in the schema document -
setUseBaseImportedSchemaLocationsToIgnore
public void setUseBaseImportedSchemaLocationsToIgnore(boolean useBaseImportedSchemaLocationsToIgnore) If settrue
, the comparison for importedSchemaLocationsToIgnore is done on base filename without any path- Default value
- false
-
setImportedNamespacesToIgnore
Comma separated list of namespaces which are excluded from an import or include in the schema document -
setWarn
-
setIgnoreUnknownNamespaces
@ReferTo(AbstractXmlValidator.class) public void setIgnoreUnknownNamespaces(Boolean ignoreUnknownNamespaces) -
getIgnoreUnknownNamespaces
-
setIgnoreCaching
-
setXmlSchemaVersion
-
setSoapNamespace
Deprecated.The namespace of the SOAP envelope, when this property has a value and the input message is a SOAP message, the content of the SOAP Body is used for validation, hence the SOAP Envelope and SOAP Body elements are not considered part of the message to validate. Please note that this functionality is deprecated, usingSoapValidator
is now the preferred solution in case a SOAP message needs to be validated, in other cases give this property an empty value.- Default value
- http://schemas.xmlsoap.org/soap/envelope/
-
getSoapNamespace
Deprecated. -
setRootElementSessionKey
Key of session variable to store the name of the root element -
setRootNamespaceSessionKey
Key of session variable to store the namespace of the root element -
getSchemaLocation
- Specified by:
getSchemaLocation
in interfaceIXmlValidator
-
getNoNamespaceSchemaLocation
-
getRootElementSessionKey
-
getRootNamespaceSessionKey
-
isAddNamespaceToSchema
public boolean isAddNamespaceToSchema() -
getImportedSchemaLocationsToIgnore
-
isUseBaseImportedSchemaLocationsToIgnore
public boolean isUseBaseImportedSchemaLocationsToIgnore() -
getImportedNamespacesToIgnore
-