xquery version "3.0";
<nodes>
{
let $nodes := //classCode
for $nodo in $nodes
let $count := count($nodo)
group by $nomeNodo := $nodo/text()
order by $nomeNodo
return
<nodo>
<nodeId>
{string($nomeNodo)}
</nodeId>
<counter>
{string($count)}
</counter>
</nodo>
}
</nodes>