@@ -5,7 +5,8 @@ xquery version "3.1";
5
5
:
6
6
: @version 2.1
7
7
: @author Wolfgang Meier
8
- : @contributor Adam retter
8
+ : @contributor Adam Retter
9
+ : @contributor Joe Wicentowski
9
10
:)
10
11
module namespace templates="http://exist-db.org/xquery/templates" ;
11
12
@@ -30,6 +31,7 @@ declare variable $templates:NOT_FOUND := QName("http://exist-db.org/xquery/templ
30
31
declare variable $templates:TOO_MANY_ARGS := QName ("http://exist-db.org/xquery/templates" , "TooManyArguments" );
31
32
declare variable $templates:PROCESSING_ERROR := QName ("http://exist-db.org/xquery/templates" , "ProcessingError" );
32
33
declare variable $templates:TYPE_ERROR := QName ("http://exist-db.org/xquery/templates" , "TypeError" );
34
+ declare variable $templates:MAX_ARITY := 20 ;
33
35
34
36
declare variable $templates:ATTR_DATA_TEMPLATE := "data-template" ;
35
37
@@ -187,7 +189,11 @@ declare %private function templates:call($classOrAttr as item(), $node as elemen
187
189
if (exists ($call)) then
188
190
templates:call-by-introspection ($node, $parameters, $model, $call)
189
191
else if ($model($templates:CONFIGURATION)($templates:CONFIG_STOP_ON_ERROR)) then
190
- error ($templates:NOT_FOUND, "No template function found for call " || $func)
192
+ error ($templates:NOT_FOUND,
193
+ "No template function found for call " || $func ||
194
+ " (Max arity of " || $templates:MAX_ARITY ||
195
+ " has been exceeded in searching for this template function." ||
196
+ "If needed, adjust $templates:MAX_ARITY in the templates.xql module.)" )
191
197
else
192
198
(: Templating function not found: just copy the element :)
193
199
element { node-name ($node) } {
@@ -294,6 +300,8 @@ declare %private function templates:resolve($arity as xs:int, $func as xs:string
294
300
return
295
301
if (exists ($fn)) then
296
302
$fn
303
+ else if ($arity ge $templates:MAX_ARITY) then
304
+ ()
297
305
else
298
306
templates:resolve ($arity + 1 , $func, $resolver)
299
307
};
0 commit comments