Project

Profile

Help

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

he / src / use-cases / strong / q4a.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
(: This query is the counterpart to the published query Q4: it returns purchase orders that have a valid address :)
9

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

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