经过一番研究,我还没有找到解决方案,但很多人都遇到这个问题:
我正在尝试使用 Java 应用程序中的 XQuery 转换
net.sf.saxon.s9api
但是,在尝试编译 XQueryExecutable exec = compiler.compile(...));
我的 XQuery 时出现此错误:
Error on line 13 column 3 of AivPumaRequest.xquery:
XPST0081 XQuery static error near #... fn-bea:inlinedXML(fn:concat#:
Prefix fn-bea has not been declared
Error on line 44 column 102 of AivPumaRequest.xquery:
XPST0081 XQuery static error near #... div xdt:dayTimeDuration('P1D'#:
Prefix xdt has not been declared
Error on line 199 column 3 of AivPumaRequest.xquery:
XPST0081 XQuery static error near #... fn-bea:inlinedXML(fn:concat#:
Prefix fn-bea has not been declared
Error on line 282 column 4 of AivPumaRequest.xquery:
XPST0081 XQuery static error near #... {fn-bea:inlinedXML(fn:concat#:
Prefix fn-bea has not been declared
net.sf.saxon.s9api.SaxonApiException: Prefix fn-bea has not been declared
有没有办法静态包含此前缀,或者我缺少什么以便我的 XQuery 引擎 (SAXON) 找到该前缀?
最佳答案
您的问题的简单答案是,您可以在查询序言中使用声明命名空间前缀
declare namespace fn-bea = "http://some-appropriate-uri";
或者在 Saxon API 中使用
XQueryCompiler.declareNamespace("fn-bea", "http://some-appropriate-uri")
但这不会让您更进一步,除非 (a) 您知道将前缀绑定(bind)到哪个 URI,并且 (b) 您使具有这些名称的函数可供查询处理器使用。
对 xdt:dayTimeDuration 的引用表明,该查询是在 XQuery 仍是工作草案时编写的。例如,如果你看一下 2005 年的工作草案
https://www.w3.org/TR/2005/CR-xquery-20051103/
您将在第 2 部分中看到它使用内置前缀
xdt = http://www.w3.org/2005/xpath-datatypes
当 XQuery 1.0 成为推荐标准时,dayTimeDuration
数据类型已移至标准 XML 架构 (xs) 命名空间中,因此您可以简单地将“xdt”替换为“xs” -尽管您应该意识到该语言的语义也可能在一些小细节上发生变化。
至于fn-bea:inlinedXML
,前缀的选择向我表明这可能是 BEA 查询处理器中的内置供应商扩展,已被 Oracle 接管。此处的规范:
https://docs.oracle.com/cd/E13162_01/odsi/docs10gr3/xquery/extensions.html
说:
fn-bea:inlinedXML Parses textual XML and returns an instance of the XQuery 1.0 Data Model.
这表明该函数执行的操作与 XQuery 3.0 函数 fn:parse-xml()
非常相似,我建议您尝试在查询中进行替换。
关于java - OSB fn :bea Function using XQuery Engine in Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42929193/