简体   繁体   English

XSLT 3.0 fn:document() 在找不到 404 时抛出错误,而 XSLT 2.0、1.1 和 1.0 则没有 (Saxon-JS)

[英]XSLT 3.0 fn:document() throws error on 404 not found while XSLT 2.0, 1.1, and 1.0 did not (Saxon-JS)

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 (eg 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. XSLT 规范一直说当无法从 URL(例如 404 未找到)和浏览器的 XSLT 处理器以及 Saxon(版本 I)加载文档时,document() 和 doc() 函数可能会抛出动态错误即使在十年后继续使用 8.1.1)通常都是这样。 But now trying Saxon-JS, I see an exception is thrown.但是现在尝试 Saxon-JS,我看到抛出异常。 Now I need to use the new fn:doc-available function which, however, isn't in XSLT/XPath 2.0.现在我需要使用新的 fn:doc-available function,但是它不在 XSLT/XPath 2.0 中。 So I have to break my backward compatibility of my XSLT code because of that new super-strict behavior.因此,由于这种新的超严格行为,我必须打破我的 XSLT 代码的向后兼容性。

Is there some option in Saxon-JS where the old behavior of fn:document can be selected as an option? Saxon-JS 中是否有一些选项可以选择 fn:document 的旧行为作为选项?

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).doc() function 的情况下,规范非常明确应该抛出动态错误(尽管与外部环境交互的 function 总是留下一些 scope 供供应商解释)。

For document() the error handling has always been at vendor option.对于document() ,错误处理一直由供应商选择。 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.在 Java 平台上的 Saxon 中,我们选择将选择委托给用户作为配置选项。 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;很难追溯 20 年的历史,但我认为默认值很可能在某个时间点发生了变化; 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.当然在现代 Saxon 版本中,默认是抛出错误,现在try/catch在 3.0 中可用,这似乎是最合适的选择。

For SaxonJS, keeping the product small and simple is desirable, and we want to have as few configuration options as possible.对于 SaxonJS,保持产品小而简单是可取的,我们希望配置选项尽可能少。 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.鉴于此处的“恢复”选项仅用于向后兼容,并且可以使用try/catch (或doc-available() )满足要求,因此似乎没有必要提供另一种控制方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM