如何在Saxon中使用XPath 3.1? [英] How to use XPath 3.1 in Saxon?

查看:94
本文介绍了如何在Saxon中使用XPath 3.1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用XPath 3.1语法,但由于某种原因,Saxon输出错误:

I am currently using XPath 3.1 syntax but for some reason Saxon outputs the error:

要使用XPath 3.1语法,必须配置XPath解析器以对其进行处理.

我该怎么做?

非常感谢!

推荐答案

如果您使用的是s9api API,请使用 XPathCompiler.setLanguageVersion("3.1").

If you're using the s9api API, use XPathCompiler.setLanguageVersion("3.1").

如果您使用的是JAXP,那可能是个坏主意,因为JAXP XPath API无法处理XPath 3.1数据类型的丰富性;但如果需要,则将XPath对象强制转换为net.sf.saxon.xpath.XPathEvaluator;然后调用getStaticContext().setXPathLanguageLevel().

If you're using JAXP, that's probably a bad idea because the JAXP XPath API can't handle the richness of XPath 3.1 data types; but if you must, cast the XPath object to net.sf.saxon.xpath.XPathEvaluator; then call getStaticContext().setXPathLanguageLevel().

在Saxon 9.7中,支持的默认XPath语言级别是3.0,因为这是已达到推荐"状态的最新W3C规范.

In Saxon 9.7 the default XPath language level supported is 3.0, because that's the latest W3C spec that has reached Recommendation status.

更新

在Saxon 9.8中,XPath 3.1是默认设置.

In Saxon 9.8, XPath 3.1 is the default.

这篇关于如何在Saxon中使用XPath 3.1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆