A template function can only have 10 parameters.
Closed this issue · 7 comments
declare function app:hello($a as node()*, $model as map(*), $p1 as xs:string?,
$p2 as xs:string?, $p3 as xs:string?, $p4 as xs:string?, $p5 as xs:string?,
$p6 as xs:string?, $p7 as xs:string?, $p8 as xs:string?, $p9 as xs:string?) {
'hello world'
};
raises the error,
templates:NotFound No template function found for call app:hello [at line 189, column 85, source: /Applications/exist_dev/webapp/WEB-INF/data/expathrepo/shared-0.4.0/content/templates.xql]
whereas removing one of the $p parameters does not.
We are currently working with a query function with 12 parameters, so more parameters should be allowed.
The current version of templates.xql allows 15 parameters. It is easy to support an arbitrary number of parameters if we switch to the new fn:apply function, but this will break backwards compatibility. I'm currently extending the package repo to properly handle version incompatibilities. Once this is done, we can release a new templating package without limits.
I see that, but I still have to say that it breaks after 10 parameters. And it's not just my own setup: I just tried it out in the Shakespeare app on exist-db.org. Note that the error comes from templates:call(), not from templates:call-with-args() (then it should be "Too many arguments to function …).
As I said, it's easy to fix with the help of arrays and fn:apply. I just committed the corresponding changes to a branch:
https://github.com/eXist-db/shared-resources/tree/xq31-templating
You may copy templates.xql from there. Before we can officially update the app, I have to finish some work to ensure compatibility.
This is fine, but it does not really help, for the error comes from templates:call(), not templates:call-with-args(). The error still occurs after shifting in the new templates.xql.
Yes, I understand. templates:call calls templates:resolve, which contained this:
if ($arity > 15) then
()
else
I removed this in my version because it's no longer needed. It does work for me. Note that you also have to replace templates.xql in the EXIST_DATA/expathrepo dir, so it gets picked up by the loader.
Even though 15 parameters were made possible a long time ago in templates:call-with-args(), templates:resolve() at first ruled this out, limiting the arity to 10. This was fixed 6 months ago in eXist-db/shared-resources#13, but this commit is not included in the latest xar, which is from 2014-07-21. This explains the error. What is needed is therefore an up-to-date xar.
move to correct repo