Project

Profile

Help

How to connect?
Download (767 Bytes) Statistics
| Branch: | Revision:

he / src / use-cases / string / q2.xq @ a31dd97a

1

    
2
declare namespace my="my.uri";
3
declare function my:partners($company as xs:string) as element()*
4
{
5
    let $c := doc("company-data.xml")//company[name = $company]
6
    return $c//partner
7
};
8

    
9
let $foobar_partners := my:partners("Foobar Corporation")
10

    
11
for $item in //news_item
12
where
13
  some $t in $item//title satisfies
14
    (contains($t/text(), "Foobar Corporation")
15
    and (some $partner in $foobar_partners satisfies
16
      contains($t/text(), $partner/text())))
17
  or (some $par in $item//par satisfies
18
   (contains(string($par), "Foobar Corporation")
19
     and (some $partner in $foobar_partners satisfies
20
        contains(string($par), $partner/text())))) 
21
return
22
    <news_item>
23
        { $item/title }
24
        { $item/date }
25
    </news_item>
(8-8/11)