Project

Profile

Help

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

he / src / use-cases / strong / q4.xq @ a31dd97a

1
import schema namespace ipo="http://www.example.com/IPO" at "ipo.xsd";
2
import schema namespace pst="http://www.example.com/postals" at "postals.xsd";
3
import schema namespace zips="http://www.example.com/zips" at "zips.xsd";
4

    
5
import module namespace zok="http://www.example.com/xq/zips" at "q2.xqlib";
6
import module namespace pok="http://www.example.com/xq/postals" at "q3.xqlib";
7

    
8
declare function local:address-ok($a as element(*, ipo:Address))
9
 as xs:boolean
10
{
11
  typeswitch ($a)
12
      case $zip as element(*, ipo:USAddress)
13
           return zok:zip-ok($zip)
14
      case $postal as element(*, ipo:UKAddress )
15
           return pok:postal-ok($postal) 
16
      default return false()
17
};
18

    
19
for $p in doc("ipo.xml")/schema-element(ipo:purchaseOrder)
20
where not( local:address-ok($p/shipTo) and local:address-ok($p/billTo))
21
return $p 
22

    
23
(: returns an empty sequence, by design :)
(16-16/27)