0

i am trying to pass a parameter to an app using existDB , my problem is while using the templates , it gives me this error :

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]

And the code that i actually have is this one , i have all the code that is auto generated while you created an app equal except this files:

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>

};

And this are the pages that use the templates :

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>

What i am trying to do with all this is given a registration number , show some information of the bus with that number

Thanks for the help

1 Answers1

1

I have found the error , it was in the code of the html in "busPorMatricula.html"

there is a space in the content of the data-template and that was the problem.

I hope it helps others ,I have spent like 4 hours looking for one hundred more complicated things than that.