I need to validate XML files against a wide array of constraints: type and/or format of element's text, co-occurrences, date comparisons and date math, as well as some user defined rules from a database (i.e. element X can only contain child elements A, B, and C) and I am not sure how to go about it.
The current incarnation of this application enforces these constrains via Perl, through I feel that the Perl code duplicates a lot of the functionality that I would get out-the-box using XSD or RELAX NG. Unfortunately using either of these would result in error messages that would be cryptic to the end users. Mapping these cryptic message to something friendly seems impossible (other than providing line/col numbers).
Then there's Schematron. It allows me to generate friendly messages and check constraints that the aforementioned schema langs can't. Unfortunately, type/format checking and date math become big XSLT template hacks.
Now I'm not sure what to do.
A combination between Schematron and, say, RELAX NG, seems to be the best approach, yet the errors generated by RELAX NG make it impossible to provide anything informative to the end user.
I had hoped to use a master schema template that would be modified based on the custom rules in the DB.
Is keeping the original approach the best, or should I move forward using Schematron/RELAX NG and wrestling the format/type enforcement into XSLT templates?