8000 XmlValidator · frankframework/frankframework Wiki · GitHub
[go: up one dir, main page]

Skip to content
LEEERRoooYYY JJJEENNKINNSSS edited this page Jul 27, 2021 · 15 revisions

Explanation

The XmlValidator is a pipe that validates an input message against a XML-Schema.

It's available in the form of XmlInputValidator, XmlOutputValidator and XmlValidatorPipe.

XmlInputValidator when put on the pipeline it will validate the input it recieves against the XML-schema, when used in a sender the inputvalidator will be validating the input it recieves which will become the output of the sender.

XmlOutputValidator when put on a sender it will validate the input recieved back from the sender which is output for the sender it resides in.

After the correct validator has been chosen there should be specified in which way the pipe can find the xml-schema:

  • schema The path to the file in which the schema resides.
  • schemaLocation This should be a pair where the first part of the pair should be the namespace (this can be found within the xml-schema as the xmlns) followed by a space and then the location of the file where the schema resides in.

example:schemaLocation="http://nn.nl/XSD/LifeRetailCB/PolicyJuice/1/GetPolicyDetails/1 /GetPolicyDetails_1/xsd/GetPolicyDetails.xsd"

  • schemaSessionKey This is a sessionkey which contains the location of a xml-schema to use

Important attributes

  • root With this attribute you specify what the root element is within the input, this can also be comma separated. If root element is not present the validation will fail.

  • throwException If there is not a forward with the name 'failure' specified in your pipe, this attribute should be used to be able to throw the exeption originating from a validation error.

  • validateFile When this is set to true the input of the pipe will be assumed to be the name of the file that needs to be validated

Examples

The following example uses the schemaLocation which consists of firstly a namespace derived from the xml-schema followed by a space then the actual location of the xml-schema in the classpath, also it uses the root attribute to specify then first element name that needs to be present in the input in order to be able to pass the validation, the use of the attribute throwException makes it possible to use this pipe without specifying a failure forward:

<pipe
	name="validation"
	className="nl.nn.adapterframework.pipes.XmlValidator"
	schemaLocation="http://www.w3.org/2001/XMLSchema testing/xsd/testing.xsd"
	root="test"
	throwException="true">
	<forward name="success" path="EXIT" />
</pipe>

The following example uses the attribute schema, which is a direct path to the xml-schema:

<pipe
	name="validation"
	className="nl.nn.adapterframework.pipes.XmlValidator"
	schema="testing/xsd/testing.xsd"
	root="test"
	throwException="true">
	<forward name="success" path="EXIT" />
</pipe>

Clone this wiki locally

0