11

I've been looking around for at a way to make some more advanced business rule validation of XML documents. So far Schematron seems to be able to do, what I need.

I've been looking around, and the few libraries I've found was very old and seemingly not supported any longer. Was Schematron only "hot" in 2002? Are there any libraries that can do the validation in C# - or how do I do it?

Or are there others that can do the advanced validation and have C# libraries and are standardized?

reinierpost
  • 8,425
  • 1
  • 38
  • 70
asgerhallas
  • 16,890
  • 6
  • 50
  • 68
  • 1
    I know this is an *old* question, but: did you ever find a solution? I am now in this situation - I use XSD for schema validation, but I would like to use an approach like Schematron for business rules. I actually didn't know about it until I started researching "making my own XSLT validator", and I'd prefer to just use an exiting validator, should a practical implementation of Schematron (or other) exist .. –  Feb 19 '13 at 22:02

1 Answers1

13

For what it's worth, this has been my experience...

I've had moments where I wish schemas could do more along the lines of business rule validation. However, in my experience a schema is there to define a data contract (format, types, etc)... NOT to enforce business rules. Trying to make it more than that runs into all sorts of problems and may be why Schematron seems to have died down in its popularity (possibly bad assumption that I cannot backup).

To get around this, one can generally do a two pass approach:

  • Validate the xml structure/data types, etc using schema validation.
  • Apply business rules checking against the xml (in normal c# code).

I understand if you're wanting to do an all-in-one approach to validation but attempting to use schema for this causes more headaches in the long run. In the end you'll end up having finer control over your business rule checking by isolating to code.

Scott Saad
  • 17,962
  • 11
  • 63
  • 84
  • 5
    It's worth a lot! I have had some of the same thoughts my self, but the problem is not so much that I need an all-in-one approach - it's that I need a "validation package" that can be shared among many applications - many of which I'm not the affiliated with. So it's more the need for some kind of open standard for business rule validation on XML. – asgerhallas Apr 24 '09 at 21:34
  • This is exactly what I did after messing about with Schematron after months. – scope_creep Jun 06 '10 at 02:34
  • 5
    Its also worth noting that Schematron is now an ISO standard. – scope_creep Jun 06 '10 at 02:36