Add exception handling to schematron

This should cover W3C XML Schema, Relax NG and DTD related problems.
Patrik
Posts: 227
Location: Hamburg/Germany

Add exception handling to schematron

Wed Apr 08, 2015 9:58 am

Hi,

currently it can be quite difficult to find the responsible code when an exception occurs during schematron validation.

Thus, I modified the skeleton script to support queryBinding "xslt3". In this mode the execution of each pattern is surrounded by an xsl:try. In the xsl:catch it reports the error description together with the id/title of the pattern and also finds the responsible schematron code (by evaluating $err:line-number and identify the element in the stylesheet itself with the same line number and use the @oxy:elementLine).

This works fine when running the generated xslt manually. However, when overwriting the builtin skeleton stylesheets and validate my xml, it complains about "Unknown XSLT element: try". This confuses me, since I configured oXygen to use Saxon EE (which supports xslt 3.0) for schematron validation and the generated stylesheet has version set to 3.0!?

Is it not possible to use XSLT v3.0 within schematron or is there anything I can do about it?

Thanks and regards,
Patrik
tavy
Posts: 137

Re: Add exception handling to schematron

Wed Apr 08, 2015 5:29 pm

Hi Patrik,

You need to leave the query binding set to "xslt2". Just make sure that the result stylesheet has 3.0 version.
For this you just need to change the the following line from skeleton:

Code: Select all

<xsl:attribute name="version">2.0</xsl:attribute>

to:

Code: Select all

<xsl:attribute name="version">3.0</xsl:attribute>


Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 227
Location: Hamburg/Germany

Re: Add exception handling to schematron

Thu Apr 09, 2015 8:27 am

Hi Tavy,

keeping queryBinding on xslt2 and adding an additional parameter "exception-handling" instead indeed solved this problem. Thanks for that.

Unfortunately, now the next problem arised: When executing the generated script during validation, document('') does not return the xslt code (which I need to interpret $err:line-number for identifying the actual line number in the schematron file) but the schematron code. Do you know any way to get access to the xslt code from within the xslt script?
(My workaround would be to to duplicate the code during xslt generation and put it into a variable.)

Thanks and regards,
Patrik
tavy
Posts: 137

Re: Add exception handling to schematron

Thu Apr 09, 2015 5:16 pm

Hi Patrik,

Yes, we set the systemId of the schematron during validation for the stylesheet. This is because we what that any reference to document('') from schematron to be translated to the schematron system ID. The stylesheet is a temporarily file, so we don't want that document('') to refer to a temporarily file.

Best Regards,
Octavian

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests