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.

3
  • 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. Commented Jan 14, 2018 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? Commented Jan 15, 2018 at 8: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. Commented Jan 15, 2018 at 9:36

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

4 Comments

I am talking about ISO Schematron format. I just wanted to know a framework/api rather than XSLT conversion method. Thanks.
You can find payed solution like altova sdk.
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#.
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. ikvm.net

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.