Runtime Errors from parse-xml not catched

Having trouble installing Oxygen? Got a bug to report? Post it all here.
fsteimke
Posts: 80
Joined: Tue Jan 01, 2013 3:19 pm

Runtime Errors from parse-xml not catched

Post by fsteimke »

Hi,
i have to parse strings with escaped markup, contained in the @body attribute of an ownedComment Element. An example woud be @body='<p>test</p>'

In order to deal with parser errors, which could be caused by typos in the string above, i'd like to use the new try/catch mechanism of XSLT 3.

So i wrote something along these lines:

Code: Select all


<xsl:try>
<xsl:variable name="doc" as="document-node()" select="parse-xml-fragment(db:escapeEntities($string))"/>
<xsl:apply-templates select="$doc/*" mode="db-ns"/>
<xsl:catch>
<db:para>ERROR</db:para>
</xsl:catch>
</xsl:try>
Everything works fine as long as the input can be parsed without errors. But if it is not well-formed, or if it contains references to undeclared entities, the runtime error is not catched. I would like to get the DocBook para Element with error as content, but instead the transformation fails with an error message from saxon which tells me, why the string cannot be parsed.

This is a bug, isn't it?

Oxygen 17.0, build 2015051321 on Windows 7 64 bit with Saxon EE 9.6.0.5. Stylesheet Version is 3.0.

Sincerely,
Frank
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Runtime Errors from parse-xml not catched

Post by radu_pisoi »

Hi,

I have tried to reproduce the problem by running the transformation with Saxon EE 9.6.0.5 from the command line. In this case, the transformation behavior is the expected one. If the document to be parsed is not wellformed then the result of the try instruction is given by the evaluation of the catch clause.

So, this seems to be an oXygen specific issue that comes from the interaction between oXygen and the Saxon processor.
I will register it to our issue tracking system to be resolved in a future oXygen version.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dsewell
Posts: 125
Joined: Mon Jun 09, 2003 6:02 pm
Location: Charlottesville, Virginia USA

Re: Runtime Errors from parse-xml not catched

Post by dsewell »

There is a similar problem with XQuery and fn:parse-xml():

Code: Select all

xquery version "3.0";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:omit-xml-declaration "true";

try {
let $xml-string := '<para>Paragraph</p>'
return parse-xml($xml-string)
}
catch * {
<error>{$err:code}</error>
}
If you run that with standalone Saxon 9.6.0.7, the output is
<error>err:FODC0006</error>
and a message is sent to standard error
SXXP0003: Error reported by XML parser: The element type "para" must be terminated by the
matching end-tag "</para>".
If I run the code in oXygen, I get only the "Transformation problems" message reporting "Error reported by XML parser", but there is no output from the transformation.

I hope that behavior can be fixed -- I also need to use fn:parse-xml() with try/catch in order to find bad quoted HTML that looks like my variable above.
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Runtime Errors from parse-xml not catched

Post by radu_pisoi »

Hi,

Yes, it seems to be a similar problem. The transformation execution should not be stopped when an dynamic error is caught by try/catch instruction.

I will also register this case in our issue tracking system.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: Runtime Errors from parse-xml not catched

Post by Radu »

Hi,

Just to update this thread, the issue should be fixed in Oxygen 18.1 which we released a couple of weeks ago.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dsewell
Posts: 125
Joined: Mon Jun 09, 2003 6:02 pm
Location: Charlottesville, Virginia USA

Re: Runtime Errors from parse-xml not catched

Post by dsewell »

Excellent, thanks for the update and the fix.
Post Reply