logo       

Re: Re[2]: Xquery+ reduce two docs into one: msg#00025

Subject: Re: Re[2]: Xquery+ reduce two docs into one
 
> Hello - The result was just one empty meta element. Something like
> this:
> 
> <FF>
>     </meta>
> </FF>

That's strange, I got the right results when I ran his solution. Are
you sure you updated the filenames properly?

I thought that solution looked pretty good, though the thing that
irritated me (other than the multiple many-to-many operations) was the
fact that we were both limiting ourselves to 2 input documents.

A slightly extended version that I think will work if one needs to
add new documents would be something that understands the concepts
behind the fn:collection() function. But anyway, I hope others can
point out if there is a way to do this without multiple many-to-many
type joins (which I think both David and my solution require).

declare namespace f="uri.local-functions";

(: simulate a DB where we have a collection() function and indicies :)
declare function f:collection() {
  (doc("sebi-1.xml"), doc("sebi-2.xml"))
};

(: count the number of documents :)
let $total          := count(f:collection())
(: load all metadata :)
let $meta           := f:collection()/*/meta
(: find unique filenames in all metadata  :)
let $files          := distinct-values(f:collection()/*/meta/FileName)
(: find all filenames which are in all metadata :)
let $file_intersect := (
  for $f in $files
  return (
    let $meta := f:collection()/*/meta[FileName = $f]
    where (count($meta) = $total)
    return $f
  )
)
(: find all metadata with the intersecting files :)
let $meta_intersect := (
  for $m in $meta[FileName = $file_intersect]
  return
    $m/*[not(self::FileName)]
)
(: and return the new document :)
return (
  <FF>
   <meta>{
     
     for $m in $meta_intersect
     order by local-name($m)
     return $m,
     
     for $f in $file_intersect
     return <FileName>{$f}</FileName>

   }</meta>
 </FF>
)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       
jim.robinson-FGKo4X94FMn2fBVCVOL8/A@xxxxxxxxxxxxxxxx
Stanford University HighWire Press      http://highwire.stanford.edu/
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
region.costa-ri...    user-groups.lin...    lang.prothon.us...    xfree86.cvs/200...    finance.aqbanki...    ietf.smtp/1993-...    web.turbogears....    jakarta.cactus....    yellowdog.gener...    php.gtk+.genera...    org.region.indo...    hurd.l4/2005-10...    culture.religio...    apple.fink.gene...    db.mysql.window...    bluez.devel/200...    security.pgp-ba...    video.blender.d...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe