我正在尝试使用existDB将参数传递给应用,我的问题是在使用模板时,它给了我这个错误:
templates:NotFound No template function found for call app:getBusPorMatricula [at line 189, column 85, source: C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
In function:
templates:call(item(), element(), map) [135:36:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [146:81:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [146:81:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [146:81:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [462:17:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:surround(node(), map, xs:string, xs:string?, xs:string?, xs:string?) [34:9:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:call-with-args(function, function*, element(), map) [208:13:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process-output(element(), map, item()*, element()) [205:9:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:call-by-introspection(element(), map, map, function) [187:28:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:call(item(), element(), map) [135:36:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [131:51:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [88:9:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:apply(node()+, function, map?, map?) [45:5:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
我实际拥有的代码就是这个代码,除了这些文件之外,我创建的应用程序是自动生成的所有代码:
app.xql:
xquery version "3.0";
module namespace app="http://gijonapp1.es/templates";
declare namespace bus="http://docs.gijon.es/sw/busgijon.asmx";
import module namespace templates="http://exist-db.org/xquery/templates" ;
import module namespace config="http://gijonapp1.es/config" at "config.xqm";
(:~
: This is a sample templating function. It will be called by the templating module if
: it encounters an HTML element with an attribute data-template="app:test"
: or class="app:test" (deprecated). The function has to take at least 2 default
: parameters. Additional parameters will be mapped to matching request or session parameters.
:
: @param $node the HTML node with the attribute which triggered this call
: @param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function local:getNumeroBusesFuncionando()
{
let $numero:=count(doc('http://datos.gijon.es/doc/transporte/busgijontr.xml')//bus:posicion)
return $numero
};
declare function local:getBusesFuncionando()
{
<buses numero="{local:getNumeroBusesFuncionando()}">{
for $bus in doc('http://datos.gijon.es/doc/transporte/busgijontr.xml')//bus:posicion
order by xs:integer($bus/bus:idlinea)
return <bus>{$bus/bus:matricula,$bus/bus:idlinea,$bus/bus:idtrayecto,$bus/bus:utmx,$bus/bus:utmy}</bus>}
</buses>
};
declare function app:showMenu($node as node(), $model as map(*)){
<div>
<ul>
<li><a href="./busesFuncionando.html">Buses Funcionando</a></li>
<form action="./busPorMatricula.html">
Inserte la matricula del autobus a buscar :
<input type="text" name="matricula"/>
<input type="submit" value="Buscar"/>
</form>
</ul>
</div>
};
declare function app:showBusFuncionando($node as node(), $model as map(*)) {
<div>
<h2> Buses funcionado a las {hours-from-time(current-time())}:{minutes-from-time(current-time())}</h2>
<ul>
{
for $bus in local:getBusesFuncionando()//bus
return <li><b>Linea :{$bus/bus:idlinea}</b> Trayecto : {$bus/bus:idtrayecto} Matricula : {$bus/bus:matricula} Posicion : {$bus/bus:utmx},{$bus/bus:utmy}</li>
}
</ul>
</div>
};
(: !!!!!The PROBLEM is HERE !!!!:)
declare function app:getBusPorMatricula($node as node(), $model as map(*))
{
let $matricula:=request:get-parameter('matricula', '')
let $bus :=doc('http://datos.gijon.es/doc/transporte/busgijontr.xml')//bus:posicion[bus:matricula=$matricula]
return
<p>asd</p>
};
这是使用模板的页面:
的index.html:
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
<h1> Menu </h1>
<div data-template="app:showMenu"/>
</div>
busPorMatricula.html:
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
<h1> Bus con matricula </h1>
<div data-template=" app:getBusPorMatricula" data-template-matricula="{request:get-parameter('matricula', ''}"/>
</div>
我试图用这一切做的是给出一个注册号,用这个号码显示公交车的一些信息
感谢您的帮助
答案 0 :(得分:1)
我发现了错误,它出现在&#34; busPorMatricula.html&#34;
中的html代码中数据模板的内容中有一个空格,这就是问题所在。
我希望它能帮助别人,我花了4个小时寻找比这更复杂的事情。