[xquery-talk] separating attribute name from its value and alsocounting similar attribute names and values

Michael Kay mhk at mhk.me.uk
Fri Mar 3 11:44:02 PST 2006


> thanks it worked using name() and string , now i need
> to count the similar attribute values

In XQuery, finding and counting duplicates always hinges on the
distinct-values() function. Call distinct values to find the values that are
present, then query your original source to find how many of each. Something
like

for $v in distinct-values(//@*[name()=$n])
return <attribute name="{$n}" value="{$v}"
count="{count(//@*[name()=$n][.=$v])}"/>

Michael Kay
http://www.saxonica.com/




More information about the talk mailing list