[xquery-talk] attribute names and their distinct values

Michael Kay mhk at mhk.me.uk
Thu May 25 14:24:08 PDT 2006

> can i get the name of all attributes in each path $p and get 
> the count of their distint values to produce it as the 
> summary produced on leaf nodes

I assume by attributes "in a path", you mean the attributes of the elements
on the ancestor-or-self axis of a node, that is


You can get the names of these attributes as


and you can eliminate duplicates using


You can get the distinct values for each attribute name using

for $a in
return distinct-values($node/ancestor-or-self::*/@*[node-name() eq $a])

but at this stage I suspect I'm guessing wildly at what you actually want to

Michael Kay

More information about the talk mailing list