[xquery-talk] attribute names and their distinct values
fatma helmy
fatmahelmy2000 at yahoo.com
Thu May 25 01:03:31 PDT 2006
regarding my xquery
declare function local:pathOfNode($node)
{if(empty($node/..)) then "" else
concat(local:pathOfNode($node/..), "/",
local-name($node))};
let $j:= doc("try.XML")
let $paths := for $n in $j//* return
local:pathOfNode($n)
for $p in distinct-values($paths)
let $papa:= replace($p,'/[^/]*$','')
let $leafs :=$j//text()[normalize-space()]
[string-join(ancestor-or-self::element()/name(),'/')
eq substring-after(string($p),"/") ]
return
<STATISTICS>
<PATH>
{string($p)}
</PATH>
<RATIO>
{string( round( count($paths[.=$p]) div
count($paths[.=$papa]) * 100 ) )}
</RATIO>
{for $val in distinct-values( $leafs)
let $kval := normalize-space($val)
return <value-per-path value='{$kval}'
count='{count($leafs[. eq $kval ])}'/>}
</STATISTICS>
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
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the talk
mailing list