[xquery-talk] Fwd: Question

David Carlisle davidc at nag.co.uk
Tue Feb 21 11:22:18 PST 2006


> I dont want the null values for bookstre/book and bookstore/book/author

the values are not null, they are the newlines and white space in the
source file used to indent the input. You can filter the white space
nodes by adding [normalize-space()] as below. Also your value-attribute
contains white space at each end coming from teh indentation, so I've
added normalize-space there as well,.

David


let $j:= doc("book_sample.xml")
for $path in
("bookstore/book/title","bookstore/book/price","bookstore/book",
"bookstore/book/author","bookstore/book/author/firstname")
let $leafs :=
$j//text()[normalize-space()][string-join(ancestor-or-self::element()/name(),'/')
eq $path]
return
  <attr-per-path path='{$path}'>{
    for $val in distinct-values($leafs)  
    return <value-per-path value='{normalize-space($val)}'
count='{count($leafs[. eq
$val])}'/>
  }</attr-per-path>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the talk mailing list