Runtime Errors from parse-xml not catched
Posted: Wed Aug 12, 2015 8:35 am
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:
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
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>
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