Welcome Guest! Log in

Actually, Stambia doesn't have a standard feature to validate an XML file with it's corresponding XSD.

But it is possible to do it through scripting in a Process, as shown in this article.


Validation process

We create for the validation a small process, with a scripting action and two parameters, to indicate the XML and XSD paths.


The body of the scripting actions is:

factory = javax.xml.validation.SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema") ;
xsdFile = new org.xml.sax.InputSource(new java.io.FileInputStream("%x{md:paramValue($this,'xsdPath')}x%"));
xsdSource = new javax.xml.transform.sax.SAXSource(xsdFile);
schema = factory.newSchema(xsdSource);
validator = schema.newValidator() ;
validator.validate(new javax.xml.transform.stream.StreamSource(new java.io.File("%x{md:paramValue($this,'xmlPath')}x%"))) ;

We are using some Java classes to do the expected validation.

And here we are, we have our validation process!


Using the validation in another process

The validation process can be dragged and dropped from the Project explorer in another process, for error handling, ...


The XML and XSD path's parameters can be set in the properties of the xsdValidator sub-process.


You can show too the parameters on it by clicking on the (x) button to show or hide parameters.




You have no rights to post comments


Suggest a new Article!