1

Using ISO Schematron (with XSLT1), how can the XPath for the matched context of a rule be obtained in the validation report?1

It obviously makes no sense to try and get the XPath for each assertion test, but a means to re-find the applied context element would be very handy for automated processing, such as field highlighting, if exposed to the application layer.


1 I found the answer today, after a good bit of searching where I found the "obvious" solution only by a stumble, but not by the expected keywords - Schematron definitely had its heyday in 2003/2007. I will self answer (in a day or two) if there are no submitted answers, but I would prefer a good submitted answer.

  • 1
    `svrl:failed-assert/@location`? – Max Toro Feb 23 '13 at 00:12
  • @MaxToro Yup, post that with an answer - with an applicable link to the specification (and excerpt) for free points. My searches were thrown off with the (overweight) abundance of such xslt functions/templates - which does not work here at all. –  Feb 23 '13 at 00:14

2 Answers2

0

I would say the answer is using SVRL and therefore the SVRL enabled stylesheet to process the Schematron rules. Also answered here: https://stackoverflow.com/a/12896201/227785

Community
  • 1
  • 1
Clemens
  • 1,744
  • 11
  • 20
0

I appreciate that this is a slightly late answer, but for lowly personal reasons I would like to note that there is another Schematron implementation that implemented precisely this feature, mentioned at http://xml.ascc.net/schematron/1.3/old-index.html#implementations

schematron-xml: Generates XML with an attribute location containing an XPath to the location of the suspect element. Also available in version for documents with no namespace (Uses new architecture).

schematron-xml is surely obsolete now, but if you're interested in how to generate the XPath for a matched context, see the pleasingly simple template named "mypath" in http://xml.ascc.net/schematron/1.3/FrancisNorton/sch-xml.xsl.

Francis Norton
  • 674
  • 1
  • 8
  • 16