Validating XML
Problem:
I want to be able to import XML (say, using %XML.Reader) to Caché objects permissively (ignoring invalid/unexpected tags/attributes), but also to validate the same XML and list any/all invalid tags/attributes that it contains.
Possible path to a solution:
XML-enabled classes (see documentation) inherit XMLIGNOREINVALIDTAG and XMLIGNOREINVALIDATTRIBUTE parameters that can customize the treatment of unexpected tags/attributes in XML import. One heavy-handed option would be to have parallel sets of classes representing the same XML document, one with both parameters set to 0 and one with both parameter set to 1. (And different XML namespaces, of course.) But this seems like a lot of work, and I strongly suspect that %XML.Reader would give up at the first error, which doesn't help the user much if there are lots of problems in the XML document. Ideally there would be some runtime option to make a list of the times XMLIGNOREINVALIDTAG=1/XMLIGNOREINVALIDATTRIBUTE=1 made a difference.
Any thoughts/recommendations? Has anyone done this before in Caché?
Hi Tim,
I'm highly interested to see this result.
I tried to do something similar recently to to be able to feed back to the sender what was wrong if something was wrong.
I failed to get the combinations of params for XERCES parser right. XMLIGNORE* worked OK but was not so useful.
You might have a shorter link to contact Marvin Tenner then me.

Thanks Eduard, this looks promising. I'll try it out and post any interesting results.
I did not test this approach, but something along these lines can help. The general idea is that SAX parser can validate against the XML schema, and we can use that.
1. Generate schema from your XML enabled classes.
2. Call %XML.Reader:Open method, and provide it with your xml data and schema:
3. sc should contain errors, $$$SAXFULLDEFAULT is defined in %occSAX and contains several possible values:
SAXFULLDEFAULT = All flags except SAXVALIDATIONSCHEMAFULLCHECKING.
Maybe try change the flags , but defaults seems to do what you need.
If you actually try this approach can you please post if it works or not?