element-wise validation report with schematron

Once a document has been validated via shematron, is there a way to get the validation report for a specific element in the document? With store_report=True, I can find all the elements in the validation_report with a "location" attribute (which is an xpath) and see if any of them point to the element in question. If they do, the child "text" element in the validation_report contains the assertion/report message I'm looking for. If no locations point to the element, can I assume the element passed validation? I plan to use this element-wise validation to present the user with a colour-coded tree (PySide treeview with delegate) of the document with valid elements in green and invalid elements in red. To make such a tree I would have to search the validation report "len(elements)" times and re-do the whole process after any change to the document. Is there an easier/faster way to get element-wise validation? Thank you, Ben

Von: Ben Orr Once a document has been validated via shematron, is there a way to get
Hi, "lxml" <lxml-bounces@lxml.de> schrieb am 02.05.2014 23:36:25: the
validation report for a specific element in the document? With store_report=True, I can find all the elements in the validation_report with a "location" attribute (which is an xpath) and see if any of them point to the element in question. If they do, the child "text" element in the validation_report contains the assertion/report message I'm looking for. If no locations point to the element, can I assume the element passed validation?
IIRC the "SVRL" only reports the fired rules and plus the rule violations, unless extra diagnostics output has been activated (sch:report elements). So yes, if there's no <svrl:failed-assert ... location="/path/to/test/violating/node"></svrl:failed-assert... with a location path for a certain node in the validation report this would mean that the node in question did not violate a rule. But I've gotten a bit rusty on schematron so you might want to check the standard and/or svrl implementation for details. I realize that a simple example for a validation report would be a nice addition to the lxml docs, especially since the main schematron site doesn't provide obvious examples, either (more here, though: http://www.dpawson.co.uk/schematron/index.html).
I plan to use this element-wise validation to present the user with a colour-coded tree (PySide treeview with delegate) of the document with valid elements in green and invalid elements in red. To make such a tree I would have to search the validation report "len(elements)" times and re-do the whole process after any change to the document.
Is there an easier/faster way to get element-wise validation?
Default to green/valid and set all location paths found (<svrl:failed-assert location"...">) to red/invalid? I.e. search the validation report for svrl:failed-assert. Best regards Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart
participants (2)
-
Ben Orr
-
Holger Joukl