0

I have a set of XMLs along with XSD/Schematron documents for validation. I had to validate my XMLs against XSD (for data types/structure/schema validation) and this is straightforward. The challenging part is Schematron validation which is a customer requirement for business rules validation and etc.

How can i implement Schematron validation with C# and if possible is there any good/active framework/API for Schematron validation. What i found so far is outdated/inactive projects for Schematron validation which lacks documentation and API completeness. By the way i am successfully using several XML Editor applications (Oxygen etc.) to validate my documents against Schematron but i need to do that programmatically in C# and add this feature to a bigger project. Thanks in advance.

Ahmet
  • 1,045
  • 13
  • 28
  • You can't when generating the xml. But after generating the xml you can read it using the schema and if it reads correctly then you have validated it. – jdweng Jan 14 '18 at 10:47
  • @jdweng Needless to say I am not talking about an on the fly validation (i.e. while the xml is being generated); i am talking about a validation after the xml is generated. So what you are suggesting is to use the ordinary xml read with the Schematron (just like XSD). Am i correct? – Ahmet Jan 15 '18 at 08:22
  • Yes. The only way of validation during xml generation (on-the-fly) is to use xml serialization and reference the schema in the serialization. – jdweng Jan 15 '18 at 09:36

1 Answers1

1

Schematron has multiple format, which one are you working on? There is no framework in .net for it. Converting schematron to xslt and using it easy and stable way. Check this project for sch -> xslt: https://github.com/Schematron/stf/tree/master/iso-schematron-xslt2

mkysoft
  • 5,392
  • 1
  • 21
  • 30
  • I am talking about ISO Schematron format. I just wanted to know a framework/api rather than XSLT conversion method. Thanks. – Ahmet Jan 15 '18 at 08:23
  • You can find payed solution like altova sdk. – mkysoft Jan 15 '18 at 08:41
  • Payed solution does not applicable for us in this case. I had to go with using Java Schematron Validation technique and i called java jar from c#. – Ahmet Feb 18 '18 at 11:03
  • 1
    I think this is not good idea. Because java not using same environment (for example proxy for network) with .net. You can create dll from your jar package with IKVM for .net. https://www.ikvm.net/ – mkysoft Feb 18 '18 at 11:54