Project

Profile

Help

Bug #1872

closed

doc-available() fails with error on XML parse error

Added by Adrian Buza over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2013-08-27
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

The XPath specification for doc-available mentions that an error can be raised only if the used URI is not valid according to the rules applied by the implementation of fn:doc. Otherwise, if unsuccessful, the function should return false.

http://www.w3.org/TR/xpath-functions/#func-doc-available

One of our Oxygen users reported that this is not the case of Saxon 9.5 and doc-available raises a SXXP0003 error.

We've tested with these files:

bad.xml

<bad>content & stuff</bad>

test.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    version="2.0">
    <xsl:template name="start">
        <xsl:if test="doc-available('bad.xml')">
            <xsl:message>worked</xsl:message>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

When running Saxon 9.5.0.2 in the command line:

java -cp saxon9ee.jar net.sf.saxon.Transform -xsl:test.xsl -it:start

the transformation fails with an error:

Error on line 1 column 15 of bad.xml:
  SXXP0003: Error reported by XML parser: The entity name must immediately follow the '&' in
  the entity reference.
<?xml version="1.0" encoding="UTF-8"?>

I've also tested this with older versions of Oxygen/Saxon 9 and this seems to go back at least as far as Saxon 9.1.

Seems related to:

https://saxonica.plan.io/issues/89


Related issues

Related to Saxon - Bug #89: doc-available() outputs error message on XML parse errorClosed

Actions
Related to Saxon - Bug #1849: ValidationException reported to ErrorListener even if in try/catchClosedMichael Kay2013-07-20

Actions
Actions #1

Updated by O'Neil Delpratt over 8 years ago

  • Assignee set to Michael Kay
Actions #2

Updated by Michael Kay over 8 years ago

Yes, this is a reappearance of issue 89. In fact, the code that was added to fix the problem at that time has been commented out. The reason for this is that the old approach of setting a different ErrorListener in the Controller no longer works, because it isn't thread-safe (we need to suppress errors in this thread, but not in other threads of the same transformation).

Note that Saxon is reporting the error to the ErrorListener but runs to successful completion. However, I think we found that oXygen treats any call to the ErrorListener as fatal (certainly a call to the fatalError() method).

Note also that the same thing happens with a call to doc() inside try/catch: the error is reported to the ErrorListener, but Saxon continues to successful completion.

See also https://saxonica.plan.io/issues/1849

Actions #3

Updated by Michael Kay over 8 years ago

  • Status changed from New to In Progress
  • Priority changed from Low to Normal
Actions #4

Updated by Michael Kay over 8 years ago

  • Status changed from In Progress to Resolved
  • Found in version changed from 9.5.0.2 to 9.5

I have fixed this for the doc-available() case by setting a new ErrorHandler in the ParseOptions, which is set to not call the ErrorListener in the event of a parse error. This isn't a perfect solution because it can interact with error handling defined by a user-written URIResolver, but it will handle the common case. It doesn't solve the try/catch problem.

Actions #5

Updated by Adrian Buza over 8 years ago

Michael Kay wrote:

Note that Saxon is reporting the error to the ErrorListener but runs to successful completion. However, I think we found that oXygen treats any call to the ErrorListener as fatal (certainly a call to the fatalError() method).

Note also that the same thing happens with a call to doc() inside try/catch: the error is reported to the ErrorListener, but Saxon continues to successful completion.

See also https://saxonica.plan.io/issues/1849

Thank you for pointing this out. When I tested this, I didn't realize that it runs to successful completion.

You are right that oXygen treats any transformation error as fatal. It allows the transformation to finish, but if an error was raised, it discards the result. I've logged this problem on our issue tracking tool to be resolved in the next release of oXygen.

Actions #6

Updated by O'Neil Delpratt over 8 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.2

Bug fix applied in the Saxon maintenance release 9.5.1.2

Please register to edit this issue

Also available in: Atom PDF