Hi
I can successfully create an object instance of https://www.stringtemplate.org/api/index.html when using the parameter-less default init:
declare namespace ST = 'java:org.stringtemplate.v4.ST'; let $template := "Hello <who>" let $stInstance := ST:new($template) let $call := ST:add($stInstance, "who", "World!") return ST:render($stInstance)
Template delimiters can be changed by supplying left and right delimiters (type char) upon init (by default ST4 uses < and > as template delimiters). The signature for this would be:
ST(java.lang.String template, char delimiterStartChar, char delimiterStopChar)
Documentation is at https://www.stringtemplate.org/api/org/stringtemplate/v4/ST.html#ST-java.lan...
So I defined the types at invocation, but executing following code I get an error.
declare namespace ST = 'java:org.stringtemplate.v4.ST'; let $template := "Hello $who$" let $stInstance := ST:new·java.lang.String·char·char($template,"$","$") let $call := ST:add($stInstance, "who", "World!") return ST:render($stInstance)
The error is:
[XPTY0004] java.lang.IllegalArgumentException: argument type mismatch. Caused by: org.stringtemplate.v4.ST(String, String, String).
The query plan of this unsuccessfull invocation is:
<QueryPlan compiled="true" updating="false"> <GFLWOR type="item()*"> <Let type="item()*" name="$stInstance" id="1"> <DynJavaConstr name="org.stringtemplate.v4.ST" type="item()*"> <Str type="xs:string" size="1">Hello $who$</Str> <Str type="xs:string" size="1">$</Str> <Str type="xs:string" size="1">$</Str> </DynJavaConstr> </Let> <List type="item()*"> <ProfVoid name="prof:void" type="empty-sequence()" size="0"> <DynJavaFunc name="org.stringtemplate.v4.ST:add" type="item()*"> <VarRef type="item()*" name="$stInstance" id="1"/> <Str type="xs:string" size="1">who</Str> <Str type="xs:string" size="1">World!</Str> </DynJavaFunc> </ProfVoid> <DynJavaFunc name="org.stringtemplate.v4.ST:render" type="item()*"> <VarRef type="item()*" name="$stInstance" id="1"/> </DynJavaFunc> </List> </GFLWOR> </QueryPlan>
I can see no deviation from https://docs.basex.org/wiki/Java_Bindings#Functions_and_Variables in my code. What am I doing wrong? Thanks.