Package org.frankframework.pipes
Class XmlValidator
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasTransactionAttribute,IConfigurable,IDualModeValidator,IForwardTarget,IPipe,IScopeProvider,IValidator,IWithParameters,IXmlValidator,NameAware,EventThrowing,SchemasProvider,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle
- Direct Known Subclasses:
Json2XmlValidator
@Category(BASIC)
public class XmlValidator
extends AbstractValidator
implements SchemasProvider, 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
Nested ClassesModifier and TypeClassDescriptionstatic classWrapper for the XML response validator. -
Field Summary
FieldsFields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUniqueFields inherited from class org.frankframework.core.TransactionAttributes
logFields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddInvalidRootNamespaces(List<String> path, List<String> invalidRootNamespaces) protected voidprotected voidvoidprotected voidvoidConfigure the XmlValidatorprotected RootValidationscreateRootValidation(String messageRoot) protected PipeForwarddetermineForward(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 PipeRunResultgetErrorResult(String reason, PipeLineSession session, boolean responseMode) getMessageRoot(boolean responseMode) protected RootValidationsprotected RootValidationsgetRootValidations(boolean responseMode) getSchemas(boolean checkRootValidations) getSchemas(PipeLineSession session) getSchemasId(PipeLineSession session) Deprecated.getXsds()List<org.apache.xerces.xs.XSModel> protected booleanbooleanbooleanbooleanvoidsetAddNamespaceToSchema(boolean addNamespaceToSchema) If settrue, the namespace from schemalocation is added to the schema document as targetnamespacevoidsetCharset(String string) voidsetFullSchemaChecking(boolean fullSchemaChecking) voidsetIgnoreCaching(boolean ignoreCaching) voidsetIgnoreUnknownNamespaces(Boolean ignoreUnknownNamespaces) voidsetImplementation(Class<? extends AbstractXmlValidator> clazz) voidsetImportedNamespacesToIgnore(String string) Comma separated list of namespaces which are excluded from an import or include in the schema documentvoidComma separated list of schemaLocations which are excluded from an import or include in the schema documentvoidsetNoNamespaceSchemaLocation(String noNamespaceSchemaLocation) A URI reference as a hint as to the location of a schema document with no target namespace.voidsetReasonSessionKey(String reasonSessionKey) voidsetResponseRoot(String responseRoot) Name of the response root element, or a comma separated list of element names.voidName of the root element, or a comma separated list of element names.voidsetRootElementSessionKey(String rootElementSessionKey) Key of session variable to store the name of the root elementvoidsetRootNamespaceSessionKey(String rootNamespaceSessionKey) Key of session variable to store the namespace of the root elementvoidThe filename of the schema on the classpath.voidsetSchemaLocation(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.voidsetSoapNamespace(String string) Deprecated.voidsetThrowException(boolean throwException) voidsetUseBaseImportedSchemaLocationsToIgnore(boolean useBaseImportedSchemaLocationsToIgnore) Iftrue, the comparison for importedSchemaLocationsToIgnore is done on base filename without any pathvoidsetValidateFile(boolean b) voidsetWarn(boolean warn) voidsetXmlReasonSessionKey(String xmlReasonSessionKey) voidsetXmlSchemaVersion(String xmlSchemaVersion) voidstart()Perform necessary action to start the pipe.voidstop()Perform necessary actions to stop thePipe.
For instance, closing JMS connections, DBMS connections etc.protected PipeForwardvalidate(Message messageToValidate, PipeLineSession session, boolean responseMode, String messageRoot) Methods inherited from class org.frankframework.pipes.AbstractValidator
determineForward, doPipe, setForwardFailureToSuccess, setSchemaSessionKey, validate, validateMethods inherited from class org.frankframework.pipes.FixedForwardPipe
getParameterValue, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipeMethods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getEventSourceName, getForwards, getParameterList, hasRegisteredForward, isRunning, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, throwEventMethods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, isTransacted, isTransacted, setTransacted, setTransactionTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.HasTransactionAttribute
getTransactionAttribute, getTransactionTimeout, getTxDef, setTransactionAttributeMethods inherited from interface org.frankframework.core.IForwardTarget
getNameMethods 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, throwEventMethods inherited from interface org.frankframework.core.IValidator
setName, validateMethods inherited from interface org.frankframework.core.IXmlValidator
getSchemaLocationMethods inherited from interface org.springframework.context.Lifecycle
isRunning
-
Field Details
-
validator
-
configurationException
-
-
Constructor Details
-
XmlValidator
public XmlValidator()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
configure
Configure the XmlValidator- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classAbstractValidator- Throws:
ConfigurationException- when:- the schema cannot be found
isThrowException()isfalseand there is no forward defined for "failure"- when the parser does not accept setting the properties for validating
-
start
public void start()Description copied from interface:IPipePerform necessary action to start the pipe. This method is executed after theIConfigurable.configure()method, for each start and stop command of the adapter.- Specified by:
startin interfaceIPipe- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Overrides:
startin classAbstractPipe
-
stop
public void stop()Description copied from interface:IPipePerform necessary actions to stop thePipe.
For instance, closing JMS connections, DBMS connections etc.- Specified by:
stopin interfaceIPipe- Specified by:
stopin interfaceorg.springframework.context.Lifecycle- Overrides:
stopin classAbstractPipe
-
checkSchemaSpecified
- Throws:
ConfigurationException
-
getConfigurationException
- Specified by:
getConfigurationExceptionin interfaceIXmlValidator
-
getXSModels
-
doPipe
public PipeRunResult doPipe(Message input, PipeLineSession session, boolean responseMode, String messageRoot) throws PipeRunException - Overrides:
doPipein classAbstractValidator- Throws:
PipeRunException
-
validate
protected PipeForward validate(Message messageToValidate, PipeLineSession session, boolean responseMode, String messageRoot) throws XmlValidatorException, PipeRunException, ConfigurationException - Specified by:
validatein classAbstractValidator- Throws:
XmlValidatorExceptionPipeRunExceptionConfigurationException
-
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:
isConfiguredForMixedValidationin classAbstractValidator
-
getMessageRoot
-
getSchemasId
- Specified by:
getSchemasIdin interfaceSchemasProvider
-
getXsds
- Specified by:
getXsdsin interfaceIXmlValidator- Throws:
ConfigurationException
-
getSchemas
- Specified by:
getSchemasin interfaceSchemasProvider- Throws:
ConfigurationException
-
getSchemas
- Throws:
ConfigurationException
-
getResponseValidator
- Specified by:
getResponseValidatorin interfaceIDualModeValidator- Overrides:
getResponseValidatorin classAbstractValidator
-
getRootValidations
-
getSchemasId
- Specified by:
getSchemasIdin interfaceSchemasProvider- Throws:
PipeRunException
-
getSchemas
- Specified by:
getSchemasin interfaceSchemasProvider- Throws:
PipeRunException
-
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:IXmlValidatorProvide 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:
getDocumentationin 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:
getSchemain 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:
setRootin 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:
setResponseRootin classAbstractValidator
-
getMessageRoot
- Specified by:
getMessageRootin interfaceIXmlValidator
-
setFullSchemaChecking
-
isFullSchemaChecking
public boolean isFullSchemaChecking() -
setThrowException
-
isThrowException
public boolean isThrowException() -
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) Iftrue, 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, usingSoapValidatoris 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
-