0
votes

I would like to highlight certain parts of XML documents after using multiple validation techniques. Locating XSD validation failures in the XML poses no problem, the erroneous lines can be tracked. However, some validation steps are done by Schematron assert and report statements. When I send back the current XPath location when the assert/report statement was fired by using diagnostic elements I can only get back the root even when the context is very specific for the statement.

Is there any way to get either line number or XPath string to locate where the Schematron assert statement was fired?

1
What validation tool or library do you use Schematron with? Tools like Xerces will always point to the specific point in the document where the assertion failed.Mathias Müller
Actually I use C# to extract Schematron rules from xsd files and then using C# commands to validate for both XSD and Schematron and then I read the validation messages for both. I thought that there might be an option in the Schematron assert/report statement with which I could call the XPath location easily but I haven't found such option.Pydan

1 Answers

1
votes

In the svrl (Schematron Validation Report Language) report there is a 'location' attribute which returns the context of the assert/report statement. The last bit of the path can be collected by utilizing diagnostic elements and returning the current node. This way cleaning the report text and combining it with the diagnostic it is still possible to save the user from lengthy error messages and getting the parts that can be used to assemble the XPath of the fired assert/report statement.

<sch:diagnostics>
    <sch:diagnostic id="testDiagnostic">
        <sch:name path="."/>
    </sch:diagnostic>
</sch:diagnostics>

<sch:rule context="//ELEMENT1[ELEMENT2/ELEMENT3 = 'TRIAL TEXT']/ELEMENT4">
    <sch:assert test="ELEMENT5[@name = 'TRIAL TEXT2' and @type = 'TRIAL TEXT3']" diagnostics="testDiagnostic">TEST FEEDBACK.</sch:assert>
</sch:rule>