The fn:doc-available() function is returning en error when the URI contains non-well-formed XML.
The fn:doc-available() function should return false() when the URI cannot return a document node. See https://www.w3.org/TR/xpath-functions-31/#func-doc-available.
The following query:
xquery version "3.1";
fn:doc-available("https://www.kingjamesbibleonline.org/Genesis-Chapter-1_Original-1611-KJV/")
... returns the following error:
err:FODC0005 An error occurred while parsing https://www.kingjamesbibleonline.org/Genesis-Chapter-1_Original-1611-KJV/: Open quote is expected for attribute "lang" associated with an element type "html". [source: xquery version "3.1"; fn:doc-available("https://www.kingjamesbibleonline.org/Genesis-Chapter-1_Original-1611-KJV/")]
Saxon and BaseX both return false(). QT3's tests for this function (https://dev.w3.org/cvsweb/2011/QT3-test-suite/fn/doc-available.xml?rev=1.9;content-type=text%2Fx-cvsweb-markup) don't seem to include a test for this possibility, but I believe the expected behavior is clear enough from the spec.
It was closed without test, reopen...
@shabanovd It is not possible to write an automated XQuery Test without introducing external dependencies. As such the test will need to be manual, which I have done, and which you could also do. Re-opening this issue makes no sense as the issue has been fixed, you can confirm that for yourself by testing it. So I am again closing this issue.
@adamretter I tested your fix in develop 0151784a7 and can confirm it fixes the issue as reported. Many thanks!
Seems there has been a regression here, testing on 3.5.0
@tuurma do you still have an issue on 3.5.0? If so, how do I reproduce it? Let me know, I am happy to fix...
@adamretter I tested using @joewiz's example above
fn:doc-available("https://www.kingjamesbibleonline.org/Genesis-Chapter-1_Original-1611-KJV/")
and I am getting FODC0005 as he described
@tuurma Okay I will take a look...
@tuurma Just sent a PR for your issue. Please ask @wolfgangmm to merge before tomorrow 12:00 UTC.
so what wil fn:doc-available() return is it points to a collection? false() or the exception?