Domanda

I found some think about call function in function but i got this error:

NotFound No template function found for call app:PokazRodzica

But first. Here is my MAIN function

    declare function app:WyswietlAkweny($node as node(), $model as map(*), $nazwa as xs
    :string?) {

        <table border="1" width="100%">
        <th>Podrzędne</th><th>Nazwa</th><th>Typ</th><th>Powierzchnia</th><th>Edycja</th>
        {
            for $x in doc('/db/Dane/akweny.xml/')//akwen
            let $nazwa := $x/nazwa,
                $typ := $x/typ,
                $powierzchnia := $x/powierzchnia
                return <tr>
(:~ THIS DOSENT WORK :)
                    <th><a href="{app:PokazRodzica($nazwa)}"><img src="/exist/apps/Obrazki/lupa.jpg" alt="Podrzedny" /> KLIK</a></th>
                    <th bgcolor="#F46978">{$nazwa}</th>
                    <th>{$typ}</th>
                    <th>{$powierzchnia}</th>
                    <th>Edytuj</th>
                    </tr>
        }
        </table>
    };

And here is my function what i want to run when i press on image

declare function app:PokazRodzica($nazwa1 as xs:string?)  {


<table border="1" width="100%">
<th>Podrzędne</th><th>Nazwa</th><th>Typ</th><th>Powierzchnia</th><th>Edycja</th>
{
let $nodes := doc('/db/Dane/akweny.xml')//akweny[parent::akwen/nazwa=$nazwa1]
for $x in $nodes/*
let $nazwa := $x/nazwa/text()
let $typ := $x/typ/text()
let $powierzchnia := $x/powierzchnia/text()
    return 
       <tr>
        <th><img src="/exist/apps/Obrazki/lupa.jpg" alt="Podrzedny" /> {count($nazwa/text())} KLIK</th>
        <th bgcolor="#F46978">{$nazwa}</th>
        <th>{$typ}</th>
        <th>{$powierzchnia}</th>
        <th>Edytuj</th>
        </tr>
}</table>
};

And here is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<akweny>
    <akwen>
        <nazwa>Atlantycki</nazwa>
        <typ>ocean</typ>
        <powierzchnia>106450</powierzchnia>
        <akweny>
            <akwen>
                <nazwa>Północne</nazwa>
                <typ>morze</typ>
                <powierzchnia>750</powierzchnia>
            </akwen>
            <akwen>
                <nazwa>Batyckie</nazwa>
                <typ>morze</typ>
                <powierzchnia>386</powierzchnia>
                <akweny>
                    <akwen>
                        <nazwa>Botnicka</nazwa>
                        <typ>zatoka</typ>
                        <powierzchnia>117</powierzchnia>
                    </akwen>
<akweny>
                        <akwen>
                        <nazwa>Botnicka</nazwa>
                        <typ>zatoka3</typ>
                        <powierzchnia>11777</powierzchnia>
                        </akwen>
</akweny>
                </akweny>
            </akwen>
        </akweny>
    </akwen>
    <akwen>
        <nazwa>Spokojny</nazwa>
        <typ>ocean</typ>
        <powierzchnia>179700</powierzchnia>
    </akwen>
</akweny>

I call MAIN function like this:

<p class="app:WyswietlAkweny"/>

I'm trying to find any akweny that have a parent akwen with a nazwa child and child and infinity with the value of $nazwa1.

È stato utile?

Soluzione

I think I understand the problem now. I'm suspect you want this function to be called and its value returned when the user clicks on this anchor tag while viewing the web page:

<a href="{app:PokazRodzica($nazwa)}">

This is not what's happening. When you output this anchor tag, anything in the AVT ({}) will be evaluated before returning. So this calls the function you referenced and stores its output literally in that attribute. What you need to is to reference an endpoint so the browser can call the function via the endpoint:

<a href="/call-app-PokazRodzica.xqy?value={$nazwa}">

Then in the endpoint script, call-app-PokazRodzica.xqy, accept a value parameter, and call your function:

app:PokazRodzica($value-param)

Now, when your user clicks on the anchor, it will call the endpoint and pass it the value. The browser will then return the results of the endpoint call.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top