|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Xquery+ reduce two docs into oneJames A. Robinson jim.robinson at stanford.eduFri Jan 12 06:33:24 PST 2007
> I am quite new to xquery and I have a FLWOR question So am I, so take this with a large grain of salt. Most of my recent XQuery experience hasn't been at the target domain of the language, join operations! So anyway, here is one solution (I think): (: Get metadata from documents :) let $m1 := doc("sebi-1.xml")/*/meta let $m2 := doc("sebi-2.xml")/*/meta (: determine common FileName by textual value :) let $intersect := ( let $common := ( for $f in ($m1/FileName, $m2/FileName) where (($f = ($m1/FileName)) and ($f = $m2/FileName)) return $f ) return ( for $name in distinct-values($common) return $common[. = $name][1] ) ) return <FF> <meta>{ (: for each meta with an intersecting FileName :) for $m in ($m1, $m2) where ($intersect = $m/FileName) return (: return the meta elements which are not FileName :) $m/*[not(self::FileName)], (: return the FileName intersect :) $intersect }</meta> </FF> This returns <?xml version="1.0" encoding="UTF-8"?> <FF> <meta> <Value2>2.8</Value2> <Value1>7.90mm</Value1> <FileName>file7</FileName> <FileName>file8</FileName> <FileName>file9</FileName> <FileName>file14</FileName> <FileName>file15</FileName> <FileName>file16</FileName> <FileName>file17</FileName> <FileName>file18</FileName> <FileName>file19</FileName> </meta> </FF> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - James A. Robinson http://x-query.com/mailman/listinfo/talk Stanford University HighWire Press http://highwire.stanford.edu/ +1 650 7237294 (Work) +1 650 7259335 (Fax)
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






