0
votes

I have created a tool to create XML files however I now need to validate the generated XML against an SCH (Schematron) file. However, none of the tools I have tried have worked.

As the namespace, URI's can't be accessed.

Is there any tool available that I can use for java or javascript to validate this XML against an SCH file or an XSLT file?

Any answers would be greatly appreciated Many thanks ~ Ben

1

1 Answers

0
votes

A common approach is to use the XSLT-based process described on the Schematron web site at http://schematron.com/front-page/the-schematron-skeleton-implementation/ .

The process transforms the Schematron schema into an XSL document, then uses that XSL document to transform the document you are trying to validate. The end result is an SVRL (Schematron Validation Report Language) document that describes any validation issues found.

A shell script process would look like this:

To transform the Schematron schema into XSL:

xslt -stylesheet iso_dsdl_include.xsl  theSchema.sch > theSchema1.sch
xslt -stylesheet iso_abstract_expand.xsl  theSchema1.sch > theSchema2.sch
xslt -stylesheet iso_svrl_for_xsltn.xsl  theSchema2.sch > theSchema.xsl

To validate an XML document:

xslt -stylesheet theSchema.xsl  myDocument.xml > myResult.xml

The process could be done in Java using an XSLT library. If your Schematron schema uses XSLT2/Xpath 2, then I would recommend using the Saxon XSLT library.