Welcome Guest! Log in
Stambia versions 2.x, 3.x, S17, S18, S19 and S20 are reaching End of Support January, 15th, 2024. Please consider upgrading to the supported Semarchy xDI versions. See Global Policy Support and the Semarchy Documentation.

The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…

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.





Suggest a new Article!