let $a := (
for $b in log
where (($b/description = “App search”) and (tf:containsText($b/date,“???06/2008*”)))
return $b
)
for $d in distinct-values($a/username/text())
return
{$d}
{
let $z := (for $c in input()/log
where (
($c/description = “App search”) and (tf:containsText($c/date,“???06/2008*”))
and ($c/username = “$d/text()”)
)
staying as close as possible to your query, you would have to modify as follows:
declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
let $a := (for $b in input()/log
where (($b/description = "App search") and
(tf:containsText($b/date,"???06/2008*")))
return $b)
for $d in distinct-values($a/username/text())
return
<usu>
<nom>{$d}</nom>
{
let $z := (for $c in input()/log
where ($c/description = "App search") and
tf:containsText($c/date,"???06/2008*")
and ($c/username = $d)
)
return $c
)
return <cont>{count($z)}</cont>
}
</usu>
actually only minor changes (in particular, you cannot apply /text() to $d as $d is already a text node, and you must not quote $d)
The query could be written more compact as
declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
let $log:=input()/log[./description = "App search" and
tf:containsText(./date,"???06/2008*")]
for $d in distinct-values ($log/username/text()) return
<usu>
<nom>
{$d}
</nom>
<cont>
{count($log[username=$d])}
</cont>
</usu>