Hi all,
    Thanks for your answers. Actually I have to use Java binding to call some methods, the code which I provided is just an example. I wanted to call this method: 
public ProcessingResult process(List<Document> documents,
                                String queryHint,
                                Class<?>... processingComponentClasses)
                         throws ProcessingException
(https://get.carrot2.org/stable/javadoc/org/carrot2/core/Controller.html#process-java.util.List-java.lang.String-java.lang.Class...-)

On 4/23/2019 13:51, Christian Grün wrote:
And a complementary remark: You can also use the built-in function
out:format (it will be optimized better than Java functions):

  let $string := 'Format string: %1$d - %2$s'
  let $i := 1
  let $j := 'text'
  return out:format($string, $i, $j)

For formatting numbers, XQuery provides the function fn:format-number:

  format-number(1, '0000')

Best,
Christian



On Tue, Apr 23, 2019 at 6:41 AM Johannes Bauer <johannes.bauer@tanner.de> wrote:
Hi Luan,

try this:

declare namespace java = "java:java.lang.String";

let $string := 'Format string: %1$d - %2$s'
let $i := 1
let $j := 'text'
let $args := ($i, $j)

return java:format($string, $args)

Best regards
Johannes

Am 23.04.2019 um 06:29 schrieb Luan Bui:

Hello all,
    How can I call a method with variable arguments in BaseX with Java binding? I am trying to do this:

        let $string := 'Format string: %1$d - %2$s'
    let $i := 1
    let $j := 'text'
    return Q{java.lang.String}format·java.lang.String·java.lang.Object*($string, $string, $i, $j)

However, I got the error: [XPDY0002] {java.lang.String}format·java.lang.Stri...: Context is undeclared.
Thank you for your time.




--
With best regards,

Bui The Luan (Mr.)
Lead Software Developer

----------------------------------------------------
TANNER Vietnam Ltd.
43D/8, Ho Van Hue Street
Ward 9, Phu Nhuan Dist
Ho Chi Minh City, Vietnam

Tax Code: 0303 620 482

tel. +84 28 3997 3452 - 103
fax. +84 28 3997 3465
mobi. +84 168 688 0001
luan.bui@tanner.de
http://www.tanner.vn

TANNER
          Vietnam
------------------------------------------------------------------------------