Welcome Guest! Log in
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.


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.

validator

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, ...

mainProcess

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.

mainProcessWithParameter

 

 

You have no rights to post comments

Articles

Suggest a new Article!