从 XQuery 调用 JAVA 方法 [英] Calling JAVA Method from XQuery

查看:32
本文介绍了从 XQuery 调用 JAVA 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 XQuery 调用 JAVA 方法.但它失败了

I am trying to call a JAVA method from XQuery. But it is failing

我已经声明了这个类:

declare namespace b64 = "java:java.util.Base64";

我这样称呼它:

(: Encode a string into Base64 :)
declare function javautil:encodebase64($in as xs:string) as xs:string {
    b64:getEncoder().encodeToString($in)
};

(: Decode a string from Base64 :)
declare function javautil:decodebase64($in as xs:string) as xs:string {
    b64:getDecoder().decode($in)
};

但我收到错误:

XPST0003: XQuery syntax error in #...64:getEncoder().encodeToString#:
expected "}", found "."

我不确定是语法问题还是其他问题.我在谷歌上寻找例子.但其中大多数仅限于单个方法调用.不是像 getEncoder().encodeToString() 这样的链式方法.任何帮助,将不胜感激.谢谢!

I am not sure if its a syntax problem or something else. I looked for examples on Google. But most of them are restricted to a single method call. Not chained method like getEncoder().encodeToString(). Any help would be appreciated. Thanks!

推荐答案

您将 Java 语法与 XQuery 语法混淆了 - 没有."XQuery 中的运算符.

You're confusing Java syntax with XQuery syntax - there's no "." operator in XQuery.

在 XQuery 1.0 中,我希望看到 b64:decode(b64:getDecoder(), $in),或在 XQuery 3.1 b64:getDecoder() =>b64:decode($in)

In XQuery 1.0 I would expect to see b64:decode(b64:getDecoder(), $in), or in XQuery 3.1 b64:getDecoder() => b64:decode($in)

这篇关于从 XQuery 调用 JAVA 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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