Thanks a lot ! it solved it. I had tried to change the view file to xquery, but i dont’t know why, i didn’t test with a variable declaration at first. It works with individual variable declaration (`view1.xq`), but I can’t get back the map itself (in `view2.xq`). Is it a consistent behavior ? Am I missing some Xquery’subtleties here ? Emmanuel ```xquery xquery version "3.0" ; module namespace test = 'test.test'; import module namespace xquery = "http://basex.org/modules/xquery"; declare function test:render($template as xs:string, $map as map(*)){ xquery:invoke($template, $map) }; declare %restxq:path('/test') %restxq:GET function test:test(){ let $map := map{ "greeting" : "hello", "who": "world"} return test:render('view1.xq', $map ) }; declare %restxq:path('/test2') %restxq:GET function test:test2(){ let $map := map{ "greeting" : "hello", "who": "world"} return test:render('view2.xq', $map) }; ``` view1.xq ```xquery xquery version "3.0" ; declare variable $greeting external; declare variable $who external; <div>{$greeting, $who}</div> ``` view2.xq ```xquery xquery version "3.0" ; declare variable $map as map(*) external; <div>{map:get($map, 'greeting')}</div> ``` Le 17 oct. 2014 à 19:03, Emmanuel Chateau <emchateau@laposte.net> a écrit :
Hi,
I’ve been trying to use the templating proposed by Andy Bunce here http://cubeb.blogspot.fr/2012/11/xquery-templating-engines-and-txq.html https://mailman.uni-konstanz.de/pipermail/basex-talk/2012-November/004209.ht...
I’ve tried with txq module in different ways. But, I can’t figure out why I couldn’t reproduce it. Here is the simpler exemple I’ve tried :
In the webapp folder an xml file, named `view1.xml` wich contains : ```xml <div>{map:get($map, 'greeting')}</div> ```
In webapp a restxq file with :
```xquery
module namespace test = 'test.test'; import module namespace xquery = "http://basex.org/modules/xquery";
declare function test:render($template as xs:string, $map as map(*)){ xquery:invoke($template,$map) };
declare %restxq:path('/test') %restxq:GET function test:test(){ let $map := map{ "greeting" : "hello", "who": "world"} return test:render('view1.xml', $map ) }; ```
Arrêté à /Users/emmanuelchateau/Documents/basex/webapp/view1.xq, 1/15: [XPST0008] Undefined variable $map.
I’m running BaseX version 7.9 Is there still anybody with this kind of templating running ?
Thanks a lot for your help.
Emmanuel