Add exception handling to schematron

This should cover W3C XML Schema, Relax NG and DTD related problems.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Add exception handling to schematron

Post by Patrik »

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: 364
Joined: Thu Jul 01, 2004 12:29 pm

Re: Add exception handling to schematron

Post by tavy »

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: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Add exception handling to schematron

Post by Patrik »

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: 364
Joined: Thu Jul 01, 2004 12:29 pm

Re: Add exception handling to schematron

Post by tavy »

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
Post Reply