1

The XSLT specification has always said that the document() and doc() functions MAY throw a dynamic error when the document cannot be loaded from the URL (e.g. 404 not found) and in the browser's XSLT processors as well as Saxon (the version I keep using even after a decade is 8.1.1) usually that has all been that way. But now trying Saxon-JS, I see an exception is thrown. Now I need to use the new fn:doc-available function which, however, isn't in XSLT/XPath 2.0! So I have to break my backward compatibility of my XSLT code because of that new super-strict behavior.

Is there some option in Saxon-JS where the old behavior of fn:document can be selected as an option?

2
  • There is a function doc-available in XPath 2 and later. I don't see how the use of Saxon 8.1.1, some version of Saxon from before even XSLT 2 became a W3C standard, is relevant to claim that "XSLT 2.0" did not throw an error. And Saxon-JS is not based on Saxon Java 8.1.1 or Saxon Java at all, so I don't understand the request to select the "old behaviour". Commented Apr 19, 2022 at 13:00
  • 1
    Closer to two decades, actually: Saxon 8.1.1 came out in October 2004 (markmail.org/thread/vvklrjp4id4rbaav) Commented Apr 19, 2022 at 13:44

1 Answer 1

0

In the case of the doc() function the spec is pretty clear that a dynamic error should be thrown (although a function like this that interacts with the external environment always leaves some scope for vendor interpretation).

For document() the error handling has always been at vendor option. If an error occurs, the processor has the option of not reporting the error, but simply returning nothing. In Saxon on the Java platform, we've chosen to delegate the choice to the user as a configuration option. It's difficult to trace 20 years of history, but I think it's entirely likely that the default has changed at some point in time; certainly in modern Saxon releases, the default is to throw the error, and now that try/catch is available in 3.0 this certainly seems the most appropriate choice.

For SaxonJS, keeping the product small and simple is desirable, and we want to have as few configuration options as possible. Given that the "recovery" option here exists only for backwards compatibility, and that the requirement can be met using try/catch (or doc-available()), it seems unnecessary to provide another way of controlling it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the prompt authoritative answer. Even if it isn't what I wanted to hear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.