Showing posts with label Schema. Show all posts
Showing posts with label Schema. Show all posts

Sunday, August 31, 2014

[WSO2 ESB] Using [resource] attribute for [xsd:import] elements in a scheme file with Validate Mediator

The Validate Mediator in WSO2 ESB is used for schema validation of messages. Then this message is validated against the schema specified.

When we use validate mediator against a schema that schema file itself can contain some other schema references under <xsd:import> elements like below.


If our schema file is like this, in this scenario validate mediator tries to map and find the internal schemas which are defined in <xsd:import> elements. If these cannot be found, ESB will log an error saying that "The resource "{resource_file_name} can not be located"

Therefore in order to use these schema files with validate mediator follow the steps given below.

1. First add all the xsd files as local entries to ESB. These is no relative paths or nested folders supported so the xsd files has to be in local-entries folder itself. However if you put the schemas into registry nested folders are supported.

2. In the validate mediator there is an attribute called <resource>. Use this option to tell the validate mediator on where to find the files to import as below. Make sure ‘location’ and ‘schemaLocation’ entries has the same file name in order to map those correctly. Then the 'key' attribute is used to specify the current location of this schema file as shown in the given exmaple.


If you have added the schema files as registry entries, and when there are relative paths mentioned in parent schema, validate mediator can be used in  the following manner.