ibm XQuery 参考


IBM DB2 10.1 for Linux, UNIX, and Windows XQuery N< |B1d 2013 j 1 B S151-1774-01  IBM DB2 10.1 for Linux, UNIX, and Windows XQuery N< |B1d 2013 j 1 B S151-1774-01  "b 9CKE"0d'VDz70,kHDAZ 211 3D=< B, :yw;BD#fE"# ^)fyw KD5|, IBM DyP(E"#|ZmI-iPa),R\f((D#$#>vfoP|,DE";|(TNNz7D #$,Ra)DNNod<;h*gKbM# zIZ_r(}1XD IBM zm&): IBM vfo# v *Z_):vfo,k*A IBM vfoPD,x7*:http://www.ibm.com/shop/publications/order v *iR1XD IBM zm&,k*A IBM +r*5K?<,x7*:http://www.ibm.com/planetwide/ *S@zrSCsD DB2 P!Mz[?): DB2 vfo,kBg 1-800-IBM-4YOU(426-4968)# z"ME"x IBM s,4Zh IBM G@<(^,IBM IT4|O*J1DNN==9CrV"zya)DNNE"x ^kTzP#NNpN# © Copyright IBM Corporation 2006, 2013. ?< XZ>i ..............vii Z 1 B DB2 XQuery En .......1 XQuery ri ..............1 XQuery k SQL DHO...........2 9C XQuery /}lw DB2 }] .......3 XQuery M XPath }]#M .........4 rPMn...............4 -S5 ...............5 ZccNa9 .............5 ZctT...............7 ZcV`...............7 ZcDD53r ............9 Zcj6 ..............10 ZcD`M5MV{.5 .........10 XDM DrP/ .............10 XML {FUdM QName ..........11 ^({F(QName) ..........11 2,Q*{FUd ...........11 oT<( ...............12 xVs!4 .............12 Uq ................13 "M ................13 N&IR=PX XQuery D|`E" ......14 Z 2 B `M53 ..........15 `McNa9 ..............15 4`p.VD`M ............16 ZC}]`MD9l/} ..........20 `M*; ...............21 anyAtomicType }]`M ..........24 anySimpleType }]`M ..........24 anyType }]`M ............24 anyURI }]`M ............24 base64Binary }]`M ...........24 boolean }]`M ............25 byte }]`M..............25 date }]`M..............25 dateTime }]`M ............25 dayTimeDuration }]`M .........27 decimal }]`M ............28 double }]`M .............28 duration }]`M ............28 ENTITY }]`M ............30 float }]`M .............30 gDay }]`M .............30 gMonth }]`M ............31 gMonthDay }]`M ...........31 gYear }]`M .............31 gYearMonth }]`M ...........32 hexBinary }]`M ............32 ID }]`M ..............32 IDREF }]`M .............32 int }]`M ..............33 integer }]`M .............33 language }]`M ............33 long }]`M .............33 Name }]`M .............33 NCName }]`M ............33 negativeInteger }]`M ..........33 NMTOKEN }]`M ...........34 nonNegativeInteger }]`M .........34 nonPositiveInteger }]`M .........34 normalizedString }]`M..........34 NOTATION }]`M ...........34 positiveInteger }]`M ..........34 QName }]`M ............35 short }]`M .............35 string }]`M .............35 time }]`M .............35 token }]`M .............36 unsignedByte }]`M ...........36 unsignedInt }]`M ...........36 unsignedLong }]`M...........36 unsignedShort }]`M ..........37 untyped }]`M ............37 untypedAtomic }]`M ..........37 yearMonthDuration }]`M .........37 Z 3 B rT ............39 f>yw ...............39 _gUqyw ..............40 9lyw ...............40 4F{FUdyw ............41 1!*X/`M{FUdyw .........41 1!/}{FUdyw ...........42 UEryw ..............43 Er==yw ..............43 {FUdyw ..............44 Z 4 B mo= ...........47 mo=s5M&m ............47 /,OBDM9c ...........47 EH3r ..............47 XQuery mo=Pa{D3r ........48 -S/ ...............50 S`Mf; .............50 `Ma} ..............51 P'<{5 .............51 wmo= ...............52 DV ................52 d?}C ..............54 © Copyright IBM Corp. 2006, 2013 iii x(Emo= .............54 OBDnmo= ............55 /}wC ..............55 76mo= ..............56 76mo=Do( ...........56 a=h ...............57 76mo=Du4o( ..........60 =J .................62 rPmo= ..............63 CZ9lrPDmo= ..........63 }Kmo= .............64 O"ZcrPDmo= ..........64 cumo= ..............65 HOmo= ..............67 5HO ...............67 #fHO ..............69 ZcHO ..............71 _-mo= ..............72 9l/} ...............73 9l/}PDx(Emo= ........73 1S*X9l/} ...........74 Fc*X9l/} ...........80 FctT9l/} ...........81 D5Zc9l/} ...........82 D>Zc9l/} ...........83 &m8n9l/} ...........83 "M9l/} .............84 FLWOR mo= .............85 FLWOR mo=Do( ..........85 for M let Sd............87 where Sd .............90 order by Sd ............91 return Sd .............93 FLWOR >} .............93 u~mo= ..............96 (?mo= ..............97 ?F`M*;mo= ...........98 I*Mmo= ..............99 d;mo=M|Bmo=..........101 Zd;mo=P9C|BYw .......101 d;mo= .............104 y>|Bmo=............106 Z 5 B ZC/} ..........117 4`p.VD DB2 XQuery /} .......117 adjust-date-to-timezone /} .........122 adjust-dateTime-to-timezone /} .......123 adjust-time-to-timezone /} .........125 abs /} ...............126 avg /} ...............127 boolean /}..............128 ceiling /} ..............129 codepoints-to-string /} ..........130 compare /} .............130 concat /} ..............131 contains /} .............131 count /} ..............132 current-date /} ............132 current-dateTime /} ...........133 current-local-date /}...........133 current-local-dateTime /} .........134 current-local-time /}...........134 current-time /} ............134 data /} ...............135 dateTime /} .............135 day-from-date /} ............136 day-from-dateTime /} ..........136 days-from-duration /} ..........137 deep-equal /} .............137 default-collation /} ...........139 distinct-values /}............139 empty /} ..............140 ends-with /} .............141 exactly-one /} ............141 exists /} ..............142 false /}...............143 floor /} ..............143 hours-from-dateTime /} .........144 hours-from-duration /} ..........144 hours-from-time /} ...........145 implicit-timezone /}...........146 in-scope-prefixes /} ...........146 index-of /} .............146 insert-before /} ............147 last /} ...............148 local-name /}.............148 local-name-from-QName /} ........149 local-timezone /} ...........149 lower-case /} .............150 matches /} .............151 max /} ...............152 min /} ...............153 minutes-from-dateTime /} .........154 minutes-from-duration /} .........155 minutes-from-time /} ..........156 month-from-date /} ...........156 month-from-dateTime /} .........157 months-from-duration /} .........157 name /} ..............158 namespace-uri /}............159 namespace-uri-for-prefix /} ........160 namespace-uri-from-QName /} .......160 node-name /}.............161 normalize-space /} ...........161 normalize-unicode /} ..........162 not /} ...............163 number /} ..............163 one-or-more /} ............164 position /}..............165 QName /}..............165 remove /} ..............166 replace /} ..............166 iv XQuery N< resolve-QName /} ...........168 reverse /} ..............169 root /} ...............169 round /} ..............170 round-half-to-even /} ..........171 seconds-from-dateTime /} .........172 seconds-from-duration /} .........173 seconds-from-time /} ..........174 sqlquery /} .............174 starts-with /} .............177 string /} ..............177 string-join /} .............178 string-length /} ............179 string-to-codepoints /} ..........179 subsequence /} ............180 substring /} .............180 substring-after /}............181 substring-before /} ...........182 sum /} ...............183 timezone-from-date /} ..........184 timezone-from-dateTime /} ........184 timezone-from-time /} ..........185 tokenize /} .............185 translate /} .............187 true /} ...............188 unordered /} .............188 upper-case /} .............189 xmlcolumn /}.............190 year-from-date /} ...........191 year-from-dateTime /} ..........191 years-from-duration /} ..........192 zero-or-one /} ............193 Z 6 B}rmo= .........195 Z 7 B ^F ............201 XQuery }]`MD^F ..........201 s!^F ...............202 =< A. DB2 SQL 4,oz ......205 CJ;,f>D DB2 E"PD .......206 |B20ZFczrZ?x~qwOD DB2 E"P D .................206 V/|B20ZFczrZ?x~qwOD DB2 E "PD................207 DB2 LL...............209 DB2 JOoOE"............209 E"PDunMu~ ...........210 =< B. yw ............211 w} ...............215 ?< v vi XQuery N< XZ>i XQuery }Chv DB2® }]bCZk XML }]dO9CD XQuery oT# ||(PX XQuery En"}]`M"oT*X"XQuery (eD/}M DB2 DZC /}DE"#C}C9|(PX DB2 XQuery fZs!M XQuery }]`M=fD^ FDE"# © Copyright IBM Corp. 2006, 2013 vii viii XQuery N< Z 1 B DB2 XQuery En BPwbi\y> XQuery En,"hv XQuery gNk DB2 }]bdO$w# XQuery ri XQuery Gr,x*K(W3C)hFD;V/}`LoT,CZzci/M^D XML } ]DX(hs# kI$bD"_P#fa9DX5}];,,XML }]IdT\_#XML }](#G ;I$b"!hMThvD# IZ XML }]Da9;I$b,yTh*T XML }]4PDi/(#kdMDX5 i/;,#XQuery oTa)K4Pb)`MYwyhDinT#}g,I\h*9C XQuery oT4PBPYw: v QwcNa9P3)4*cTsD XML }]# v T}]4Pa9d;(}g,zI\k9*cNa9)# v 5X_PlO`MDa{# v |BVP XML }]# XQuery i/DiI?V Z XQuery P,mo=Gi/Dw*9(i#mo=ITxP6W,C4iIi/Dw e#i/9ITZKwe0f_PrT#rT|,;5PCZ(ei/&m73Dy w#i/we|,CZ(ei/a{Dmo=#Kmo=II9CKc{rX|Vi OxID`v XQuery mo=9I# Z 2 3D< 1 5wKdMi/Da9#ZK>}P,rT|,=vyw:;vGf>y w,|8(*C4&mi/D XQuery o(Df>;m;vG1!{FUdyw,|8 (*CZ^0:*X{FM`M{D{FUd URI#i/we|,;vCZ9l price_list *XDmo=#price_list *XDZ]G+ product *X4[q5rEP qCDPm# © Copyright IBM Corp. 2006, 2013 1 XQuery k SQL DHO DB2 'V+q=}Z9C XQuery,rK DB2 ~qwXk9CJCZ XQuery oTRxVs!4Dfr# ms&mGy]C4&m XQuery mo=DSZ4xPD#(f XQuery ms 1aa) SQLCODE M SQLSTATE,k(f SQL msD==`,#&m XQuery mo=1;a5X/f#XQuery (}wCS DB2 mMS{for $prod in db2-fn:xmlcolumn("PRODUCT.DESCRIPTION")/product/description order by xs:decimal($prod/price) descending return {$prod/name, $prod/price}} Prolog Query body < 1. XQuery PDdMi/Da9 2 XQuery N< XQuery d?+]x XQuery mo=#ITZ SQL i/DOBDPx ;=&mI XMLQUERY 5XD XML 5# XMLTABLE XMLTABLE G;vm/},|9C XQuery mo=4S XML }] zI SQL m,SQL ITx;=&mC SQL m# XMLEXISTS XMLEXISTS G;v SQL =J,|7( XQuery mo=Gq5XI; vr`vniIDrP(x;G;vUrP)# 9C XQuery /}lw DB2 }] Z XQuery P,i/ITwCBP/}.;4q! DB2 }]bPDdk XML }]: db2-fn:sqlquery M db2-fn:xmlcolumn# db2-fn:xmlcolumn /}+lw{v XML P,x db2-fn:sqlquery +lwyZ SQL + i/D XML 5# db2-fn:xmlcolumn db2-fn:xmlcolumn /}IC;vV{.DVTd?,CZj6;vmrS}P,i/9C db2-fn:xmlcolumn /}4q! BUSINESS.ORDERS m D PURCHASE_ORDER PPDyPI:)%#;s,i/+TKdk}]4 PYw,Sb)I:)%D;uX7Pi!GP#i/a{G;6)%DyP GPDPm# db2-fn:xmlcolumn(’BUSINESS.ORDERS.PURCHASE_ORDER’)/shipping_address/city db2-fn:sqlquery db2-fn:sqlquery /}IC;vm>+i/DV{.Td?,"5X;vI+i/ 5XD XML 5"CxID XML rP#+i/Xk8(%Pa{/,xRP D}]`MXk* XML#(}8(+i/,+Jmz9C SQL D&\4r XQuery a) XML }]#C/}'V9CN}r SQL od+]5# ZTB>}P,BUSINESS.ORDERS mP|,{* PURCHASE_ORDER D XML P#ZC>}P,i/9C db2-fn:sqlquery /}4wC SQL,Tq!; uUZ* 2005 j 6 B 15 UDyPI:)%#;s,i/+TKdk}]4 PYw,Sb)I:)%D;uX7Pi!GP#i/a{GZ 6 B 15 U; 6)%DyPGPDPm# db2-fn:sqlquery(" SELECT purchase_order FROM business.orders WHERE ship_date = ’2005-06-15’ ")/shipping_address/city *c:I db2-fn:sqlquery r db2-fn:xmlcolumn /}5XD XML rPIT|,NN XML 5(|(-S5MZc)#b)/}";a\G5Xq=}PD BUSINESS.ORDERS M PURCHASE_ORDER#Z SQL odP,IT9C!4{F4}Cb)P(} g,business.orders M purchase_order),Z&m SQL od1b){FaT/ *;*s4#(Z SQL P,9IT(}+{FC+}E}p44(F*(gj 6DxVs!4D{F)# XQuery G;VxVs!4DoT XQuery ;a+!4{F*;*s4{F#bVnpaZ,19C XQuery M SQL 1}P,m{ business.orders T0P{ purchase_order M ship_date HITs4N=2IT!4N=vV#+G,db2-fn:xmlcolumn DYw};G SQL i/#Yw}GxVs!4D"CZm>P{D XQuery V{.DV#r *5JP{G BUSINESS.ORDERS.PURCHASE_ORDER,yTZ db2- fn:xmlcolumn DYw}PXkCs48(K{F# XQuery M XPath }]#M XQuery mo=T XQuery M XPath }]#M(XDM)D5}xPKc"5X}]# MD5}# XDM GT;vr`v XML D5r,NDism>#}]#Ma(e XQuery PDm o=DJm5,|(PdFcZd9CD5# + XML }]bv* XDM,"Z XQuery &m}].0kT#=4i$b)}]#Z zI}]#MZd,+bvdk XML D5,"+|*;* XDM D5}#ZbvD5 1,ITxPi$,2IT;xPi$# XDM G4U-S5MZcrP4xPhvD# rPMn XQuery M XPath }]#M(XDM)D5}*rP#rPG 0 vnr`vnDPr/ O#;vnMG;v-S5r;vZc# ;vrPIT|,Zc"-S5r_GZcM-S5DNbiO#}g,BfPmP D?vu? v (2, 3, 4) v (36, , "cat") v () }PmPDu?.b,f"Z DB2 }]bD XML PPD XML D5G;vrP# >}PC4m>rPDm>(,kC49l XQuery PDrPDo(G;BD: v rPPD?n.dC:EVt# v {vrPGC2(E(p4D# 4 XQuery N< v ;TUD2(Em>;vUrP# v g{;vnZ|TmO=vV,G4`1Z;v;|,;nDrP# }g,rP (36) k-S5 36 ;Pxp# ;\TrPxP6W#1iO=vrP1,qCDa{1YDE"r4*E"# -S5 -S5GI XML #=(eDdP;VZC-S}]`MD5}#b)}]`M|( String"Integer"Decimal"Date Md{-S`M#b)`M<;hv*-S`M,-r G|G^(Y8VK# kZc;,DG,-S5;Pj6#-S5D?v5}(}g,{} 7)kC5Dd{ ?v5}}G;)zI-S5D=(: v (};vF*“-S/”D}LSZcPi!#?1h*-S5rP1,mo=Ma 9C-S/# v 8(*}VrV{.DV#XQuery a+DVbM*-S5#}g,BPDVMa; bM*-S5: – “this is a string”(`M* xs:string) –45(`M* xs:integer) – 1.44(`M* xs:decimal) v I9l/}FcqC#}g,TB9l/}+y]V{.“2005-01-01”49(`M* xs:date D5: xs:date("2005-01-01") v IZC/} fn:true() M fn:false() 5X#b)/}+5X<{5 true M false#b )5;\m>*DV# v I`Vmo=(}g,cumo=M_-mo=)5X# ZccNa9 iI;vr`vcNa9rwDZcrP,b)cNa9rwI;vyZcMISC yZc1SrdSCJDyPZciI# ?vZc;tZ;vcNa9,x?vcNa9;P;vyZc#DB2 'VTB 6 V Zc:D5"*X"tT"D>"&m8>E"M"M# TB XML D5 products.xml |(;vy*X products,Cy*XV|,;) prod- uct *X#?v product *X Fleece jacket Z 1 B DB2 XQuery En 5 19.99 Nylon pants 9.99 < 2 T> products.xml D}]#MDr/m>#CZc(T)# g>}Py>,;vZcI+d{Zcw*Sz,SxiI;vr`vZccNa 9#ZC>}P,product *XG products DSz#description *X4G product DSz#name M price *XZcG name *XDSz,xD>Zc 19.99 G price *XDSz# pid Fleece jacket Nylon pants19.99 9.99 products.xml pid E E D A A E E TT TT EEE E E < 2. products.xml D5D}]#M< 6 XQuery N< ZctT ?vZc<_P;)XT,b)XTC4hvCZcDXw#}g,ZcDXTI\ |(:ZcD{F"Sz"8z"tTT0C4hvCZcDd{E"#ZcV`7 (*X(Zca)KD)tT# ;vZcIT_PBfD;vr`vtT: node-name ZcD{F,m>* QName# 8z G10ZcD8zDZc# type-name ZcD/,(KP1)`M(2F*`M"M)# Sz G10ZcDSzDZcrP# tT tZ10ZcD;itTZc# string-value ITSZcPi!DV{.5# typed-value ITSZcPi!DIcvrcvTO-S5iIDrP# {FUdwCr kZc`X*DwCrZ{FUd# content ZcDZ]# ZcV` DB2 'VTB 6 VZc:D5"*X"tT"D>"&m8>E"M"M# D5Zc D5Zc|, XML D5# D5ZcIT_P`vSz,2IT;PSz#SzITG*XZc"&m8nZ c""MZcMD>Zc# D5ZcDV{.5HZ+|DyPszD>ZcDZ]4D53rxP"CDa {#V{.5D`M* xs:string#D5ZcD`M5kV{.5`,,+`M5D`M * xdt:untypedAtomic# D5Zc_PBPZctT: v children(I\GUD) v string-value v typed-value ITZ XQuery mo=P9C-}FcqCD9l/}49lD5Zc#db2- fn:xmlcolumn /}9IT5X;5PD5Zc# *XZc *XZc|, XML *X# Z 1 B DB2 XQuery En 7 ;v*XIT_P;v8z,2IT;P8z;,1,|IT_P`vSz,2IT ;PSz#SzITG*XZc"&m8nZc""MZcMD>Zc#D5ZcM tTZcv;aG*XZcDSz#+G,ITO**XZcG|T:DtTD8 z#*XZcDtTXk_P(;D QName# *XZc_PBPZctT: v node-name v parent(I\GUD) v type-name v children(I\GUD) v attributes(I\GUD) v string-value v typed-value v in-scope-namespaces ITZ XQuery mo=P9C1S9l/}r_-}FcqCD9l/}49l*XZ c# *XZcD type-name tT8>|D`M5kV{.5.dDX5#}g,g{;v* XZc_P type-name tT xs:decimal MV{.5“47.5”,G4`M5MG!}5 47.5# g{*XZcD type-name tTG xdt:untyped,G4*XD`M5HZdV{.5," R`M* xdt:untypedAtomic# tTZc tTZcm> XML tT# tTZcIT_P;v8z,2IT;P8z#I+5PtTD*XZcO*G|D 8z,!\tTZc;G|D8*XDSz# tTZc_PBPZctT: v node-name v parent(I\GUD) v type-name v string-value v typed-value ITZ XQuery mo=P9C1S9l/}r_-}FcqCD9l/}49ltTZ c# tTZcD type-name tT8>|D`M5kV{.5.dDX5#}g,g{;vt TZc_P type-name tT xs:decimal MV{.5“47.5”,G4|D`M5MG!}5 47.5# D>Zc D>Zc|, XML V{Z]# 8 XQuery N< D>ZcIT_P;v8z,2IT;P8z#w*D5Zcr*XZcDSzDD >Zcv;aw*`Z,zvV#19lD5Zcr*XZc1,NN`ZDD>Z c,zZc#g{qCDD>ZcGUD,G4a+|Oz# D>Zc_PBPZctT: v content(I\GUD) v parent(I\GUD) ITZ XQuery mo=P9C-}FcqCD9l/}49lD>Zc,2IT(}1 S*X9l/}DYw49lD>Zc# &m8nZc &m8nZcab0 XML &m8n# &m8nZcIT_P;v8z,2IT;P8z#&m8nDZ];\|,V{. ?>#&m8nD?jXkG;v NCName#C?jC4j6*+8>E""MxD&C Lr# &m8nZc_PBPZctT: v target v content v parent(I\GUD) ITZ XQuery mo=P9C1S9l/}r_-}FcqCD9l/}49l&m8 nZc# "MZc "MZc|, XML "M# "MZcIT_P;v8z,2IT;P8z#"MZcDZ];\|(V{.“--” (=v,V{),"Rns;vV{;\G,V{(-)# "MZc_PBPZctT: v content v parent(I\GUD) ITZ XQuery mo=P9C1S9l/}r_-}FcqCD9l/}49l"MZ c# ZcDD53r ;vcNa9PDyPZc<*qS3;3r(4,D53r)#4UC3r,?v Zc<+ZdSz0fvV#g{ZccNa9GCQrP/D XML m>D,G4D 53rkZcDvV3r`T&# cNa9PDZc4TB3rvV: v yZcGZ;vZc# v *XZcZ|GDSz0fvV# Z 1 B DB2 XQuery En 9 v tTZctzZk|G`X*D*XZcsfvV#tTZcD`T3rITGN bD,+GZ&mi/ZdK3r;aDd# v ,zD`T3rI|GZZccNa9PD3r47(# v ;vZcDSzMsz+ZCZcsfD,z0fvV# Zcj6 ?vZc ZcDZ]4D53rxP"CDa{# xdt:untypedAtomic }]`MD5},|G+|DyP szD>ZcDZ]4D53rxP"CDa{# XML D5P D*X xs:string }]`MD5},|G+|DyPD>Zc szDZ]4D53rxP"CDa{# xdt:untypedAtomic }]`MD5},|G+|DyP D>ZcszDZ]4D53rxP"CDa{# XML D5P DtT xs:string }]`MD5},|m>-< XML D5P DtT5# xdt:untypedAtomic }]`MD5},|m>-< XML D5PDtT5# D> w* xs:string }]`MD5}DZ]# w* xdt:untypedAtomic }]`MD5}DZ]# "M w* xs:string }]`MD5}DZ]# w* xs:string }]`MD5}DZ]# &m8n w* xs:string }]`MD5}DZ]# w* xs:string }]`MD5}DZ]# XDM DrP/ XQuery mo=Da{,|G XDM D5},I(}rP/xLd;* XML m>(# (}rP/,ZcM-S5DrP(XDM D5})a*;* XML m>(#rP/D a{"Gq=b=v QName `H#bb6E49=v QName D0:;,(|GD 0:s(A,;{FUd URI),b=v QName 2G%dD# TB>}|( QName: v ns1:name v ns2:name v name ZK>}P,ns1 Gs(A URI http://posample.org D0:#0: ns2 +s(A URI http://mycompany.com#1!*X{FUdGm; URI,;,Z ns1 M ns2 DX* URI#yP}v*XDV?{This text is in an element named "name" that is qualified by the prefix "ns1". This text is in an element named "name" that is qualified by the prefix "ns2". This text is in an element named "name" that is in the default element namespace. K>}PD*X2C,;V?{ name,+;a"z|{e;,-rGb)*XZ;,{ FUdP#Z&mmo=Zd,{F ns1:name +)9*|(s(A ns1 D URI MV ?{ name D{F#,y,{F ns2:name +)9*|(s(A ns2 D URI MV?{ name D{F#r*48(NN0:,yT_PU0:D*X name +s(A1!*X{ FUd#g{3v{F9C4s(A URI D0:,G4a5Xms# QName(^({F)q- W3C Recommendation Namespaces in XML P(eDo(# 2,Q*{FUd {FUdywa+{FUd0:s(A URI#CZXF QName Zi/mo=PDbM D{FUds(/OF*2,Q*{FUd# Z 1 B DB2 XQuery En 11 2,Q*{FUdGi/mo=DtT,kmo=&mD}]^X# 3){FUd0:G$HywD;d{{FUdrI(}i/rTr*X9l/}P DywxPmS#BmhvK DB2 XQuery |(D$Hyw{FUd0:# m 2. DB2 XQuery PD$Hyw{FUd 0: URI hv xml http://www.w3.org/XML/1998/namespace XML #t{FUd xs http://www.w3.org/2001/XMLSchema XML #={FUd xsi http://www.w3.org/2001/XMLSchema-instance XML #=5}{FUd fn http://www.w3.org/2005/xpath-functions 1!/}{FUd xdt http://www.w3.org/2005/xpath-datatypes XQuery `M{FUd db2-fn http://www.ibm.com/xmlns/prod/db2/functions DB2 /}{FUd }$Hyw{FUdb,9I(}BP==a);i2,Q*{FUd: v Zi/rTPyw,(}9C{FUdywr1!{FUdyw#TB>}{FU dyw9{FUd0: ns1 k URI http://mycompany.com `X*: declare namespace ns1 = "http://mycompany.com"; TB>}1!*X/`M{FUdywa*i/P;P0:D*X{FhC URI: declare default element namespace "http://posample.org"; v I*X9l/}PD{FUdywtTyw#TB>}G|,{FUdywtTD *X9l/},CtT+0: ns2 s(A9l*XwCrZD URI http:// mycompany.com: 14.99 v I SQL/XML a)#SQL/XML Ia)BP;i{FUd: – SQL/XML $Hyw{FUd# – Z SQL/XML 9l/}Md{ SQL/XML mo=PywD{FUd# rTPD{FUdywr*X9l/}PDsx{FUdywtTI\2G SQL/ XML a)D{FUd#*X9l/}PD{FUdywtTI\2GrTPywD {FUd# oT<( BPwb+hv XQuery oT<(# xVs!4 XQuery G;VxVs!4DoT# XQuery PDX|V9C!4V{,"R;G#tX|V#XQuery mo=PD{FIT koTX|V`,# 12 XQuery N< Uq s`} XQuery mo=PJm9CUqTDxIAT,49Uq"Gmo=o(D;? V`gK#UqIUqV{(X’20’)"X5{(X’0D’)";P{(X’0A’)MFm{ (X’09’)iI# ;c45,UqZi/P;Pbe,+ZBPivB#tUq1}b: v UqZV{.DVP# v Uq(}h9bvw+=v`ZjG6p*;vjGT9mo=dC|Sw@# v UqZ*X9l/}P#rTPD_gUqyw7(GZ*X9l/}#t9G} %Uq# }g,BPmo=h*9CUqT9mo=dC|Sw@: v name- name azzms#bvw+ name- 6p*%v QName(^({F),"Z R;=Kc{15Xms# v name -name ;azzms#bvw+Z;v name 6p* QName,+uE(-)6p *Kc{,"+Z~v name 6p*m;v QName# v name-name ;azzms#+G,mo=abv*%v QName,-rG,V{(-) Z QName PGP'V{# v BPmo=}G XQuery PD"M: (: A comment. You can use comments to make your code easier to understand. :) BP(CfrJCZZ DB2 XQuery P9C"M: v Jm9CIvTUqD;C}5wO(D"MT0azzmsD"M: v (: is this a comment? ::) GO("M# v (: is this a comment? ::) or an error? :) azzms,-rG{E (: M :) D6W'b# v (: commenting out a (: comment :) might be confusing, but is often helpful :) GO("M,-rGJmxP=bD"M6W# v "this is just a string :)" GO(mo=# v (: "this is just a string :)" :) azzms#,y,"this is another string (:" GO(mo=,x (: "this is another string (:" :) azzms#DVZ ]I\a}|( xs:integer"xs:string M xs:date# XQuery D$(e`MZ{FUd http://www.w3.org/2005/xpath-datatypes P,C {FUd_P$HywD{FUd0: xdt#XQuery D$(e`MD>}|( xdt:untypedAtomic"xdt:yearMonthDuration M xdt:dayTimeDuration# ?v}]`Mx(` MD5DV{.# `McNa9 DB2 XQuery `McNa9T>IZ XQuery mo=P9CDyP`M# Z 16 3D< 3 PDcNa9|(isy>`MMIz`M#yP-S`MIzT}] `M xdt:anyAtomicType#?vIz}]`MkIz|Dy>`M.daC5_,Sp 4# © Copyright IBM Corp. 2006, 2013 15 4`p.VD`M DB2 XQuery _PBP`M`p:(C"^`M"V{."}V"UZ"1d"Vx1 d0d{# xs:NOTATION xs:QName xs:anyURI xs:base64Binary xs:hexBinary xs:boolean xs:positiveInteger xs:unsignedByte xs:unsignedShort xs:unsignedInt xs:unsignedLong xs:float xs:double xs:decimal xs:integer xs:string xs:anySimpleType xdt:untyped xdt:untypedAtomicxdt:anyAtomicType xs:anyType xs:nonNegativeInteger xs:byte xs:short xs:int xs:long xs:negativeInteger xs:nonPositiveInteger xs:gMonth xs:gDay xs:gMonthDay xs:gYear xs:gYearMonth xdt:dayTimeDuration xdt:yearMonthDuration xs:token xs:normalizedString xs:NCName xs:Name xs:NMTOKEN xs:language xs:ENTITY xs:IDREF xs:ID xs:duration xs:time xs:date xs:dateTime < 3. DB2 XQuery `McNa9 16 XQuery N< (C}]`M m 3. (C}]`M `M hv Z 24 3D:anyType }]`M; xs:anyType }]`M|,cvrcvTOZc0 cvrcvTO-S5DNNrP# Z 24 3D:anySimpleType }]`M; xs:anySimpleType }]`M8>I9CNNr% `MDOBD#K}]`Md1yPr%`M Dy>`M#r%`MD5}ITGNN-S 5rP#|IzT xs:anyType }]`M# Z 24 3D:anyAtomicType }]`M; xdt:anyAtomicType }]`M8>I9CNN- S`MDOBD#K}]`Md1yP-S` MDy>`M#-S`MD5}G%v;IV bD5,g{}"V{.rUZ# ^`M}]`M m 4. ^`M}]`M `M hv Z 37 3D:untyped }]`M; xdt:untyped }]`M8>4-} XML #=i $DZc#|IzT}]`M xs:anyType# Z 37 3D:untypedAtomic }]`M; xdt:untypedAtomic }]`M8>4-} XML # = i $ D - S 5 # | I z T } ] ` M xdt:anyAtomicType# V{.}]`M m 5. V{.}]`M `M hv Z 35 3D:string }]`M; xs:string }]`Mm>V{.#|IzT}]` M xdt:anyAtomicType# Z 34 3D:normalizedString }]`M; xs:normalizedString }]`Mm>Uqf6/D V{.#|IzT}]`M xs:string# Z 36 3D:token }]`M; xs:token }]`Mm>jG/V{.#|IzT xs:normalizedString }]`M# Z 33 3D:language }]`M; xs:language }]`Mm> RFC 3066 (eDT ;oTj6#|IzT}]`M xs:token# Z 34 3D:NMTOKEN }]`M; xs:NMTOKEN }]`Mm> XML 1.0 (Third Edition) PD NMTOKEN tT`M#|IzT xs:token }]`M# Z 33 3D:Name }]`M; xs:Name }]`Mm> XML {F#|IzT xs:token }]`M# Z 33 3D:NCName }]`M; xs:NCName }]`Mm>;9C0ED XML {F#|IzT xs:Name }]`M# Z 32 3D:ID }]`M; xs:ID }]`Mm> XML 1.0 (Third Edition) P Dj6tT`M#|IzT xs:NCName }]` M# Z 2 B `M53 17 m 5. V{.}]`M (x) `M hv Z 32 3D:IDREF }]`M; xs:IDREF }]`Mm> XML 1.0 (Third Edi- tion) PD IDREF tT`M#|IzT xs:NCName }]`M# Z 30 3D:ENTITY }]`M; xs:ENTITY }]`Mm> XML 1.0 (Third Edi- tion) PD ENTITY tT`M#|IzT xs:NCName }]`M# }V}]`M m 6. }V}]`M `M hv Z 28 3D:decimal }]`M; xs:decimal }]`Mm>IC.xF}Vm>D 5}S / # | I z T } ] ` M xdt:anyAtomicType# Z 30 3D:float }]`M; xs:float }]`MD#=Gy] IEEE %+H 32 ; ! c ` M 7 ( D # | I z T } ] ` M xdt:anyAtomicType# Z 28 3D:double }]`M; xs:double }]`MD#=Gy] IEEE ++H 64 ;!c`M7(D#|IzT}]`M xdt:anyAtomicType# Z 33 3D:int }]`M; xs:int }]`Mm>!ZrHZ 2 147 483 647 "RsZrHZ -2 147 483 648 D{}#|I zT xs:long }]`M# Z 34 3D:nonPositiveInteger }]`M; xs:nonPositiveInteger }]`Mm>!ZrHZc D{}#|IzT xs:integer }]`M# Z 33 3D:negativeInteger }]`M; xs:negativeInteger }]`Mm>!ZcD{}# |IzT}]`M xs:nonPositiveInteger# Z 34 3D:nonNegativeInteger }]`M; xs:nonNegativeInteger }]`Mm>sZrHZ cD{}#|IzT xs:integer }]`M# Z 33 3D:long }]`M; xs:long }]`Mm>!ZrHZ 9 223 372 036 854 775 807 "sZrHZ -9 223 372 036 854 775 808 D { } # | I z T } ] ` M xs:integer# Z 33 3D:integer }]`M; xs:integer }]`Mm>!ZrHZ 9 223 372 036 854 775 807 "sZrHZ -9 223 372 036 854 775 808 D}V#|IzT xs:decimal } ]`M# Z 35 3D:short }]`M; xs:short }]`Mm>!ZrHZ 32767 "sZ rHZ -32 768 D{}#|IzT xs:int }] `M# Z 25 3D:byte }]`M; xs:byte }]`Mm>!ZrHZ 127 "sZr HZ -128 D{}#|IzT xs:short }]` M# 18 XQuery N< m 6. }V}]`M (x) `M hv Z 36 3D:unsignedLong }]`M; xs:unsignedLong }]`Mm>!ZrHZ 9 223 372 036 854 775 807 D^{E{}#|IzT xs:nonNegativeInteger }]`M# Z 36 3D:unsignedInt }]`M; xs:unsignedInt }]`Mm>!ZrHZ 4 294 967 295 D ^ { E { } # | I z T xs:unsignedLong }]`M# Z 37 3D:unsignedShort }]`M; xs:unsignedShort }]`Mm>!ZrHZ 65 535 D^{E{}#|IzT xs:unsignedInt } ]`M# Z 36 3D:unsignedByte }]`M; xs:unsignedByte }]`Mm>!ZrHZ 255 D^{E{}#|IzT xs:unsignedShort }] `M# Z 34 3D:positiveInteger }]`M; xs:positiveInteger }]`Mm>sZrHZ 1 D }{}#|IzT xs:nonNegativeInteger }]` M# UZ"1dMVx1d}]`M m 7. UZ"1dMVx1d}]`M `M hv Z 28 3D:duration }]`M; xs:duration }]`Mm>(}qP_{zDj" B"U"!1"VSMk?Vm>DVx1 d#|IzT}]`M xdt:anyAtomicType# Z 37 3D:yearMonthDuration }]`M; xdt:yearMonthDuration }]`Mm>(}qP_ {zDjMB?Vm>DVx1d#|IzT xs:duration }]`M# Z 27 3D:dayTimeDuration }]`M; xdt:dayTimeDuration }]`Mm>Cl}"!1 }"VS}Mk}?Vm>DVx1d#|I zT xs:duration }]`M# Z 25 3D:dateTime }]`M; xs:dateTime }]`Mm>;v1L,_PBP T{}5m>Dj"B"U"!1"VSt T"T.xF5m>DktTT0I!1x8 >{#|IzT}]`M xdt:anyAtomicType# Z 25 3D:date }]`M; xs:date }]`Mm>Vx1d}C;lD1d dt,pDj"BMUtT0 I!1x8>{#S xdt:anyAtomicType }]` MIz# Z 35 3D:time }]`M; xs:time }]`Mm>?;lX4vVD1L# |IzT}]`M xdt:anyAtomicType# Z 32 3D:gYearMonth }]`M; xs:gYearMonth }]`Mm>X(qP_{zj ]DX(qP_{zB]#qP_{zB]G Z ISO 8601 P(eD#|IzT}]`M xdt:anyAtomicType# Z 2 B `M53 19 m 7. UZ"1dMVx1d}]`M (x) `M hv Z 31 3D:gYear }]`M; xs:gYear }]`Mm>qP_{zj]#qP_ {zj]GZ ISO 8601 P(eD#|IzT} ]`M xdt:anyAtomicType# Z 31 3D:gMonthDay }]`M; xs:gMonthDay }]`Mm>X4vVDqP_ {zUZ#qP_{zUZGZ ISO 8601 P( eD#|IzT}]`M xdt:anyAtomicType# Z 30 3D:gDay }]`M; xs:gDay }]`Mm>X4vVDqP_{zU Z#qP_{zUZGZ ISO 8601 P(eD# |IzT}]`M xdt:anyAtomicType# Z 31 3D:gMonth }]`M; xs:gMonth }]`Mm>?jX4vVDqP_ {zB]#qP_{zB]GZ ISO 8601 P( eD#|IzT}]`M xdt:anyAtomicType# d{}]`M m 8. d{}]`M `M hv Z 25 3D:boolean }]`M; xs:boolean }]`M'V~xF5_-D}'E n : true r false# | I z T } ] ` M xdt:anyAtomicType# Z 24 3D:anyURI }]`M; xs:anyURI }]`Mm>3;J4j6 (URI)# |IzT}]`M xdt:anyAtomicType# Z 35 3D:QName }]`M; xs:QName }]`Mm> XML ^({ (QName) #QName |(I!{FUd0:"CZj6 XML {FUdD URI M>X?V(4 NCName) # | I z T } ] ` M xdt:anyAtomicType# Z 34 3D:NOTATION }]`M; xs:NOTATION }]`Mm> XML 1.0 (Third Edition) PD NOTATION tT`M#|IzT }]`M xdt:anyAtomicType# Z 32 3D:hexBinary }]`M; xs:hexBinary }]`Mm>.yxF`kD~x F } ] # | I z T } ] ` M xdt:anyAtomicType# Z 24 3D:base64Binary }]`M; xs:base64Binary }]`Mm>y> 64 ;`kD ~ x F } ] # | I z T } ] ` M xdt:anyAtomicType# ZC}]`MD9l/} 9l/}+;V-S`MD5}*;*m;V-S`MD5}#XML #=P(eD?v ZC-S`M XML #=}]`M xs:unsignedInt D9l/}Do(: xs:unsignedInt(value) I+]AK9l/}D5GIP'*;*?j}]`MDNN-S5#}g,K/} DBPwCa5X,;a{,4 xs:unsignedInt 5 12: xs:unsignedInt(12) xs:unsignedInt("12") ZZ;v>}P,}VDV 12 ++]A9l/}#r*DV;|,!}c,yT+b v* xs:integer,x xs:integer 5+*;*`M xs:unsignedInt#ZZ~v>}P,V{ .DV“12”++]A9l/}#V{.DV+bv* xs:string,x xs:string 5+*;* `M xs:unsignedInt# 9I+Zcw*Td?wC9l/}#ZKivB,DB2 XQuery a+Zc-S/Ti !d`M5,;s9CC5wC9l/}#g{+]A9l/}D5;\*;*?j }]`M,G4a5Xms# xs:QName D9l/}k9l/}(Co(D;,.&ZZ,C9l/};`M.d'V`M*;#?F `M*;mo=M`M9l/}Pa9C`M*;# BmP8>K\'VD`M*;#?vmZs_T>w*`M*;4Dy>`M," Z%?T>w*`M*;?jDy>`M#Z;vm|,S xdt:untypedAtomic A xs:dateTime D?j,Z~vm|,S xs:time A xs:NOTATION D?j# Z 2 B `M53 21 mPD%*q|,BP}vV{DdP;v: Y G#8>'VS4`MD5*;A?j`M# N q#8>;'VS4`MD5*;A?j`M# M I\#8>xP4`MA?j`MD*;1,3)5D*;I\I&,m;) 5D*;I\'\# ;'Vk xs:anySimpleType r xdt:anyAtomicType .dxP*;# g{"TxP;\'VD?F`M*;,G4a5Xms# m 9. y>`M*;,Z 1 ?V(S xdt:untypedAtomic A xs:dateTime D?j) 4}]`M ?j uA ?j string ?j float ?j double ?j decimal ?j integer ?j dur ?j yMD ?j dTD ?j dT uAY YMMMMMMMM string Y Y MMMMMMMM float YYYYMMNNNN double Y Y M Y M M NNNN decimal YYYYYMNNNN integer YYYYYYNNNN durYYNNNNYYYN yMDYYNNNNYYNN dTDYYNNNNYNYN dTYYNNNNNNNY time YYNNNNNNNN date YYNNNNNNNY gYMYYNNNNNNNN gYrYYNNNNNNNN gMDYYNNNNNNNN gDay YYNNNNNNNN gMon YYNNNNNNNN bool YYYYYYNNNN b64YYNNNNNNNN hxBYYNNNNNNNN aURI YYNNNNNNNN QNYYNNNNNNNN NOTYYNNNNNNNN m 10. y>`M*;,Z 2 ?V(S xs:time A xs:NOTATION D?j) 4}]` M ?j time ?j date ?j gYM ?j gYr ?j gMD ?j gDay ?j gMon ?j bool ?j b64 ?j hxB ?j aURI ?j QN ?j NOT uAMMMMMMMMMMMN N string MMMMMMMMMMMMM float NNNNNNNYNNNNN 22 XQuery N< m 10. y>`M*;,Z 2 ?V(S xs:time A xs:NOTATION D?j) (x) 4}]` M ?j time ?j date ?j gYM ?j gYr ?j gMD ?j gDay ?j gMon ?j bool ?j b64 ?j hxB ?j aURI ?j QN ?j NOT double NNNNNNNYNNNNN decimal NNNNNNNYNNNNN integer NNNNNNNYNNNNN durNNNNNNNNNNNNN yMDNNNNNNNNNNNNN dTDNNNNNNNNNNNNN dTYYYYYYYNNNNNN time YNNNNNNNNNNNN date NYYYYYYNNNNNN gYMNNYNNNNNNNNNN gYrNNNYNNNNNNNNN gMDNNNNYNNNNNNNN gDay NNNNNYNNNNNNN gMon NNNNNNYNNNNNN bool NNNNNNNYNNNNN b64NNNNNNNNYYNNN hxBNNNNNNNNYYNNN aURI NNNNNNNNNNYNN QNNNNNNNNNNNNNN NOTNNNNNNNNNNNNM PMPIj6BP`MDrLzkj6: v uA = xdt:untypedAtomic v string = xs:string v float = xs:float v double = xs:double v decimal = xs:decimal v integer = xs:integer v dur = xs:duration v yMD = xdt:yearMonthDuration v dTD = xdt:dayTimeDuration v dT = xs:dateTime v time = xs:time v date = xs:date v gYM = xs:gYearMonth v gYr = xs:gYear v gMD = xs:gMonthDay v gDay = xs:gDay Z 2 B `M53 23 v gMon = xs:gMonth v bool = xs:boolean v b64 = xs:base64Binary v hxB = xs:hexBinary v aURI = xs:anyURI v QN = xs:QName v NOT = xs:NOTATION anyAtomicType }]`M xdt:anyAtomicType }]`M8>I9CNN-S`MDOBD#K}]`Md1yP- S`MDy>`M#-S`MD5}G%v;IVbD5,g{}"V{.rUZ# |IzT xs:anySimpleType }]`M# }]`M xdt:anyAtomicType _P^I9CNNr%`MDOBD#K}]`Md1yPr %`MDy>`M#r%`MD5}ITGNN-S5rP#|IzT xs:anyType }] `M# xs:anySimpleType }]`M_P^3;J4j6 (URI)#|IzT}]`M xdt:anyAtomicType# xs:anyURI }]`MDJ(q=G;vO(D URI V{.,{ORFC 2396(eMRFC 2732^}DZ]#k!?\bZK`MD5P9CUq,qrUq+;`k* %20# base64Binary }]`M xs:base64Binary }]`Mm>y> 64 ;`kD~xF}]#|IzT}]`M xdt:anyAtomicType# TZy> 64 ;`kD~xF}],{v~xFwG(}9Cy> 64 ;V8`4D# y> 64 ;V8mZ RFC 2045 PwKhv# 24 XQuery N< xs:base64Binary DJ(q=;^F*;\9C RFC 2045 P(eDy> 64 ;V8m D 65 vV{#P'V{|( a = z"A = Z"0 = 9"SE(+)"}1\(/)" HE(=)"XML 1.0 (Third Edition)P(eDV{0Uq#;Jm9Cd{V{# boolean }]`M xs:boolean }]`M'V~xF5_-D}'En:true r false#|IzT}]`M xdt:anyAtomicType# xs:boolean }]`MDJ(q=;!ZrHZ 127 "sZrHZ -128 D{}#|IzT xs:short } ]`M# xs:byte DJ(q=G;vI!{E,sz^($HD.xF}rP#g{{E;!T, G4m>}E(+)#BP}VGK}]`MDP'>}:-1"0"126 M +100# date }]`M xs:date }]`Mm>Vx1d}C;lD1ddt,pDj"BMUtT0I!1x8>{#S xdt:anyAtomicType }]`MIz# `M* xs:date DV1x5ay]7(D1xG<;lDp<1L#;lDp<1Lp ,;1ddt# xs:date DJ(q=GTBq=D^($HV{rP:yyyy-mm-ddzzzzzz#;Jm9C:5 UZ#BPu4CZhvKq=: yyyy CZm>j]D 4 ;}V#P'5G 0001 = 9999 D{}#;Jm9CSE (+)# mm CZm>B]D 2 ;}V# dd CZm>UZD 2 ;}V# zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# dateTime }]`M xs:dateTime }]`Mm>;v1L,_PBPT{}5m>Dj"B"U"!1"VS t T " T . x F5m > D k t T T 0 I ! 1 x 8 > { # | I z T } ] ` M xdt:anyAtomicType# Z 2 B `M53 25 xs:dateTime DP'J(;PT=1x#TZ;PT=1xDm>,+9C~=1x UTC (+rj<1d,2F*qV~Nj<1d)#m>*}V5D?vtT;j]D 4 ;}V#P'5G 0001 = 9999 D{}#;Jm9CSE (+)# - UZ?V.dDVt{# mm CZm>B]D 2 ;}V# dd CZm>UZD 2 ;}V# T CZ8>;lPD1dDVt{# hh CZm>!1D 2 ;}V#v1VSMk*c1EJm9C5 24#|(1 d 24:00:00 Di/+;S*Z~lD 00:00:00 &m# : 1d?V.dDVt{# mm CZm>VSD 2 ;}V# ss CZm>kD{}?VD 2 ;}V# .ssssss I!#g{fZ,G4*m>kD!}?VD 1 = 6 ;}V# zzzzzz I!#g{fZ,G4m>1x#kND:1x8>{;TKbPXKtTDq= DE"# }g,TBq=8>@z+?j<1d 2005 j 10 B 10 UPg: 2005-10-10T12:00:00-05:00 K1dC UTC m>* 2002-10-10T17:00:00Z# 1x8>{ 1x8>{DJ(q=G|(BP=Vq=.;DV{.: v }E(+)r:E(-),sz hh:mm,dP9CKBPu4: hh CZm>!1D 2 ;}V(h*0VSD 2 ;}V#g{!1tTD5* 24,G4VStTD5Xk* c# + 8>H UTC ,0D1xPD8(1L,0 hh !1 mm VS# - 8>H UTC dsD1xPD8(1Lds hh !1 mm VS# v DV Z m> UTC PD1d,Z m>f31d,k UTC H[#T1x8( Z `1 Z8( +00:00 r -00:00# 26 XQuery N< dayTimeDuration }]`M xdt:dayTimeDuration }]`Mm>Cl}"!1}"VS}Mk}?Vm>DVx1d# |IzT xs:duration }]`M# K}]`MIm>D6'Z -P83333333333333Y3M11574074074DT1H46M39.999999S = P83333333333333Y3M11574074074DT1H46M39.999999S r -999999999999999 vB -999999999999999.999999 k= 999999999999999 vB 999999999999999.999999 k. d# xdt:dayTimeDuration DJ(q=* PnDTnHnMnS,|G ISO 8601 q=DuuN=#B Pu4CZhvKq=: P Vx1d8>{# nD n G^{E{},CZm>l}# T UZM1dVt{# nH n G^{E{},CZm>!1}# nM n G^{E{},CZm>VS}# nS n G^{E{},CZm>k}#g{vV!}c,G4Xksz 1 = 6 ;}V Tm>kD!}?V# }g,TBq=8> 3 lV 10 !1 30 VS# P3DT10H30M TBq=8>: 120 lDVx1d: -P120D I!0:Vx1d#g{!TC{E,G4IC}Vx1d# Jm9CKq=Duu+HMXOm>,+|GXk{OBP*s: v g{mo=PDl}"!1}"VS}rk}HZc,G4}V0d`&8>{I T!T#+G,XkPAYdP;v}V0d8>{# v k}?VI\P!}?V# v 1Rv1yP1dn<;fZ1,8>{ T ;(;fZ#8>{ P XkIC.xF}Vm>D5}S/#|IzT}]`M xdt:anyAtomicType# xs:decimal DJ(q=G^($HD.xF}rP,(}d1!}8>{Ddct*# Jm9CI!0<{E#g{{E;!T,G4m>}E(+)#0}: -1.23 12678967.543233 +100000.00 210 double }]`M xs:double }]`MD#=Gy] IEEE ++H 64 ;!c`M7(D#|IzT}] `M xdt:anyAtomicType# xs:double Dy>5UdI6'Z -1.7976931348623158e+308 = -2.2250738585072014e- 308 .dT06'Z +2.2250738585072014e-308 = +1.7976931348623158e+308 .dD 5iI#xs:double D5Ud9|(BPXb5:}^n,:^n,}c,:cMG}V (NaN)# xs:double DJ(q=G;v2},"RI!qszV{ E r e 08}#8}XkG{ }#2}XkG.xF}#8}M2}Dm>Xkq- xs:integer M xs:decimal DJ( fr#g{ E r e 0szD8};!T,G4aY(8}5* 0# c D J ( q = I T I C } E r : E # B P D V G K } ] ` M D P ' > }:-1E4"1267.43233E12"12.78e-2"12"-0 M 0# Xb5}^n":^nMG}VDJ(q=Vp* INF"-INF M NaN#}^nDJ( q=;\IC}E# a>:Xb5 INF"-INF M NaN ;PVf5#I9C xs:double `M9l/}(}V {.49l5 INF"-INF M NaN#}g:xs:double("INF")# duration }]`M xs:duration }]`Mm>(}qP_{zDj"B"U"!1"VSMk?Vm>DV x1d#|IzT}]`M xdt:anyAtomicType# K}]`MIm>D6'Z -P83333333333333Y3M11574074074DT1H46M39.999999S = P83333333333333Y3M11574074074DT1H46M39.999999S r -999999999999999 vB -999999999999999.999999 k= 999999999999999 vB 999999999999999.999999 k. d# 28 XQuery N< xs:duration DJ(q=* ISO 8601 )9q= PnYnMnDTnHnMnS#BPu4CZhv) 9q=: P Vx1d8>{# nY n G^{E{},CZm>j}# nM n G^{E{},CZm>B}# nD n G^{E{},CZm>l}# T UZM1dVt{# nH n G^{E{},CZm>!1}# nM n G^{E{},CZm>VS}# nS n G^{E{},CZm>k}#g{vV!}c,G4Xksz 1 = 6 ;}V Tm>kD!}?V# }g,TBq=8> 1 j 2 vBc 3 lV 10 !1 30 VSDVx1d: P1Y2M3DT10H30M TBq=8>: 120 lDVx1d: -P120D I!0:Vx1d#g{!TC{E,G4IC}Vx1d# Jm9CKq=Duu+HMXOm>,+|GXk{OBP*s: v g{mo=PDj}"B}"l}"!1}"VS}rk}HZc,G4}V0d `&8>{IT!T#+G,XkPAYdP;v}V0d8>{# v k}?VI\P!}?V# v 1Rv1yP1dn<;fZ1,8>{ T ;(;fZ# v 8>{ P Xk XML 1.0 (Third Edition) PD ENTITY tT`M#|Iz T xs:NCName }]`M# xs:ENTITY DJ(q=G;|,0ED XML {F(NCName)# float }]`M xs:float }]`MD#=Gy] IEEE %+H 32 ;!c`M7(D#|IzT}]` M xdt:anyAtomicType# xs:float Dy>5UdI6'Z -3.4028234663852886e+38 = -1.1754943508222875e-38 .dT06'Z +1.1754943508222875e-38 = +3.4028234663852886e+38 .dD5iI# xs:float D5Ud9|(BPXb5:}^n,:^n,}c,:cMG}V(NaN)# xs:float DJ(q=G;v2},"RI!qszV{ E r e 08}#8}XkG{ }#2}XkG.xF}#8}M2}Dm>Xkq- xs:integer M xs:decimal DJ( fr#g{ E r e 0szD8};!T,G4aY(8}5* 0# c D J ( q = I T I C } E r : E # B P D V G K } ] ` M D P ' > }:-1E4"1267.43233E12"12.78e-2"12"-0 M 0# Xb5}^n":^nMG}VDJ(q=Vp* INF"-INF M NaN#}^nDJ( q=;\IC}E# a>:Xb5 INF"-INF M NaN ;PVf5#I9C xs:float `M9l/}(}V{ .49l5 INF"-INF M NaN#}g:xs:float("INF")# gDay }]`M xs:gDay }]`Mm>X4vVDqP_{zUZ#qP_{zUZGZ ISO 8601 P (eD#|IzT}]`M xdt:anyAtomicType# K}]`Mm>3vBDX(UZ#}g,K}]`MICZ8>"=UG?vBD 15 E# xs:gDay DJ(q=* ---ddzzzzzz,|G xs:date DXOm>,4|(B]Mj]t T#;Jm9CNN0<{E#;Jm9CNNd{q=#BPu4CZhvKq =: dd CZm>UZD 2 ;}V# zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# }g,TBq=8>3vBD 16 E,?vB?jX4vVDqP_{zB]#qP_{zB]GZ ISO 8601 P(eD#|IzT}]`M xdt:anyAtomicType# K}]`Mm>3jDX(B]#}g,K}]`MICZ8> 12 BD%.Z# xs:gMonth DJ(q=* --mmzzzzzz,|G xs:date DXOm>,4|(j]MUZt T#;Jm9CNN0<{E#;Jm9CNNd{q=#BPu4CZhvKq =: mm CZm>B]D 2 ;}V# zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# }g,TBq=8> 12 B,?jX4vVDqP_{zUZ#qP_{zUZGZ ISO 8601 P(eD#|IzT}]`M xdt:anyAtomicType# K}]`Mm>3jDX(UZ#}g,K}]`MICZ8>?jD 4 B 16 Uw* zU# xs:gMonthDay DJ(q=* --mm-ddzzzzzz,|G xs:date DXOm>,4|(j]t T#;Jm9CNN0<{E#;Jm9CNNd{q=#BPu4CZhvKq =: mm CZm>B]D 2 ;}V# dd CZm>UZD 2 ;}V# zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# }g,TBq=8> 4 B 16 U,?jqP_{zj]#qP_{zj]GZ ISO 8601 P(eD#| IzT}]`M xdt:anyAtomicType# xs:gYear DJ(q=* yyyyzzzzzz#Kq=G xs:dateTime DXOm>,4|(B]" UZr1l1dtT#;Jm9C:5UZ#BPu4CZhvKq=: yyyy CZm>j]D 4 ;}V#P'5G 0001 = 9999 D{}#;Jm9CSE (+)# Z 2 B `M53 31 zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# }g,TBq=m>qP_{z 2005 j:2005# gYearMonth }]`M xs:gYearMonth }]`Mm>X(qP_{zj]DX(qP_{zB]#qP_{z B]GZ ISO 8601 P(eD#|IzT}]`M xdt:anyAtomicType# xs:gYearMonth DJ(q=* yyyy-mmzzzzzz#Kq=G xs:dateTime DXOm>,4| (1l1dtT#;Jm9C:5UZ#BPu4CZhvKq=: yyyy CZm>j]D 4 ;}V#P'5G 0001 = 9999 D{}#;Jm9CSE (+)# mm CZm>B]D 2 ;}V# zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# }g,TBq=4|(I!1x8>{,CZ8> 2005 jD 10 B: 2005-10 hexBinary }]`M xs:hexBinary }]`Mm>.yxF`kD~xF}]#|IzT}]`M xdt:anyAtomicType# xs:hexBinary DJ(q=G;vV{rP,dP?v~xF~*#}g,TBq=G 16 ;{} 4023 D.yxF`k,d~xFm>* 111110110111:0FB7# ID }]`M xs:ID }]`Mm> XML 1.0 (Third Edition) PDj6tT`M#|IzT xs:NCName }]`M# xs:ID DJ(q=G;|,0ED XML {F(NCName)# IDREF }]`M xs:IDREF }]`Mm> XML 1.0 (Third Edition) PD IDREF tT`M#|IzT xs:NCName }]`M# xs:IDREF DJ(q=G;|,0ED XML {F(NCName)# 32 XQuery N< int }]`M xs:int }]`Mm>!ZrHZ 2 147 483 647 "RsZrHZ -2 147 483 648 D{ }#|IzT xs:long }]`M# xs:int DJ(q=G;vI!{E,sz^($HD.xF}rP#g{{E;!T,G 4m>}E(+)#BP}VGK}]`MDP'>}:-1"0"126789675 M +100000# integer }]`M xs:integer }]`Mm>!ZrHZ 9 223 372 036 854 775 807 "sZrHZ -9 223 372 036 854 775 808 D}V#|IzT xs:decimal }]`M# xs:integer DJ(q=G^($HD.xF}(xPI!0<{E)rP#g{{E;! T , G 4 m > } E ( + ) # B P } V G K } ] ` M D P ' > }:-1"0"12678967543233 M +100000# language }]`M xs:language }]`Mm> RFC 3066 (eDT;oTj6#|IzT}]`M xs:token# xs:language DJ(q=GC,V{,SDjGV{.#?vjG|,DV{;,} 8 v#Z;vjG;\|,V8V{,sxjGI|,V8V{M}VV{#}g,5 en-US m>@z"o#CV{.{O#= [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*# long }]`M xs:long }]`Mm>!ZrHZ 9 223 372 036 854 775 807 "sZrHZ -9 223 372 036 854 775 808 D{}#|IzT}]`M xs:integer# xs:long DJ(q=G;vI!{E,sz^($HD.xF}rP#g{{E;!T, G4m>}E(+)#BP}VGK}]`MDP'>}:-1"0"12678967543233 M +100000# Name }]`M xs:Name }]`Mm> XML {F#|IzT xs:token }]`M# xs:Name DJ(q=Gk XML 1.0 (Third Edition) PD{Fz7`%dDV{.# NCName }]`M xs:NCName }]`Mm>;9C0ED XML {F#|IzT xs:Name }]`M# xs:NCName DJ(q=G;|,0ED XML {F# negativeInteger }]`M xs:negativeInteger }]`Mm>!ZcD{}#|IzT}]`M xs:nonPositiveInteger# Z 2 B `M53 33 xs:negativeInteger DJ(q=G;v:E(-),sz^($HD.xF}rP#K}] `MIm>D6'Z -9223372036854775808 = -1 .d#BP}VGK}]`MDP '>}:-1"-12678967543233 M -100000# NMTOKEN }]`M xs:NMTOKEN }]`Mm> XML 1.0 (Third Edition) PD NMTOKEN tT`M#| IzT xs:token }]`M# xs:NMTOKEN DJ(q=Gk XML 1.0 (Third Edition) PD Nmtoken z7`%dD V{.# nonNegativeInteger }]`M xs:nonNegativeInteger }]`Mm>sZrHZcD{}#|IzT xs:integer }]`M# xs:nonNegativeInteger J(q=G;vI!{E,sz^($HD.xF}rP#g{{ E;!T,G4m>}E(+)#TZ8>cDJ(q=,{EIT*}E(+)r: E(-)#ZyPd{J(q=P,g{fZ{E,G4Xk*}E(+)#K}]` MIm>D6'Z 0 = +9223372036854775807 .d#BP}VGK}]`MDP'> }:1"0"12678967543233 M +100000# nonPositiveInteger }]`M xs:nonPositiveInteger }]`Mm>!ZrHZcD{}#|IzT xs:integer }]`M# xs:nonPositiveInteger DJ(q=G;vI!0<{E,sz^($HD.xF}rP# TZ8>cDJ(q=,{EIT*}E(+),2I!T;ZyPd{J(q=P, XkJ>:E(-)#K}]`MIm>D6'Z -9223372036854775808 = 0 .d# BP}VGK}]`MDP'>}:-1"0"-12678967543233 M -100000# normalizedString }]`M xs:normalizedString }]`Mm>Uqf6/DV{.#|IzT}]`M xs:string# xs:normalizedString DJ(q=G;|,X5{(X’0D’)";P{(X’0A’)rFm{ (X’09’)DV{.# NOTATION }]`M xs:NOTATION }]`Mm> XML 1.0 (Third Edition) PD NOTATION tT`M# |IzT}]`M xdt:anyAtomicType# xs:NOTATION }]`MDJ(q=G`M* xs:QName DJ(q=# positiveInteger }]`M xs:positiveInteger }]`Mm>sZrHZ 1 D}{}#|IzT xs:nonNegativeInteger }]`M# 34 XQuery N< xs:positiveInteger DJ(q=G;vI!}E(+),sz^($HD.xF}rP#K }]`MIm>D6'Z +1 = +9223372036854775807 .d#BP}VGK}]`M DP'>}:1"12678967543233 M +100000# QName }]`M xs:QName }]`Mm> XML ^({ (QName)#QName |(I!{FUd0:"C Zj6 XML {FUdD URI M>X?V(4 NCName)#|IzT}]`M xdt:anyAtomicType# xs:QName }]`MDJ(q=*9CTBq=DV{.:prefix:localName#BPu 4CZhvKq=: prefix I!#{FUd0:#{FUd0:XkI{FUdyws(A URI }C#0:; \d1{FUdD<;{#g{48(NN0:,G4a9C1!*X/`M{F UdD URI# localName d1^({FDV?D NCName#NCName G;P0ED XML {F# }g,TBV{.G|,0:D QName DP'J(q=: ns1:emp short }]`M xs:short }]`Mm>!ZrHZ 32767 "sZrHZ -32 768 D{}#|IzT xs:int }]`M# xs:short DJ(q=G;vI!{E,sz^($HD.xF}rP#g{{E;!T, G4m>}E(+)#BP}VGK}]`MDP'>}:-1"0"12678 M +10000# string }]`M xs:string }]`Mm>V{.#|IzT}]`M xdt:anyAtomicType# xs:string DJ(q=G;vV{rP,I|,;Z XML O(V{6'ZDNNV{# time }]`M xs:time }]`Mm>?;lX4vVD1L#|IzT}]`M xdt:anyAtomicType# xs:time DJ(q=G hh:mm:ss.sssssszzzzzz#Kq=G xs:dateTime DXOm>,4 |(j]"B]rUZtT#BPu4CZhvKq=: hh CZm>!1D 2 ;}V#v1VSMk*c1EJm9C5 24#|(1 d 24:00:00 Di/+;S*Z~lD 00:00:00 &m# : 1d?V.dDVt{# mm CZm>VSD 2 ;}V# ss CZm>kD{}?VD 2 ;}V# Z 2 B `M53 35 .ssssss I!#g{fZ,G4*m>kD!}?VD 1 = 6 ;}V# zzzzzz I!#g{fZ,G4m>1x#kNDZ 26 3D:1x8>{;TKbPXK tTDq=DE"# }g,TBq=|(I!1x8>{,m>+?j<1dBg 1:20,|H+rj<1d (UTC)a0 5 v!1: 13:20:00-05:00 token }]`M xs:token }]`Mm>jG/V{.#|IzT xs:normalizedString }]`M# xs:token DJ(q=G;|,BPNNV{DV{.: v X5{(X’0D’) v ;P{(X’0A’) v Fm{(X’09’) v 0!ZrHZ 255 D^{E{}#|IzT xs:unsignedShort }]`M# xs:unsignedByte DJ(q=G^($HD.xF}rP#BP}VGK}]`MDP' >}:0"126 M 100# unsignedInt }]`M xs:unsignedInt }]`Mm>!ZrHZ 4 294 967 295 D^{E{}#|IzT xs:unsignedLong }]`M# xs:unsignedInt DJ(q=G^($HD.xF}rP#BP}VGK}]`MDP'> }:0"1267896754 M 100000# unsignedLong }]`M xs:unsignedLong }]`Mm>!ZrHZ 9 223 372 036 854 775 807 D^{E{}# |IzT xs:nonNegativeInteger }]`M# xs:unsignedLong DJ(q=G^($HD.xF}rP#BP}VGK}]`MDP' >}:0"12678967543233 M 100000# 36 XQuery N< unsignedShort }]`M xs:unsignedShort }]`Mm>!ZrHZ 65 535 D^{E{}#|IzT xs:unsignedInt }]`M# xs:unsignedShort DJ(q=G^($HD.xF}rP#BP}VGK}]`MDP' >}:0"12678 M 10000# untyped }]`M xdt:untyped }]`M8>4-} XML #=i$DZc#|IzT}]`M xs:anyType# g{*XZc"M* xdt:untyped,G4|DyPsz*XZc2a"M* xdt:untyped# untypedAtomic }]`M xdt:untypedAtomic }]`M8>4-} XML #=i$D-S5#|IzT}]`M xdt:anyAtomicType# }]`M xdt:untypedAtomic 9C^(}qP_{zDjMB?Vm>DVx1d#| IzT xs:duration }]`M# K}]`MIm>D6'Z -P83333333333333Y3M = P83333333333333Y3M r -999999999999999 vB= 999999999999999 vB.d# xdt:yearMonthDuration DJ(q=* PnYnM,bG ISO 8601 q=DuuN=#BPu 4CZhvKq=: nY n G^{E{},CZm>j}# nM n G^{E{},CZm>B}# I!0:Vx1d#g{!TC{E,G4IC}Vx1d# }g,TBq=8>Vx1d 1 jc 2 vB: P1Y2M TBq=8>: 13 vBDVx1d: -P13M Jm9CKq=Duu+HMXOm>,+|GXk{OBP*s: v 8>{ P Xk{IT!T#+ G,XkPAYdP;v}V0d8>{(Y r M)# }g,Jm9CBPq=: Z 2 B `M53 37 P1347Y P1347M ;Jm9Cq= P-1347M,+Jm9Cq= -P1347M#;Jm9C P24YM M PY43M,- rG Y XkAYP;v0<}V,"R M 2XkAYP;v0<}V# DB2 }]b53Tf6/q=f" xdt:yearMonthDuration 5#Zf6/q=P,B} ?V!Z 12#? 12 vB*;* 1 j#}g,TB XQuery mo=wC;v9l/}, C9l/}8( yearMonthDuration 20 j 30 vB: xquery xdt:yearMonthDuration("P20Y30M") ZKVx1dP,30 vB*;* 2 jc 6 vB#mo=5Xf6/ yearMonthDuration 5 P22Y6M# 38 XQuery N< Z 3 B rT rTG;5Pyw,CZ(ei/D&m73#rTPD?vywyw"{FUdywM setter,setter GhC0li/&mDtT5D I!yw# DB2 XQuery 'V_gUdyw,CywICZ|Di/D&m==#rT9|({F UdywM1!{FUdyw# DB2 XQuery 9'VBP setter#+G,r* DB2 XQuery Z?VivBv'V;v! n,yT|G;a|D&m73: v 9lyw v 4F{FUdyw v UEryw v Er==yw g{f>ywfZ,G4XkvVZrT*7#setter 0d{ywI4Nb3rvVZr TPf>yw.sD;C# o( (1) Version declaration Boundary-space declaration Construction declaration Copy-namespaces declaration Empty order declaration Default element/type namespace declaration Default function namespace declaration Namespace declaration Ordering mode declaration ": 1 ?vyw;\8(;N,+{FUdyw}b# f>yw f>ywvVZi/*7,CZj6&mi/yhD XQuery o(MoeDf>#f> ywI|,`kyw,+`kywa; DB2 XQuery vT# g{fZ,G4f>ywXkZrT*7#DB2 XQuery (;'VDf>*“1.0”# o( xquery version ″1.0″ ; encoding StringLiteral © Copyright IBM Corp. 2006, 2013 39 1.0 8(&mi/h*f> 1.0 D XQuery o(Moe# StringLiteral 8(m>`k{FDV{.DV#r* StringLiteral D5;vT,yT8(`ky w;a0li/#DB2 XQuery \GY(`k* UTF-8# >} TBf>yw8>i/XkI'V XQuery f> 1.0 D5V4&m: xquery version "1.0"; _gUqyw i/rTPD_gUqywaTi/hC_gUq_T#_gUq_TaXF*X9 l/}TUqD&m==# _gUq|(*X9l/}PDjGrx(Emo=.dD_gPT:vVDyPU qV{# _gUq_TI8(9l*X1G#t_gUq9G}%_gUq#g{48(_g Uqyw,G41!P*GZ9l*X1}%_gUq# TZ?vi/,rT;\|,;v_gUqyw# o( declare boundary-space strip ; preserve strip 8(9l*X1}%_gUq# preserve 8(9l*X1#t_gUq# >} TB_gUqyw8(9l*X1+#t_gUq: declare boundary-space preserve; 9lyw i/rTPD9lyw+*i/hC9l==#9l==XFgNT4FD*XMt TZc8(`M"M,TNIBD9lZcDZ]# Z DB2 XQuery P,Q9l*XZcD9l==} TB9lywP',+;a|D*X9lD1!P*: declare construction strip; 4F{FUdyw 4F{FUd==XF*X9l/}4FVP*XZc18(D{FUds(# Z DB2 XQuery P,4F{FUd==P#1!{FUdD&m= =kNNd{{FUds(`,:4FDZc#td1!{FUdr1Y1!{FU d#hC inherit 8(4FDZcS9lZcLP{FUdwCr#g{"ze;,G 4S-P# inherit 8(4FDZc+LP9lZcD{FUdwCr# >} TB4F{FUdywP',+;a|D*X9lD1!P*: declare copy-namespaces preserve, inherit; 1!*X/`M{FUdyw i/rTPD1!*X/`M{FUdyw+8({FUd,C{FUdCZ*XM` M{FD^0: QName(^({F)# Z 3 B rT 41 i/rT;\|,;v1!*X/`M{FUdyw#}GKyw;1S*X9l/} PD{FUdywtT2G,qrywZywi/DwCrZ#g{4ywNN1! *X/`M{FUd,G4^0:*XM`M{F;ZNN{FUdZ# 1!*X/`M{FUd;JCZG^(tT{F#^0:tT{FMd?{F;ZN N{FUdZ# o( declare default element namespace URILiteral ; element 8(yw*1!*X/`M{FUdyw# URILiteral 8(m>{FUdD URI DV{.DV#V{.DVXkGP' URI rc$HV {.#g{1!*X/`M{FUdywPDV{.DVGc$HV{.,G4^ 0:*XM`M{F;ZNN{FUdZ# >} TByw8(*XM`M{FD1!{FUdGk URI http://posample.org `X* D{FUd: declare default element namespace "http://posample.org"; Snow boots 4P>}PDi/1,B4(DZc(*XZc name)Zk{FUd URI http:// posample.org `X*D{FUdP# 1!/}{FUdyw i/rTPD1!/}{FUdyw8(CZ/}wCP^0:/}{D{FUd URI# i/rT;\|,;v1!/}{FUdyw#g{4ywNN1!/}{FUd, G41!/}{FUdG XPath M XQuery /}D{FUd http://www.w3.org/2005/ xpath-functions#g{ywK1!/}{FUd,G4IZ;8(0:DivBZ1 !/}PwCNN/}# g{^0:/}wCDV?{k1!/}{FUdPD/};%d,G4 DB2 XQuery azzms# o( declare default function namespace URILiteral ; function 8(CywG1!/}{FUdyw# URILiteral 8(m>{FUdD URI DV{.DV#V{.DVXkGP' URI rc$HV 42 XQuery N< {.#g{1!/}{FUdywPDV{.DV*c$HV{.,G4yP/} wC} TByw8(1!/}{FUdk URI http://www.ibm.com/xmlns/prod/db2/ functions `X*: declare default function namespace "http://www.ibm.com/xmlns/prod/db2/functions"; ZK>}Di/weP,;CZ/}{PSk0:MIT}C1!/}{FUdPD NN/}#K1!/}{FUd|(/} xmlcolumn,yTIdk xmlcolumn (’T1.MYDOC’) 4zf db2-fn:xmlcolumn(’T1.MYDOC’)#+G,r*K>}PD1!/ }{FUd;Yk XQuery /}D{FUd`X*,yTwC XQuery ZC/}1h* 8(0:#}g,Xkdk fn:current-date() 4zf current-date()# UEryw Z&m FLWOR mo=D order by Sd1,i/rTPDUErywCZXFUrP r NaN 5GbM*n_59GnM5# Z DB2 XQuery P,&m FLWOR mo=PD order by Sd1UrP\GbM*n _5#NaN 5bM*sZUrPTbDyPd{5#KhC;a;2G#8( empty greatest TbD5DUErywazzms#TZ?vi/,i/rT;\|,;vU Eryw# o( declare default order empty greatest ; greatest &m FLWOR mo=PD order by Sd1UrP\GbM*n_5#NaN 5b M*sZUrPTbDyPd{5# >} TBUErywP': declare default order empty greatest; Er==yw i/rTPDEr==ywhCi/DEr==#Er==a(ei/a{PDZc Er# r* DB2 XQuery ;'V XQuery : An XML Query Language P(eDEr==,y Tg{Er==ywfZ,G4Xk8(^r#TZ DB2 XQuery PCZXFi/a{ 3rDfr,kNDZ 48 3D:XQuery mo=Pa{D3r;# i/rT;\|,;vEr==yw#8(^ra{TbD5DEr==ywazz ms# Z 3 B rT 43 o( declare ordering unordered ; unordered 8( XQuery 1.0: An XML Query Language PDEr==fr;pwC#TZ DB2 XQuery PCZXFi/a{3rDfr,kNDZ 48 3D:XQuery mo=Pa {D3r;# >} TBywP',+;a|DErD1!P*,-rG DB2 XQuery v'V^r==: declare ordering unordered; {FUdyw i/rTPD{FUdywayw{FUd0:"9C0:k{FUd URI `X*# 0:k{FUd URI .dDX*F*{FUds(#Z{FUdywPs(D{FU d+mSA2,Q*{FUd#2,Q*{FUd|,&mi/ZdICZbv{F Ud0:DyP{FUds(# }G{FUdyw;1S*X9l/}PD{FUdywtT2G,qrKywZy wi/DwCrZ#g{i/rTPfZ,;{FUd0:D`vyw,G4azz ms# o( declare namespace prefix = URILiteral ; prefix 8(s(A URILiteral 8(D URI D{FUd0:#C{FUd0:Z^({F (QName)PCZj6*X"tT"}]`Mr/}D{FUd# 0: xmlns M xml Q;53#t,;\Z{FUdywP8(*0:# URILiteral 8(0:s(AD URI#URILiteral Xk*|,P' URI DGc$HDV.# >} TBi/|(;v{FUdyw,CZyw{FUd0: ns1 "9dk{FUd URI http://posample.org `X*: declare namespace ns1 = "http://posample.org"; Thermal gloves 4P>}PDi/1,B4(DZc(*XZc name)Zk{FUd URI http:// posample.org `X*D{FUdP# 44 XQuery N< $HywD{FUd0: XQuery P;)$HywD{FUd0:,&m?vi/0|GZ2,Q*{FUdP# IZ;PT=ywDivB9CNN$HywD{FUd0:#DB2 XQuery D$Hy wD{FUd0:|(BmPT>D0:M URI T: m 11. DB2 XQuery PD$Hyw{FUd 0: URI hv xml http://www.w3.org/XML/1998/namespace XML #t{FUd xs http://www.w3.org/2001/XMLSchema XML #={FUd xsi http://www.w3.org/2001/XMLSchema-instance XML #=5}{FUd fn http://www.w3.org/2005/xpath-functions 1!/}{FUd xdt http://www.w3.org/2005/xpath-datatypes XQuery `M{FUd db2-fn http://www.ibm.com/xmlns/prod/db2/functions DB2 /}{FUd I(}Zi/rTP8({FUdyw42G$HywD{FUd0:#+G,;\ 2Gk0: xml `X*D URI# Z 3 B rT 45 46 XQuery N< Z 4 B mo= mo=Gi/Dy>9(i#mo=I%@9C,2Ikd{mo=iOT9I4S i/#DB2 XQuery 'V9C`Vmo=4&m XML }]# mo=s5M&m mo=D&mP(#|,tIYw#b)Yw|(SZci!-S5,9C`Ma} MS`Mf;Tq!Z{`MD5,T0FcrPD<{5# Z DB2 XQuery P,;\Zd;mo=D modify SdP9C|Bmo=#PX XQuery d;mo=0|Bmo=&mDE",kNDZ 104 3D:d;mo=;MZ 101 3 D:Zd;mo=P9C|BYw;# /,OBDM9c mo=D/,OBDGTmo=s51ICDE"#9cIOBDn"OBD;CM OBDs!iI,G/,OBDDX*iI?V# DB2 XQuery &mrPPD?;n1,9caf.Dd#9c|,BPE": OBDn 10&mD-S5rZc#I(}I%vciIDOBDnmo=(.)4l wOBDn# OBD;C rPP10&mDOBDnD;C#I(} fn:position() /}lwOBDn# OBDs! rPP10&mDn}#I(} fn:last() /}lwOBDs!# EH3r XQuery o((eKc{kmo=.dDZCEH3r#g{EH3rOMDmo=Cw EH3rO_Dmo=DYw},G4EH3rOMDmo=XkC2(E(p4# Bm4SM=_DEH3rP> XQuery Kc{Mmo=#X*TP8>_P`HEH 3rDKc{rmo=D&C3r# m 12. DB2 XQuery PDEH3r Kc{rmo= X*T ,(:E) SsAR :=(35) SRAs FLWOR, some, every, if SsAR or SsAR and SsAR eq, ne, lt, le, gt, ge, =, !=, <, <=, >, >=, is, <<, >> SsAR to SsAR © Copyright IBM Corp. 2006, 2013 47 m 12. DB2 XQuery PDEH3r (x) Kc{rmo= X*T +, - SsAR *, div, idiv, mod SsAR union, | SsAR intersect, except SsAR I*M SsAR ?F`M*; SsAR -(unary), +(unary) SRAs ? SsAR /, // SsAR [],(),{} SsAR XQuery mo=Pa{D3r 9C DB2 XQuery 1,3)V`D XQuery mo=a47(3r5XrP,xd{V `Dmo=a4;7(D3r5XrP# BPV`Dmo=47(3r5XrP: v |,T= order by SdD FLWOR mo=48(3r5Xa{#}g,TBmo =4[q}r5Xz7*XrP: for $p in /product order by $p/price return $p v mS*X"9CT=;CX|VD|Bmo=5Xa{1,mSD*XaEZ8( ;C#}g,TB|Bmo=9C as first into X|V,"ek*X current w* customerinfo *XPDZ;vn*X: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1001’) modify do insert current as first into $mycust/customerinfo return $mycust v +rPk union"intersect r except Kc{iO=;pDmo=a4D53r5 Xa{# v {OBPu~D76mo=a4D53r5Xa{: – 76mo=v|,}ra=h# – 76mo=p4Z%vZc,}g,I(}/}wCrd?}CzI# – 76mo=PDNN=h<;|,%v=J# – 76mo=;|, fn:position /}wCr fn:last /}wC# TB>}G4D53r5Xa{D76mo=,Y(d? $bib s(A%v*X# $bib/book[title eq "War and Peace"]/chapter v 6'mo=G|, to Kc{Dmo=,"Ra4}r5X{}rP#}g,15 to 25# v TZ|,:EKc{Dmo=,g{Yw}Dmo=5X`n,G4rPPDn}G;7(D# m 13. XQuery mo=Pa{D3r\a mo=V` _P7(ErDu~ a{3r >} FLWOR T= order by Sd I order by Sd7( TBmo=4[q} rEP5Xz7*X rP: for $p in /product order by $p/price return $p |Bmo= ZmS*X19C8 (;CDX|V I|Bmo=X|V 7( 9CX|V as last into ek*X1,C *X+mS*8(Z cDns;vSz# 9C union"inter- sect r except Kc {Dmo= ^D53r $managers union $students 76mo= v 76mo=v|, }ra=h# v 76mo=p4Z %vZc,}g, I(}/}wCr d?}CzI# v 76mo=PDN N=h<;|,% v=J# v 76mo=;|, fn:position /}wC r fn:last /}w C# D53r TB>}G4D53 r5Xa{D76m o=,Y(d? $bib s(A%v*X# $bib/book [title eq "War and Peace"] /chapter 6'mo=,4|, to Kc{Dmo= ^ 4}rEPD{}r P 15 to 25 |,:EKc{Dm o= yPYw}GxP7 (3rDrP 5X4Yw}3rE PDa{ (5, 10, 15 to 20, 25) Z 4 B mo= 49 m 13. XQuery mo=Pa{D3r\a (x) mo=V` _P7(ErDu~ a{3r >} d{mo= Yw}mo=+?5 X47(3rEPD a{ I6Wmo=Da{ 3r7( Y(d? $pub s(A %v*X,G4TB u~mo=a5XP ra{,-rG then M else SdPD76 m o = 5 X P r a {: if ($pub/type eq "journal") then $pub/editor else $pub/author ":g{T;P7(3rDrP&C;C=J,G4a{G;7(D,bb6EI\ !qrPPDNbn# -S/ -S/G+nrP*;*-S5rPD}L#?1h*-S5rP1,mo=Ma9 C-S/# (}&CBPfr,rPPD?;nMore text, 1.23,1001) TKrP&C-S/azIBP-S5rP: ("Some text", "More text", 1.23, 1001) BP XQuery mo=9C-S/+wn*;*-S5: v cumo= v HOmo= v 9C$Z`M*-SDTd?D/}wC v ?F`M*;mo= v CZwVZcD9l/}mo= v FLWOR mo=PD order by Sd v `M9l/} S`Mf; S`Mf;G89Cd/,`MIzTZ{`MD5# 50 XQuery N< S`Mf;;a|D5D5J`M#}g,g{y9C5D`M* xs:integer xC5D $Z`M* xs:decimal,G4C5a+#td xs:integer `M# ZTB>}P,fn:compare /}a+ xs:string 5k xs:NCName 5xPHO: fn:compare("product", xs:NCName("product")) 5XD5* 0,bb6ETd?DHOa{*`H#!\ fn:compare /}Z{`M* xs:string DTd?,+I9C`M* xs:NCNAME D5wCC/},-rGK`MIz T xs:string# ?NTmo=+]IzTZ{`MD51,a9CS`Mf;# `Ma} `Ma}G+-S5Sd-<`M*;*mo=Z{`MD}L#XQuery aZTS\} VrV{.Yw}D/}wC"order by SdMKc{s5Zd9C`Ma}# XQuery Jm4PBP`Ma}: }V`Ma}: `M* xs:float(ry] xs:float PD^FIzDNN`M)D5Ia}A`M xs:double#a{Gk-<5`,D xs:double 5# `M* xs:decimal(ry] xs:decimal PD^FIzDNN`M)D5Ia} A`M xs:float r xs:double#Ka}Da{G(}+-<5*;*Xh`M5 VD#K`a}I\a}P,|, xs:double 5 13.54e-2 M xs:decimal 5 100 DrP++ ]A fn:sum /},C/}a5X`M* xs:double D5: fn:sum(xs:double(13.54e-2), xs:decimal(100)) URI `Ma}: `M* xs:anyURI(ry] xs:anyURI PD^FIzDNN`M)D5Ia} A`M xs:string#Ka}Da{G(}+-<5*;*`M xs:string 5VD# ZTB>}P,URI 5+a}AZ{`M xs:string,x/}a5X 18: fn:string-length(xs:anyURI("http://example.com")) "b,9CBP==1,`Ma}MS`Mf;aPy;,: v TZ`Ma},5JOa+-S5Sd-<`M*;*mo=Z{D`M# v TZS`Mf;,I9CIzTC`MD5wCZ{X(`MDmo=#+G,C 5T#td-<5# P'<{5 rPDP'<{5(EBV)GZ&mh*9C<{5Dmo=Zd~=FcD#5D EBV G(}T5&C fn:boolean /}7(D# BmhvTX(5`M5XD EBV# m 14. T XQuery PDX(5`M5XD EBV 5Dhv 5XD EBV UrP false Z 4 B mo= 51 m 14. T XQuery PDX(5`M5XD EBV (x) 5Dhv 5XD EBV Z;n*ZcDrP true `M* xs:boolean rIzT xs:boolean D%v 5 false - g{ xs:boolean 5* false true - g{ xs:boolean 5* true `M* xs:string r xdt:untypedAtomic rIzT dP;V`MD%v5 false - g{5$H*c true - g{5$HsZc Nb}V`MrIzT}V`MD%v5 false - g{5* NaN r_d}5HZc true - g{C5D}5;HZc yPd{5 ms ":TZ|,AY;vZcMAY;v-S5DrP,dP'<{5Z3r;I$bDi/PG ;7(D# rPDP'<{5GZ&mBPmo=`M1~=FcD: v _-mo=(and M or) v fn:not /} v FLWOR mo=D where Sd v X(`MD=J,g a[b] v u~mo=(if) v (?mo=(some M every) wmo= wmo=GoTDy>we#|G|(DV"d?}C"x(Emo="OBDnm o="9l/}M/}wC# DV DVG-S5D1So(m>#DB2 XQuery 'V=V`MDDV:}VDVMV{. DV# }VDVG`M* xs:integer"xs:decimal r xs:double D-S5: v ;|,!}c(.)0 e r E V{D}VDVG`M* xs:integer D-S5#}g, 12 G}VDV# v |,!}c(.)+;|, e r E V{D}VDVG`M* xs:decimal D-S5# }g,12.5 G}VDV# v |, e r E V{D}VDVG`M* xs:double D-S5#}g,125E2 G}VD V# }VDVD5Gy] XML #=frbMD# V{.DVG`M* xs:string D-S5,(Z(g%}E(’)r+}E(″)P#V{ .DVI|($(e5e}CMV{}C#}g,BPV{.DV:*ZC%}E(gDV{.DVPSk%}E,k8(=v`Z%}E#, y,*ZC+}E(gDV{.DVPSk+}E,k8(=v`Z+}E# ZV{.DVP,Pa2Gy] XML 1.0 (Third Edition) Dfrf6/D#|,X5 {(X’0D’)"sz;P{(X’0A’)DNN=V{rP<+*;*%v;P{ (X’0A’)#4sz;P{(X’0A’)DNNX5{(X’0D’)+*;*%v;P{ (X’0A’)# g{*_e/D5;PDVm>,G4I9C9l/}rZC/}5XC5#BP/ }M9l/}a5X;PDVm>D5: v 9CZC/} fn:true() M fn:false() aVp5X<{5 true M false#9I9C9 l/} xs:boolean(″false″) M xs:boolean(″true″) 5Xb)5# v 9C9l/} xs:date("2005-04-16") a5X`M* xs:date "R5m> 2005 j 4 B 16 UDn# v 9C9l/} xdt:dayTimeDuration("PT4H") a5X`M* xdt:dayTimeDuration " R5m>Dv!1Vx1dDn# v 9C9l/} xs:float("NaN") a5XXb!c5“Not a Number”# v 9C9l/} xs:double("INF") a5XXb++H5“positive infinity”# $(e5e}C $(e5e}CG;vrLV{rP,m>Z DB2 XQuery P_P;(o(beDV {# $(e5e}CTME(&)*7,TVE(;)a2#&mV{.DV1,?v$( e5e}C+f;*|ym>DV{# BmP> DB2 XQuery 6pD$(e5e}C# m 15. DB2 XQuery PD$(e5e}C 5e}C m>DV{ < < > > & & " ″ ' ’ V{}C V{}CGT Unicode V{D XML y=}C,Unicode V{Id.xFr.yxFz kcj6# Z 4 B mo= 53 V{}CT &#x r &# *7,TVE(;)a2#g{V{}CT &#x *7,G4U9 VE(;).0D}VMV8+y] ISO/IEC 10646 j*V{zkcD.yxF N=#g{V{}CT &# *7,G4U9VE(;).0D}V+m>*V{zkcD .xFN=# >} V{}C € r € m>7*{E(€)# d?}C d?}CG+@*{E($)Cw0:D NCName#Ti/s51,?vd?}Cab v*s(ACd?D5#?vd?}CXkkd?wCrP}C;C&D{F`% d# d?G9CBP==mSAd?wCrD: v I(}woT73"SQL/XML"XMLQUERY /}"XMLTABLE /}r XMLEXISTS =Jrd?wCrmSd?#TZI SQL/XML mSDd?,}GCd ?; XQuery mo=P,;d?Dm;s(2G,qrCd?Z{vi/DwCr P# v d?Iy] XQuery mo=s(A3v5#Is(d?Dmo=V`|( FLWOR m o=M(?mo=#Z4P/}e.0,/}wC2a+5s(A/}DNN#I XQuery mo=s(Dd?ZCmo=DwCrP# d?{F;\Z FLWOR mo=Pyw;N#}g,DB2 XQuery ;'VTBmo =: for $i in (1, 2) for $i in ("a", "b") return $i g{d?}CkwCrPD=vr|`d?s(`%d,G4C}Ca}CZ?s (,4wCr|!Ds(# a>:*a_zkDIAT,kTi/PDd?9C(;{F# >} ZTB>}P,FLWOR mo=+d? $seq s(ArP (10, 20, 30): let $seq := (10, 20, 30) return $seq[2]; 5XD5* 20# x(Emo= 2(EICZZ|,`vKc{Dmo=P?F5VX(s53r# }g,mo= (2+4)*5Ds5a{* 30,-rGHTx(Emo= (2+4)s 5,;sTda{K 5#g{;P2(E,G4mo= 2+4*5Ds5a{* 22, -rGK(Kc{DEH3r_ZS(Kc{# U2(E8>UrP# 54 XQuery N< OBDnmo= OBDnmo=I%vdcV{(.)iI#OBDnmo=as5*10}Z&mD n,VF*OBDn# OBDnITGZcr-S5#;\Z76mo=M=Jmo=P(eOBDn# >} TB>}|,OBDnmo=,|+T6'mo= 1to100y5XrPPD?nwC #}Kc{: (1 to 100)[. mod 5 eq 0] K>}+zI 1 A 100 .dI; 5 {}D{}rP# /}wC /}wCI QName iI,szC2(E(p4DcvrcvTOmo=(F*Td ?)#DB2 XQuery 'VwCZC XQuery /}M DB2 ZC/}# ZC XQuery /}Zs(A0: fn D{FUd http://www.w3.org/2005/xpath- functions P#DB2 ZC/}Zs(A0: db2-fn D{FUd http://www.ibm.com/ xmlns/prod/db2/functions P#g{/}wCPD QName ;P{FUd0:,G4C /}X(Z1!/}{FUdP#}G{FUd;i/rTPD1!/}yw2G, qr1!/}{FUdGZC XQuery /}D{FUd(s(A0: fn)# *c:r*/}wCDTd?GC:EVtD,yTXk9C2(E+|,%6:E Kc{DTd?mo=(p4# BP=h5w DB2 XQuery T/}s51yCD}L: 1. DB2 XQuery T/}wCPw*Td?+]D?vmo=s5,"5X?vmo=D 5# 2. T?vTd?5XD5+*;*CTd?&9CD}]`M#g{Td?&C*- S5r-S5rP,G4 DB2 XQuery a9CBPfr+Td?D5*;*$Z` M: a. +Tx(5xP-S/#bazz-S5rP# b. -SrPP`M* xdt:untypedAtomic D?nD}]`M+*;*$Z-S`M# TZ&C*-STd?DZC/},`M* xdt:untypedAtomic DTd?D}] `M+*;* xs:double# c. +T-SrPPNNIa}A$Z-S`MD}Vn&C}V`Ma}#}V n|(`M* xs:integer(rIzT xs:integer)"xs:decimal"xs:float r xs:double Dn# d. g{$Z`M* xs:string,G4-SrPP`M* xs:anyURI(rIzT xs:anyURI)D?n+a}A xs:string# 3. +9C/}Td?D*;5T/}s5#/}wC+zI/}ywD5X`MD5 },r_zzms# Z 4 B mo= 55 >} 9CV{.Td?D/}wC:TB/}wCIC`M* xs:string DTd?,"5X` M* xs:string D5,dPyPV{*s4: fn:upper-case($ns1_customerinfo/ns1:addr/@country) ZK>}P,+]A fn:upper-case /}DTd?*76mo=#wCC/}1,aT7 6mo=s5,"RaTzIDZcrPxP-S/#rPPD?v-S5+*;* $Z`M xs:string#+TC/}s5,"5X`M* xs:string D-S5rP# 9CrPTd?D/}wC:TB/}ICrP (1, 2, 3) w*%vTd?# fn:max((1, 2, 3)) r*/} fn:max h*-S5rPN=D%vTd?,yTh*6W2(E#5XD5 * 3# 76mo= 76mo=j6 XML wPDZc#DB2 XQuery PD76mo=T XPath 2.0 Do (*y!# 76mo=|,C1\(/)r+1\(//)V{t*D;vr`v=h#76mo= IC=h*7,2IC1\r+1\V{*7#nU=h.0D?v=hazIZc rP,b)Zc+Cwsx=hDOBDZc# Z;v=h8(76Dpc,(#a(}9C5XZcrZcrPD/}wCrd? }C8(#u<“/”8>76p76p 76p76p# node-test TZa=h!qD?vZcXk* true Du~#KbTITGy]Zc{F!qZ cD{FbT,r_Gy]ZcV`!qZcDV`bT# PrimaryExpression wmo=# PredicateExpression CZ7(G#t9GOzrPnDmo=# >} TB>}T>|(=v=JDa=h#K=h!q_P secretary S*XM assis- tant S*XDOBDZcDyP employee Sz: child::employee[secretary][assistant] TB>}+}Kmo=Cw76mo=PD;v=h#Cmo=5XZx(i.P| ,`vE"D?vBZr=<# $book/(chapter | appendix)[fn:count(footnote)> 1] a=h a=hI}?ViI:a(I!)"ZcbT0cvrcvTO=J#aC48(F /=r,ZcbT8(CZ!qZcDu~,x=JC4}K=h5XDrP# a=hDa{\GcvrcvTOZcDrP# Z 4 B mo= 57 a=hITG}r=hrfr=h#}r=hSOBDZc*<"R4D53rZ XML wPF/,xfr=hSOBDZc*<"R4frD53rZ XML wPF/#g{ OBDn;GZc,G4mo=azzms# a=hDGu4o(|(C=v0Et*Da{FMZcbT,"szcvrcvT O=J#I(}!Ta"9CYGm>(4u4amo=Do(# ZTB>}P,child GaD{F,x para G*TKa!qD*XZcD{F# child::para K>}PDa=h!qd1OBDZcSzDyP para *X# a aGa=hD;?V,CZ8( XML D5PDF/=r# aITG}rarfra#}ra|,OBDZcM@]D53rZOBDZcsD Zc#fra|,OBDZcM@]D53rOBDZc.0DZc# Bmhv DB2 XQuery P\'VDa# m 16. DB2 XQuery P\'VDa a hv =r "M Sz 5XOBDZcDSz# }r vD5ZcM*XZc_PSz#g{OBDZcG NNd{`MDZc,r_OBDZcG;PNNS zDD5Zcr*XZc,G4Sa*UrP#D5 Zcr*XZcDSzITG*X"&m8n""M rD>Zc#tTMD5Zcv;\d1Sz# sz 5XOBDZcDsz(Sz"S zDSzHH)# }r tT 5XOBDZcDtT# }r g{OBDZc;G*XZc,G4KaGUD# Tm v5XOBDZc# }r sz- r- Tm 5XOBDZc0dsz# }r 8z 5XOBDZcD8z,g{OB DZc;P8z,G45XUr P# fr 49tTZcv;\G*XZcDSz,+*XZc ITGtTZcD8z# a=h!qZcrP1,+T?vZc8(;vOBD;C,C;CT&CZcZr PPD;C#g{CaG}ra,G4a4D53rTZc8(OBD;C,"RS 1 *<#g{CaGfra,G4a4frD53rTZc8(OBD;C,"RS 1 * <#8(OBD;CJmz(}!q;CSrPP!qZc# ZcbT ZcbTG;vu~,TZa=h!qD?vZc,Ku~Xk* true#ZcbTIm o*{FbTrV`bT# {FbTy]Zc{F!qZc#V`bTy]ZcV`!qZc# 58 XQuery N< {FbT {FbTI QName r(d{iI#Za=hP8({FbT1,C=haZ8(aO !qk QName r(d{`%dDZc#g{{FbTGTtTa8(D,G4C=h a!qk{FbT`%dDyPtT#ZyPd{aO,C=ha!qk{FbT` %dDNN*X#g{Zzkc=fZcD)9 QName HZZ{FbTP8(D)9 QName,G4m> QName `%d#g{=v)9 QName D{FUd URI 0V?{ `H(49{FUd0:;`H),G4m>b=v)9 QName `H# *c:Z{FbTP8(DNN0:XkT&Zmo=DdP;v2,Q*{FU d#TZZtTaO4PD{FbT,^0: QName ;P{FUd URI#TZZyP d{aObTD{FbT,^0: QName _P1!*X/`M{FUdD{FUd URI# BmhvZ DB2 XQuery P\'VD{FbT# m 17. DB2 XQuery P\'VD{FbT bT hv>} QName %dd QName HZ8( QName DN NZc(Z8(aO)#g{Ca* tTa,G4KbTktTZc`% d#ZyPd{aO,KbTk*X Zc`%d# Zmo= child::para P,{FbT para a!qSaODyP para *X# * %d8(aODyPZc#g{Ca *tTa,G4KbTkyPtTZ c`%d#ZyPd{aO,KbT kyP*XZc`%d# Zmo= child::* P,{FbT * k SaODyP*X`%d# NCName:* 8 ( m > QName D 0 : ? V D NCName#K{FbTk8(aOD3 )Zc`%d,b)ZcD{FUd URI k0:s(AD{FUd URI ` %d#g{Ca*tTa,G4Kb TktTZc`%d#ZyPd{a O,KbTk*XZc`%d# Zmo= child::ns1:* P,{FbT ns1:* kSaOD3)*X`%d,b )*Xks(A0: ns1 D{FUd` X*# *:NCName 8(m> QName DV?D NCName# K{FbTk8(aOD3)Zc` % d , b ) Z cDV ? { H Z NCName#g{Ca*tTa,G4K bTktTZc`%d#ZyPd{ aO,KbTk*XZc`%d# Zmo= child::*:customerinfo P, {FbT *:customerinfo kSaOV ?{* customerinfo DyP*X`% d,;\{FUdGqk*X{`X *} node() %d8(aODNNZc# Zmo= child::node() P,V` bT node() a!qSaODyP Zc# text() %d8(aODNND>Zc# Zmo= child::text() P,V` bT text() a!qSaODyP D>Zc# comment() %d8(aODNN"MZc# Zmo= child::comment() P,V `bT comment() a!qSaOD yP"MZc# processing-instruction() %d8(aODNN&m8nZ c# Zmo= child::processing- instruction() P,V`bT pro- cessing-instruction() a!qSa ODyP&m8nZc# element() r element(*) %d8(aODNN*XZc# Zmo= child::element() P,V `bT element() a!qSaOD y P * X Z c # Z m o = child::element(*) P,V`bT element(*) a!qSaODyP* XZc# attribute() or attri- bute(*) %d8(aODNNtTZc# Zmo= child::attribute() P, V`bT attribute() a!qSa O D y P t T Z c # Z m o = child::attribute(*) P,V`bT attribute(*) a!qSaODyP tTZc# document-node() %d8(aODNND5Zc# Zmo= self::document-node() P,V`bT document-node() a !qd1OBDZcDD5Zc# 76mo=Du4o( XQuery a)Ku4o(Tmo76mo=PDa# Bmhv76mo=PJmDu4# m 19. 76mo=Du4o( u4o( hv>} 48(a child:: DYGu4,+a=h8(ZcbTD attribute() 1}b#a=h8(tTbT1, !TaG attribute:: DYGN=# 76mo= section/para G child::section/ child::para Du4#76mo= section/ attribute() G child::section/ attribute::attribute() Du4# @ attribute:: DYGu4# 76mo= section/@id G child::section/ attribute::id Du4# 60 XQuery N< m 19. 76mo=Du4o( (x) u4o( hv>} // /descendant-or-self::node()/ DYGu4,+ Ku4vVZ76mo=*71}b# Ku4vVZ76mo=*71,a=h+!q u} Bma)u4o(MGu4o(D>}# m 20. Gu4o(Mu4o( Gu4o( u4o( a{ child::para para !qd1OBDZcSzD para *X# child::* * !qd1OBDZcSzD yP*X# child::text() text() !qd1OBDZcSzD yPD>Zc# child::node() node() !qOBDZcDyPS z#r*tT4;SwZc DSz,yTKmo=;5 XNNtTZc# attribute::name @name !qOBDZcD name t T# attribute::* @* !qOBDZcDyPt T# child::para[fn:position() = 1] para[1] !qd1OBDZcSzD Z;v para *X# child::para[fn:position() = fn:last()] para[fn:last()] !qd1OBDZcSzD ns;v para *X# /child::book/child::chapter[fn:position() = 5] /child::section[fn:position() = 2] /book/chapter[5]/section[2] !qCiZ 5 BZ 2 Z, d8zG|,OBDZcD D5Zc# child::para[attribute::type="warning"] para[@type="warning"] !qOBDZcD`MtT 5* warning DyP para Sz# child::para[attribute::type=’warning’] [fn:position() = 5] para[@type="warning"][5] !qOBDZcD`MtT 5* warning DZ 5 v para Sz# Z 4 B mo= 61 m 20. Gu4o(Mu4o( (x) Gu4o( u4o( a{ child::para[fn:position() = 5] [attribute::type="warning"] para[5][@type="warning"] !qOBDZcD`MtT 5* warning DZ 5 v para Sz# child::chapter[child::title=’Introduction’] chapter[title="Introduction"] !qOBDZcD chapter Sz,CSzD;vr`v title SzD`M5HZV {. Introduction# child::chapter[child::title] chapter[title] !qOBDZcD chapter Sz,CSz_P;vr` v title Sz# =J =Ja(}#t^(n4}KrP#=JImo=iI,Cmo=aC=(E([])( p4,F*=Jmo=# =Jmo=a+y!nw*OBDnTrPPD?;nxP;Ns5#=Jmo=D ?Ns5+5X xs:boolean 5,F*=J<{5#=J<{5* true Dna#tB4, x=J<{5* false Dna;Oz# BPfrCZ7(=J<{5: v g{=Jmo=5XG}V5,G4=J<{5*=Jmo=DP'<{5# v g{=Jmo=5X}V5,G4;PZrPPy&;CHZC}5DnD=J< {5E* true#TZd{n,=J<{5* false#K`=JF*}V=Jr;C= J#}g,Zmo= $products[5] P,}V=J [5] ;#ts(Ad? $prod- ucts DrPPDZ 5 n# *c:v1rP_P7(3r1,9C}V=JSrPP!qDnEG7(D# a>:=JDP*!vZ=Jmo=Gq5X}V5,bI\^((}[l=Jmo =xPPO#I(}9C fn:boolean /}?F=J9CP'<{5,g [fn:boolean (PredicateExpression)] Py>#Kb,9I(}9C fn:position /}?F=J4; C=J&m,g [fn:position() eq PredicateExpression] Py># BP>}_P=J: v chapter[2] a!qw*OBDZcSzDZ~v chapter *X# v descendant::toy[@color = "Red"] a!qd1*X toy "RU+tT5*“Red”D yPOBDZcsz# v employee[secretary][assistant] a!q,1_P secretary S*XM assistant S *XDyPOBDZc01Sz# v (, , 47, )[2] a5X*X # 62 XQuery N< rPmo= rPmo=CZ9l"}KMO"n?rP#rP;\6W#}g,+5 1"(2, 3) M ()O"=%vrPPazzrP (1, 2, 3)# CZ9lrPDmo= I(}9C:EKc{r6'mo=49lrP# :EKc{ *9C:EKc{9lrP,k8(C:Et*D=vr|`Yw}(mo=)#T rPmo=s51,:EKc{aT?vYw}s5,"+zIDrP"CTzI% va{rP#}g,TBmo=+zI|, 5 v{}DrP: (15, 1, 3, 5, 7) rPI|,X4D-S5MZc#+G,rPv;\Gm;vrPPD;n#g{B rPG(}"C=vr|`dkrP4(D,G4BrP+|,dkrPPDyP n,"RrP$HGdkrP$HD\M# BPmo=9C:EKc{49lrP: v Kmo=+$HVp* 1"2"0 M 2 D 4 vrPO"I$H* 5 D%vrP#K mo=+zIrP 10, 1, 2, 3, 4# (10, (1, 2), (), (3, 4)) v Kmo=+zI;vrP,|,yPd1OBDZcSzD salary *X(szd1 OBDZcSzDyP bonus *X)# (salary, bonus) v Y(d? $price s(A5 10.50,G4Kmo=+zIrP 10.50, 10.50# ($price, $price) 6'mo= 6'mo=a9l,x{}rP#6'mo=I(} to Kc{t*D=vYw}(m o=)iI#?vYw}D5XkI*;*`M* xs:integer D5#g{N;Yw}* UrP,r_Z;vYw}IzD{}sZZ~vYw}IzD{},G46'mo =+zIUrP#qrazIby;vrP,CrP|,Yw}IzD=v{}0d .d?v{},b){}4}rEP#}g,TB6'mo=s5*rP 1, 2, 3, 4: (1 to 4) TB>}9C6'mo=49lrP: v TB>}Z9lrP1+6'mo=Cw;vYw}#rPmo=s5*rP 10, 1, 2, 3, 4# (10,1to4) v TB>}9l$H* 1 "R|,%v{} 10 DrP# 10 to 10 v TB>}zI$H* 0 DrP# 15 to 10 Z 4 B mo= 63 v TB>}9C fn:reverse /}9l|, 6 v{}"R45rEPDrP#KrPmo =s5*rP 15, 14, 13, 12, 11, 10# fn:reverse(10 to 15) }Kmo= }Kmo=IszcvrcvTO=JDwmo=iI#g{=JfZ,G4=JC Z}Kwmo=5XDrP# }Kmo=Da{I=Jf55* ture DyPniI,b)nGIwmo=5XD#g {48(NN=J,G4a{MGwmo=Da{#a{rPPwnDErkwmo =5X|G1DEr`,#ZT=Js5Zd,?n |ZC=J}Z}KDrPPD;C#Z;vOBD;C* 1# o( PrimaryExpression [ PredicateExpression ] PrimaryExpression wmo=# PredicateExpression CZ7(G#t9GOzrPnDmo=# >} TB>}9C}Kmo=5X}KsDrP: v g{z7rPQs(Ad?,G4Kmo=v5X[q_Z 100 Dz7: $products[price gt 100] v TBmo=9CxP=JD6'mo=4P> 1 = 100 .dIC 5 }DyP{}# r*6'mo=GC2(Ep4D,yT+w*wmo=&m: (1 to 100)[. mod 5 eq 0] v TBmo=zI{} 5: (1 to 21)[5] v TBmo=+}Kmo=Cw76mo=PD;v=h#Cmo=5Xs(Ad? $book Di.PDns;Br=<: $book/(chapter | appendix)[fn:last()] O"ZcrPDmo= DB2 XQuery a)K;)Kc{CZO"ZcrP#b)Kc{|( union"inter- sect M except# BmhvICZO"ZcrPDKc{# 64 XQuery N< m 21. CZO"ZcrPD XQuery Kc{ Kc{ hv union r | +=vZcrP1wYw},"5X|,N;Yw}PvV DyPZcDrP#union X|VM | V{GH[D# intersect +=vZcrP1wYw},"5X|,=vYw}PvV DyPZcDrP# except +=vZcrP1wYw},"5X|,Z;vYw}Pv V+Z~vYw}P4vVDyPZcDrP# yPKc{ay]Zcj6Sa{rPPE}X4Zc#zIDrP+4D53r5 X# union"intersect r except DYw}Xkbv*v|,ZcDrP#g{Yw}|, "GZcDn,G4a5Xms# }K>wbPhvDKc{Tb,DB2 XQuery 9a)K;)/}TxPBPYw:T rPnrSrPxPw}CJ(fn:index-of)"TrPPDn4Pw}ekr}%Yw (fn:insert-before M fn:remove)T0}%rPPDX4n(fn:distinct-values)# >} Zb)>}P,Y(d? $managers s(A;i01Zc,b)Zcm>m*-mD0 1,"Rd? $students 2s(A;i01Zc,b)Zcm>m*'zD01# BPmo=},|G9CKc{iOZcrP: v $managers union $students a5Xm>m*-mr'zD01D;iZc# v $managers intersect $students a5Xm>,1m*-mM'zD01D;iZc# v $managers except $students a5Xm>m*-m+;G'zD01D;iZc# cumo= cumo=4Pf0S("u("K("}(M#}DKc# Bm4S_=MDKc{EH63rhv"P>cuKc{#}G9C2(E?FT ~?Kc{xPs5,qr;*Kc{DEH3r_Z~?Kc{# m 22. XQuery PDcuKc{ Kc{ ?D X*T -(unary), +(unary) TYw}D5s4,#tYw}D5 SRAs *, div, idiv, mod K(,}(,}(s{,s# SsAR +, - S(,u( SsAR ":u(Kc{.0XkSOUq,qrYw}I\bM*0;vjGD;?V#}g,a-b b M*{F,+ a-bM a-bbM*cuKc# cumo=Da{G}5"UrPrms#Tcumo=s51,?vYw}<;- S/(*;*-S5),"RfZBPfr: Z 4 B mo= 65 v g{-S/Yw}*UrP,G4cumo=Da{*UrP# v g{-S/Yw}G|,`v5DrP,G4a5Xms# v g{-S/Yw}G^`MD-S5(xdt:untypedAtomic),G4C5D}]`M+ *;* xs:double#g{?F`M*;'\,G4a5Xms# g{Yw}D`MZs5sd*cuKc{DP'iO,G4aT-S/Yw}&C CKc{,"RKKcDa{G-S5rms,}g,}cI\mo=PDZ;vYw } , V 8 B m > Z ~ v Y w } # u o numeric 8 > ` M xs:integer"xs:decimal"xs:float"xs:double rIzTdP;V`MDNN`M#g{Kc { D a { ` M P > * numeric, G 4 a { ` M + G P r P m (xs:integer"xs:decimal"xs:float M xs:double)PyPYw}(}S`Mf;M`Ma }*;I\NIDZ;V`M# m 23. cumo=Yw}P'`M xYw}DKc{ Yw} A D`M Yw} B D`M a{`M A + B numeric numeric numeric A + B xs:date xdt:yearMonthDuration xs:date A + B xdt:yearMonthDuration xs:date xs:date A + B xs:date xdt:dayTimeDuration xs:date A + B xdt:dayTimeDuration xs:date xs:date A + B xs:time xdt:dayTimeDuration xs:time A + B xdt:dayTimeDuration xs:time xs:time A + B xs:dateTime xdt:yearMonthDuration xs:dateTime A + B xdt:yearMonthDuration xs:dateTime xs:dateTime A + B xs:dateTime xdt:dayTimeDuration xs:dateTime A + B xdt:dayTimeDuration xs:dateTime xs:dateTime A + B xdt:yearMonthDuration xdt:yearMonthDuration xdt:yearMonthDuration A + B xdt:dayTimeDuration xdt:dayTimeDuration xdt:dayTimeDuration A - B numeric numeric numeric A - B xs:date xs:date xdt:dayTimeDuration A - B xs:date xdt:yearMonthDuration xs:date A - B xs:date xdt:dayTimeDuration xs:date A - B xs:time xs:time xdt:dayTimeDuration A - B xs:time xdt:dayTimeDuration xs:time A - B xs:dateTime xs:dateTime xdt:dayTimeDuration A - B xs:dateTime xdt:yearMonthDuration xs:dateTime A - B xs:dateTime xdt:dayTimeDuration xs:dateTime A - B xdt:yearMonthDuration xdt:yearMonthDuration xdt:yearMonthDuration A - B xdt:dayTimeDuration xdt:dayTimeDuration xdt:dayTimeDuration A * B numeric numeric numeric A * B xdt:yearMonthDuration numeric xdt:yearMonthDuration A * B numeric xdt:yearMonthDuration xdt:yearMonthDuration 66 XQuery N< m 23. cumo=Yw}P'`M (x) xYw}DKc{ Yw} A D`M Yw} B D`M a{`M A * B xdt:dayTimeDuration numeric xdt:dayTimeDuration A * B numeric xdt:dayTimeDuration xdt:dayTimeDuration A idiv B numeric numeric xs:integer A div B numeric numeric numeric,+=vYw}<* xs:integer 1r* xs:decimal A div B xdt:yearMonthDuration numeric xdt:yearMonthDuration A div B xdt:dayTimeDuration numeric xdt:dayTimeDuration A div B xdt:yearMonthDuration xdt:yearMonthDuration xs:decimal A div B xdt:dayTimeDuration xdt:dayTimeDuration xs:decimal A mod B numeric numeric numeric >} v ZTB>}P,Z;vmo=5X xs:decimal 5 -1.5,xZ~vmo=5X xs:integer 5 -1: -3 div 2 -3 idiv 2 v ZBfDmo=P,=vUZ5Du(+zI`M* xdt:dayTimeDuration D5: $emp/hiredate - $emp/birthdate v TB>}5wd?{F unit-price M unit-discount P9CDuEKc{k,V{ .dDnp: $unit-price - $unit-discount HOmo= HOmo=aT=v5xPHO#XQuery a)K}VHOmo=:5HO"#fHOM ZcHO# 5HO 5HOaT=v-S5xPHO#5HOKc{|( eq"ne"lt"le"gt M ge# Bmhvb)Kc{# m 24. XQuery PD5HOKc{ Kc{ ?D eq g{Z;v5HZZ~v5,G45X true# ne g{Z;v5;HZZ~v5,G45X true# lt g{Z;v5!ZZ~v5,G45X true# le g{Z;v5!ZrHZZ~v5,G45X true# gt g{Z;v5sZZ~v5,G45X true# ge g{Z;v5sZrHZZ~v5,G45X true# Z 4 B mo= 67 g{=v5D`M`,r_;vYw}Gm;vYw}DS`M,G4IT=v5x PHO#IT}V`M(`M xs:float"xs:integer"xs:decimal"xs:doubl 0IzTdP ;V`MD`M)D=vYw}IxPHO#xR xs:string M xs:anyURI 5IxPH O# Xb5:TZ xs:float M xs:double 5,}cM:cHO`H#INF HZ INF,x -INF HZ -INF#NaN ;HZTm#}^nsZyPd{G NaN 5;:^n!ZyPd{ G NaN 5#NaN ne NaN * true,xf0 NaN 5DNNd{HO* false#g{` M* xs:QName D=v5D{FUd URI MV?{`H({FUd0:;X*),G 4b=v5;S*`H# 5HODa{ITG<{5"UrPrms#T5HOs51,?vYw}<;-S /(*;*-S5),"RfZBPfr: v g{-S/Yw}*UrP,G45HODa{*UrP# v g{-S/Yw}G|,`v5DrP,G4a5Xms# v g{-S/Yw}G^`M-S5(xdt:untypedAtomic),G4C5D}]`M+ *;* xs:string# +`M* xdt:untypedAtomic D5*;* xs:string 95HOdII+]D#`4,# fHOq-k*;^`M}];,Dfr,rK,#fHOG;I+]TD#Zx P`M*;Zd,5HOD+]TI\r*+HB5x\=p&#}g,r* xs:float D+HMZ xs:integer,yTPa"npD=v xs:integer 5I\a;S*HZ,; xs:float 5# v g{Yw}D`MZs5sTZKc{GP'iO,G4aT-S/Yw}&CCK c{,"RHOa{+* true r false#g{Yw}D`MTZHOKc{G^'i O,G4a5Xms# B P ` M I 9 C eq r ne K c { x P H O # u o q P _ {z8 D G ` M xs:gYearMonth"xs:gYear"xs:gMonthDay"xs:gDay M xs:gMonth#TZS\=vqP_ {z`MDYw}D~?Kc{,=vYw}Xk_P`,`M,}g,g{;vY w}D`M* xs:gDay,G4m;vYw}D`MXk* xs:gDay#uo}V8DG`M xs:integer"xs:decimal"xs:float"xs:double 0IzTdP;V`MDNN`M#ZxPf 0}5DHO1,a9CS`Mf;M}V`Ma}+Yw}*;*PrPm (xs:integer"xs:decimal"xs:float M xs:double)PyPYw}} v TBHOa9mo= $book/author 5XDZc-S/#v1-S/Da{*5 “Kennedy”"RG xs:string r xdt:untypedAtomic D5}1,HOE* true#g{- S/Da{G|,`v5DrP,G4a5Xms# $book1/author eq "Kennedy" v TB76mo=|,=J,CZ!qX?,} 100 Dz7#TZ;PX?S*XDN Nz7,C=JD5*UrP,"R;a!qCz7: //product[weight gt 100] v r*Z?VivB=v9lZcZ-S/s_P`,5(49|G_P;,Dj6 r{F),yTBPHO5X true: 5 eq 5 5 eq 5 #fHO #fHOaHONb$HD=vrP,T7(Z;vrPPDAY;nMZ~vrP PD;nGq{O8(DHO##fHOKc{P ="!="<"<="> M >=# Bmhvb)Kc{# m 25. XQuery PD5HOKc{ Kc{ ?D = g{Z;vrPPD3v5HZZ~vrPPD3v5,G45X true# != g{Z;vrPPD3v5;HZZ~vrPPD3v5,G45X true# < g{Z;vrPPD3v5!ZZ~vrPPD3v5,G45X true# <= g{Z;vrPPD3v5!ZrHZZ~vrPPD3v5,G45X true# > g{Z;vrPPD3v5sZZ~vrPPD3v5,G45X true# >= g{Z;vrPPD3v5sZrHZZ~vrPPD3v5,G45X true# Z 4 B mo= 69 gsfD“>}”;Zy>,#fHO;GI+]D,"Rk"b,= M != Kc{;G `fD# #fHODa{G<{5rms#T#fHOs51,+T?vYw}xP-S/ (*;*-S5rP)#HOwv-S51,BPfrJCZyxPD~=?F`M *;: ;vrPPD-S5 m;vrPPD-S5 +~=`M5?F*;*D` M xdt:untypedAtomic }V`M xs:double g{z}Z9CG#sD{ },G4I\ap'+H#} g , + 19 ; } 9223372036854775672 ?F*; * xs:double 1,a{* 9.223372036854776E18(p' K};+H)#(}+K5? F*;* xs:decimal r xs:long `M,4I\bzzK+Hp '# xdt:untypedAtomic xdt:untypedAtomic r xs:string xs:string xdt:untypedAtomic } V ` M . b D 5 , xdt:untypedAtomic r xs:string m;v5D`M g{I&xPK?F`M*;,G4+9CBPdP;v5HOKc{4HO-S 5:eq"ne"lt"le"gt r ge#g{P;T-S5,;vZZ;vYw}rPP,m ;vZZ~vYw}rPP,"RbT-S5DHO* true,G4HOa{* true#} g,HO (1, 2) = (2, 3) +5X true,-rG 2eq2* true#g{~=?F`M *;Yw'\,G4HO+5X false#}g,TBodPDHO [b<3.4]+5X false,-rG^(I&+V{.“N/A”?F`M*;* xs:double: Xquery let $doc := N/A return $doc[b < 3.4]; a>:*pnHO=vrP,k9C XQuery /} fn:deep-equal# >} v g{ $book1 D3vw_S*XD`M5*“Kennedy”,"RG xs:string r xdt:untypedAtomic D5},G4TBHO* true: $book1/author = "Kennedy" v TB>}|,}v#fHO#0=vHOD5* true,xZ}vHOD5* false#K >}5w#fHO;I+]b;B5: (1, 2) = (2, 3) (2, 3) = (3, 4) (1, 2) = (3, 4) v TB>}|,=v#fHO,=vHO<* true#K>}5w = M != Kc{;G `fD# (1, 2) = (2, 3) (1, 2) != (2, 3) 70 XQuery N< v ZTB>}P,d? $a"$b M $c Qs(A`M"M* xdt:untypedAtomic D*X Zc#Z;v*XZc|,V{.5“1”,Z~v*XZc|,V{.5“2”,Z} v*XZc|,V{.5“2.0”#ZK>}P,TBmo=5X false,-rGs(A $b M $c(“2”M“2.0”)D5Gw*V{.xPHOD: ($a, $b) = ($c, 3.0) +G,TBmo=+5X true,-rGs(A $b(“2”)D5k5 2.0 Gw*}Vx PHOD: ($a, $b) = ($c, 2.0) ZcHO ZcHOCZHO=vZc#I(}HOZc47(|GGq2C,;j6,r_7 (4D53r;vZcGqZm;vZc.0r.s# Bmhv XQuery PICDZcHOKc{# m 26. XQuery PDZcHOKc{ Kc{ ?D is g{xPHOD=vZc_P`,j6,G45X true# << g{4D53rZ;vYw}ZcZZ~vYw}Zc.0,G45X true# >> g{4D53rZ;vYw}ZcZZ~vYw}Zc.s,G45X true# ZcHODa{G<{5"UrPrms#ZcHODa{Gy]BPfr(eD: v ?vYw}XkG%vZcrUrP;qra5Xms# v g{N;Yw}GUrP,G4HODa{*UrP# v g{xPHOD=vZc_P,;j6,G49C is Kc{DHO* true;qrH O* false# v g{4D53rsYw}ZcZRYw}Zc.0,G49C << Kc{DHO5X true;qrHO5X false# v g{4D53rsYw}ZcZRYw}Zc.s,G49C >> Kc{DHO5X true;qrHO5X false# >} v v1sYw}MRYw}s5a{}C*,;Zc1,TBHOE* true: /books/book[isbn="1558604820"] is /books/book[call="QA76.9 C3845"] v TBHO* false,-rG?v9lZcPT:Dj6: 5 is 5 v v14D53rIsYw}j6DZcvVZIRYw}j6DZc.01,TB HOE* true: /transactions/purchase[parcel="28-451"] << /transactions/sale[parcel="33-870"] Z 4 B mo= 71 _-mo= _-mo=9CKc{ and M or Fc<{5(true r false)# Bm4S_=MDKc{EH63rhv"P>cuKc{# m 27. XQuery PD_-mo=Kc{ Kc{ ?D and g{=vmo=* true,G45X true# or g{;vr=vmo=* true,G45X true# _-mo=Da{*<{5(true r false)rms#T_-mo=s51,a7(?v Yw}DP'<{5(EBV)#;saTYw}D EBV &CKc{,zIDa{G< {5rms#g{Yw}D EBV Gms,G4_-mo=azzms#BmT>_- mo=y]dYw}D EBV 5XDa{# m 28. y]Yw}D EBV Fc_-mo=Da{ Yw} 1 D EBV Kc{ Yw} 2 D EBV a{ true and true true true and false false false and true false false and false false true and ms ms ms and true ms false and ms false rms ms and false false rms ms and ms ms true or true true false or false false true or false true false or true true true or ms true rms ms or true true rms false or ms ms ms or false ms ms or ms ms a>:}_-mo=.b,XQuery 9a)K/} fn:not,|a+#frPw*N}"5 X<{5# >} v BPmo=5X true: 1eq1and2eq2 1eq1or2eq3 v TBmo=I\5X false rms: 72 XQuery N< 1eq2and3idiv0=1 v TBmo=I\5X true rms: 1eq1or3idiv0=1 v TBmo=5Xms: 1eq1and3idiv0=1 9l/} 9l/}aZi/P4( XML a9#XQuery a)K9l/}TCZ4(*XZc" tTZc"D5Zc"D>Zc"&m8nZcM"MZc#XQuery a)K=V9l/ }:1S9l/}MFc9l/}# 1S9l/}9C`F XML Dm>(Zi/P4( XML a9#XQuery a)K1S 9l/}TCZ4(*XZc(I\|(tTZc"D>ZcM6W*XZc)"& m8nZcM"MZc#}g,TB9l/}a4(|,tTM3)6W*XD book * X: Harold and the Purple Crayon Crockett Johnson Fc9l/}9CyZx(Emo=Dm>(Zi/P9C XML a9#Fc9l/} Tj6*4(DZc`MDX|V*7,"RszZcD{F,;sGCZFcZc Z]Dx(Emo=#XQuery a)KFc9l/}TCZ4(*XZc"tTZc"D 5Zc"D>Zc"&m8nZcM"MZc#}g,TBi/|,Fc9l/}, |GzIDa{k0f>}PD1S9l/}j+`,: element book { attribute isbn {"isbn-0060229357" }, element title { "Harold and the Purple Crayon"}, element author { element first { "Crockett" }, element last {"Johnson" } } } 9l/}PDx(Emo= x(Emo=Z9l/}PCZ**XMtTZ]a)Fc5#&m9l/}1aT b)mo=s5"f;*|GD5#x(Emo=GC((E({})(p4D,Tc kDVD>xp*4# IZBP9l/}P9Cx(Emo=Ta)Fc5: v 1S*X9l/}: – 1S*X9l/}p

Here is a query.

$b/title

Here is the result of the query.

{ $b/title } TK9l/}s51,|azzTBa{(TK>}mSUqG*Ka_IAT):

Here is a query.

$b/title

Here is the result of the query.

Harold and the Purple Crayon
a>:*Z*XrtTZ]P+((ECwU(V{,ImS;Tj+`,D((E r9CV{}C#}g,I9C {{ T4m>V{ {#,y,I9C }} T4m> }# Kb,9I9CV{}C { M } 48>((EV{#%vs((E({); bM*x(Emo=Dp<(g{#g{;P%vR((E(})x;P`%dDs( (E,G4a"zms# 1S*X9l/} 1S*X9l/}9C`F XML Dm>(44(*XZc#9lZcITGr%*X r|,tT"D>Z]M6W*XD4S*X# 1S*X9l/}azIzI_PTmZcj6DB*XZc#B*XZcDyPt TMszZc,12G_PdTmj6DBZc# o( < ElementName AttributeName = ' AttributeValue ' ″″ Namespace declaration attribute /> > ElementContent Namespace declaration attribute: xmlns:prefixToBind = URILiteral xmlns ElementName m>*9lD*X{FD QName#Za2jGPCZ ElementName D{FXkk T&p*9lDtT{FD QName#g{ AttributeName |({FUd0:,G4a (}9C2,Q*{FUd+0:bv*{FUd URI#g{ AttributeName ;P {FUd0:,G4tT;aZNN{FUdP#(}T AttributeName s5xzI D)9 QName +I*9ltTZcD{F#?vtTD)9 QName XkG(; D,qrmo=azzms# 1S*X9l/}PD?vtTDV{#BmP>Z AttributeValue PP'+XkC+XV{r5e}Cm>DXbV{# m 29. tT5PXbV{Dm> V{ tT5PXhDm> { =vs((E({{) } =vR((E(}}) < < & & ″ " r=v+}E(″″) ’ ' r=v%}E(’’) xmlns {FUdywtTD*<%J#Z QName P8(*0:1,xmlns 8> prefixToBind D5+s(AI URILiteral 8(D URI#TZK9l/}mo=M6 WZmo=PDyPmo=,K{FUds(+mSA2,6p{FUd,}Gs (;6W{FUdywtT2G#ZTB>}P,{FUdywtT xmlns:metric = "http://example.org/metric/units" +0: metric s(A{FUd http:// example.org/metric/units# 8(*;P0:Dj{ QName 1,xmlns 8>1!*X/`M{FUdhC*5 URILiteral#}Gyw;6W{FUdywtT2G,qrK1!*X/`M{FU dTK9l/}mo=0dP6WDyPmo=P'#ZTB>}P,{FUdy wtT xmlns = "http://example.org/animals" +1!*X/`M{FUdhC* http://example.org/animals# prefixToBind *s(A* URILiteral 8(D URI D0:#prefixToBind D5;\* xml r xmlns#8(dPNb;v5azzms# URILiteral CZm> URI DV{.DV,GIC%}Er+}E(p4DcvrcvTOV{ Z 4 B mo= 75 iIDrP#V{.DV5Xk*P' URI#v1{FUdywtTCZhC1! *X/`M{FUd1,URILiteral D5E\*c$HV{.#qr,T URILiteral 8(c$HV{.azzms# ElementContent 1S*X9l/}DZ]#CZ]|,9l/}DpV{(|(x(Emo=zI DD>)+O"I%vD>Zc#ZzIDZ]rPP,zIDyPtTZcXk ZNNd{Z].0# ElementContent IIBPNbZ]iI: v D>V{#D>V{a4(D>Zc,"R`ZD>ZcaO"I%vD>Z c#V{rPPDPa2+y]T XML 1.0 8(DPax&mfrxPf6/# BmP>Z ElementContent PP'+XkC+XV{r5e}Cm>DXbV {# m 30. *XZ]PXbV{Dm> V{ *XZ]PXhDm> { =vs((E({{) } =vR((E(}}) < < & & v 6W1S9l/}# v CDataSections#CDataSections G9CTBo(8(D:, dP contents I;5PV{iI#T contents 8(DV{(|( < M & .` DXbV{)+;SwDVV{x;G(g{#rP ]]> CZU9 CDataSection, rK;JmZ contents P9C# v V{}CM$(e5e}C#Z&mZd,$(e5e}CMV{}Ca)9 =;}CV{.P# v x(Emo=#x(Emo=GC((E(p4D XQuery mo=#}g, {5 + 7} G;vx(EDmo=#x(Emo=D5ITGIZcM-S5iIDNb rP#x(Emo=Ik1S*X9l/}DZ];p9C,TFc9lZc DZ]MtT#TZx(Emo=5XD?vZc,+a4(CZc0dyP szDB1>,x|GT#t-<`M"M#ElementContent 5XDyPtTZ cXkZzIDZ]rPD*7;b)tTZc+I*9l*XDtT# ElementContent 5XDNN*X"Z]r&m8nZc+I*B9lZcDSz# ElementContent 5XDyP-S5+*;*V{."f"ZD>ZcP,xb) Zc+I*9lZcDSz#`ZD>Zc+O"I%vD>Zc# >} v TB1S*X9l/}a4( book *X#book *X|,,PtTZc";)6W* XZcM;)D>ZcD4SZ]: Harold and the Purple Crayon 76 XQuery N< Crockett Johnson v TB>}5wgNZ1S*X9l/}P&m*XZ]: – TBmo=a9l_P;vSzD*XZc,CSzG|,5“1”DD>Zc: {1} – TBmo=a9l_P;vSzD*XZc,CSzG|,5“123”DD>Zc: {1, 2, 3} – TBmo=a9l_P;vSzD*XZc,CSzG|,5“123”DD>Zc: {1}{2}{3} – TBmo=a9l_P;vSzD*XZc,CSzG|,5“123”DD>Zc: {1, "2", "3"} – TBmo=a9l_P;vSzD*XZc,CSzG|,5“I saw 8 cats”DD >Zc:: I saw 8 cats. – TBmo=a9l_P;vSzD*XZc,CSzG|,5“I saw 8 cats”DD >Zc: I saw {5 + 3} cats. – TBmo=a9l_PTB}vSzD*XZc:|,“I saw”DD>Zc"{* howmany DS*XZcM|,“cats.”DD>Zc#S*XZc|,%vSz,4 |,5“8”DD>Zc# I saw {5 + 3} cats. {FUdywtT {FUdywtTGZ1S*X9l/}PDp:+{FUd0:s(A URI T0*9l*XZc0dtTMszhC1 !*X/`M{FUd# So(O5,{FUdywtTDq=k1S*X9l/}PDtT`,:tTGI {FM58(D#tT{FG#? QName#tT5Gm>P' URI DV{.DV# {FUdywtT;a 3 6 18 hC1!*X/`M{FUd g{ QName G;P0:D xmlns,G4ywCZhC1!*X/`M{FUd#}g, {FUdywtT xmlns = "http://example.org/animals" a+1!*X/`M{FU dhC* http://example.org/animals# &m{FUdywtT1,tTD5bM*{FUd URI#K URI 8(9l/}mo =D1!*X/`M{FUd,xBDf6a2GNNVP1!5#C URI 9amSA 9l*XD{FUdwCr(;x0:),xBDf6a2G;x0:DNNVP{ FUds(#g{{FUd URI Gc$HV{.,G49l/}mo=D1!*X/` M{FUdahC*“none”# }g,ZTB1S*X9l/}P,{FUdywtTa+1!*X/`M{FUdh C* http://example.org/animals: Persian 1S*X9l/}PD_gUq Z1S*X9l/}P,_gUqGZ?;Ky]Z]D*7ra2"1S9l/} rx(Emo=(gD,xUqV{rP# }g,IZ9l/}DZ]P9C_gUq+1S9l/}DaxjGk6W*XD p1S*X9l/}D>},d_gUq+;vT>: { " enclosed expression " } K>}PD_gUq|(BPV{:vVZ product M description *XDp} v ZTB>}P,9lD cat *XZcP=vS*XZc,Vp{* breed M color: {$b} {$c} r*1!ivBD_gUq_T* strip,yT*X9l/}a}%S*X\'DU q# v ZTB>}P,_gUq_T* strip#K>}H[Z abc: declare boundary-space strip; {"abc"} v +TB>}PD_gUq_T* preserve#K>}H[Z abc : declare boundary-space preserve; {"abc"} r*_gUq_T* preserve,yT*X9l/}a#tvVZx(Emo=0sD Uq# v ZTB>}P,z \'DUq"G_gUq#CUq+}H[Z z abc: z {"abc"} v ZTB>}P,;\_gUq_TgN,IV{}CzIDUqV{M`ZUqV {}H[Z abc: {"abc"} v ZTB>}P,;\_gUq_TgN,x(Emo=PDUqa#tB4,-r Gx(Emo=zIDUqv;a;S*_gUq#K>}H[Z : {" "} x(Emo=PD=vUqa;*X9l/}#tB4,"vVZa{Dpwb,h*KbBPEn.dDnp: 2,Q*{FUd 2,Q*{FUdGmo=tT#KtT8>Z&mmo=Zd,XQuery CZ bv{FUd0:D;i{FUds(#b)s(4|(Zi/a{P# {FUdwCr {FUdwCrG*XZctT#KtT8>Z&m*X0dZ]1,I) Z 4 B mo= 79 XQuery b?D&CLr9CD;i{FUds(#b)s(TrP/==vV Zi/a{P,yT|GI)b?&CLr9C# 9l*XD{FUdwCr|(9CBP==4(DyP{FUds(: v (}{FUdywtTT=xP#+*BP9l/}PywD?v{FUdywt T4(;v{FUds(# – 10*X9l/}# – bU1S*X9l/}(}G{FUdywtT;10*X9l/}rPd9l /}2G)# v I53T/xP#+ZTBivB4({FUds(: – *+0: xml s(A{FUd URI http://www.w3.org/XML/1998/namespace#+ *?v9l*X4(Ks(# – TZ9l*X{FrdtT{FP9CD?v*X(}G*XD{FUdwCr PQfZ{FUds()#g{ZcD{F|,0:,G4aZ{FUds(P 9CC0:#g{C{F;P0:,G4a*U0:4(s(#g{"ze; (h*9C,;0:D=v;,s(),G4Zc{P9CD0:+|D*Nb 0:,"R*CNb0:4({FUds(# PG:QName P9CD0:Xkbv*P' URI,r_C0:Ds(;\mSA *XD{FUdwCr#g{;\bv QName,G4mo=azzms# >} TBi/|,rTMwe,rT|,{FUdyw,xwe|,1S*X9l/}: declare namespace p="http://example.com/ns/p"; declare namespace q="http://example.com/ns/q"; declare namespace f="http://example.com/ns/f"; rTPD{FUdywa+{FUds(mSAmo=D2,Q*{FUd#+G, v19l/}PD QName 9Cb){FUd1,Ea+{FUds(mSA9l*X D{FUdwCr#rK,p:newElement D{FUdwCr|,BP{FUds(: v p = "http://example.com/ns/p" - K{FUds(+mSA{FUdwCr,-r G0: p vVZ QName p:newElement P# v q = "http://example.com/ns/q" - K{FUds(+mSA{FUdwCr,-r G0: q vVZtT QName q:b P# v r = "http://example.com/ns/r" - K{FUds(+mSA{FUdwCr,-r G|GI{FUdywtT(eD# v xml = "http://www.w3.org/XML/1998/namespace" - K{FUds(+mSA{F UdwCr,-rG|GT?v9l*XZc(eD# "b,{FUd f="http://example.com/ns/f" DNNs(;amSA{FUdwC r#bGr**X9l/}4|,9C0: f D*XrtT{,49 f:func(2) vV ZtT q:b DZ]P2GgK#rK,K{FUds(;avVZi/a{P,49| vVZ2,Q*{FUdP"RIZ&mi/Zd9C2GgK# Fc*X9l/} Fc*X9l/}a4(*XZc,dZcZ]Gy]x(Emo=FcD# 80 XQuery N< Fc*X9l/}azI_PTmZcj6DB*XZc#B*XZcDyPtTM szZc,12G_PdTmj6DBZc,49|GGVPZcD1>`gK# o( element ElementName {} ContentExpression element CZ8>+9l*XZcDX|V# ElementName *9lD*XD QName#g{ ElementName |({FUd0:,G4a(}9C 2,Q*{FUd+0:bv*{FUd URI#g{ ElementName ;P{FUd0 :,G4{FI1!*X/`M{FUd~=^(#(}T ElementName s5xzI D)9 QName +I*9l*XZcD{F# ContentExpression CZzI9l*XZcZ]Dmo=#ContentExpression D5ITGIZcM-S 5iIDNNrP#ContentExpression ICZFc9lZcDZ]MtT#TZ ContentExpression 5XD?vZc,+a4(CZc0dyPszDB1>,x| GT#t-<`M"M#ContentExpression 5XDyPtTZcXkZZcrPD * 7 ( Z N N d { Z c . 0 );b ) t T Z c + I * 9 l*X D t T # ContentExpression 5XDNN*X"Z]r&m8nZc+I*B9lZcDSz# ContentExpression 5XDyP-S5+*;*V{."f"ZD>ZcP,xb) Zc+I*9lZcDSz#`ZD>Zc+O"I%vD>Zc# >} ZTBmo=P,Fc*X9l/}+4(VP*XD^D1>#Y(d? $e Qs( A_P}VZ]D*X#K9l/}+4(B*X length,|DtTk $e `,"Rd }VZ]G $e Z]D=6: element length {$e/@*, 2 * fn:data($e)} ZK>}P,g{d? $e s(Amo= let $e := {5},G4>}mo=+zI*X 10# FctT9l/} FctT9l/}a4(tTZc,dtT5Gy]x(Emo=FcD# FctT9l/}azI_PTmZcj6DBtTZc# ":*1S9ltTZc,kZ1S*X9l/}PywCtT# o( attribute AttributeName {} AttributeValueExpression attribute CZ8>+9ltTZcDX|V# Z 4 B mo= 81 AttributeName *9lDtTD QName#g{ AttributeName |({FUd0:,G4a(}9C 2,Q*{FUd+0:bv*{FUd URI#g{ AttributeName ;P{FUd 0:,G4tT;aZNN{FUdP#(}T AttributeName s5xzID)9 QName +I*9ltTZcD{F#*XP?vtTD)9 QName XkG(; D,qrmo=azzms# AttributeValueExpression CZzItTZc5Dmo=#Z&mZd,+T AttributeValueExpression Da{ &C-S/,"RzIrPPD?v-S5D}]`M<+*;*V{.#(}? F`M*;zIDwvV{.+kekDUqV{"C#"CV{.+I*9lt TZcD5# >} TBFctT9l/}+9l{* size 5*“7”DtT# attribute size {4 + 3} D5Zc9l/} yPD5Zc9l/}+9lD5ZcDX|V# ContentExpression CZzI9lD5ZcZ]Dmo=#ContentExpression D5ITGIZcM-S 5(tTZc}b)iIDNNrP#Z]rPPDtTZcazzms#Z]r PPDD5Zcaf;*dSz#TZ ContentExpression 5XD?vZc,+a4 (CZc0dyPszDB1>,x|GT#t-<`M"M#Z]mo=5XD yP-S5+*;*V{."f"ZD>ZcP,xb)Zc+I*9lD5Zc DSz#`ZD>Zc+O"I%vD>Zc# >} TBD5Zc9l/}|(Z]mo=,Cmo=+5X|,y*X customer-list D XML D5: 82 XQuery N< document { {db2-fn:xmlcolumn(’MYSCHEMA.CUSTOMER.INFO’)/ns1:customerinfo/name} } D>Zc9l/} yPD>Zc9l/}Zc9l/}a4(D>Zc,dZ cZ]Gy]x(Emo=FcD# D>Zc9l/}azI_PTmZcj6DBD>Zc# o( text { ContentExpression } text CZ8>+9lD>ZcDX|V# ContentExpression CZzI9lD>ZcZ]Dmo=#Z&mZd,+T ContentExpression Da{ &C-S/,"RzIrPPD?v-S5D}]`M<+*;*V{.#(}? F`M*;zIDwvV{.+kekDUqV{"C#"CV{.+I*9lD >ZcDZ]#g{-S/zzUrP,G4;a9lD>Zc# ":I9CD>Zc9l/}49l|,c$HV{.DD>Zc#+G,g{Z9 l*XrD5ZcDZ]P9CKD>Zc,G4a>}CD>Zcr+dkm;D >ZcO"=;p# >} TB9l/}4(|,V{.“Hello”DD>Zc: text {"Hello"} &m8n9l/} &m8n9l/}a4(&m8nZc#XQuery a)K1S9l/}MFc9l/}T CZ4(&m8nZc# 9lZc_PBPZctT: ?jtT j6&m8n+}(44(&m8nZc# Z 4 B mo= 83 o( DirPIContents PITarget m>&m&CLr{FD NCName,&m8n+;}# >} TB9l/}a4(&m8nZc: Fc&m8n9l/} Fc&m8n9l/}a4(&m8nZc,dZcZ]Gy]x(Emo=Fc D# Fc&m8n9l/}azI_PTmZcj6DB&m8nZc# o( processing-instruction PITarget {} PIContentExpression processing-instruction CZ8>+9l&m8nZcDX|V# PITarget m>&m&CLr{FD NCName,&m8n+;}”# >} TBFc9l/}4(&m8n : processing-instruction audio-output {"beep"} "M9l/} "M9l/}a4("MZc#XQuery a)K1S9l/}MFc9l/}TCZ4( "MZc# 84 XQuery N< 1S"M9l/} 1S"M9l/}9C`F XML Dm>(44("MZc# o( DirCommentContents CZ8("MZ]D;5PV{#"MDZ];\|,=v,xD,V{rT,V {a2# >} TB9l/}a4("MZc: Fc"M9l/} Fc"M9l/}a4("MZc,dZcZ]Gy]x(Emo=FcD# Fc"M9l/}azI_PTmZcj6DB"MZc# o( comment { CommentContents } comment CZ8>+9l"MZcDX|V# CommentContents CZzI"MZ]Dmo=#Z&mZd,+T CommentContents Da{&C-S /,"R-S/rPPD?v-S5D}]`M<+*;*V{.#(}?F`M *;zIDwvV{.+kekDUqV{"C#g{-S/zzUrP,G4C rPa;f;*c$HV{.#Z]rP;\|,=v`Z,V{rT,V{a 2# >} TBFc9l/}4("M : let $homebase := "Houston" return comment {fn:concat($homebase, ", we have a problem.")} FLWOR mo= FLWOR mo=aTrPxP|z"+d?s(APda{#FLWOR mo=TZFc =vr|`D5.dD,S"X9}]MTa{ErG#PC# FLWOR mo=Do( FLWOR mo=IBPSdiI,dP;)SdGI!D:for"let"where"order by M return# Z 4 B mo= 85 for clause let clause where Expression , ascending order by Expression descending return Expression for clause: , for $VariableName in Expression at $PositionalVariableName let clause: , let $VariableName := Expression for for SdDp}P,for Sd|,d? $i MCZ9lrP (1, 2, 3) Dmo=: for $i in (1, 2, 3) return {$i} T for Sds51,a4(}vd?s((rPPD?nT&;vs(): $i=1 $i=2 $i=3 >}PD return SdT?vs(4P;N#Cmo=azzTBdv: 1 2 3 for SdI|,`vd?,?vd?s(Amo=Da{#ZTB>}P,for Sd| ,=vd? $a M $b 0CZ9lrP 12M 45Dmo=: for $a in (1, 2), $b in (4, 5) return {$a, $b} T for Sds51,a*?v5iO4(;vd?s(*i#bazzDvd?s(* i: ($a=1,$b=4) ($a=2,$b=4) ($a=1,$b=5) ($a=2,$b=5) >}PD return SdaT?vs(*i4P;N#Cmo=azzTBdv: 1 4 2 4 1 5 2 5 Z 4 B mo= 87 s(mo=s5a{*UrP1,;azINN for s(,2;a4PNN|z#ZT B>}P,s(rPs5a{*UrP"R;4PNN|z#;a5X return SdP DZcrP# for $node in (, , )[@test = "1"] return Sample return response for SdPD;Cd? for SdPs(D?vd?b)nZr PPD;CD{}(S 1 *<)xP|z# ZTB>}P,for Sd|,d? $cat MCZ9lrP ("Persian", "Calico", "Siamese") Dmo=#CSd9|,;Cd? $i,tT9l/}Pa}CCd?TF c order tTD5: for $cat at $i in ("Persian", "Calico", "Siamese") return { $cat } T for Sds51,a4(}vd?s(*i,?v*i|,T&;Cd?Ds(# ($i = 1, $cat = "Persian") ($i = 2, $cat = "Calico") ($i = 3, $cat = "Siamese") >}PD return SdaT?vs(*i4P;N#Cmo=azzTBdv: Persian Calico Siamese !\?vdv*X<|,3rtT,+";\#$*XZdvwPD5J3r,}G FLWOR mo=|, order by $i .`D order by Sd#;Cd?m>3v5Zd krP(x;GdvrP)PDr};C# let Sd let Sda+d?s(Amo=D{va{#let Sd;a4PNN|z# let SdDnr%`M|,;vd?MX*mo=#ZTB>}P,let Sd|,d? $j MCZ9lrP (1, 2, 3) Dmo=# let $j := (1, 2, 3) return {$j} T let Sds51,a*Tmo=s5zzD{vrP4(%vs(: $j=123 >}PD return Sd4P;N#Cmo=azzTBdv: 1 2 3 let SdI|,`vd?#+G,k for Sd;,,let Sda+?vd?s(AdX *mo=Da{x;xP|z#ZTB>}P,let Sd|,=vd? $a M $b 0C Z9lrP 12M 45Dmo=: 88 XQuery N< let $a := (1, 2), $b := (4, 5) return {$a, $b} T let Sds51,a4(;vd?s(*i: ($a=12,$b=45) >}PD return SdTC*i4P;N#Cmo=azzTBdv: 1 2 4 5 s(mo=s5a{*UrP1,a4(|,UrPD let s(# ,;mo=PD for M let Sd g{ FLWOR mo=,1|, for M let Sd,G4 let SdzIDd?s(+m SA for SdzIDd?s(# ZTB>}P,for Sd|,d? $a 0CZ9lrP (1, 2, 3) Dmo=#let S d|,d? $b MCZ9lrP (4, 5, 6) Dmo=: for $a in (1, 2, 3) let $b := (4, 5, 6) return {$a, $b} K>}PD for M let Sdazz}vs(*i#*i}?I for Sd7(# ($a=1,$b=456) ($a=2,$b=456) ($a=3,$b=456) >}PD return SdaT?vs(*i4P;N#Cmo=azzTBdv: 1 4 5 6 2 4 5 6 3 4 5 6 for M let SdDHO !\ for M let Sd},|GaHO|,`F for M let SdD FLWOR mo=5XD a{# m 31. FLWOR mo=PD for M let SdDHO i/hv FLWOR mo= a{ 9C for s(%vd? for $i in ("a", "b", "c") return {$i} a b c 9C let s(%vd? let $i := ("a", "b", "c") return {$i} a b c 9C for s(`vd? for $i in ("a", "b"), $j in ("c", "d") return {$i, $j} a c b c a d b d 9C let s(`vd? let $i := ("a", "b"), $j := ("c", "d") return {$i, $j} a b c d ":r*KmPDmo=4|( order by Sd,yTdv*XD3rG;7(D# Z 4 B mo= 89 for M let SdPDd?wCr for r let SdPs(Dd?Zd?s(svVZ FLWOR mo=DyPSmo=w CrP# bb6E for r let SdI}C.0Sds(Dd?r,;Sd.0s(PDd?# ZTB>}P,FLWOR mo=_PBPSd: v s(d? $orders D let Sd# v }C $orders "s(d? $i D for Sd# v }C $orders M $i "s(d? $c Dm; let Sd# C>}Z;i)%PiRyP;,n?`E,"5X?v;,n?`ED)%}?# let $orders := db2-fn:xmlcolumn("ORDERS.XMLORDER") for $i in fn:distinct-values($orders/order/itemno) let $c := fn:count($orders/order[itemno = $i]) return {$i} {$c} *c:FLWOR mo=D for M let Sd;\`Ns(,;d?{# where Sd FLWOR mo=PD where SdCZ}KI for M let SdzIDd?s(*i# where SdCZ8(&CZ?vd?s(*iDu~#g{u~* true(4mo=zI P'<{5 true),G4a#tC*i,"RaZ4P return Sd19C|Ds(# qraOzC*i# ZTB>}P,for Sda+d? $x M $y s(A}5rP: for $x in (1.5, 2.6, 1.9), $y in (.5, 1.6, 1.7) where ((fn:floor($x) eq 1) and (fn:floor($y) eq 1)) return {$x, $y} T for Sds51,a4( 9 vd?s(*i: ($x = 1.5, $y = .5) ($x = 2.6, $y = .5) ($x = 1.9, $y = .5) ($x = 1.5, $y = 1.6) ($x = 2.6, $y = 1.6) ($x = 1.9, $y = 1.6) ($x = 1.5, $y = 1.7) ($x = 2.6, $y = 1.7) ($x = 1.9, $y = 1.7) where Sda}Kb)*i,xBP*ia#tB4: ($x = 1.5, $y = 1.6) ($x = 1.9, $y = 1.6) ($x = 1.5, $y = 1.7) ($x = 1.9, $y = 1.7) return SdaT?v#t*i4P;N,xmo=azzTBdv: 90 XQuery N< 1.5 1.6 1.9 1.6 1.5 1.7 1.9 1.7 r*K>}PDmo=4|( order by Sd,yTdv*XD3rG;7(D# order by Sd FLWOR mo=PD order by Sd8( return Sd&m51y9CD3r#g{; P order by Sd,a4;7(D3r5X FLWOR mo=Da{# order by Sd|,;vr`vErf6#Erf6CZT where Sd}Ks#tB4 Dd?s(*iXBEr#zIDEr+7(T return Sds5D3r# ?vErf6Imo=M3r^N{iI,aTmo=xPs5TzIEr|,x3 r^N{CZ8(Er|DEr(}rr5r)#=v*iD`T3r(}+dEr |D5w*V{.xPHO47(,&m3r*SsAR# ZTB>}P,FLWOR mo=|, order by Sd,CSda4U[q5r4Tz7 xPEr: { for $prod in db2-fn:xmlcolumn(’PRODUCT.DESCRIPTION’)/product/description order by xs:decimal($prod/price) descending return {$prod/name, $prod/price}} &m order by Sd1,TZ for SdzID?v*i,aTErf6PDmo=s 5#TZZ;v*i,mo= xs:decimal($prod/price) 5XD5* 9.99#;sak TB;v*iTmo=s5,xmo=a5X5 19.99#r*Erf68>wn45r Er,yT[q* 19.99 Dz7aEZ[q* 9.99 Dz7.0#KEr}LaVx= yP*iDXBErax#;s,return SdaTXBErD*iwPD?v*i4P ;N# T SAMPLE }]bD PRODUCT.DESCRIPTION mKP1,>}PDi/+5XTB a{: Snow Shovel, Super Deluxe 26" 49.99 Snow Shovel, Deluxe 24" 19.99 Snow Shovel, Basic 22" 9.99 Ice Scraper, Windshield 4" Wide 3.99 Z 4 B mo= 91 ZK>}P,Erf6PDmo=ay] price *XD59l xs:decimal 5#r* price *XD`M* xdt:untypedAtomic,yTh*xPK`M*;#g{;xP*;, G4a{a9CV{.Erx;G}VEr# a>:IZ FLWOR mo=P9C order by Sd48(>4;X|zDi/PD5E r#}g,TB76mo=a5XM'j6(Cid)_Z 1000 D customerinfo *XP m: db2-fn:xmlcolumn(’CUSTOMER.INFO’)/customerinfo[@Cid > "1000"] +G,*4M'{FD}rTb)nxPEr,zh*8(|, order by SdD FLWOR mo=: for $custinfo in db2-fn:xmlcolumn(’CUSTOMER.INFO’)/customerinfo where ($custinfo/@Cid > "1000") order by $custinfo/name ascending return $custinfo Er|;X|,ZdvP#TBi/azIz7{FPm"4[q5rEP,+dv P;|([q: for $prod in db2-fn:xmlcolumn(’PRODUCT.DESCRIPTION’)/product order by xs:decimal($prod/description/price) descending return $prod/name HOErf6Dfr s5MHOErf6D}LyZBPfr: v aTErf6PDmo=xPs5"RTa{&C-S/#-S/Da{XkG% v-S5rUrP;qra5Xms#TErf6s5Da{F*Er|# v g{Er|D`M* xdt:untypedAtomic,G4C|D}]`Ma*;* xs:string#g {;1+^`M5SwV{.,G4ErxL\;Z;j+*@*ErDyP5` MDivB*<# v g{Erf6zID5"G,;`M,G4a(}S`Mf;r`Ma}+b)5 (|)*;*+2`M#|G(}+|*;*'V gt Kc{DnM+2`M4HO D#}g,g{Erf6zI|, xs:anyURI 5M xs:string 5D|Pm,G4a9 C`M* xs:string D gt Kc{HOb)|#g{x(Erf6zIDEr|;P' V gt Kc{D+2`M,G4azzms# v Er|D5CZ7(+s(d?*i+]A*4PD return Sd1y9CD3r#* iDErG(}HOEr|7(D,&m3r*SsAR,"R@]BPfr: – g{Er3r*}r,G4Er|O_D*iEZOsD;C# – g{Er3r*5r,G4Er|O_D*iEZO0D;C# Er|DsZX5D(egBy>: – UrPsZyPd{5# – NaN bM*sZUrPTbDyPd{5# – g{+3v5km;v5xPHO1 gt Kc{5X true,G4m>C5sZm; v5# – Xb!c5}cM:c^(HOs!,-rG +0.0 gt -0.0 M -0.0 gt +0.0 < * false# 92 XQuery N< ":g{8(K ascending !n(1!5),G4Er|*UD*ivVZdvwD a2,g{8(K descending !n,G4Er|*UD*ivVZdvwD*7# return Sd return Sd+zI FLWOR mo=Da{# return Sd+T FLWOR mo=Dd{SdzID?vd?s(*ixP;Ns5# return Sd&ms(d?*i1y9CD3rG;7(D,}G FLWOR mo=|, order by Sd# g{ return SdPDmo=GG|Bmo=,G4yP return Sds5Da{+" CTNIG|B FLWOR mo=Da{# g{ return SdPDmo=G|Bmo=,G4yP return Sds5Da{G|B Pm#Z+|Bkd;mo=D modify SdPDd{|Bmo=5XD|BO"s, |, FLWOR mo=Dd;mo=a4P|B# a>:Z return SdP,&9C2(E+|,%6:EKc{Dmo=(p4#r* FLWOR mo=DEH3r_Z:EKc{DEH3r,yT,g{;9C2(E,| ,:EKc{Dmo=I\azzmsrbba{# FLWOR >} BP>}T>gNZj{i/P9C FLWOR mo=4P,S"ViM[/# CZ,S XML }]D FLWOR mo= TBi/a,S SAMPLE }]bD PRODUCT M PURCHASEORDER mPD XML }],TP> 2005 jzzD)%P):Dz7{F# r*z7D5M PurchaseOrder D5PD*XZ,;{FUdP,yTi/aSyw1 !{FUd*<,byi/PD*X{FM;h*0:#XpGTZ|,T“2005”* 7D OrderDate tT5D)%,for SdaT PURCHASEORDER.PORDER PxP| z#TZ?v)%,let Sda+ partid 58(x $parts d?#;s return Sda P>)%P|,Dz7D{F# for $po in db2-fn:xmlcolumn(’PURCHASEORDER.PORDER’) /PurchaseOrder[fn:starts-with(@OrderDate, "2005")] let $parts := $po/item/partid return { db2-fn:xmlcolumn(’PRODUCT.DESCRIPTION’) /product[@pid = $parts]/description/name } i/+5XTBa{: Snow Shovel, Deluxe 24 inch Snow Shovel, Super Deluxe 26 inch Ice Scraper, Windshield 4 inch Snow Shovel, Basic 22 inch Z 4 B mo= 93 Snow Shovel, Basic 22 inch Snow Shovel, Super Deluxe 26 inch CZT*XxPViD FLWOR mo= TBi/a4GPT SAMPLE }]bD CUSTOMER mPDM'{FxPVi#for SdaT customerinfo D5xP|z,"+?vGP*Xs(Ad? $city#TZ?v GP,let Sda+d? $cust-names s(ACGPyPM'{FD^rPm#i/a 5XGP*X,?v*X|,GP{F0S!ZCGPDyPM'D6W{F*X# for $city in fn:distinct-values(db2-fn:xmlcolumn(’CUSTOMER.INFO’) /customerinfo/addr/city) let $cust-names := db2-fn:xmlcolumn(’CUSTOMER.INFO’) /customerinfo/name[../addr/city = $city] order by $city return {$city, $cust-names} i/+5XTBa{: Aurora Robert Shoemaker Markham Kathy Smith Jim Noodle Toronto Kathy Smith Matt Foreman Larry Menard CZ[/}]D FLWOR mo= TBi/5X 2005 jD?E)%zzD\Uf"4( HTML (f# i/aT)%UZ* 2005 jD?v PurchaseOrder *XxP|z,"+C*Xs(A for SdPDd? $po#;s,76mo= $po/item/ a+OBD;CFA PurchaseOrder *XPD?vn*X#6Wmo= (price * quantity) a7(CnD\ Uf#fn:sum /}aFc?nD\UfDzIrP.M#let Sda+ fn:sum /}D a{s(Ad? $revenue#order by Sday]?E)%D\UfTa{xPEr# ns,return SdaZ(fmP*?E)%4(;P#

PO totals

{ for $po in db2-fn:xmlcolumn(’PURCHASEORDER.PORDER’)/ PurchaseOrder[fn:starts-with(@OrderDate, "2005")] let $revenue := sum($po/item/(price * quantity)) order by $revenue descending return 94 XQuery N< }
PO Number Status Revenue
{string($po/@PoNum)} {string($po/@Status)} {$revenue}
i/+5XTBa{:

PO totals

PO Number Status Revenue
5004 Shipped 139.94
5001 Shipped 123.96
5003 UnShipped 9.99
Z/@wPi41,i/dv`FBm: m 32. PO \F PO `E 4, Uf 5004 Q;6 139.94 5001 Q;6 123.96 5003 4;6 9.99 CZ|B XML }]D FLWOR mo= TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# d;mo=a4(|,M'E"D XML D5D1>#Z modify SdP,FLWOR m o=MX|{mo=a+Zc{ phone DyP5}|D*{F phonenumber: Z 4 B mo= 95 xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1003’) modify for $phone in $mycust/customerinfo/phone return do rename $phone as "phonenumber" return $mycust T SAMPLE }]bKP1,Cmo=a+Zc{ phone |D* phonenumber "5X TBa{: Robert Shoemaker 1596 Baseline Aurora Ontario N8X 7F8 905-555-7258 416-555-2937 905-555-8743 613-555-3278 u~mo= u~mo=9CX|V if"then M else Ty]bTmo=D5G true 9G false 4 T=vmo=DdP;vs5# o( if ( TestExpression ) then Expression else Expression if 1SEZbTmo=.0DX|V# TestExpression 7(TD?Vu~mo=s5D XQuery mo=# then g{ TestExpression DP'<{5* true,G4aTzZKX|V.sDmo=s 5#g{bTmo=DP'<{5* false,G4;aTmo=s5rliGqP m# else g{ TestExpression DP'<{5* false,G4aTzZKX|V.sDmo=s 5#g{bTmo=DP'<{5* true,G4;aTmo=s5rliGqPm# Expression XQuery mo=#g{mo=|,%6:EKc{,G4XkC2(E+mo=(p 4# g{ then r else u~V'|,|Bmo=,G4u~mo=*|Bmo=#| Bmo=XkZd;mo=D modify SdP# TZ|Bu~mo=,?vV'Xk|,|Bmo=rUrP#y]bTmo=D 5,+!q then r else SdrTds5#u~|Bmo=+zIy!V'5X 96 XQuery N< D|BPm#Z+|Bkd;mo=D modify SdPDd{|Bmo=5XD| BO"s,|,d;Dmo=a4P|B# >} ZTB>}P,i/a9l|,tT basic D product *XDPm#basic tTD5 Gy] price *XD5Gq!Z 10 b;u~8(D: for $prod in db2-fn:xmlcolumn(’PRODUCT.DESCRIPTION’)/product/description return ( if (xs:decimal($prod/price) < 10) then {fn:data($prod/name)} else {fn:data($prod/name)}) i/+5XTBa{: Snow Shovel, Basic 22" Snow Shovel, Deluxe 24" Snow Shovel, Super Deluxe 26" Ice Scraper, Windshield 4" Wide ZK>}P,bTmo=ay] price *XD59l xs:decimal 5#xs:decimal /} CZ?FxP.xFHO# (?mo= g{;vr`vrPPD3nr?n<{OX(u~,G4(?mo=5X true#(? mo=D5mo=G4PVP?/9G+V? /#?Jsz;vr`vSd,T+d?s(Amo=5XDn#;saZbTmo =P}Cs(Dd?,T7(Gq3)r+?s(5<{OX(u~# o( , some $VariableName in Expression satisfies TestExpression every some 8(KX|Vs,g{ Expression 5XDAY;nD TestExpression P'<{5* true,G4(?mo=5X true#qr,(?mo=5X false# every 8(KX|Vs,g{ Expression 5XD?nD TestExpression P'<{5* true, G4(?mo=5X true#qr,(?mo=5X false# VariableName *s(A Expression a{P?;nDd?D{F#(?mo=Ps(Dd?Z(? mo=Ps(d?svVDyPSmo=wCrP# Expression XQuery mo=#g{mo=|,%6:EKc{,G4XkC2(E+mo=(p 4# Z 4 B mo= 97 satisfies 1SEZbTmo=.0DX|V# TestExpression ;v XQuery mo=,CZ8( Expression 5XDrPPD3nr?nXk{OD u~# ":"zms1,(?HODa{I\*<{5rms# >} v g{ SAMPLE }]b CUSTOMER.INFO PPD?vM'}PD(?mo=a5X true: every $cust in db2-fn:xmlcolumn(’CUSTOMER.INFO’)/customerinfo satisfies $cust/addr/@country = "Canada" v ZBP>}P,TZs(Ad? a M b D5D?viO(;2P 9 viO),? v(?mo=aTdbTmo=s5# TBmo=Da{* true: some $a in (3, 5, 9), $b in (1, 3, 5) satisfies $a * $b = 27 TBmo=Da{* false: every $a in (3, 5, 9), $b in (1, 3, 5) satisfies $a * $b = 27 v TB>}5w(?mo=Da{;\7(GqfZms#mo=I\5X true rm s,-rGbTmo=aT;vd?s(5X true,"Tm;vd?5Xms: some $a in (3, 5, "six") satisfies $a*3=9 ,y,TBmo=I\5X false rms: every $a in (3, 5, "six") satisfies $a*3=9 ?F`M*;mo= ?F`M*;mo=ay]VP54(X(`MDB5# ?F`M*;mo=P=vYw}:dkmo=M?j`M#T?F`M*;mo= s51,-S/CZ+dkmo=Da{*;*-S5rUrP#g{-S/azI |,`v-S5DrP,G4a5Xms#g{45Xms,G4?F`M*;mo =a"Ty]dk54(BD?j`M5#?F`M*;;'VdkM?j`MD3 )iO#PXD)`MI*;*d{`MDE",kNDZ 21 3D:`M*;;#+ 5*;*3V}]`M1,I9CI*Mmo=4bTC5Gq\*;*C}]` M# v1?j`MszJE(?)1,UrPEGP'Ddk5# g{*Mmo=D?j`M* xs:QName rIzT xs:QName r xs:NOTATION D` M,"Rdkmo=`M* xs:string +;GDV.,G4a5Xms# 98 XQuery N< o( Expression cast as TargetType ? Expression 5X%v-S5rUrPD XQuery mo=#v1 TargetType szJE(?)1, EJm9CUrP# TargetType Expression D5+*;AD`M#TargetType XkGtZ$(e-S XML #=` MD-S`M#}]`M xs:NOTATION"xdt:anyAtomicType M xs:anySimpleType TZ TargetType G^'`M# ? 8> Expression Da{I\*UrP# >} ZTB>}P,?F`M*;mo=CZT price *XD5xP?F`M*;,C5+ I`M xs:string *;*`M xs:decimal# for $price in db2-fn:xmlcolumn(’PRODUCT.DESCRIPTION’)/product/description/price return $price cast as xs:decimal T SAMPLE }]bD PRODUCT.DESCRIPTION mKP1,>}PDi/+5XTB a{: 9.99 19.99 49.99 3.99 I*Mmo= I*Mmo=bT3v5Gq\*;*X(}]`M#g{C5I*;*C}]` M,G4I*Mmo=5X true#qrCmo=5X false# I*Mmo=ICw=JT\bs51vV?F`M*;ms#9I9C|G4!q CZ&m5DJ1`M#PXD)`MI*;*d{`MDE",kNDZ 21 3D :`M*;;# o( Expression castable as TargetType ? Expression 5X%v-S5rUrPD XQuery mo=# TargetType CZbT Expression D5GqIxP?F`M*;D`M#TargetType XkGtZ $(e XML #=`MD-S`M#}]`M xs:NOTATION"xdt:anyAtomicType M xs:anySimpleType TZ TargetType G^'`M# Z 4 B mo= 99 ? 8>UrP;S*P'D?j`M5}#g{ Expression s5*UrP"R48( ?,G4I*Mmo=5X False# 5XD5 g{ Expression I*M* TargetType,G4I*Mmo=5X true#qrCmo=5 X false# g{ Expression Da{GUrP"RJE8>{zZ TargetType .s,G4I*Mm o=5X true#ZTB>}P,JE8>{zZ?j`M xs:integer .s# $prod/revision castable as xs:integer? g{I*Mmo=D TargetType * xs:QName rIzT xs:QName r xs:NOTATION D`M,"R Expression D`M* xs:string +"GDV.,G4I*Mmo=D5X 5* false# g{ Expression Da{G|,`v-S5DrP,G4a5Xms# >} TB>}+I*Mmo=Cw=JT\bs51"zms#TB>}\b @OrderDate " GP'UZ1"z/,ms# $po/orderID[if ( $po/@OrderDate castable as xs:date) then xs:date($po/@OrderDate) gt xs:date("2000-01-01") else false()] v1UZtTG 2000 j 1 B 1 UTsDP'UZ1,=JEas5* true "5X orderID#qr=Js5* false "5XUrP# TB>}9CI*Mmo=4!qCZ&mx(5DJ1`M#C>}9CI*Mm o=+J~`k*;*{}rV{.: if ($postalcode castable as xs:integer) then $postalcode cast as xs:integer else $postalcode cast as xs:string TB>}Z FLWOR let SdP9CI*Mmo=bT $prod/mfgdate D5,"+5 s(A $currdate#I*Mmo=M*Mmo='V9CJE8>{&mUrP# let $currdate := if ($prod/mfgdate castable as xs:date?) then $prod/mfgdate cast as xs:date? else "1000-01-01" cast as xs:date g{ $prod/mfgdate D5I*;* xs:date,G4|a*;*C}]`M"s(A $currdate#g{ $prod/mfgdate GUrP,G4a+UrPs(A $currdate#g{ $prod/mfgdate ;\*;* xs:date,G4a+`M* xs:date D5 1000-01-01 s(A $currdate# TB>}Z4PHO.09CI*Mmo=bTz7`pD5#Z XML P FEATURES.INFO P,D5|,*X /prod/category#C5G}VzkrV{.zk# Z4PHO.0,XMLEXISTS =JPDI*Mmo=bT /prod/category D5T\ bs51"zms# 100 XQuery N< SELECT F.PRODID FROM F FEATURES WHERE xmlexists(’$test/prod/category[ (( . castable as xs:double) and.>100)or (( . castable as xs:string) and . > "A100" )]’ passing F.INFO as "test") 5XD5G`pzksZ}V 100 rsZV{.“A100”Dz7j6# d;mo=M|Bmo= *9C DB2 XQuery |BVP XML }],k9Cd;mo= modify SdPD|B mo=# Zd;mo=P9C|BYw XkZd;mo=D modify SdP9C DB2 XQuery |Bmo=#|Bmo=aw CZd;mo= copy Sd4(D4FZc# BPmo=G|Bmo=: v >}mo= v ekmo= v X|{mo= v f;mo= v d return Sd|,|Bmo=D FLWOR mo= v d then r else Sd|,|Bmo=Du~mo= v C:Et*D=vr|`|Bmo=,dPyPYw}""Mr&m 8nZc# 2. 9C before"after"as first r as last .`DErX|VDekYw# 3. 48(X|V value of Df;Yw# 4. f;Yw,dP8(KX|V value of "R?jZc**XZc# 5. yP>}Yw# &C|DYwD3r&7#;5P`v|D+zI7(Da{#PX|BYwD4P 3rgN#$;5P`v|DzI7(a{D>},kND:>};PDns;v XQuery mo=# ^' XQuery |BYw &md;mo=Zd,g{vVBPdP;Viv,G4 DB2 XQuery a5Xms: v T,;Zc&CK=vr|`X|{Yw# v T,;Zc&CK9CX|V value of D=vr|`f;Yw# v T,;Zc&CK49CX|V value of D=vr|`f;Yw# v d;mo=Da{"GP' XDM 5}# |,D*XD=vtT,{MG;v^' XDM 5}D>}# v XDM 5}|,;;BD{FUds(# BfG;;BD{FUds(D>}: – tTZcD QName PD{FUds(kd8*XZcPD{FUds(;;B# – _P,;8zD=vtTZcPD{FUds(`%;;B# >} ZTB>}P,d;mo=D copy Sd+d? $product s(A*XZcD1>,x d;mo=D modify Sd9C=v|Bmo=4|D4FZc: xquery transform copy $product := db2-fn:sqlquery( "select description from product where pid=’100-100-01’")/product modify( do replace value of $product/description/price with 349.95, do insert Available as last into $product ) return $product TB>}Z SQL UPDATE odP9C XQuery d;mo=4^D CUSTOMER mP D XML }]#SQL UPDATE odawCZ CUSTOMER mD3P#d;mo=ay ]CPD INFO P4( XML D5D1>,"+ status *XmSAD51># UPDATE oda+CP INFO PPDD5f;*d;mo=^DsDD51>: UPDATE customer SET info = xmlquery( ’transform copy $newinfo := $info modify do insert Current as last into $newinfo/customerinfo return $newinfo’ passing info as "info") WHERE cid = 1003 102 XQuery N< TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# ZTB>}P,SQL SELECT odawCZ CUSTOMER mD3P#d;mo=D copy Sday]P INFO 4( XML D5D1>#>}mo=a>}D51>PDX 7E"MG$wg0Ek#return a9C CUSTOMER mD- {data($d/customerinfo/@Cid)} {$mycust/customerinfo/*} {data($d/customerinfo/addr/@country)} ’ passing INFO as "d") FROM CUSTOMER WHERE CID = 1003 T SAMPLE }]bKP1,Cod+5XTBa{: 1003 Robert Shoemaker 905-555-7258 Canada ZTB>}P,XQuery mo=a5w|BYwD3rgN#$;5P`v|D+zI7 (Da{#ekmo=aZ phone *XsmS status *X,xf;mo=a+ phone *Xf;* email *X: xquery let $email := jnoodle@my-email.com let $status := current return transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1002’) modify ( do replace $mycust/customerinfo/phone with $email, do insert $status after $mycust/customerinfo/phone[@type = "work"] ) return $mycust Z modify SdP,f;mo=Zekmo=.0#+G,|B4FZcrP $mycust 1,aZf;|BYw.04Pek|BYw,T7#zI7(Da{#T SAMPLE } ]bKP1,Cmo=+5XTBa{: Jim Noodle 25 EastCreek Markham Ontario N9C 3T6 jnoodle@my-email.com current Z 4 B mo= 103 g{H4Pf;Yw,G4 phone *X;aZZcrPP,xCZZ phone *Xse k status *XDYw;PNNbe# PX|BYwD3rDE",kNDZ 101 3D:&m XQuery |BYw;# d;mo= d;mo=a4(;vr`vZcD1>#d;mo= modify SdPD|Bmo=a |D4FDZc#return SdPDmo=a8(d;mo=Da{# o( transform copy clause modify clause return clause copy clause: , copy $VariableName := CopySourceExpression modify clause: modify ModifyExpression return clause: return ReturnExpression N} transform ICwd;mo=DI!p# VariableName *s(A CopySourceExpression 5XDZcwD1>Dd?{F# CopySourceExpression "G|Bmo=D XQuery mo=#mo=Xk5X%vZc0dF*ZcwDs z(g{fZ)# g { m o = | , % 6 : E K c { , G 4 C m o = X k ( Z2( E P # CopySourceExpression s51aw**X9l/}PDx(Emo=&m# copy Sd4(DZc_PBDZcj6"RtZ^`MZc# modify d;mo=D modify SdDpZc#zI DD>ZcDV{.5G;PekUqD`ZD>ZcD"CV{.5#g{4( DSZcGV{.5*c$HV{.DD>Zc,G4a>}CD>Zc# return d;mo=D return SdDp} TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# ZTB>}P,d;mo=D copy Sday]P INFO 4( XML D5D1>#Z modify SdP,>}mo=a>} XML D5Pg0D`MtT"G home DyPg 0Ek: xquery transform copy $mycust := db2-fn:sqlquery(’select INFO from CUSTOMER where Cid = 1003’) modify do delete $mycust/customerinfo/phone[@type!="home"] return $mycust; T SAMPLE }]bKP1,Cmo=+5XTBa{: Robert Shoemaker 1596 Baseline Aurora Ontario N8X 7F8 416-555-2937 TBmo=;a9CI!X|V transform#d;mo=T copy Sd*7"H[ZH 0Dmo=# Z 4 B mo= 105 xquery copy $mycust := db2-fn:sqlquery(’select INFO from CUSTOMER where Cid = 1003’) modify do delete $mycust/customerinfo/phone[@type!="home"] return $mycust; ZTB>}P,SQL UPDATE oda^D"i$ CUSTOMER mD3PPD XML D 5#d;mo=D copy Sday]P INFO 4( XML D5D1>#f;mo=a |D XML D51>P name *XD5#;ai$D51>#XMLVALIDATE /}a i$D51>: UPDATE customer set info = XMLVALIDATE( XMLQUERY(’transform copy $mycust := $cust modify do replace value of $mycust/customerinfo/name with "Larry Menard, Jr." return $mycust’ passing info as "cust" ) ACCORDING TO XMLSCHEMA ID customer) where cid = 1005 y>|Bmo= (}9C 4 Vy> XQuery |Bmo=,I4(4S|Bmo=T|BVP XML } ]#9C DB2 XQuery 1,aZd;mo=D modify SdP9C|Bmo=# >}mo= >}mo=aSZcrPP>}cvrcvTOZc# o( do delete TargetExpression do delete >}mo=Dp}mo=s5,"zII*>}DZciID|BPm#k TargetExpression `%dDNNZc+;jG*>}#>} TargetExpression Zc1, b)Zcakd8ZcO*,S#Zc0ZcSz;Y|(ZZcrPP# >} TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# TBmo=aS XML D5P>}X7*X0dyPSzZc,T0g0tT`M"G R%DyPg0Ek# 106 XQuery N< xquery transform copy $mycust := db2-fn:sqlquery(’select INFO from CUSTOMER where Cid =1003’) modify do delete ($mycust/customerinfo/addr, $mycust/customerinfo/phone[@type!="home"]) return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Robert Shoemaker 416-555-2937 TB>}SNNg0*XZcP>}tT5* home D`MtT# xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1004’) modify ( for $phone in $mycust/customerinfo//phone[@type="home"] return do delete $phone/@type ) return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Matt Foreman 1596 Baseline Toronto Ontario M3Z 5H9 905-555-4789 416-555-3376 Gopher Runner 416-555-3426 Cmo=a>}M'g0EkMzmg0EkPD`MtT# ekmo= ekmo=a+;vr`vZcD1>ek=ZcrPD8(;CP# o( do insert SourceExpression before TargetExpression after as first into as last into into do insert ekmo=Dp* TargetExpression DZ;zSz#g{ ekrP|,HvVZrPPDtTZc,G4b)tTZcaI*?jZcDt T# as last into CZ8( SourceExpression ZcDX|V+I* TargetExpression ZcDns;z Sz# g{`vZcw* TargetExpression ZcDns;zSzek,G4a4;7(D 3rek|G,+QekZcD/OaT>* TargetExpression ZcDns;zS z#g{ekrP|,HvVZrPPDtTZc,G4b)tTZcaI*?j ZcDtT# into CZ8( SourceExpression ZcDX|V+I*9C;7(3rD TargetExpression ZcDSz# SourceExpression Zc+w* TargetExpression ZcDSzek=;7(D;CP# g{ekrP|,HvVZrPPDtTZc,G4b)tTZcaI*?jZc DtT# TargetExpression "G|Bmo=D XQuery mo=#g{mo=|,%6:EKc{,G4XkC 2(E+mo=(p4#y]Z TargetExpression .08(DX|V,BPfrJ C: 108 XQuery N< v g{8( before r after,G4 TargetExpression Da{Xk*8tT;*U D*X"D>"&m8nr"MZc#g{ TargetExpression ZcD8zGD5 Zc"R8( before r after,G4ekrP;\|,tTZc# v g{8( into"as first into r as last into,G4 TargetExpression Da {Xk*%v*XZcr%vD5Zc# v g{8( into "R TargetExpression *D5Zc,G4ekrP;\|,tT Zc# >} TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# ZTB>}P,d;mo=D copy Sday]P INFO 4( XML D5D1>#e kmo=aZns;v phone *X.sek billto *X0dyPSz: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1004’) modify do insert 4441 Wagner Aurora Ontario N8X 7F8 after $mycust/customerinfo/phone[last()] return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Matt Foreman 1596 Baseline Toronto Ontario M3Z 5H9 905-555-4789 416-555-3376 4441 Wagner Aurora Ontario N8X 7F8 Gopher Runner 416-555-3426 TB>}+5* x2334 DtT extension ek=d`MtT* work D phone *X P: xquery let $phoneext := attribute extension { "x2334" } return transform Z 4 B mo= 109 copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1004’) modify do insert $phoneext into $mycust/*:customerinfo/*:phone[@type="work"] return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Matt Foreman 1596 Baseline Toronto Ontario M3Z 5H9 905-555-4789 416-555-3376 Gopher Runner 416-555-3426 X|{mo= X|{mo=a+}]#MZcD{FtTf;*BD QName# o( do rename TargetExpression as NewNameExpression do rename X|{mo=Dp} TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# ZTB>}P,d;mo=D copy Sday]P INFO 4( XML D5D1>#X |{mo=a+ addr *XD{FtT|D* shipto: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1000’) modify do rename $mycust/customerinfo/addr as "shipto" return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Kathy Smith 5 Rosewood Toronto Ontario M6W 1E6 416-555-1358 ZTB>}P,d;mo=D modify Sd|, FLWOR mo=MX|{mo=,s_ a+*X phone DyP5}D{FtT|D* phonenumber: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1003’) modify for $phone in $mycust/customerinfo/phone return do rename $phone as "phonenumber" return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Robert Shoemaker 1596 Baseline Aurora Ontario N8X 7F8 905-555-7258 416-555-2937 905-555-8743 613-555-3278 ZTB>}P,X|{mo=a+ addr *XtTD{FS country |D* geogra- phy: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1000’) modify do rename $mycust/customerinfo/addr/@country as "geography" return $mycust Z 4 B mo= 111 T SAMPLE }]bKP1,Cmo=+5XTBa{: Kathy Smith 5 Rosewood Toronto Ontario M6W 1E6 416-555-1358 TB>}9CX|{mo=M fn:QName /},T+{FUd0: other mSAM' G$wg0Ek*XMtTD{F#0: other +s(A URI http:// otherphone.com: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1004’) modify for $elem in $mycust/customerinfo/phone[@type != "work"] let $elemLocalName := fn:local-name($elem) let $newElemQName := fn:QName("http://otherphone.com", fn:concat("other:", $elemLocalName)) return ( do rename $elem as $newElemQName, for $a in $elem/@* let $attrlocalname := fn:local-name($a) let $newAttrName := fn:QName("http://otherphone.com", fn:concat("other:", $attrlocalname)) return do rename $a as $newAttrName ) return $mycust T SAMPLE }]bKP1,Cmo=+5XTBa{: Matt Foreman 1596 Baseline Toronto Ontario M3Z 5H9 905-555-4789 416-555-3376 Gopher Runner 416-555-3426 g{Zd;mo=D return SdP9CTBmo=,G49C1!*X{FUdD phone *XZcaT>* primary ZcDSZc,x other:phone *XZcaT>* secondary ZcDSZc# { $mycust//phone } { $mycust//other:phone } 112 XQuery N< T SAMPLE }]bKP1,d;mo=+5XTBa{: 905-555-4789 416-555-3426 416-555-3376 f;mo= f;mo=a+VPZcf;*|,cvrcvTOZcDBrP,rZ#tZcj 6D,1f;Zc5# o( do replace TargetExpression with SourceExpression value of do replace f;mo=DpZc9l/ }DZ]mo=&m#SourceExpression Da{G%vD>ZcrUrP# g{48( value of X|V,G4 SourceExpression Da{XkGZcrP# SourceExpression Zs51aw*(Z*X9l/}PDmo=&m#g{ SourceExpression rP|,D5Zc,G4D5Zcaf;*dSz# SourceExpression rPXkIBPZc`MiI: v g{ TargetExpression ZcGtTZc,G4f;rPXkIcvrcvTOt TZciI# v g{ TargetExpression ZcG*X"D>""Mr&m8nZc,G4f;rP XkIcvrcvTO*X"D>""Mr&m8nZcD3)iOiI# BP|BGZ8( value of X|VszID: Z 4 B mo= 113 v g{ TargetExpression ZcG*XZc,G4 TargetExpression ZcDVPSz+f ;* SourceExpression 5XDD>Zc#g{ SourceExpression 5XUrP,G4 TargetExpression ZcDSztT+*U#g{ TargetExpression Zc|,tTZc, G4|G;\0l# v g{ TargetExpression Zc"G*XZc,G4 TargetExpression ZcDV{.5+ f;* SourceExpression 5XDD>ZcDV{.5#g{ SourceExpression 45X D>Zc,G4 TargetExpression ZcDV{.5+f;*c$HV{.# BP|BGZ48( value of X|VDivBzID: v SourceExpression Zcaf; TargetExpression Zc#TargetExpression ZcD8Zc aI*?v SourceExpression ZcD8z#SourceExpression Zc<]KZccNa 9P-4I TargetExpression Zc<]D;C# v TargetExpression Zc0dyPtTMsz+kZcrPVk# >} TB>}9C DB2 SAMPLE }]bPD CUSTOMER m#Z CUSTOMER mP,XML P INFO |,M'X7Mg0E"# ZTB>}P,d;mo=D copy Sday]P INFO 4( XML D5D1>#f ;mo=+f; addr *X0dSz: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1000’) modify do replace $mycust/customerinfo/addr with 1596 14th Avenue NW Calgary Alberta T2N 1M7 return $mycust T SAMPLE }]bKP1,Cmo=+9Cf;sDX7E"5XTBa{: Kathy Smith 1596 14th Avenue NW Calgary Alberta T2N 1M7 416-555-1358 TBmo=a+M'g0*X type tTD5 home f;* personal: xquery transform copy $mycust := db2-fn:sqlquery(’select info from customer where cid = 1004’) modify do replace value of $mycust/customerinfo/phone[@type="home"]/@type with "personal" return $mycust T SAMPLE }]bKP1,Cmo=+9Cf;sDtT55XTBa{: 114 XQuery N< Matt Foreman 1596 Baseline Toronto Ontario M3Z 5H9 905-555-4789 416-555-3376 Gopher Runner 416-555-3426 zmDg0tTD5P4|D# Z 4 B mo= 115 116 XQuery N< Z 5 B ZC/} DB2 XQuery a)CZ&m XML }]DZC/}b#b)ZC/}|( XQuery ( eD/}M DB2 ZC/}# XQuery (eD/} XQuery (eD/}Zs(A0: fn D{FUdP#K{FUdG1!/}{ FUd,bb6EIZ48({FUd0:DivBwC XQuery (eD/}# g{9Ci/rTPD1!/}{FUdyw2GK1!/}{FUd,G4 Xk9C0: fn 4wC XQuery (eD/}# DB2 (eD/} DB2 (eD/}|( db2-fn:xmlcolumn M db2-fn:sqlquery,I9C|GCJ DB2 }]bPD XML 5#0: db2-fn "G1!/}{FUd,yTZwC b)/}1Xk9C{FUd0:,}G9Ci/rTPD1!/}{FUd yw2G1!{FUd# 4`p.VD DB2 XQuery /} DB2 XQuery /}DBP`pIC:V{."<{5"}V"UZM1d"rP" QName"Zc0d{# V{./} /} hv Z 130 3D:codepoints-to-string /}; fn:codepoints-to-string /}5X Unicode zkc rPDH[V{.# Z 130 3D:compare /}; fn:compare /}HO=vV{.# Z 131 3D:concat /}; fn:concat /}5X=vr|`-S5"CDV {.# Z 131 3D:contains /}; fn:contains /}7(V{.Gq|,X(S.# 9C1!{m4%dQwV{.# Z 141 3D:ends-with /}; fn:ends-with /}7(V{.GqTX(S.a x#9C1!{m4%dQwV{.# Z 150 3D:lower-case /}; fn:lower-case /}+V{.*;*!4# Z 151 3D:matches /}; fn:matches /}7(V{.GqkX(#=`% d# Z 161 3D:normalize-space /}; fn:normalize-space /}}%V{.PD0# Z 178 3D:string-join /}; fn:string-join /}5X(}"Cwn"CVt{ xPVtxzIDV{.# Z 179 3D:string-length /}; fn:string-length /}5XV{.D$H# Z 179 3D:string-to-codepoints /}; fn:string-to-codepoints /}5XT&ZV{.5 D Unicode zkcrP# Z 180 3D:substring /}; fn:substring /}5XV{.DS.# Z 181 3D:substring-after /}; fn:substring-after /}5XV{.P;ZZ;N vVDX(QwV{.sfDS.#9C1! {m4%dQwV{.# Z 182 3D:substring-before /}; fn:substring-before /}5XV{.P;ZZ;N vVDX(QwV{.0fDS.#9C1! {m4%dQwV{.# Z 185 3D:tokenize /}; fn:tokenize /}+V{.V*;5PS.# Z 187 3D:translate /}; fn:translate /}+V{.PDy!V{f;*f ;V{# Z 189 3D:upper-case /}; fn:upper-case /}+V{.*;*s4# <{5/} /} hv Z 128 3D:boolean /}; fn:boolean /}5XrPDP'<{5# Z 143 3D:false /}; fn:false /}5X xs:boolean 5 false# Z 163 3D:not /}; g{rPDP'<{5* true,G4 fn:not / }5X false,g{rPDP'<{5* false, G4C/}5X true# Z 188 3D:true /}; fn:true /}5X xs:boolean 5 true# }V/} /} hv Z 126 3D:abs /}; fn:abs /}5X}V5DxT5# Z 127 3D:avg /}; fn:avg /}5XrPPD=y5# Z 129 3D:ceiling /}; fn:ceiling /}5XsZrHZX(}V5Dn !{}# Z 143 3D:floor /}; fn:floor /}5X!ZrHZX(}V5Dns {}# Z 152 3D:max /}; fn:max /}5XrPPDns5# Z 153 3D:min /}; fn:min /}5XrPPDn!5# Z 163 3D:number /}; fn:number /}+5*;* xs:double }]` M# Z 170 3D:round /}; fn:round /}5XnS|X(}V5D{}# 118 XQuery N< /} hv Z 171 3D:round-half-to-even /}; fn:round-half-to-even /}5XnS|X(}V5 "_P8(+HD}V5# Z 183 3D:sum /}; fn:sum /}5XrPPD5D\M# UZ"1dMVx1d/} /} hv Z 122 3D:adjust-date-to-timezone /}; fn:adjust-date-to-timezone /}w{X(1xD xs:date 5r}%C5D1x?V# Z 123 3D:adjust-dateTime-to-timezone /}; fn:adjust-dateTime-to-timezone /}w{X(1x D xs:dateTime 5r}%C5D1x?V# Z 125 3D:adjust-time-to-timezone /}; fn:adjust-time-to-timezone /}w{X(1xD xs:time 5r}%C5D1x?V# Z 132 3D:current-date /}; fn:current-date /}5X UTC D~=1xD1 0UZ# Z 133 3D:current-dateTime /}; fn:current-dateTime /}5X UTC D~=1x D10UZM1d# Z 133 3D:current-local-date /}; db2-fn:current-local-date /}5X>X1xD1 0UZ# Z 134 3D:current-local-dateTime /}; db2-fn:current-local-dateTime /}5X>X1x D10UZM1d# Z 134 3D:current-local-time /}; db2-fn:current-local-time /}5X>X1xD1 01d# Z 134 3D:current-time /}; fn:current-time /}5X UTC D~=1xD1 01d# Z 135 3D:dateTime /}; fn:dateTime /}y] xs:date 5M xs:time 5 9l xs:dateTime 5# Z 136 3D:day-from-date /}; fn:day-from-date /}5X xs:date 5DUZ? V# Z 136 3D:day-from-dateTime /}; fn:day-from-dateTime /}5X xs:dateTime 5 DUZ?V# Z 137 3D:days-from-duration /}; fn:days-from-duration /}5XVxUZDl} ?V# Z 144 3D:hours-from-dateTime /}; fn:hours-from-dateTime /}5X xs:dateTime 5 D!1}?V# Z 144 3D:hours-from-duration /}; fn:hours-from-duration /}5XVx1d5D! 1}?V# Z 145 3D:hours-from-time /}; fn:hours-from-time /}5X xs:time 5D!1} ?V# Z 146 3D:implicit-timezone /}; fn:implicit-timezone /}5X~=1x5 PT0S, C5D`M* xs:dayTimeDuration#5 PT0S 8 > UTC *~=1x# Z 149 3D:local-timezone /}; db2-fn:local-timezone /}5X>X53D1x# Z 154 3D:minutes-from-dateTime /}; fn:minutes-from-dateTime /}5X xs:dateTime 5DVS}?V# Z 5 B ZC/} 119 /} hv Z 155 3D:minutes-from-duration /}; fn:minutes-from-duration /}5XVx1dDV S}?V# Z 156 3D:minutes-from-time /}; fn:minutes-from-time /}5X xs:time 5DVS }?V# Z 156 3D:month-from-date /}; fn:month-from-date /}5X xs:date 5DB] ?V# Z 157 3D:month-from-dateTime /}; fn:month-from-dateTime /}5X xs:dateTime 5 DB]?V# Z 157 3D:months-from-duration /}; fn:months-from-duration /}5XVx1d5D B}?V# Z 172 3D:seconds-from-dateTime /}; fn:seconds-from-dateTime /}5X xs:dateTime 5Dk}?V# Z 173 3D:seconds-from-duration /}; fn:seconds-from-duration /}5XVx1dDk }?V# Z 174 3D:seconds-from-time /}; fn:seconds-from-time /}5X xs:time 5Dk} ?V# Z 184 3D:timezone-from-date /}; fn:timezone-from-date /}5X xs:date 5D1 x?V# Z 184 3D:timezone-from-dateTime /}; fn:timezone-from-dateTime /}5X xs:dateTime 5D1x?V# Z 185 3D:timezone-from-time /}; fn:timezone-from-time /}5X xs:time 5D1 x?V# Z 191 3D:year-from-date /}; fn:year-from-date /}5X xs:date 5Dj]? V# Z 191 3D:year-from-dateTime /}; fn:year-from-dateTime /}5X xs:dateTime 5 Dj]?V# Z 192 3D:years-from-duration /}; fn:years-from-duration /}5XVx1dDj} ?V# rP/} /} hv Z 132 3D:count /}; fn:count /}5XrPPDtI5# Z 135 3D:data /}; fn:data /}Z+dkrPPDNNZcf;* d`M5s5XdkrP# Z 137 3D:deep-equal /}; fn:deep-equal /}HO=vrPT7(|GGq {OnH`HD*s# Z 139 3D:distinct-values /}; fn:distinct-values /}5XrPPD`l5# Z 140 3D:empty /}; fn:empty /}8>Td?Gq*UrP# Z 141 3D:exactly-one /}; g{Td?}C|,;n,fn:exactly-one /}5 XdTd?# Z 142 3D:exists /}; fn:exists /}ITliGqfZm`;,`MD n,}g,*X"tT"D>Zc"2,5 (}g,{})r_ XML D5# Z 148 3D:last /}; fn:last /}5XrPP}Z&mD5D}?# 120 XQuery N< /} hv Z 146 3D:index-of /}; fn:index-of /}5X3nvVZrPPD;C# Z 147 3D:insert-before /}; fn:insert-before /}Z;vrPPDX(;C. 0ekm;rP# Z 164 3D:one-or-more /}; g{Td?|,;nr`n,G4 fn:one-or- more /}5XdTd?# Z 165 3D:position /}; fn:position /}5XrPP}Z&mDOBDn D;C# Z 166 3D:remove /}; fn:remove /}}%rPPD;n# Z 169 3D:reverse /}; fn:reverse /}9rPPDnEr4r# Z 180 3D:subsequence /}; fn:subsequence /}5XrPDSrP# Z 188 3D:unordered /}; fn:unordered /}T;7(D3r5XrPPD n# Z 193 3D:zero-or-one /}; g{Td?|,;nr*UrP,G4 fn:zero- or-one /}5XTd?# QName /} /} hv Z 146 3D:in-scope-prefixes /}; fn:in-scope-prefixes /}5X*XDyP{FU dwCrD0:Pm# Z 149 3D:local-name-from-QName /}; fn:local-name-from-QName /}5X xs:QName 5DV?# Z 160 3D:namespace-uri-for-prefix /}; fn:namespace-uri-for-prefix /}5Xk*X{F UdwCrPD0:`X*D{FUd URI# Z 160 3D:namespace-uri-from-QName /}; fn:namespace-uri-from-QName /}5X xs:QName 5D{FUd URI ?V# Z 165 3D:QName /}; fn:QName /}y]{FUd URI M|,Jc QName(xPI!0:)DV{.9()9 {# Z 168 3D:resolve-QName /}; (}9C*XD{FUdwCr+{FUd0 :bv*{FUd URI,fn:resolve-QName /} +|,Jc QName DV{.*;*)9 QName# Zc/} /} hv Z 148 3D:local-name /}; fn:local-name /}5XZcDV?{tT# Z 158 3D:name /}; fn:name /}5XZc{D0:MV?{?V# Z 159 3D:namespace-uri /}; fn:namespace-uri /}5XZcD^({FD{ FUd URI# Z 161 3D:node-name /}; fn:node-name /}5XZcD)9 QName# Z 169 3D:root /}; fn:root /}5XZcytDwDyZc# Z 5 B ZC/} 121 d{/} /} hv Z 139 3D:default-collation /}; fn:default-collation /}5Xm>m>*}]b( eD1!{mD URI# Z 174 3D:sqlquery /}; db2-fn:sqlquery /}Z10`, DB2 }]bP lw SQL +i/zIDrP# Z 190 3D:xmlcolumn /}; db2-fn:xmlcolumn /}Z10`, DB2 }]b Plw3PPDrP# adjust-date-to-timezone /} fn:adjust-date-to-timezone /}w{X(1xD xs:date 5r}%C5D1x?V# o( fn:adjust-date-to-timezone(date-value ) ,timezone-value date-value *w{DUZ5# date-value D`M* xs:date,r_*UrP# timezone-value m> date-value *w{AD1xDVx1d# timezone-value ITGUrPr`M* xdt:dayTimeDuration D%5,6'Z -PT14H = PT14H .d(|,=_)#C5ITG{}VS5,"R;\Pk }?V#g{48( timezone-value,G41!5* PT0H,m> UTC# 5XD5 5XD5G`M* xs:date D5,r_GUrP,b!vZ8(DN}#g{ date- value ;GUrP,G45XD5`M* xs:date#BmhvI\D5X5: m 33. fn:adjust-date-to-timezone Ddk5M5X5D`M date-value timezone-value 5XD5 date-value,|,1x?V T=5,r_48(NN5 (Vx1d* PT0H) kT timezone-value m>D1x w{ date-value# date-value,|,1x?V UrP date-value with no timezone component. date-value,;|,1x?V T=5,r_48(NN5 (Vx1d* PT0H) date-value,xP1x?V#1 x?VGI timezone-value m> D1x#4kTC1xw{U Z?V# date-value,;|,1x?V UrP date-value# UrP T=5"UrPr48(NN 5 UrP# 122 XQuery N< + date-value w{*m;1x1,date-value ;S*1d?V* 00:00:00 D dateTime 5#5XD5|, timezone-value m>D1x?V#TB/}Fcw{D10UZ5: xs:date(fn:adjust-dateTime-to-timezone(xs:dateTime(date-value),timezone-value)) >} ZBP>}P,d? $tz *Vx1d -10 !1,(e* xdt:dayTimeDuration("- PT10H")# TB/}w{UZ5 2002 j 5 B 7 U(UTC+1 1x)#C/}8( timezone-value -PT10H# fn:adjust-date-to-timezone(xs:date("2002-05-07+01:00"), $tz) 5XDUZ5* 2002-05-06-10:00#UZw{* UTC-10 1x# TB/}+1x?VmSAUZ5 2002 j 3 B 7 U(;x1x?V)#C/}8( timezone-value -PT10H# fn:adjust-date-to-timezone(xs:date("2002-03-07"), $tz) 5XD5* 2002-03-07-10:00#+TUZ5mS1x?V# TB/}w{UZ5 2002 j 2 B 9 U(UTC-7 1x)#48( timezone-value 1, /}9C1!1x timezone-value PT0H# fn:adjust-date-to-timezone(xs:date("2002-02-09-07:00")) 5XDUZ* 2002-02-09Z,UZw{* UTC# TB/}}%UZ5 2002 j 5 B 7 U(UTC-7 1x)D1x?V#timezone-value G UrP# fn:adjust-date-to-timezone(xs:date("2002-05-07-07:00"), ()) 5XD5G 2002-05-07# adjust-dateTime-to-timezone /} fn:adjust-dateTime-to-timezone /}w{X(1xD xs:dateTime 5r}%C5D1x? V# o( fn:adjust-dateTime-to-timezone(dateTime-value ) ,timezone-value dateTime-value *w{D dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# timezone-value m> dateTime-value *w{AD1xDVx1d# Z 5 B ZC/} 123 timezone-value ITGUrPr`M* xdt:dayTimeDuration D%5,6'Z -PT14H = PT14H .d(|,=_)#C5ITG{}VS5,"R;\Pk }?V#g{48( timezone-value,G41!5* PT0H,m> UTC# 5XD5 5XD5G`M* xs:dateTime D5,r_GUrP,b!vZdk5D`M#g{ dateTime-value ;GUrP,G45XD5`M* xs:dateTime#BmhvI\D5X5: m 34. fn:adjust-dateTime-to-timezone Ddk5M5X5D`M dateTime-value timezone-value 5XD5 dateTime-value,|,1x?V T=5,r_48(NN5 (Vx1d* PT0H) dateTime-value w{* timezone- value m>D1x#5XD5| , timezone-value m>D1x? V# dateTime-value,|,1x?V UrP dateTime-value,;P1x? V# dateTime-value,;|,1x? V# T=5,r_48(NN5 (Vx1d* PT0H) dateTime-value,xP1x? V#1x?VGI timezone- value m>D1x#UZM1x ?V4w{*C1x# dateTime-value,;|,1x? V# UrP dateTime-value# UrP T=5"UrPr48(NN 5 UrP# >} ZBP>}P,d? $tz *Vx1d -10 !1,(e* xdt:dayTimeDuration("- PT10H")# TB/}+ dateTime 2007 j 3 B 7 UOg 10 c(UTC-7 1x)w{* timezone- value -PT10H 8(D1x# fn:adjust-dateTime-to-timezone(xs:dateTime("2002-03-07T10:00:00-07:00"), $tz) 5XD dateTime * 2002-03-07T07:00:00-10:00# TB/}w{ dateTime 5 2002 j 3 B 7 UOg 10 c#dateTime-value ;P1x ?V,x/}8( timezone-value -PT10H# fn:adjust-dateTime-to-timezone(xs:dateTime("2002-03-07T10:00:00"), $tz) 5XD dateTime * 2002-03-07T10:00:00-10:00# TB/}w{ dateTime 5 2006 j 6 B 4 UOg 10 c(UTC-7 1x)#48( timezone-value 1,/}9C1!1x PT0H# fn:adjust-dateTime-to-timezone(xs:dateTime("2006-06-04T10:00:00-07:00")) 5XD dateTime * 2006-06-04T17:00:00Z,dateTime w{* UTC# 124 XQuery N< TB/}}% dateTime 5 2002 j 3 B 7 UOg 10 c(UTC-7 1x)D1x?V# timezone-value 5*UrP# fn:adjust-dateTime-to-timezone(xs:dateTime("2002-03-07T10:00:00-07:00"), ()) 5XD dateTime * 2002-03-07T10:00:00# adjust-time-to-timezone /} fn:adjust-time-to-timezone /}w{X(1xD xs:time 5r}%C5D1x?V# o( fn:adjust-time-to-timezone(time-value ) ,timezone-value time-value *w{D1d5# time-value D`M* xs:time,r_GUrP# timezone-value m> time-value *w{AD1xDVx1d# timezone-value ITGUrPr`M* xdt:dayTimeDuration D%5,6'Z -PT14H = PT14H .d(|,=_)#C5ITG{}VS5,"R;\Pk }?V#g{48( timezone-value,G41!5* PT0H,m> UTC# 5XD5 5XD5G`M* xs:time D5,r_GUrP,b!vZ8(DN}#g{ time- value ;GUrP,G45XD5`M* xs:time#BmhvI\D5X5: m 35. fn:adjust-time-to-timezone Ddk5M5X5D`M date-value timezone-value 5XD5 time-value,|,1x?V T=5,r_48(NN5 (Vx1d* PT0H) kT timezone-value m>D1x w{ time-value#5XD5|, timezone-value m>D1x? V#g{1xw{1g}g 9,G4UZ|Da;vT# time-value,|,1x?V UrP time-value,;P1x?V# time-value,;|,1x?V T=5,r_48(NN5 (Vx1d* PT0H) time-value,xP1x?V#1 x?VGI timezone-value m> D1x#4kTC1xw{1 d?V# time-value,;|,1x?V UrP time-value# UrP T=5"UrPr48(NN 5 UrP# Z 5 B ZC/} 125 >} ZBP>}P,d? $tz *Vx1d -10 !1,(e* xdt:dayTimeDuration("- PT10H")# TB/}+1d5Og 10:00(UTC-7 1x),"R/}8( timezone-value -PT10H# fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"), $tz) 5XD5* 7:00:00-10:00#1dw{*Vx1d -PT10H m>D1x# TB/}w{1d5Bg 1:00#1d5;P1x?V# fn:adjust-time-to-timezone(xs:time("13:00:00"), $tz) 5XD5* 13:00:00-10:00#1d|,Vx1d -PT10H m>D1x?V# TB/}w{1d5Bg 10:00(UTC-7 1x)#C/}48( timezone-value "9C 1!5 PT0H# fn:adjust-time-to-timezone(xs:time("10:00:00-07:00")) 5XD5* 17:00:00Z,1dw{* UTC# TB/}}%1d5Og 8:00(UTC-7 1x)D1x?V#timezone-value *UrP# fn:adjust-time-to-timezone(xs:time("08:00:00-07:00"), ()) 5XD5* 8:00:00# TB>}HO=v1d#g{1xw{1g}g9,G4aDN;`MIzD`M v xdt:untypedAtomic 126 XQuery N< g{ numeric-value D}]`M* xdt:untypedAtomic,G4|a*;* xs:double 5# 5XD5 g{ numeric-value "GUrP,G45XD5G numeric-value DxT5# g{ numeric-value GUrP,G4 fn:abs a5XUrP# 5X5D}]`M!vZ numeric-value D}]`M: v g{ numeric-value D}]`M* xs:float"xs:double"xs:decimal r xs:integer,G4 5XD5D`Mk numeric-value `,# v g{ numeric-value D}]`MIzT xs:float"xs:double"xs:decimal r xs:integer, G45X5D}]`M* numeric-value D8z}]`M# v g{ numeric-value D}]`M* xdt:untypedAtomic,G45X5D}]`M* xs:double# >} TB/}5X -10.5 DxT5# fn:abs(-10.5) 5XD5* 10.5# avg /} fn:avg /}5XrPPD=y5# o( fn:avg(sequence-expression) sequence-expression |,BPN;-S`MDnrPrUrP: v xs:float v xs:double v xs:decimal v xs:integer v xdt:untypedAtomic v xdt:dayTimeDuration v xdt:yearMonthDuration v SOfP>DN;`MIzD`M `M* xdt:untypedAtomic Ddkn+*;* xs:double#KN?F`M*;s, dkrPPDyPnXkI(}a}rS`Mf;Sx*;*+2`M#=y 5G9CK+2`MFcD#}g,g{dkrP|,`M* money(IzT xs:decimal)M stockprice(IzT xs:float)Dn,G4=y5+9C`M xs:float xPFc# Z 5 B ZC/} 127 5XD5 g{ sequence-expression "GUrP,G45XD5G sequence-expression Pw5D= y5#5X5D}]`Mk sequence-expression PwnD}]`M`,,r_G sequence-expression Pwna}AD}]`M# g{ sequence-expression GUrP,G45XUrP# >} TB/}5XrP (5, 1.0E2, 40.5) D=y5: fn:avg((5, 1.0E2, 40.5)) b)5+a}A xs:double }]`M#C/}+5X xs:double 5 4.85E1,|+TrP /==m>*“48.5”# boolean /} fn:boolean /}5XrPDP'<{5# o( fn:boolean(sequence-expression) sequence-expression |,NN`MDnDNNrPrUrP# 5XD5 5XDP'<{5(EBV)!vZ sequence-expression D5: m 36. T XQuery PDX(5`M5XD EBV 5Dhv 5XD EBV UrP false Z;n*ZcDrP true `M* xs:boolean rIzT xs:boolean D%v 5 false - g{ xs:boolean 5* false true - g{ xs:boolean 5* true `M* xs:string r xdt:untypedAtomic rIzT dP;V`MD%v5 false - g{5$H*c true - g{5$HsZc Nb}V`MrIzT}V`MD%v5 false - g{5* NaN r_d}5HZc true - g{C5D}5;HZc yPd{5 ms ":TZ|,AY;vZcMAY;v-S5DrP,dP'<{5Z3r;I$bDi/PG ;7(D# >} Td?*%v}5D>}:TB/}5X 0 DP'<{5: fn:boolean(0) 128 XQuery N< 5XD5* false# Td?*|,`nDrPD>}:TB/}5X (
, 0, ) DP'<{5: fn:boolean((, 0, )) 5XD5* true# ceiling /} fn:ceiling /}5XsZrHZX(}V5Dn!{}# o( fn:ceiling(numeric-value) numeric-value -S5rUrP# g{ numeric-value G-S5,G4|_PBPdP;V`M: v xs:float v xs:double v xs:decimal v xs:integer v xdt:untypedAtomic v SOfP>DN;`MIzD`M g{ numeric-value D}]`M* xdt:untypedAtomic,G4|a*;* xs:double 5# 5XD5 g{ numeric-value "GUrP,G45XD5GsZrHZ numeric-value Dn!{}# 5X5D}]`M!vZ numeric-value D}]`M: v g{ numeric-value D}]`M* xs:float"xs:double"xs:decimal r xs:integer,G4 5XD5D`Mk numeric-value `,# v g{ numeric-value D}]`MIzT xs:float"xs:double"xs:decimal r xs:integer, G45X5D}]`M* numeric-value D8z}]`M# g{ numeric-value GUrP,G45XD5GUrP# >} 9C}Td?D>}:TB/}5X 0.5 DrO!{5: fn:ceiling(0.5) 5XD5* 1# 9C:Td?D>}:TB/}5X (-1.2) DrO!{5: fn:ceiling(-1.2) 5XD5* -1# Z 5 B ZC/} 129 codepoints-to-string /} fn:codepoints-to-string /}5X Unicode zkcrPDH[V{.# o( fn:codepoints-to-string(codepoint-sequence) codepoint-sequence T&Z Unicode zkcD{}rPrUrP# 5XD5 g{ codepoint-sequence "GUrP,G45XD5G;vV{.,I codepoint- sequence PwnDV{H[n"CxI#g{ codepoint-sequence PDNNn"GP' Unicode zkc,G4a5Xms# g{ codepoint-sequence GUrP,G45XD5*c$HV{.# >} TB/}5X UTF-8 zkcrP (88,81,117,101,114,121) DV{H[n# fn:codepoints-to-string((88,81,117,101,114,121)) 5XD5*“XQuery”# compare /} fn:compare /}HO=vV{.# o( fn:compare(string-1,string-2) string-1 , string-2 *HOD xs:string 5# 5XD5 g{ string-1 M string-2 "GUrP,G4a5XBPdP;v5: -1 u~G string-1 !Z string-2# 0 u~G string-1 HZ string-2# 1 u~G string-1 sZ string-2# g{string-1 k string-2 D$H`H(|(c$H),"RyPT&V{`H(y]1 !{m),G4=_`H# g{ string-1 k string-2 ;`H,G4|GDX5(4,-D5O_)G(}SV{. sKHOZ;T;`HDV{47(D#KHOGy]1!{mxPD# 130 XQuery N< g{ string-1 H string-2 $,"R string-2 DyPV{HZ string-1 D0} TB/}9C1!{mHO“ABC”k“ABD”# fn:compare(’ABC’, ’ABD’) “ABC”!Z“ABD”#5XD5* -1# concat /} fn:concat /}5X=vr|`-S5"CDV{.# o( fn:concat(atomic-value,atomic-value ) , , atomic-value atomic-value -S5rUrP#g{Td?*UrP,G4CTd?a;S*c$HV{ .#g{ atomic-value "G xs:string 5,G4|aZ"C.0*;* xs:string# 5XD5 g{yP atomic-value Td?} TB/}a+V{.“ABC”"“ABD”"UrPM“ABE”"C# fn:concat(’ABC’, ’ABD’, (), ’ABE’) 5XD5*“ABCABDABE”# contains /} fn:contains /}7(V{.Gq|,X(S.#9C1!{m4%dQwV{.# o( fn:contains(string,substring) string CZQw substring DV{.# string D}]`M* xs:string,r_GUrP#g{ string GUrP,G4 string hC*c$HV{.# Z 5 B ZC/} 131 substring *Z string PQwDS.# substring D}]`M* xs:string,r_GUrP# TZ$HD^F substring D$H;\,} 32000 vVZ# 5XD5 g{zcBPN;u~,G45XD5* xs:boolean 5 true: v substring vVZ string PDNN;C# v substring GUrPrc$HV{.# qr,5XD5* false# >} TB/}7(V{.“Test literal”Gq|,V{.“lite”# fn:contains(’Test literal’,’lite’) 5XD5* true# count /} fn:count /}5XrPPDtI5# o( fn:count(sequence-expression) sequence-expression |,NN`MDnDrPrUrP# 5XD5 g{ sequence-expression "GUrP,G45X sequence-expression P|,D5D}?# g{ sequence-expression GUrP,G45X 0# >} TB/}5XrP (5, 1.0E2, 40.5) P|,Dn}: fn:count((5, 1.0E2, 40.5)) 5XD5* 3# current-date /} fn:current-date /}5X UTC D~=1xD10UZ# 132 XQuery N< o( fn:current-date() 5XD5 5XD5*10UZD xs:date 5# >} TB/}5X10UZ# fn:current-date() g{Z 2005 j 12 B 2 UwCK/},G45XD5* 2005-12-02Z# current-dateTime /} fn:current-dateTime /}5X UTC D~=1xD10UZM1d# o( fn:current-dateTime() 5XD5 5XD5*10UZM1dD xs:dateTime 5# >} TB/}5X10UZM1d# fn:current-dateTime() g{Z`W`(1x* -PT5H)Z 2005 j 12 B 2 U 6:25 wCK/},G45X D5* 2005-12-02T011:25:30.864001Z# current-local-date /} db2-fn:current-local-date /}5X>X1xD10UZ# o( db2-fn:current-local-date() 5XD5 5XD5*10UZD xs:date 5#5XD5;|(1x?V# }g,g{ZqV~Nj<1d(GMT)2009 j 12 B 2 U 3:00 wCK/},R> X1xG+?j<1d(-PT5H),G45XD5* 2009-12-01# Z 5 B ZC/} 133 current-local-dateTime /} db2-fn:current-local-dateTime /}5X>X1xD10UZM1d# o( db2-fn:current-local-dateTime() 5XD5 5XD5*10UZM1dD xs:dateTime 5#5XD5;|(1x?V# }g,g{Z`W`(1x* -PT5H)Z 2009 j 12 B 2 U 6:25 wCK/},G 45XD5>}* 2009-12-02T06:25:30.864001# current-local-time /} db2-fn:current-local-time /}5X>X1xD101d# o( db2-fn:current-local-time() 5XD5 5XD5*101dD an xs:time 5#5XD5;|(1x?V# }g,g{ZqV~Nj<1d(GMT)6:31 wCK/},R>X1xG+?j<1d (-PT5H),G4>}5XD5* 01:31:35.519001# current-time /} fn:current-time /}5X UTC D~=1xD101d# o( fn:current-time() 5XD5 5XD5*101dD an xs:time 5# >} TB/}5X101d# fn:current-time() g{Z+rj<1d 6:31 wCK/},G45XD5+* 06:31:35.519001Z# 134 XQuery N< data /} fn:data /}Z+dkrPPDNNZcf;*d`M5s5XdkrP# o( fn:data(sequence-expression) sequence-expression NNrP,|(UrP# 5XD5 g{ sequence-expression GUrP,G45XD5GUrP# g{ sequence-expression G%v-S5,G45XD5* sequence-expression# g{ sequence-expression G%vZc,G45XD5* sequence-expression D`M5# g{ sequence-expression G|,`nDrP,G4ay] sequence-expression PDwn 5X-S5rP#sequence-expression PD?v-S5#V;d#sequence-expression P D?vZc;f;*d`M5,4|,cvrcvTO-S5DrP# >} TB/}5X|,rP (ABC,1.23) PD-S5DrP# fn:data((ABC,1.23)) 5XD5* (″ABC″,1.23)# dateTime /} fn:dateTime /}y] xs:date 5M xs:time 59l xs:dateTime 5# o( fn:dateTime(date-value,time-value) date-value xs:date 5# time-value xs:time 5# 5XD5 5XD5G;v xs:dateTime 5,dUZ?VHZ date-value,1d?VHZ time- value#a{D1xG4gB==FcD: v g{=vTd?<;P1x,G4a{2;P1x# v g{;P;vTd?P1x,r_=vTd?1x`,,G4a{9CK1x# v g{=vTd?D1x;,,G4a5Xms# Z 5 B ZC/} 135 >} TB/}y] xs:date 5M xs:time 55X xs:dateTime 5# fn:dateTime((xs:date("2005-04-16")), (xs:time("12:30:59"))) 5XD5* xs:dateTime 5 2005-04-16T12:30:59# day-from-date /} fn:day-from-date /}5X xs:date 5DUZ?V# o( fn:day-from-date(date-value) date-value *SPi!UZ?VDUZ5# date-value D`M* xs:date,r_*UrP# 5XD5 g{ date-value D`M* xs:date,G45XD5`M* xs:integer,"RC5Z 1 = 31 .d(|,=_)#C5G date-value DUZ?V# g{ date-value GUrP,G45XD5GUrP# >} TB/}5XUZ5 2005 j 1 B 1 UDUZ?V# fn:day-from-date(xs:date("2005-06-01")) 5XD5* 1# day-from-dateTime /} fn:day-from-dateTime /}5X xs:dateTime 5DUZ?V# o( fn:day-from-dateTime(dateTime-value) dateTime-value *SPi!UZ?VD dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# 5XD5 g{ dateTime-value D`M* xs:dateTime,G45XD5`M* xs:integer,"RC5 Z 1 = 31 .d(|,=_)#C5G dateTime-value DUZ?V# g{ dateTime-value GUrP,G45XD5GUrP# 136 XQuery N< >} TB/}5X dateTime 5 2005 j 1 B 31 UBg 8:00(UTC+4 1x)DUZ?V# fn:day-from-dateTime(xs:dateTime("2005-01-31T20:00:00+04:00")) 5XD5* 31# days-from-duration /} fn:days-from-duration /}5XVxUZDl}?V# o( fn:days-from-duration(duration-value) duration-value *SPi!l}?VDVx1d5# duration-value G U r P , r _ G B P d P ; v ` M D 5 : xdt:dayTimeDuration"xs:duration r xdt:yearMonthDuration# 5XD5 5X5!vZ duration-value D`M: v g{ duration-value D`M* xdt:dayTimeDuration r xs:duration,G45XD5` M* xs:integer,"RG*;* xdt:dayTimeDuration D duration-value Dl}?V# g{ duration-value *:5,G45XD5*:5# v g{ duration-value D`M* xdt:yearMonthDuration,G45XD5* 0# v g{ duration-value GUrP,G45XD5GUrP# *;* xdt:dayTimeDuration D duration-value Dl}?VG(} (S idiv 86400) F cD{}l}5#5 S G*;* xdt:dayTimeDuration D duration-value D\k},C Z}%j}MB}?V# >} K/}5XVx1d* -10 l 0 !1Dl}?V# fn:days-from-duration(xdt:dayTimeDuration("-P10DT00H")) 5XD5* -10# K/}5XVx1d* 3 l 55 !1Dl}?V# fn:days-from-duration(xdt:dayTimeDuration("P3DT55H")) 5XD5* 5#FcVx1dD\l}1,55 !1*;* 2 lV 7 !1#Vx1d HZ P5D7H,dl}?V* 5 l# deep-equal /} fn:deep-equal /}HO=vrPT7(|GGq{OnH`HD*s# Z 5 B ZC/} 137 o( fn:deep-equal(sequence-1,sequence-2) sequence-1, sequence-2 *HODrP#?vrPPDnITGNN`MD-S5rZc# 5XD5 g{ sequence-1 M sequence-2 nH`H,G45XD5* xs:boolean 5 true#qr, 5XD5* false# g{ sequence-1 M sequence-2 GUrP,G4|GDnH`H# g{=vrP<;GUrP,"R,1{OBP=vu~,G4=vrPDnH` H: v sequence-1 PDn}HZ sequence-2 PDn}# v sequence-1 PD?;n(item-1)k sequence-2 PDT&n(item-2){OnH`H Du~#g{ item-1 M item-2 {OBPN;u~,G4|GDnH`H: – item-1 M item-2 M*XSzrPk item-2 DD>M*XSzrPDnH` H# *X Xk{OBPyPu~: v item-1 M item-2 {F`,,bm>|GD{FUd URI MV?{`% d#{FUd0:+;vT#9C~xFHO4jI{F%d# v item-1 M item-2 DtT}?`,,"R item-1 D?vtTk item-2 D 3vtTDnH`H# v BPdP;vu~*f: – =vZc<4-}i$rQ9CJmlOZ](D>MS*X)D `MxPKi$,"R item-1 DD>M*XSzrPk item-2 DD >M*XSzrPnH`H# – =vZc<9Cr%`M(g xs:decimal)r_Pr%Z]D`M (gZ]* xs:decimal D“temperature”`M)xPKi$,"R item-1 D`M5k item-2 D`M5nH`H# – =vZc<9C;JmNNZ](H;JmD>2;JmS*X) D`MxPKi$# – =vZc<9CvJmS*X(;JmD>)D`MxPKi$, "R item-1 D?vS*Xk item-2 DT&S*XnH`H# 138 XQuery N< m 37. rPPDZcnH`H (x) item-1 M item-2 D ZcV` nH`HDu~ tT Xk{OBPyPu~: v item-1 M item-2 {F`,,bm>|GD{FUd URI MV?{`% d#{FUd0:+;vT#9C~xFHO4jI{F%d# v item-1 D`M5k item-2 D`M5nH`H# D> 9C eq Kc{w*V{.xPHO((}1!{m)1,Z]tT5` H# "M9C eq Kc{w*V{.xPHO((}1!{m)1,Z]tT5` H# &m8n Xk{OBPyPu~: v item-1 M item-2 _P`,{F# v 9C eq Kc{w*V{.xPHO((}1!{m)1,Z]tT5 `H# >} TB/}aHOrP (1,’ABC’) M (1,’ABCD’) DnHGq`H#V{.HO9C1! X*# fn:deep-equal((1,’ABC’), (1,’ABCD’)) 5XD5* false# default-collation /} fn:default-collation /}5Xm>m>*}]b(eD1!{mD URI# o( fn:default-collation() 5XD5 5XD5D`M* xs:anyURI,"Ra8(}]b{m# >} DB2 }]bGZ+ CLDR181_LEN 8(*{mDivB4(D#9C fn:default- collation /}i/K}]b1,5XTB5: http://www.ibm.com/xmlns/prod/db2/sql/collations?name=CLDR181_LEN_AN_CX_EX_FX_HX_NX_S3 distinct-values /} fn:distinct-values /}5XrPPD`l5# Z 5 B ZC/} 139 o( fn:distinct-values(sequence-expression) sequence-expression -S5rPrUrP# 5XD5 g{ sequence-expression "GUrP,G45XD5*|, sequence-expression PD; ,5DrP#g{ value1 eq value2 * false(9C1!{m),G4m> value1 M value2 D5;,#g{4T=v5(e eq Kc{,G4b=v5;S*;,# ZT5xPHO.0,`M* xdt:untypedAtomic D5+*;I`M* xs:string D5# TZ xs:float M xs:double 5,g{ sequence-expression |,`v NaN 5,G4a5 X%v NaN 5# TZ xs:dateTime"xs:date r xs:time 5,aZHO.0y]1nw{b)5#g{3 v5;P1x,G4a9C~=1x(UTC)# g{ sequence-expression GUrP,G45XUrP# g{9C eq Kc{xPHOsT>dkrPPD=v5`H+`M;,,G4a{r PPavVdPNb;v5(x;G=v5)#a{rP;a#tdkrPD3r# >} ZTrPPDZcxP-S/.s,TB/}a5XrPPD;,5: fn:distinct-values((1, ’a’, 1.0, ’A’, Hello)) 5XD5I\G (1, ’a’, ’A’, ’Hello’) r (1.0, ’A’, ’a’, ’Hello’)# empty /} fn:empty /}8>Td?Gq*UrP# o( fn:empty(item) n NN}]`MDmo=rUrP# 5XD5 g{ item GUrP,G45XD5* true#qr,5XD5* false# >} TB>}9C empty /}47(d? $seq PDrPGq*UrP# let $seq := (5, 10) return fn:empty($seq) 140 XQuery N< 5XD5* false# ends-with /} fn:ends-with /}7(V{.GqTX(S.ax#9C1!{m4%dQwV{.# o( fn:ends-with(string,substring) string CZQw substring DV{.# string D}]`M* xs:string,r_*UrP#g{ string GUrP,G4 string hC*c$HV{.# substring CZZ string a2xPQwDS.# substring D}]`M* xs:string,r_*UrP# TZ$HD^F substring D$H;\,} 32000 vVZ# 5XD5 g{zcBPN;u~,G45XD5* xs:boolean 5 true: v substring vVZ string a2# v substring GUrPrc$HV{.# qr,5XD5* false# >} TB/}7(V{.“Test literal”GqTV{.“literal”a2# fn:ends-with(’Test literal’,’literal’) 5XD5* true# exactly-one /} g{Td?}C|,;n,fn:exactly-one /}5XdTd?# o( fn:exactly-one(sequence-expression) sequence-expression NNrP,|(UrP# 5XD5 g{ sequence-expression }C|,;n,G45X sequence-expression#qra5Xm s# Z 5 B ZC/} 141 >} TB>}9C exactly-one /}47(d? $seq PDrPGq}C|,;n# let $seq := 5 return fn:exactly-one($seq) 5XD5* 5# exists /} fn:exists /}ITliGqfZm`;,`MDn,}g,*X"tT"D>Zc"2 ,5(}g,{})r_ XML D5# g{8(*K/}DTd?D XQuery mo= sequence-expression zzKUa{(Ur P),G4 fn:exists +5X false#g{KTd?5XD;GUrP,G4 fn:exists + 5X true# o( fn:exists(sequence-expression) sequence-expression NN}]`MDrPrUrP# 5XD5 g{ sequence-expression ;GUrP,G45XD5* true#g{ sequence- expression zzKUrP,G45XD5* false# >} TB>}9C exists /}47(d? $seq PDrPGq*GUrP# let $seq := (5, 10) return fn:exists($seq) 5XD5* true# B;v>}+liGqP;v*X customer _PS*X phone#g{P,G4 fn:exists /}+5X true: fn:exists($info/customer/phone) g{P;v*X customer,"RK*X_P Cid tT,G4TB>}+5X true: fn:exists($info/customer/@Cid) B;v>}+li comment *XGq_PD>Zc#ZK>}P,g{ comment *X G;vU*X,G4|;PD>Zc,rK fn:exists +5X false#Kb,g{y>M ;P comment *X,G4 fn:exists +5X false: fn:exists($info/customer/comment/text()) ns;v>}+li CUSTOMER mD XML P INFO PGqPNN XML D5: fn:exists( db2-fn:xmlcolumn("CUSTOMER.INFO") ) 142 XQuery N< false /} fn:false /}5X xs:boolean 5 false# o( fn:false() 5XD5 5XD5* xs:boolean 5 false# >} 9C false /}T5X5 false# fn:false() 5XD5* false# floor /} fn:floor /}5X!ZrHZX(}V5Dns{}# o( fn:floor(numeric-value) numeric-value -S5rUrP# g{ numeric-value G-S5,G4|_PBPdP;V`M: v xs:float v xs:double v xs:decimal v xs:integer v xdt:untypedAtomic v SOfP>DN;`MIzD`M g{ numeric-value D}]`M* xdt:untypedAtomic,G4|a*;* xs:double 5# 5XD5 g{ numeric-value "GUrP,G45XD5G!Z numeric-value Dns{}#5X 5D}]`M!vZ numeric-value D}]`M: v g{ numeric-value D}]`M* xs:float"xs:double"xs:decimal r xs:integer,G4 5XD5D`Mk numeric-value `,# v g{ numeric-value D}]`MIzT xs:float"xs:double"xs:decimal r xs:integer, G45X5D}]`M* numeric-value D8z}]`M# g{ numeric-value GUrP,G45XD5GUrP# Z 5 B ZC/} 143 >} 9C}Td?D>}:TB/}5X 0.5 DrB!{5: fn:floor(0.5) 5XD5* 0# 9C:Td?D>}:TB/}5X (-1.2) DrB!{5: fn:floor(-1.2) 5XD5* -2# hours-from-dateTime /} fn:hours-from-dateTime /}5X xs:dateTime 5D!1}?V# o( fn:hours-from-dateTime(dateTime-value) dateTime-value *SPi!!1}?VD dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# 5XD5 g{ dateTime-value D`M* xs:dateTime,G45XD5`M* xs:integer,"RC5 Z 0 = 23 .d(|,=_)#C5G dateTime-value D!1}?V# g{ dateTime-value GUrP,G45XD5GUrP# >} TB/}5X dateTime 5 2005 j 1 B 31 UBg 2:00(UTC-8 1x)D!1}? V# fn:hours-from-dateTime(xs:dateTime("2005-01-31T14:00:00-08:00")) 5XD5* 14# hours-from-duration /} fn:hours-from-duration /}5XVx1d5D!1}?V# o( fn:hours-from-duration(duration-value) duration-value *SPi!!1}?VDVx1d5# 144 XQuery N< duration-value G U r P r _ G B P d P ; V ` M D 5 : xdt:dayTimeDuration"xs:duration M xdt:yearMonthDuration# 5XD5 5X5!vZ duration-value D`M: v g{ duration-value D`M* xdt:dayTimeDuration r xs:duration,G45XD5` M* xs:integer,"RG -23 = 23 .dD5(|,=_)#C5G*;* xdt:dayTimeDuration D duration-value D!1}?V#g{ duration-value *:5, G4C5*:5# v g{ duration-value D`M* xdt:yearMonthDuration,G45XD5`M* xs:integer "R5* 0# v g{ duration-value GUrP,G45XD5GUrP# *;* xdt:dayTimeDuration D duration-value D!1}?VG4 ((S mod 86400) idiv 3600) FcD{}!1}#S G*;* xdt:dayTimeDuration D duration-value D\k }T}%l}MB}?V#5 86400 G;lDk},3600 G;!1Dk}# >} TB/}5XVx1d 126 !1D!1}?V# fn:hours-from-duration(xdt:dayTimeDuration("PT126H")) 5XD5* 6#FcVx1dD!1}1,126 !1*;* 5 l 6 !1#Vx1dH Z P5DT6H,|D!1}?V* 6 !1# hours-from-time /} fn:hours-from-time /}5X xs:time 5D!1}?V# o( fn:hours-from-time(time-value) time-value *SPi!!1}?VD1d5# time-value D`M* xs:time,r_GUrP# 5XD5 g{ time-value "GUrP,G45XD5`M* xs:integer,"RC5Z 0 = 23 . d(|,=_)#C5G time-value D!1}?V# g{ time-value GUrP,G45XD5GUrP# >} TB/}5X1d5Og 9:30(UTC-8 1x)D!1}?V# fn:hours-from-time(xs:time("09:30:00-08:00")) 5XD5* 9# Z 5 B ZC/} 145 implicit-timezone /} fn:implicit-timezone /}5X~=1x5 PT0S,C5D`M* xs:dayTimeDuration#5 PT0S 8> UTC *~=1x# o( fn:implicit-timezone() 5XD5 5XD5* PT0S,bGI`M xs:dayTimeDuration m>D UTC# >} TB/}5X xdt:dayTimeDuration(″PT0S″): fn:implicit-timezone() in-scope-prefixes /} fn:in-scope-prefixes /}5X*XDyP{FUdwCrD0:Pm# o( fn:in-scope-prefixes(element) element *Tdlw{FUdwCr0:D*X# 5XD5 5XD5* xs:NCName 5rP,b)5G element DyP{FUdwCrD0:#g {1!{FUdZ element DwCrP,G41!{FUd0:DrPn*c$HV{ .#{FUd“xml”} TBi/5X*X emp D{FUdwCrD0:(w* NCName)rP# declare namespace d="http://www.mycompany.com"; let $department := document { } return fn:in-scope-prefixes($department/d:dept/d:emp) 5XD5* (″xml″, ″comp″),3r;;(gK# index-of /} fn:index-of /}5X3nvVZrPPD;C# 146 XQuery N< o( fn:index-of(sequence-expression,search-value) sequence-expression -S5DNNrPrUrP# search-value *Z sequence-expression PiRD5# 5XD5 5XD5G xs:integer 5rP,9C eq Kc{DfrxPHO(hz1!{m)1, b)5m> sequence-expression Pk search-value `%dDnD;C#r*4Td`M (e eq Kc{x4\xPHODn+;S*k search-value ;%d,"RrK;a5 X;C#rPPDZ;nD;C* 1# g{ search-value Z sequence-expression P;P%dn,r_ sequence-expression * UrP,G4/}a5XUrP# >} TB/}a5X“ABC”vVZrPPD;C# fn:index-of((’ABC’,’DEF’,’ABC’,’123’), ’ABC’) 5XD5*rP (1,3)# insert-before /} fn:insert-before /}Z;vrPPDX(;C.0ekm;rP# o( fn:insert-before(source-sequence,insert-position,insert-sequence) source-sequence *ZdPekrPDrP# source-sequence G|,Nb}]`MDnDrPrUrP# insert-position source-sequence P.0*ekrPD;C#insert-position D}]`M* xs:integer#g{ insert-position<=0,G4 insert-position ahC* 1#g{ insert- position sZ source-sequence PDn},G4 insert-position ahC* source- sequence PDn}S 1# insert-sequence *ek= source-sequence PDrP# insert-sequence GG|,Nb}]`MDnDrPrUrP# Z 5 B ZC/} 147 5XD5 g{ source-sequence "GUrP: v g{ insert-sequence "GUrP,G45XD5*|,BPn"9CTB3rDrP: – source-sequence PDnZn insert-position .0 – insert-sequence PDn – source-sequence PDnZn insert-position P – source-sequence PDnZn insert-position .s v g{ insert-sequence GUrP,G45XD5* source-sequence# g{ source-sequence GUrP: v g{ insert-sequence "GUrP,G45XD5* insert-sequence# v g{ insert-sequence GUrP,G45XD5GUrP# >} TB/}5Xr*ZrP (1,2,3,7) PD;C 4 .0ekrP (4,5,6) xzIDrP: fn:insert-before((1,2,3,7),4,(4,5,6)) 5XD5* (1,2,3,4,5,6,7)# last /} fn:last /}5XrPP}Z&mD5D}?# o( fn:last() 5XD5 g{10&mDrP"GUrP,G45XD5*rPPD5D}?#g{10&m DrPGUrP,G45XD5GUrP# >} TB>}+C/}Cw=Jmo=,T5X10rPPDns;n: (, , )[fn:last()] 5XD5* # local-name /} fn:local-name /}5XZcDV?{tT# o( fn:local-name( ) node 148 XQuery N< node *TdlwV?{DZc#g{48( node,G4a*10OBDZcT fn:local-name s5# 5XD5 5XD5!vZGq8(K node 0 node D5: v g{48( node,G4a5XOBDZcDV?{# v g{ node {OBPN;u~,G4a5Xc$HV{.: – node GUrP# – node "G*XZc"tTZcr&m8nZc# v g{ node {OBPN;u~,G4a5Xms: – node 4(e# – node "GZc# v qra5X xs:string 5,C5|, node D)9{FDV?{?V# >} TB/}5XZc emp DV?{# declare namespace a="http://posample.org"; fn:local-name() 5XD5* b# local-name-from-QName /} fn:local-name-from-QName /}5X xs:QName 5DV?# o( fn:local-name-from-QName(qualified-name) qualified-name *SPlwV?D^({F# qualified-name D}]`M* xs:QName,r_GUrP# 5XD5 g{ qualified-name "GUrP,G45XD5*d1 qualified-name DV?D xs:NCName 5#g{ qualified-name GUrP,G45XUrP# >} TB/}5X^({FDV?# fn:local-name-from-QName(fn:QName("http://www.mycompany.com/", "ns:employee")) 5XD5*“employee”# local-timezone /} db2-fn:local-timezone /}5X>X53D1x# Z 5 B ZC/} 149 o( db2-fn:local-timezone() 5XD5 5XD5G xdt:dayTimeDuration 5,|m>k+rj<1d(UTC)D>X1x+F ?# }g,g{Z+?j<1dD>X1xPwCK/},G45XD5G -PT5H# lower-case /} fn:lower-case /}+V{.*;*!4# o( fn:lower-case(source-string ) , locale-name source-string **;*!4DV{.# source-string D`M* xs:string,r_GUrP# locale-name |,*CZ!4YwDoT73DV{.# locale-name D`M* xs:string,r_GUrP#g{ locale-name "GUrP, G4 locale-name D5G;xVs!4D,"RXkGP'oT73rc$HV {.# 5XD5 g{ source-string "GUrP,G45XD5* source-string,dP?vV{+*;* T&!4#g{ locale-name 48("*UrPr_Gc$HV{.,G4a9C Uni- code j} TB/}a+V{.“Wireless Router TB2561”*;*!4: fn:lower-case("Wireless Router TB2561") 5XD5*“wireless router tb2561”# TB/}8(AzdoT73 tr_TR "*;V8“i”0}VV{}C İ(-!s4 I DV{}C,OfPc)# fn:lower-case("Iİ", "tr_TR") 150 XQuery N< 5XD5I=vV{iI:ı m>DV{(-!!4^c i)MV8“i”#TZA zdoT73,V8“I”+*;* ı m>DV{(-!!4^c i),x İ (-!s4 I,OfPc)+*;*“i”# TB/}48(oT73,"9C Unicode jc(.)kNbV{`%d# g{48(j>,G4c(.)k;P{(X’0A’)TbDNbV{` %d# m 8>ekjG(^)kPD*7(;P{.sD;C)`%d,"R@ *{E($)kPa2(;P{.0D;C)`%d# g{48( m j>,G4ekjG(^)kV{.D*7`%d,"R @*{E($)kV{.a2`%d# i j6%dG;xVs!4D# g{48( i j>,G4a4PxVs!4%d# x 8> pattern PDUqV{a;vT# g{48( x j>,G4UqV{aCZ%d# TZ$HD^F source-string M pattern D$H;\,} 32000 vVZ# 5XD5 g{ source-string "GUrP,"R source-string k pattern `%d,G45XD5 * true#g{ source-string k pattern ;%d,G45XD5* false# Z 5 B ZC/} 151 g{ pattern 4|,V{.pCZ7(V{.*7r3P*7Gqf Z%d# g{ source-string GUrP,G45XD5* false# >} 9#=kV{.PDNbS.`%dD>}:TB/}7(V{“ac”r“bd”GqvVZ V{.“abbcacadbdcd”PDNb;C# fn:matches("abbcacadbdcd","(ac)|(bd)") 5XD5* true# 9#=k{vV{.`%dD>}:TB/}7(V{“ac”r“bd”GqkV{.“bd”` %d# fn:matches("bd","^(ac)|(bd)$") 5XD5* true# %d#=1vTUqMWV8s4D>}:TB/}9C i M x j>,TZ7(V{ .“abc1234”Gqk#=“ABC 1234”`%d1vTWV8s4MUq# fn:matches("abc1234","ABC 1234", "ix") 5XD5* true# max /} fn:max /}5XrPPDns5# o( fn:max(sequence-expression) sequence-expression |,BPN;-S`MDnrPrUrP: v xs:float v xs:double v xs:decimal v xs:integer v xs:string v xs:date v xs:time v xs:dateTime 152 XQuery N< v xdt:untypedAtomic v xdt:dayTimeDuration v xdt:yearMonthDuration v SOfP>DN;`MIzD`M `M* xdt:untypedAtomic Ddkn+*;* xs:double#KN?F`M*;s, dkrPPDyPnXkI(}a}rS`Mf;Sx*;*'V ge Kc{D +2`M#ns5G9CK+2`MFcD#}g,g{dkrP|,`M* money(IzT xs:decimal)M stockprice(IzT xs:float)Dn,G4ns5 +9C`M xs:float xPFc# ZHOUZ"1drUZ1d5.0,a+|Gw{*9C+21x#;PT =1x?VDUZ1d5+9C~=1x,4 UTC# 9C1!{m4HOV{.5# 5XD5 g{ sequence-expression "GUrP,G45XD5G sequence-expression PD5Dn s5#5X5D}]`Mk sequence-expression PwnD}]`M`,,r_G sequence-expression Pwna}AD+2}]`M# g{ sequence-expression GUrP,G45XUrP#g{CrP|,5 NaN,G4 a5X NaN# >} TB/}5XrP (500, 1.0E2, 40.5) Dns5# fn:max((500, 1.0E2, 40.5)) b)5+a}A xs:double }]`M#C/}+5X xs:double 5 5.0E2,|+TrP /==m>*“500”# min /} fn:min /}5XrPPDn!5# o( fn:min(sequence-expression) sequence-expression |,BPN;-S`MDnrPrUrP: v xs:float v xs:double v xs:decimal v xs:integer v xs:string v xs:date v xs:time v xs:dateTime v xdt:untypedAtomic Z 5 B ZC/} 153 v xdt:dayTimeDuration v xdt:yearMonthDuration v SOfP>DN;`MIzD`M `M* xdt:untypedAtomic Ddkn+*;* xs:double#KN?F`M*;s, dkrPPDyPnXkI(}a}rS`Mf;Sx*;*'V le Kc{D +2`M#n!5G9CK+2`MFcD#}g,g{dkrP|,`M* money(IzT xs:decimal)M stockprice(IzT xs:float)Dn,G4n!5 +9C`M xs:float xPFc# ZHOUZ"1drUZ1d5.0,a+|Gw{*9C+21x#;PT =1x?VDUZ1d5+9C~=1x,4 UTC# 9C1!{m4HOV{.5# 5XD5 g{ sequence-expression "GUrP,G45XD5G sequence-expression PD5Dn !5#5X5D}]`Mk sequence-expression PwnD}]`M`,,r_G sequence-expression Pwna}AD+2}]`M# g{ sequence-expression GUrP,G45XUrP#g{CrP|,5 NaN,G4 a5X NaN# >} 9C}VTd?D>}:TB/}5XrP (500, 1.0E2, 40.5) Dn!5: fn:min((500, 1.0E2, 40.5)) b)5+a}A xs:double }]`M#C/}5X xs:double 5 4.05E1,|+TrP/ ==m>*“40.5”# 9CV{.Td?D>}:TB/}9C1!{m5XrP (″x″, ″y″, ″Z″) Dn!5# Y(1!{mZEr1+!4V8V{EZs4V8V{.0# fn:min(("x", "y", "Z")) 5XD5*“x”# minutes-from-dateTime /} fn:minutes-from-dateTime /}5X xs:dateTime 5DVS}?V# o( fn:minutes-from-dateTime(dateTime-value) dateTime-value *SPi!VS}?VD dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# 154 XQuery N< 5XD5 g{ dateTime-value D`M* xs:dateTime,G45XD5`M* xs:integer,"RC5 Z 0 = 59 .d(|,=_)#C5G dateTime-value DVS}?V# g{ dateTime-value GUrP,G45XD5GUrP# >} TB/}5X dateTime 5 2005 j 1 B 23 UOg 9:42(UTC-8 1x)DVS}? V# fn:minutes-from-dateTime(xs:dateTime("2005-01-23T09:42:00-08:00")) 5XD5* 42# minutes-from-duration /} fn:minutes-from-duration /}5XVx1dDVS}?V# o( fn:minutes-from-duration(duration-value) duration-value *SPi!VS}?VDVx1d5# duration-value G U r P , r _ G B P d P ; v ` M D 5 : xdt:dayTimeDuration"xs:duration r xdt:yearMonthDuration# 5XD5 5X5!vZ duration-value D`M: v g{ duration-value D`M* xdt:dayTimeDuration r xs:duration,G45XD5` M* xs:integer,"RG -59 = 59 .dD5(|,=_)#C5G*;* xdt:dayTimeDuration D duration-value DVS}?V#g{ duration-value *:5, G4C5*:5# v g{ duration-value D`M* xdt:yearMonthDuration,G45XD5* 0# v g{ duration-value GUrP,G45XD5GUrP# *;* xdt:dayTimeDuration D duration-value VS}?VG(} ((S mod 3600) idiv 60) FcD{}VS}#5 S G*;* xdt:dayTimeDuration D duration-value D\k },CZ}%j}MB}?V# >} TB/}5XVx1d 2 l 16 !1 93 VSDVS}# fn:minutes-from-duration(xdt:dayTimeDuration("P2DT16H93M")) 5XD5* 33#FcVx1dD\VS}1,93 VS+*;* 1 !1 33 VS#V x1dHZ P2DT17H33M,|DVS}?V* 33 VS# Z 5 B ZC/} 155 minutes-from-time /} fn:minutes-from-time /}5X xs:time 5DVS}?V# o( fn:minutes-from-time(time-value) time-value *SPi!VS}?VD1d5# time-value D`M* xs:time,r_GUrP# 5XD5 g{ time-value D`M* xs:time,G45XD5`M* xs:integer,"RC5Z 0 = 59 .d(|,=_)#C5G time-value DVS}?V# g{ time-value GUrP,G45XD5GUrP# >} TB/}5X1d5Og 8:59(UTC-8 1x)DVS}?V# fn:minutes-from-time(xs:time("08:59:00-08:00")) 5XD5* 59# month-from-date /} fn:month-from-date /}5X xs:date 5DB]?V# o( fn:month-from-date(date-value) date-value *SPi!B]?VDUZ5# date-value D`M* xs:date,r_*UrP# 5XD5 g{ date-value D`M* xs:date,G45XD5`M* xs:integer,"RC5Z 1 = 12 .d(|,=_)#C5G date-value DB]?V# g{ date-value GUrP,G45XD5GUrP# >} TB/}5XUZ5 2005 j 12 B 1 UDB]?V# fn:month-from-date(xs:date("2005-12-01")) 5XD5* 12# 156 XQuery N< month-from-dateTime /} fn:month-from-dateTime /}5X xs:dateTime 5DB]?V# o( fn:month-from-dateTime(dateTime-value) dateTime-value *SPi!B]?VD dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# 5XD5 g{ dateTime-value D`M* xs:dateTime,G45XD5`M* xs:integer,"RC5 Z 1 = 12 .d(|,=_)#C5G dateTime-value DB]?V# g{ dateTime-value GUrP,G45XD5GUrP# >} TB/}5X dateTime 5 2005 j 10 B 31 UOg 8:15(UTC-8 1x)DB]? V# fn:month-from-dateTime(xs:dateTime("2005-10-31T08:15:00-08:00")) 5XD5* 10# months-from-duration /} fn:months-from-duration /}5XVx1d5DB}?V# o( fn:months-from-duration(duration-value) duration-value *SPi!B}?VDVx1d5# duration-value G U r P , r _ G B P d P ; v ` M D 5 : xdt:dayTimeDuration"xs:duration r xdt:yearMonthDuration# 5XD5 5X5!vZ duration-value D`M: v g{ duration-value D`M* xs:duration r xdt:yearMonthDuration,G45XD5` M* xs:integer,"RG -11 = 11 .dD5(|,=_)#C5G*;* xdt:yearMonthDuration D duration-value DB}?V#g{ duration-value *:5, G4C5*:5# v g{ duration-value D`M* xdt:dayTimeDuration,G45XD5* 0# v g{ duration-value GUrP,G45XD5GUrP# Z 5 B ZC/} 157 *;* xdt:yearMonthDuration D duration-value B}?VG duration-value \B}}T 12 7(D`}7(D{}B}5# >} TB/}5XVx1d 20 jc 5 vBDB}?V# fn:months-from-duration(xs:duration("P20Y5M")) 5XD5* 5# TB/}5X yearMonthDuration -9 j -13 vBDB}?V# fn:months-from-duration(xdt:yearMonthDuration("-P9Y13M")) 5XD5* -1#FcVx1dD\B}1,-13 vB+*;* -1 j -1 vB#Vx1 dHZ -P10Y1M,dB}?V* -1 vB# TB/}5XVx1d 14 jc 11 vB 40 lV 13 !1DB}?V# xquery fn:months-from-duration(xs:duration("P14Y11M40DT13H")) 5XD5* 11# name /} fn:name /}5XZc{D0:MV?{?V# o( fn:name( ) node node *Tdlw{FDZcD^({F#g{48( node,G4a*10OBDZ cT fn:name s5# 5XD5 5XD5!vZ node D5: v g{ node {OBPN;u~,G4a5Xc$HV{.: – node GUrP# – node "G*XZc"tTZcr&m8nZc# v g{ node {OBPN;u~,G4a5Xms: – node 4(e# – node "GZc# v qra5X xs:string 5,C5|, node D0:(g{fZ)MV?{# >} TBi/5X5“comp:emp”: 158 XQuery N< declare namespace d="http://www.mycompany.com"; let $department := document { } return fn:name($department/d:dept/d:emp) TBi/9a5X5“comp:emp”: declare namespace d="http://www.mycompany.com"; let $department := document { } return $department/d:dept/d:emp/fn:name() namespace-uri /} fn:namespace-uri /}5XZcD^({FD{FUd URI# o( fn:namespace-uri( ) node node *Tdlw{FUd URI DZcD^({F#g{48( node,G4a*1 0OBDZcT fn:namespace-uri s5# 5XD5 5XD5!vZ node D5: v g{ node {OBPN;u~,G4a5Xc$HV{.: – node GUrP# – node "G*XZcrtTZc# – node G*XZcrtTZc,+ node D)9^({F;Z{FUdP# v g{ node {OBPN;u~,G4a5Xms: – node 4(e# – node "GZc# v qra5X xs:string 5,C5|, node D)9{FD{FUd URI# >} TBi/5X5“http://www.mycompany.com”: declare namespace d="http://www.mycompany.com"; let $department := document { } return fn:namespace-uri($department/d:dept/d:emp) TBi/9a5X5“http://www.mycompany.com”: declare namespace d="http://www.mycompany.com"; let $department := document { Z 5 B ZC/} 159 } return $department/d:dept/d:emp/fn:namespace-uri() namespace-uri-for-prefix /} fn:namespace-uri-for-prefix /}5Xk*X{FUdwCrPD0:`X*D{FUd URI# o( fn:namespace-uri-for-prefix(prefix,element) prefix *Td5X{FUdD0:# prefix D}]`M* xs:string "R$HI\*c,r_GUrP# element d{FUdwCrs(A prefix D*X# 5XD5 5XD5!vZ prefix D5: v g{ element D{FUdwCrD0:5k prefix D5`%d,G4a5XC{FU dD{FUd URI# v g{ element ;Pd0:5k prefix D5`%dD{FUdwCr,G4a5XUr P# v g{ prefix Gc$HV{.rUrP,G4a5X1!{FUdD{FUd URI# >} TBi/5X5“http://www.mycompany.com”: declare namespace d="http://www.mycompany.com"; let $department := document { } return fn:namespace-uri-for-prefix("comp", $department/d:dept/d:emp) namespace-uri-from-QName /} fn:namespace-uri-from-QName /}5X xs:QName 5D{FUd URI ?V# o( fn:namespace-uri-from-QName(qualified-name) qualified-name *SPlw{FUd URI ?VD^({F# qualified-name D}]`M* xs:QName,r_GUrP# 160 XQuery N< 5XD5 g{ qualified-name "GUrP,G45XD5*d1 qualified-name D{FUd URI ?VD xs:string 5#g{ qualified-name ;Z{FUdP,G4a5Xc$HV{.# g{ qualified-name GUrP,G45XUrP# >} K/}5XV{.5“http://www.mycompany.com”: fn:namespace-uri-from-QName(fn:QName("http://www.mycompany.com", "comp:employee")) node-name /} fn:node-name /}5XZcD)9 QName# o( fn:node-name(node) node *Tdlw)9{FDZc# 5XD5 5XD5G|, node D)9 QName D xs:QName 5#g{ node GUrP,G4a 5XUrP# >} TBi/5XT&Z URI http://www.mycompany.com MJc QName comp:emp D) 9 QName: declare namespace d="http://www.mycompany.com"; let $department := document { } return fn:node-name($department/d:dept/d:emp) normalize-space /} fn:normalize-space /}}%V{.PD0} TB/}aSV{.“abcd”P}%nbDUqV{# fn:normalize-space("abcd") 5XD5*“abcd”# normalize-unicode /} fn:normalize-unicode /}TV{.4P Unicode f6/# o( fn:normalize-unicode(source-string ) ,normalization-type source-string *Td4P Unicode f6/D5# source-string G xs:string 5rUrP# normalization-type 8>*4PD Unicode f6/D`MD xs:string 5#I\D5|(: NFC Unicode f6/q= C#g{48( normalization-type,G4a4P Unicode f6/# NFD Unicode f6/q= D# NFKC Unicode f6/q= KC# NFKD Unicode f6/q= KD# g{8(Kc$HV{.,G4;a4Pf6/# 5XD5 g{ source-string "GUrP,G45XD5GT source-string 4P normalization- type 8(D Unicode f6/1zID xs:string 5#g{48( normalization-type,G 4aT source-string 4P Unicode f6/q= C(NFC)#Character Model for the World Wide Web 1.0 PT Unicode f6/wKhv# 162 XQuery N< g{ source-string GUrP,G4a5Xc$HV{.# >} TB/}TV{.“ṃ”(BfxcD-!!4V8 m)4P Unicode f6 /q= C: fn:normalize-unicode("ṃ","NFC") 5XD5GI}VV{}C &x1e43;(BfxcD-!!4V8 m)m>D UTF-8 V {# TB>}+f6/ Unicode *;*.xFzkc: fn:string-to-codepoints(fn:normalize-unicode("ṃ", "NFC")) 5XD5* 7747# not /} g{rPDP'<{5* true,G4 fn:not /}5X false,g{rPDP'<{5* false,G4C/}5X true# o( fn:not(sequence-expression) sequence-expression |,NN`MDnDNNrPrUrP# 5XD5 g{ sequence-expression "GUrP,"RrPDP'<{5* false,G45XD5 * true#g{rPDP'<{5* true,G45XD5* false# g{ sequence-expression GUrP,G45XD5* true# >} TB/}5X false,-rGZcDP'<{5* true# fn:not() number /} fn:number /}+5*;* xs:double }]`M# o( fn:number( ) atomic-value Z 5 B ZC/} 163 atomic-value -S5rUrP#g{48( atomic-value,G4a*10OBDnT fn:number s5# 5XD5 g{ atomic-value "GUrP,G45XD5G(}+ atomic-value D?F`M*;* xs:double zID#g{ atomic-value ;\*;* xs:double }]`M,G4a5X NaN# g{ numeric-value GUrP,G4a5X NaN# >} + xs:decimal 5*;* xs:double D>}:TB/}a+ xs:decimal 5 2.75 *; * xs:double# fn:number(2.75) 5XD5* 2.75E0# + xs:boolean D5*;* xs:double D>}:TB/}a+<{5 false() *;* xs:double# fn:number(false()) 5XD5* 0.0E0# one-or-more /} g{Td?|,;nr`n,G4 fn:one-or-more /}5XdTd?# o( fn:one-or-more(sequence-expression) sequence-expression NNrP,|(UrP# 5XD5 g{ sequence-expression |,;nr`n,G4a5X sequence-expression#qra5 Xms# >} TB>}9C fn:one-or-more /}47(d? $seq PDrPGq|,;nr`n# let $seq := (5,10) return fn:one-or-more($seq) 5X (5,10)# 164 XQuery N< position /} fn:position /}5XrPP}Z&mDOBDnD;C# o( fn:position() 5XD5 5XD5G;v xs:integer 5,C58>rPP10&mDOBDnD;C#g{4( eOBDn,G4a5Xms#v1|,OBDnDrP_P7(3r1,position /} Ea5X7(a{#(#aZ=JP9C position /}# >} ZTBmo=P,aT|, 10 nDrPPD?nwC position /}#TZ?;n,posi- tion /}* true# (11 to 20)[position() eq 5] mo=5XD5* 15# QName /} fn:QName /}y]{FUd URI M|,Jc QName(xPI!0:)DV{.9( )9{# o( fn:QName(URI,QName) URI )9{FD{FUd?V# URI D}]`M* xs:string,r_*UV{.rrP# QName xs:QName }]`MD}7J(q=D5# QName D}]`M* xs:string# 5XD5 5XD5Gd1)9{FD xs:QName 5,C{F_PI URI 8(D{FUd URI T 0I QName 8(D0:MV?{# fn:QName /}a9 QName D{FUd0:k URI D5`X*#g{ QName _P {FUd0:,G4 URI ;\Gc$HV{.rUrP#g{ QName ;PV?{" R;P0:,G4 URI ITGc$HV{.rUrP# Z 5 B ZC/} 165 >} QTTB/}8({FUd URI 0|,Jc QName DV{.,"RK/}a5X` M* xs:QName D5# fn:QName("http://www.mycompany.com", "comp:employee") 5XD5* xs:QName 5,d{FUd URI *“http://www.mycompany.com”,0:* “comp”,V?{*“employee”# remove /} fn:remove /}}%rPPD;n# o( fn:remove(source-sequence,remove-position) source-sequence SP}%;nDrP# source-sequence G|,Nb}]`MDnDrPrUrP# remove-position *}%DnZ source-sequence PD;C#remove-position D}]`M* xs:integer# 5XD5 g{ source-sequence "GUrP: v g{ remove-position !Z 1 rsZ source-sequence D$H,G45XD5* source- sequence# v g{ remove-position sZrHZ 1 "R!ZrHZ source-sequence D$H,G4 5XD5G|,BPn"9CTB3rDrP: – source-sequence PDnZn remove-position .0 – source-sequence PDnZn remove-position .s v g{ source-sequence GUrP,G45XD5GUrP# >} TB/}5Xr*}%rP (1,2,4,7) P;C 3 &DnxzIDrP: fn:remove((1,2,4,7),3) 5XD5* (1,2,7)# replace /} fn:replace /}+V{.PD?iV{kX(#=xPHO,;s+kC#=%dDV{ f;*m;iV{# 166 XQuery N< o( fn:replace(source-string,pattern,replacement-string ) ,flags source-string |,*f;DV{DV{.# source-string G xs:string 5rUrP# pattern *k source-string xPHOD}rmo=#}rmo=GCZZQw#=P( e;vr;iV{.DV{"(d{MKc{/O# pattern G xs:string 5# replacement-string ;vV{.,|,CZf;k source-string PD pattern `%dDV{# replacement-string G xs:string 5# replacement-string I|,d? $0 = $9#$0 m> pattern PD{vV{.# d? $1 = $9 m> pattern P 9 vI\x(ESmo=PD;v#($1 m >Z;vSmo=,$2 m>Z~vSmo=,TK`F#) *Z replacement-string P9CDV@*{E“$”,k9CV{.“\$”#*Z replacement-string P9CDV41\(\),k9CV{.“\\”# flags ;v xs:string 5,I|,BPCZXF pattern k source-string D%divD NN5: s m>c(.)If;NNV{# g{48(j>,G4c(.)f;;P{(X’0A’)TbDNbV {# m m>ekjG(^)+f;PD*7(;P{.sD;C),x@*{ E($)f;PDa2(;P{.0D;C)# g{48( m j>,G4ekjG(^)+f;V{.D*7,"R@ *{E($)af;V{.Da2# i j6%dG;xVs!4D# g{48( i j>,G4a4PxVs!4%d# x 8> pattern PDUqV{a;vT# g{48( x j>,G4UqV{aCZ%d# TZ$HD^F source-string"pattern M replacement-string D$H;\,} 32000 vVZ# 5XD5 g{ source-string "GUrP,G45XD5GT source-string 4PBPYw1zI DV{.: v +Qw source-string TiRk pattern `%dDV{#g{ pattern |,=ir|` 8CV{/,G4k source-string PV{`%dD pattern PDZ;iV{;S*% d#=# Z 5 B ZC/} 167 v k pattern %dD source-string PD?iV{+f;* replacement-string#g{ replacement-string |,d? $0 = $9 PDNN;v,G4kT&Cd?D pattern PSmo=`%dD source-string S.+Z replacement-string Pf;Cd?#;s -}^DD replacement-string +ek= source-string P#g{r*d?},}Sm o=}r_Smo=Z source-string P;P%dx} +;vS.f;*m;S.D>}:TB/}a+V{.“abbcacadbdcd”PDyP“a” D5}f;*“ba”# fn:replace("abbcacadbdcd","a","ba") 5XD5*“babbcbacbadbdcd”# +9Cf;V{.DS.f;*d?D>}:TB/}Z“abbcacadbdcd”P+“a”Mz ZdsDV{f;*“a”.sDV{D=v5}# fn:replace("abbcacadbdcd","a(.)","$1$1") 5XD5*“bbbcccddbdcd”# resolve-QName /} (}9C*XD{FUdwCr+{FUd0:bv*{FUd URI,fn:resolve- QName /}+|,Jc QName DV{.*;*)9 QName# o( fn:resolve-QName(qualified-name,element-for-namespace) qualified-name 9C^({Fq=DV{.# qualified-name D}]`M* xs:string,r_GUrP# element-for-namespace * qualified-name a){FUdwCrD*X# element-for-namespace G*XZc# 5XD5 g{ qualified-name "GUrP,G45XD5G4gB==9lD)9{F: v )9 QName D0:MV?{!T qualified-name# v g{ qualified-name P0:,"RC0:k element-for-namespace D{FUdwCr PD0:`%d,G4K0:s(AD{FUd URI G5X5D{FUd URI# 168 XQuery N< v g{ qualified-name ;P0:,"R1!5{FUd URI GZ element-for- namespace D{FUdwCrP(eD,G4K1!{FUd URI G5X5D{F Ud URI# v g{ qualified-name ;P0:,"R4Z element-for-namespace D{FUdwCrP (eNN1!5{FUd URI,G45XD5;PNN{FUd URI# v g{ qualified-name D0:k element-for-namespace D{FUdwCrPD{FUd 0:;%d,r_ qualified-name "49CP'^({Fq=,G4a5Xms# g{ qualified-name GUrP,G45XUrP# >} TBi/5XT&Z URI http://www.mycompany.com MJc QName comp:dept D) 9 QName: declare namespace d="http://www.mycompany.com"; let $department := document { } return fn:resolve-QName("comp:dept", $department/d:dept/d:emp) reverse /} fn:reverse /}9rPPDnEr4r# o( fn:reverse(source-sequence) source-sequence *4rDrP# source-sequence G|,Nb}]`MDnDrPrUrP# 5XD5 g{ source-sequence "GUrP,G45XD5GTfr3r|, source-sequence P wnDrP# g{ source-sequence GUrP,G4a5XUrP# >} TB/}Tfr3r5XrP (1,2,3,7) PDwn: fn:reverse((1,2,3,7)) 5XD5* (7,3,2,1)# root /} fn:root /}5XZcytDwDyZc# Z 5 B ZC/} 169 o( fn:root( ) node node ZcrUrP#node D1!5GOBDZc# 5XD5 g{ node "GUrP,G45XD5G node ytDwDyZc#g{ node GwD yZc,G45XD5* node# g{ node GUrP,G45XD5GUrP# >} Y(3) XQuery d?xPKgB(e: let $f := Laura let $e := {$f} Brown let $doc := document {{$e}} 5X*XDyZcD>}:TB/}5X*X last DyZc: fn:root($e/last) 5XD5* LauraBrown# 5XD5DyZcD>}:TB/}5Xs(Ad? $doc DD5DyZc: fn:root($doc) 5XD5GD5Zc# round /} fn:round /}5XnS|X(}V5D{}# o( fn:round(numeric-value) numeric-value -S5rUrP# g{ numeric-value G-S5,G4|_PBPdP;V`M: v xs:float v xs:double v xs:decimal v xs:integer v xdt:untypedAtomic v SOfP>DN;`MIzD`M g{ numeric-value D}]`M* xdt:untypedAtomic,G4|a*;* xs:double 5# 170 XQuery N< 5XD5 g{ numeric-value "GUrP,G45XD5GnS| numeric-value D{}#4, fn:round(numeric-value) H[Z fn:floor(numeric-value+0.5)#5X5D}]`M!vZ numeric-value D}]`M: v g{ numeric-value D}]`M* xs:float"xs:double"xs:decimal r xs:integer,G4 5XD5D`Mk numeric-value `,# v g{ numeric-value D}]`MIzT xs:float"xs:double"xs:decimal r xs:integer, G45X5D}]`M* numeric-value D8z}]`M# g{ numeric-value GUrP,G45XD5GUrP# >} 9C}Td?D>}:TB/}5X 0.5 Dak5: fn:round(0.5) 5XD5* 1# 9C:Td?D>}:TB/}5X (-1.5) Dak5: fn:round(-1.5) 5XD5* -1# round-half-to-even /} fn:round-half-to-even /}5XnS|X(}V5"_P8(+HD}V5# o( fn:round-half-to-even(numeric-value ) ,precision numeric-value -S5rUrP# g{ numeric-value G-S5,G4|_PBPdP;V`M: v xs:float v xs:double v xs:decimal v xs:integer v xdt:untypedAtomic v SOfP>DN;`MIzD`M g{ numeric-value D}]`M* xdt:untypedAtomic,G4|a*;* xs:double 5# precision numeric-value *akD!}cR_D;}#precision G xs:integer 5#preci- sion D1!5* 0# Z 5 B ZC/} 171 5XD5 g{ numeric-value "GUrP,"R precision * 0 r48(,G45XD5*nS | numeric-value D{}#g{ numeric-value k=v{}DS|LH`H,G45XD 5*<}{}# g{ numeric-value "GUrP,"R precision "G* 0,G45XD5G!}cR_ P precision ;"RS| numeric-value D}5#g{ numeric-value k=v5DS|L H`H,G45XD5*dnMP'}V*<}D5# 5X5D}]`M!vZ numeric-value D}]`M: v g{ numeric-value D}]`M* xs:float"xs:double"xs:decimal r xs:integer,G4 5XD5D`Mk numeric-value `,# v g{ numeric-value D}]`MIzT xs:float"xs:double"xs:decimal r xs:integer, G45X5D}]`M* numeric-value D8z}]`M# g{ numeric-value GUrP,G45XD5GUrP# >} ;P+HTd?D>}:TB/}5X 0.5 Dak5: fn:round-half-to-even(0.5) 5XD5* 0# 9CGc+HTd?D>}:TB/}5X 1.5432,ak*=;!}# fn:round-half-to-even(1.5432,2) 5XD5* 1.54# 9C:+HD>}:TB/}5X 35600# fn:round-half-to-even(35612.25, -2) seconds-from-dateTime /} fn:seconds-from-dateTime /}5X xs:dateTime 5Dk}?V# o( fn:seconds-from-dateTime(dateTime-value) dateTime-value *SPi!k}?VD dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# 5XD5 g{ dateTime-value D`M* xs:dateTime,G45XD5`M* type xs:decimal," RC5sZrHZ 0 "!Z 60#C5G dateTime-value Dk}?VM!}k}?V# g{ dateTime-value GUrP,G45XD5GUrP# 172 XQuery N< >} TB/}5X dateTime 5 2005 j 2 B 8 UBg 2:16:23(UTC-8 1x)Dk}? V# fn:seconds-from-dateTime(xs:dateTime("2005-02-08T14:16:23-08:00")) 5XD5* 23# TB/}5X dateTime 5 2005 j 6 B 23 UOg 9:16:20.43(UTC 1x)Dk} ?V# fn:seconds-from-dateTime(xs:dateTime("2005-06-23T09:16:23.43Z")) 5XD5* 20.43# seconds-from-duration /} fn:seconds-from-duration /}5XVx1dDk}?V# o( fn:seconds-from-duration(duration-value) duration-value *SPi!k}?VDVx1d5# duration-value G U r P , r _ G B P d P ; v ` M D 5 : xdt:dayTimeDuration"xs:duration r xdt:yearMonthDuration# 5XD5 5X5!vZ duration-value D`M: v g{ duration-value D`M* xdt:dayTimeDuration r xs:duration,G45XD5` M* xs:decimal,"RGsZ -60 "!Z 60 D5#C5G*;* xdt:dayTimeDuration D duration-value Dk}?VM!}k}?V#g{ duration-value *:5,G4C 5*:5# v g{ duration-value D`M* xdt:yearMonthDuration,G45XD5`M* xs:integer "R5* 0# v g{ duration-value GUrP,G45XD5GUrP# *;* xdt:dayTimeDuration D duration-value Dk}?VM!}k}?VG4 (S mod 60) FcD#5 S G*;* xdt:dayTimeDuration D duration-value DkM!}kD\ M,CZ}%j}MB}?V# >} TB/}5XVx1d 150.5 kDk}?V# fn:seconds-from-duration(xdt:dayTimeDuration("PT150.5S")) 5XD5* 30.5#FcVx1dD\k}1,150.5 k+*;* 2 V 30.5 k#Vx1 dHZ PT2M30.5S,|Dk}?V* 30.5 k# Z 5 B ZC/} 173 seconds-from-time /} fn:seconds-from-time /}5X xs:time 5Dk}?V# o( fn:seconds-from-time(time-value) time-value *SPi!k}?VD1d5# time-value D`M* xs:time,r_GUrP# 5XD5 g{ time-value D`M* xs:time,G45XD5`M* type xs:decimal,"RC5s ZrHZ 0 "!Z 60#C5G time-value Dk}?VM!}k}?V# g{ time-value GUrP,G45XD5GUrP# >} TB/}5X1d5Og 08:59:59(UTC-8 1x)Dk}?V# fn:seconds-from-time(xs:time("08:59:59-08:00")) 5XD5* 59# sqlquery /} db2-fn:sqlquery /}Z10`, DB2 }]bPlw SQL +i/zIDrP# o( db2-fn:sqlquery(string-literal ) , parameter-expression string-literal |,+i/#+i/Xk8(%Pa{/,"RCPD}]`MXk* XML# +i/DwCrGBD SQL i/wCr,x;G6W SQL i/# +i/;\|, isolation Sdr lock-request Sd# g{+i/|,%}E(}g,ZV{.#?=_),G4&+/}Td?( Z+}EP#}g: "select c1 from t1 where c2 = ’Hello’" g{+i/|,+}E(}g,Z(gj6=_),G4&+/}Td?(Z %}EP#}g: ’select c1 from "t1" where c2 = 47’ g{+i/,1|,%}EM+}E,G4&+/}Td?(Z%}EP," C=v`Z%}EV{4m>?vZ?%}E#}g: 174 XQuery N< ’select c1 from "t1" where c2 = ’’Hello’’’ +i/I|,T PARAMETER /}DwC,T}C db2-fn:sqlquery /}wC P8(D?v parameter-expression Da{5#Z4P+i/1,PARAM- ETER /}wC+f;*T& parameter-expression Da{5# parameter-expression a5X5D XQuery mo=#I(}8(D SQL /} PARAMETER 0 SQL +i/PD{}5Td?4}C?v parameter-expression Da{5#C{}5 G parameter-expression Dw},8>|Z db2-fn:sqlquery /}wCPD;C# P'{}5Z 1 =/}wCPD parameter-expression \}.d#}g,g{ string-literal Td?Z SQL +i/P|, PARAMETER(1) M PARAMETER(2), G4/}wCXk8(=v XQuery parameter-expression Td?#PARAM- ETER(1) }CZ;v parameter-expression Td?Da{,x PARAMETER(2) } CZ~v parameter-expression Td?Da{# Z&m SQL +i/Zd,?v PARAMETER /}wC+f;* db2- fn:sqlquery /}wCPT& parameter-expression Da{5#?v parameter- expression ;s5;N,;\Z SQL +i/P}C`YN#g{;\7( PARAMETER /}Da{`M,G4a5Xms# a>:g{;JmZKcP9C~=`MN}jG,G4I9C CAST f6r XMLCAST f648(`M#}g,*+ PARAMETER(1) D?F`M*;* DOUBLE,k9CTB CAST f6:CAST(PARAMETER(1) as double)# 5XD5 5XD5G string-literal PD+i/zIDrP#C+i/+w* SQL od&m,q -Z(M{FbvD#f/, SQL fr#g{+i/|,T PARAMETER /}DN NwC,G4ZT+i/s51,b)wCa;f;*T& parameter-expression Td ?D XQuery mo=Da{5#+i/5XD XML 5+a"CTNI/}a{#|, U5DP;a0la{rP#g{+i/45XNNPrv5XU5,G4/}Da {GUrP# db2-fn:sqlquery /}5XDrPPDn}I\k+i/5XDP};,,-rGdP3 )PI\|,U5rxP`nDrP# >} 5X XML D5rPD+i/D>}:TB>}T>K;)/}wC,|GSm PROD- UCT P5X`,DD5rP#b)D5ZP DESCRIPTION# BPyP/}+zz`,Da{: db2-fn:sqlquery(’select description from product’) db2-fn:sqlquery(’SELECT DESCRIPTION FROM PRODUCT’) db2-fn:sqlquery(’select "DESCRIPTION" from "PRODUCT"’) Z 5 B ZC/} 175 5X%v XML D5D+i/D>}:TB>}5X|,m PRODUCT PD%vD5 DrP#CD5ZP DESCRIPTION P,"RIP PID D5“100-103-01”j6# BPyP/}+zz`,Da{: db2-fn:sqlquery(’select Description from Product where pID=’’100-103-01’’’) db2-fn:sqlquery("select description from product where pid=’100-103-01’") db2-fn:sqlquery("select ""DESCRIPTION"" from product where pid=’100-103-01’") 9C=v PARAMETER /}wCM;vmo=D+i/D>}:TB>}5XFcU ZZ[vDyP?~D:rj6"?~j6M:r1d# xquery for $po in db2-fn:xmlcolumn(’PURCHASEORDER.PORDER’)/PurchaseOrder, $item in $po/item/partid for $p in db2-fn:sqlquery( "select description from product where promostart < parameter(1) and promoend > parameter(1)", $po/@OrderDate ) where $p//@pid = $item return {data($po/@PoNum)} {data($item)} {data($po/@OrderDate)} Z&m db2-fn:sqlquery /}Zd,T parameter(1) D=N}Ca5X)%UZtT $po/@OrderDate D5# 9C=v PARAMETER /}wCM=vmo=D+i/D>}:TB>}9C DB2 SAMPLE }]bPD PURCHASEORDER m#XQuery mo=+lw)%UZZ 2006 j 4 B 4 U.0D4;6)%,"P>?v)%D;,?~E: xquery let $status := ( "Unshipped" ), $date := ( "2006-04-04" ) for $myorders in db2-fn:sqlquery( "select porder from purchaseorder where status = parameter(1) and orderdate < parameter(2)", $status, $date ) return {data($myorders/PurchaseOrder/@PoNum)} {data($myorders/PurchaseOrder/@OrderDate)} {for $itemID in distinct-values( $myorders/PurchaseOrder/item/partid ) return {$itemID} } Z&m db2-fn:sqlquery /}Zd,T parameter(1) D}Ca5Xmo= $status D a{/,xT parameter(2) D}Ca5Xmo= $date Da{5# 176 XQuery N< T SAMPLE }]bKP1,Cmo=+5XTBa{: 5000 2006-02-18 100-100-01 100-103-01 starts-with /} fn:starts-with /}7(V{.GqTX(S.*7#9C1!{m4%dQwV{.# o( fn:starts-with(string,substring) string CZQw substring DV{.# string D}]`M* xs:string,r_GUrP#g{ string GUrP,G4 string hC*c$HV{.# substring CZZ string *7xPQwDS.# substring D}]`M* xs:string,r_GUrP# TZ$HD^F substring D$H;\,} 32000 vVZ# 5XD5 g{zcBPN;u~,G45XD5* xs:boolean 5 true: v substringvVZ string D*7# v substring G|,c$HV{.DUrP# qr,5XD5* false# >} TB/}7(V{.“Test literal”GqTV{.“lite”*7# fn:starts-with(’Test literal’,’lite’) 5XD5* false# string /} fn:string /}5X3v5DV{.m># o( fn:string( ) value Z 5 B ZC/} 177 5 *m>*V{.D5# value GZcr-S5,r_GUrP# g{48( value,G4a*10OBDnT fn:string s5#g{4(e10 OBDn,G4a5Xms# 5XD5 g{ value "GUrP: v g{ value GZc,G45XD5GZcDV{.5# v g{ value G-S5,G45XD5G+ value D?F`M*;* xs:string Da{# g{ value GUrP,G4a{*c$HV{.# >} TB/}5X 123 DV{.m>: fn:string(xs:integer(123)) 5XD5*“123”# string-join /} fn:string-join /}5X(}"Cwn"CVt{xPVtxzIDV{.# o( fn:string-join(sequence,separator) sequence *"CTNIV{.DnrP# sequence GNb xs:string 5rP,r_GUrP# separator ;v(g{,CZZ sequence PDwn.dekTNIV{.# separator D}]`M* xs:string# 5XD5 5XD5G;vV{.,|G sequence PC separator t*DwnD"C#g{ sepa- rator Gc$HV{.,G4 sequence PDwn+Z;9CVt{DivB"C#g{ sequence GUrP,G4a5Xc$HV{.# >} TB/}5X;vV{.,|G(}9CUqV{w*Vt{4"CrP (″I″, ″made″, ″a″, ″sentence!″) PDwnzID# fn:string-join(("I" , "made", "a", "sentence!"), " ") 5XD5GV{.“I made a sentence!”# 178 XQuery N< string-length /} fn:string-length /}5XV{.D$H# o( fn:string-length(source-string) source-string *Td5X$HDV{.# source-string D}]`M* xs:string,r_GUrP# 5XD5 g{ source-string "GUrP,G45XD5* source-string D$H(TV{F)# xFFFF TsDzkc9C=; 16 ;5(VF*zmT)"RZFcV{.$H1;1 I;vV{#source-string G xs:integer 5# g{ source-string GUrP,G45XD5* 0# >} TB/}5XV{.“Test literal”D$H# fn:string-length(’Test literal’) 5XD5* 12# string-to-codepoints /} fn:string-to-codepoints /}5XT&ZV{.5D Unicode zkcrP# o( fn:string-to-codepoints(source-string) source-string *Td5X?vV{D Unicode zkcDV{.5,r_GUrP# 5XD5 g{ source-string "GUrP,$H;*c,G45XD5* xs:integer 5rP,b) 5m> source-string PDV{Dzkc# g{ source-string GUrP"R$H*c,G45XD5GUrP# >} TB/}5XzkcrP,b)zkcm>V{.“XQuery”PDV{# fn:string-to-codepoints("XQuery") 5XD5* (88,81,117,101,114,121)# Z 5 B ZC/} 179 subsequence /} fn:subsequence /}5XrPDSrP# o( fn:subsequence(source-sequence,start ) ,length source-sequence SPlwSrPDrP# source-sequence GNbrP,|(UrP# start SrPZ source-sequence PDp<;C#source-sequence DZ;v;C* 1# g{ start<=0,G4 start hC* 1# start D}]`M* xs:double# length SrPPDn}#length D1!5G source-sequence PDn}#g{ start+length-1 sZ source-sequence D$H,G4 length hC* (source- sequence D$H)-start+1# length D}]`M* xs:double# 5XD5 g{ source-sequence "GUrP,G45XD5G source-sequence DSrP,dp< ;C* start "R|, length n# g{ source-sequence GUrP,G4a5XUrP# >} TB/}5XrP (’T’,’e’,’s’,’t’,’ ’,’s’,’e’,’q’,’u’,’e’,’n’,’c’,’e’) PSZ 6 n*} TB/}5Xp} TB/}9C1!{mZV{.“DEFABCD”PR=“ABC”.sDV{# fn:substring-after(’DEFABCD’, ’ABC’) 5XD5*“D”# substring-before /} fn:substring-before /}5XV{.P;ZZ;NvVDX(QwV{.0fDS.#9 C1!{m4%dQwV{.# o( fn:substring-before(source-string,search-string) source-string *SPlwS.DV{.# source-string D}]`M* xs:string,r_GUrP#g{ source-string GUrP, G4 source-string hC*c$HV{.# search-string ;vV{.,+Qw|Z source-string PZ;NvVD;C# search-string D}]`M* xs:string,r_GUrP# TZ$HD^F search-string D$H;\,} 32000 vVZ# 5XD5 g{ source-string "GUrPrc$HV{.: v g{Z source-string D;C m &R= search-string,"R m>1,G45XD5G source-string P*} TB/}9C1!{mZV{.“DEFABCD”PR=“ABC”.0DV{# fn:substring-before(’DEFABCD’, ’ABC’) 5XD5*“DEF”# sum /} fn:sum /}5XrPPD5D\M# o( fn:sum(sequence-expression ) ,empty-sequence-replacement sequence-expression |,BPN;-S`MDnrPrUrP: v xs:float v xs:double v xs:decimal v xs:integer v xdt:untypedAtomic v xdt:dayTimeDuration v xdt:yearMonthDuration v SOfP>DN;`MIzD`M `M* xdt:untypedAtomic Ddkn+*;* xs:double#KN?F`M*;s, dkrPPDyPnXkI(}a}rS`Mf;Sx*;*+2`M#\M G9CK+2`MFcD#}g,g{dkrP|,`M* money(IzT xs:decimal)M stockprice(IzT xs:float)Dn,G4\M+9C`M xs:float xPFc# empty-sequence-replacement sequence-expression *UrP15XD5#empty-sequence-replacement IT_P T sequence-expression P>D;V}]`M# 5XD5 g{ sequence-expression "GUrP,G45XD5G sequence-expression PD5D\ M#5X5D}]`Mk sequence-expression PwnD}]`M`,,r_G sequence- expression Pwna}AD}]`M# g{ sequence-expression GUrP,"R48( empty-sequence-replacement,G4 fn:sum a5X 0.0E0#g{ sequence-expression GUrP,"R8(K empty-sequence- replacement,G4 fn:sum a5X empty-sequence-replacement# >} TB/}5XrP (500, 1.0E2, 40.5) .M: fn:sum((500, 1.0E2, 40.5)) Z 5 B ZC/} 183 b)5+a}A xs:double }]`M#C/}5X xs:double 5 6.405E2,|+TrP /==m>*“640.5”# timezone-from-date /} fn:timezone-from-date /}5X xs:date 5D1x?V# o( fn:timezone-from-date(date-value) date-value *SPi!1x?VDUZ5# date-value D`M* xs:date,r_*UrP# 5XD5 g{ date-value D`M* xs:date "R_PT=1x?V,G45XD5`M* xdt:dayTimeDuration,"R5D6'Z -PT14H = PT14H .d(|,=_)#C5G UTC 1xk date-value 1x?VD+n# g{ date-value ;PT=1x?V,r_*UrP,G45XD5GUrP# >} TB/}5XUZ5 2007 j 3 B 13 U(UTC-8 1x)D1x?V# fn:timezone-from-date(xs:date("2007-03-13-08:00")) 5XD5* -PT8H# timezone-from-dateTime /} fn:timezone-from-dateTime /}5X xs:dateTime 5D1x?V# o( fn:timezone-from-dateTime(dateTime-value) dateTime-value *SPi!1x?VD dateTime 5# dateTime-value D`M* xs:dateTime,r_GUrP# 5XD5 g{ dateTime-value D`M* xs:dateTime "R_PT=1x?V,G45XD5`M * xdt:dayTimeDuration,"R5D6'Z -PT14H = PT14H .d(|,=_)#C5 G UTC 1xk dateTime-value 1x?VD+n# g{ dateTime-value ;PT=1x?V,r_*UrP,G45XD5GUrP# 184 XQuery N< >} TB/}5X dateTime 5 2005 j 10 B 30 UOg 7:30(UTC-8 1x)D1x? V# fn:timezone-from-dateTime(xs:dateTime("2005-10-30T07:30:00-08:00")) 5XD5* -PT8H# TB/}5X dateTime 5 2005 j 1 B 1 UBg 2:30(UTC+10:30 1x)D1x ?V# fn:timezone-from-dateTime(xs:dateTime("2005-01-01T14:30:00+10:30")) 5XD5* PT10H30M# timezone-from-time /} fn:timezone-from-time /}5X xs:time 5D1x?V# o( fn:timezone-from-time(time-value) time-value *SPi!1x?VD1d5# time-value D`M* xs:time,r_GUrP# 5XD5 g{ time-value D`M* xs:time "R_PT=1x?V,G45XD5`M* xdt:dayTimeDuration,"R5D6'Z -PT14H = PT14H .d(|,=_)#C5G UTC 1xk time-value 1x?VD+n# g{ time-value ;PT=1x?V,r_*UrP,G45XD5GUrP# >} TB/}5X1d5Pg 12 c(UTC-5 1x)D1x?V# fn:timezone-from-time(xs:time("12:00:00-05:00")) 5XD5* -PT5H# ZTB/}P,1d5Bg 1:00 ;P1x?V# fn:timezone-from-time(xs:time("13:00:00")) 5XD5GUrP# tokenize /} fn:tokenize /}+V{.V*;5PS.# Z 5 B ZC/} 185 o( fn:tokenize( source-string , pattern ) , flags source-string *VnIS.rPDV{.# source-string G xs:string 5rUrP# pattern source-string PDS..dD(g{# pattern G|,}rmo=D xs:string 5#}rmo=GCZZQw#=P(e ;vr;iV{.DV{"(d{MKc{/O# flags ;v xs:string 5,I|,BPCZXF pattern k source-string PV{D%d ivDNN5: s 8>}rmo=PDc(.)k|(;P{ X’0A’ ZZDNbV{`% d g{48(j>,G4c(.)k;P{(X’0A’)TbDNbV{` %d# m 8>ekjG(^)kPD*7(;P{.sD;C)`%d,x@* {E($)kPDa2(;P{.0D;C)`%d# g{48( m j>,G4ekjG(^)kV{.D*7`%d,"R @*{E($)kV{.Da2`%d# i j6%dG;xVs!4D# g{48( i j>,G4a4PxVs!4%d# x 8> pattern PDUqV{a;vT# g{48( x j>,G4UqV{aCZ%d# TZ$HD^F source-string M pattern D$H;\,} 32000 vVZ# 5XD5 g{ source-string "GUrPrc$HV{.,G45XD5GT source-string 4P BPYw1zIDrP: v +Qw source-string TiRk pattern `%dDV{# v g{ pattern |,=ir|`8CV{/,G4k source-string PV{`%dD pat- tern PDZ;iV{;S*%d#=# v k pattern ;%dD?iV{+I*a{rPPD;n# v g{ pattern k source-string *7DV{`%d,G45XrPPDZ;nGc$H V{.# v g{ source-string P"VT& pattern D=v,x%dn,G4arrPmSc$H V{.# v g{ pattern k source-string a2DV{`%d,G45XrPPDns;nGc$ HV{.# 186 XQuery N< g{Z source-string PR;= pattern,G4a5Xms# g{ source-string GUrPrc$HV{.,G4a{*UrP# >} TB/}(}V{.“Tokenize this sentence, please.”4(rP#“\s+”G;v}rmo=, CZ8>;vr`vV{# fn:tokenize("Tokenize this sentence, please.", "\s+") 5XD5GrP (″Tokenize″, ″this″, ″sentence,″, ″please.″)# translate /} fn:translate /}+V{.PDy!V{f;*f;V{# o( fn:translate(source-string,original-string,replacement-string) source-string **;dPDV{DV{.# source-string D}]`M* xs:string,r_GUrP# original-string |,I*;DV{DV{.# original-string D}]`M* xs:string# replacement-string ;vV{.,||,DV{+f; original-string PDV{# replacement-string D}]`M* xs:string# g{ replacement-string D$HsZ original-string D$H,G4 replacement- string PD``V{a;vT# TZ$HD^F original-string M replacement-string D$H;\,} 32000 vVZ# 5XD5 g{ source-string "GUrP,G45XD5G4PBPYw1zID xs:string 5: v TZ source-string PvVZ original-string PD?vV{,&+ source-string PD V{f;* replacement-string PDT&V{,CV{DvV;Ck original-string P DV{vV;C`,#9C~xFHO4%dV{# g{ original-string D$HsZ replacement-string D$H,G4&Z source-string P >}vVZ original-string PD?vV{,+ original-string PDV{;C;Xk replacement-string PDV{;C`T&# g{3vV{Z original-string PvV`N,G4CV{Z original-string PZ;N vVD;C+7( replacement-string P9CDV{# Z 5 B ZC/} 187 v TZ source-string P4vVZ original-string PD?vV{,&+CV{#t-4# g{ source-string GUrP,G4a5Xc$HV{.# >} TB/}5XZV{.“Test literal”P+ e f;* o "+ l f;* m xzIDV{ .# fn:translate(’Test literal’,’el’,’om’) 5XD5*“Tost mitoram”# TB/}5XZV{.DV“Another test literal”PxPTBf;szIDV{.:A f ;* B,t f;* f,e f;* i "R r f;* m# fn:translate(’Another test literal’, ’Ater’, ’Bfim’) 5XD5*“Bnofhim fisf lifimal”# true /} fn:true /}5X xs:boolean 5 true# o( fn:true() 5XD5 5XD5* xs:boolean 5 true# >} 9C true /}T5X5 true# fn:true() 5XD5* true# unordered /} fn:unordered /}T;7(D3r5XrPPDn# o( fn:unordered(sequence-expression) sequence-expression NNrP,|(UrP# 188 XQuery N< 5XD5 5XD5G sequence-expression P4;7(3rEPDn#baozi/E/w!q@ "ZrPPwnEP3rDf!76# >} TB/}T;7(D3r5XrP (1,2,3) PDwn# fn:unordered((1,2,3)) upper-case /} fn:upper-case /}+V{.*;*s4# o( fn:upper-case(source-string ) , locale-name source-string **;*s4DV{.# source-string D}]`M* xs:string,r_GUrP# locale-name |,*CZs4YwDoT73DV{.# locale-name D`M* xs:string,r_GUrP#g{ locale-name "GUrP, G4 locale-name D5G;xVs!4D,"RXkGP'oT73rc$HV {.# 5XD5 g{ source-string "GUrP,G45XD5* source-string,"R?vV{a*;* T&s4#g{ locale-name 48("*UrPr_Gc$HV{.,G4a9C Uni- code j} TB/}a+V{.“Test literal 1”*;*s4# fn:upper-case(’Test literal 1’) 5XD5*“TEST LITERAL 1”# TB/}8(AzdoT73 tr_TR "*;V8“i”0}VV{}C ı(-!!4 V8^c i DV{}C)# fn:upper-case("iı", "tr_TR") Z 5 B ZC/} 189 5XD5I=vV{iI:İ m>DV{(-!s4 I,OfPc)MV8“I”# TZAzdoT73,V8“i”+*;* İ m>DV{(-!s4 I,OfP c),x ı m>DV{(-!!4V8^c i)+*;*V8“I”# TB/}48(oT73,"9C Unicode j} 5XD5rPD>}:TB/}5X XML D5rP,b)D5f"Zm PRODUCT D XML P DESCRIPTIONT P,TZK>},Cm;Z SQL #= SAMPLE P# db2-fn:xmlcolumn(’SAMPLE.PRODUCT.DESCRIPTION’) 9C~= SQL #=D>}:ZTB>}P,DB2 }]bPD CURRENT SCHEMA ( CDfwhC* SAMPLE,yTC/}5XDa{kO;>}`,: db2-fn:xmlcolumn(’PRODUCT.DESCRIPTION’) 190 XQuery N< 9C SQL (gj6D>}:TB/}5Xf"Zm“Student”DP“Thesis”PDD5r P,Y(Cm;Z108(x CURRENT SCHEMA D#=P#r*m{MP{|,! 4V{,yTI9C=V==Z db2-fn:xmlcolumn /}DV{.DVTd?PTdxP 8(: v 8(* SQL (gj6((Z+}EP): db2-fn:xmlcolumn(’"Student"."Thesis"’) v 8(*V{.x;8>|GG SQL (gj6: db2-fn:xmlcolumn(’Student.Thesis’) `4,RGh* db2-fn:sqlquery /}P9CD`,mMPE"E\4gB==9C SQL (gj6: db2-fn:sqlquery(’select "Thesis" from "Student"’) year-from-date /} fn:year-from-date /}5X xs:date 5Dj]?V# o( fn:year-from-date(date-value) date-value *SPi!j]?VDUZ5# date-value D`M* xs:date,r_*UrP# 5XD5 g{ date-value D`M* xs:date,G45XD5`M* xs:integer,C5G date-value Dj]?V,"RGG:5# g{ date-value GUrP,G45XD5GUrP# >} TB/}5XUZ5 2005 j 10 B 29 UDj]?V# fn:year-from-date(xs:date("2005-10-29")) 5XD5* 2005# year-from-dateTime /} fn:year-from-dateTime /}5X xs:dateTime 5Dj]?V# o( fn:year-from-dateTime(dateTime-value) dateTime-value *SPi!j]?VD dateTime 5# Z 5 B ZC/} 191 dateTime-value D`M* xs:dateTime,r_GUrP# 5XD5 g{ dateTime-value D`M* xs:dateTime,G45XD5`M* xs:integer#C5G dateTime-value Dj]?V,"RGG:5# g{ dateTime-value GUrP,G45XD5GUrP# >} TB/}5X dateTime 5 2005 j 10 B 29 UOg 8:00(UTC-8 1x)Dj]? V# fn:year-from-dateTime(xs:dateTime("2005-10-29T08:00:00-08:00")) 5XD5* 2005# years-from-duration /} fn:years-from-duration /}5XVx1dDj}?V# o( fn:years-from-duration(duration-value) duration-value *SPi!j}?VDVx1d5# duration-value G U r P , r _ G B P d P ; v ` M D 5 : xdt:dayTimeDuration"xs:duration r xdt:yearMonthDuration# 5XD5 5X5!vZ duration-value D`M: v g{ duration-value D`M* xdt:yearMonthDuration r_* xs:duration,G45XD 5`M* xs:integer#C5G*;* xdt:yearMonthDuration D duration-value Dj} ?V#g{ duration-value *:5,G4C5*:5# v g{ duration-value D`M* xs:dayTimeDuration,G45XD5`M* xs:integer " R5* 0# v g{ duration-value GUrP,G45XD5GUrP# *;* xdt:yearMonthDuration D duration-value j}?VGI*;* xdt:yearMonthDuration D duration-value \B}}T 12 7(D# >} TB/}5XVx1d -4 j -11 vB -320 lDj}# fn:years-from-duration(xs:duration("-P4Y11M320D")) 5XD5* -4# TB/}5XVx1d 9 jc 13 vBDj}?V# 192 XQuery N< fn:years-from-duration(xdt:yearMonthDuration("P9Y13M")) 5XD5* 10#FcVx1dD\j}1,13 vB+*;* 1 jc 1 vB#Vx1 dHZ P10Y1M,dj}?V* 10 j# zero-or-one /} g{Td?|,;nr*UrP,G4 fn:zero-or-one /}5XTd?# o( fn:zero-or-one(sequence-expression) sequence-expression NNrP,|(UrP# 5XD5 g{ sequence-expression |,;nr_GUrP,G4a5X sequence-expression#q ra5Xms# >} TB>}9C fn:zero-or-one /}47(d? $seq PDrPGq|,;nrcn# let $seq := (5,10) return fn:zero-or-one($seq) 5Xms,-rGrP|,=n# Z 5 B ZC/} 193 194 XQuery N< Z 6 B}rmo= }rmo=G;vV{rP,b)V{d1%dMYwV{.D#=# }rmo=CZBP XQuery /}:fn:matches"fn:replace M fn:tokenize#DB2 XQuery }rmo='VyZ W3C Recommendation XML Schema Part 2: Datatypes Second Edi- tion P(eD XML #=}rmo='VT0 W3C Recommendation XQuery 1.0 and XPath 2.0 Functions and Operators (eD)9# o( RegularExpression (1) Branch pipeChar Branch Branch: Atom Quantifier Atom: normalCharacter CharClassExpression CharClassEscape ^ $ ( RegularExpression ) Quantifier: * + ? { min } min , max ? CharClassExpression: [ CharGroup ] © Copyright IBM Corp. 2006, 2013 195 CharGroup: XMLCharIncludeDash ^ XMLChar dashChar XMLChar charEscape charEscape CharClassEscape CharClassEscape: . charEscape multiCharEscape \nonZeroDigit \p{IsblockName} \P{IsblockName} \p{charProperty} \P{charProperty} ": 1 }rmo=Do(m>V{.DVZ],|;\|,_Pw*#=V{DUqV {DXb,eTbDUqV{#;*+o(*X.dDUqr?VS*Jm9C NNN=DUq# RegularExpression }rmo=|,;vr`vV'#V'C\@(|)t*,8>?vV'C#=XkSV{.*7%d# $ ZV'a29C1,@*{E($)8>C#=XkSV{.Da2%d# Quantifier ?J8(-SZ}rmo=DX4J}#1!ivB,?Ja9CF*07c(D= =!?k?jV{.xP%d#}g,}rmo= ’A.*A’ k{vV{. ’ABACADA’ %d,-rGXhDb? ’A’ V{.dDS.{OTNbV{D*sNbN}#I(} Z?Js8(JE(?)V{4|D1!07c(#JE8(C#=%d9Cc?c (,bak?jV{.Pzc}rmo=DB;vnLS.xP%d(4SsARD 3r)#}g,}rmo= ’A.*?A’ akS. ’ABA’ M ’ADA’ %d,x;Gk{v 196 XQuery N< V{. ’ABACADA’ %d#(}9Cc?c(k}rmo=%dDS.V{;axP| x;=D%d#bMG ’ACA’ ZO;>}P4;S*%dnD-r#c?c(k fn:replace /};p9C1\Poz,-rG|a4SsARD3r&m%dMxPf ;# }g,g{Z/} fn:replace("nonsensical","n(.*)s","mus") P9C07c(+T “n”*7“s”a2DV{.f;*V{.“mus”,G45XD5*“musical”#-9C c?c(x;G07c(# min k-S%dAY min N#min Xk*}{}# v {min} k-S}C%d min N# v {min,}k-S%dAY min N# max k-S%d;,} max N#max Xk*sZrHZ min D}{}# v {0, max} k-S%d;,} min N# v {0, 0} vkUV{.%d# CharGroup ^ 8>I CharGroup D`B?V(eDV{iD9d?V# dashChar i_V{(-)at*CZ(e;(V{6'PDb?V{D=vV{#q=* s-e DV{6'G;i UCS2 zkc,b)zkcsZrHZ s "R!ZrHZ e: v s ;G41\(\) v g{ s G CharGroup PDZ;vV{,G4|;GekjG(^) Z 6 B}rmo= 197 v e ;G41\(\)rs=(E([) v e DzkcsZ s Dzkc XMLCharIncludeDash P' XML V{D%V{N=,E}41\(\)M=(E([]),+|(i_V{ (-)#i_V{;PvVZ CharGroup D*7ra2EGP'V{#CharGroup * 7DekjG(^)8>iD9d?V#ekjGvVZiPDNNd{;C1v kekjG`%d#XMLCharIncludeDash I|(y]}rmo= [^\#5B#5D] %d DNNV{# XMLChar P' XML V{D%V{N=,E}41\(\)"=(E([])Mi_V{(-)# i_V{;PvVZ CharGroup D*7ra2EGP'V{#CharGroup *7De kjG(^)8>iD9d?V#ekjGvVZiPDNNd{;C1vkek jG`%d#XMLChar I|(y]}rmo= [^\#2D#5B#5D] %dDNNV{# charEscape 41\,sz%v*V{";P{"X5{rxxV{#XkZ}rmo=PTm 38 PDV{*eTxP%d# m 38. P'*V{*e V{*e m>DV{ hv \n #x0A ;P \r #x0D X5 \t #x09 Fm{ \\ \ 41\ \| | \@ \. . dc \- - ,V{ \^ ^ ekjG \? ? JE \$ $ @*{E \* * GE \+ + SE \{ { s((E \} } R((E \( ( s2(E \) ) R2(E \[ [ s=(E \] ] R=(E CharClassEscape . dcV{(.)k;P{MX5{TbDyPV{`%d#dcV{H[Zmo= [^\n\r]/ 198 XQuery N< \nonZeroDigit 8(ky]Smo=%dDV{.`%dDrs}C,CSmo=Z}rmo=P D nonZeroDigit ;CGC2(E(p4D#nonZeroDigit XkZ 1 = 9 .d#I }C0 9 vSmo=# ":*K+45VrOf]T,g{rs}Csz}VV{,G4&+rs}C( Z2(EP#}g,Tsz}V 3 DZ;vSmo=Drs}C&m>* (/1)3 x ;G /13,49=_?0azI,;a{2GgK# \P{IsblockName} 8( Unicode zkc6'D9d?V#6'I blockName j6,g XML Schema Part 2: Datatypes Second Edition PP>DGy# \p{IsblockName} ZX(6'D Unicode zkcP8(V{#6'I blockName j6,g XML Schema Part 2: Datatypes Second Edition PP>DGy# charEscape 41\,sz%v*V{";P{"X5{rxxV{#XkZ}rmo=PTZ 198 3Dm 38 PDV{*eTxP%d# multiCharEscape ;v41\,sz;vV{,CZZ}rmo=Pj6m 39 PD#CV{/TxP %d# m 39. `V{*e `V{*e H[}rmo= hv \s [#x20\t\n\r] Uq"Fm{";PrX5{# \S [^\s] Uq"Fm{";PrX5{TbDNNV{# \i ^ Jmw* XML {FDZ;vV{DV{/# \I [^\i] ;ZJmw* XML {FDZ;vV{DV{/P# \c ^ XML {FPJm9CDV{/# \C [^\c] Z XML {FP;Jm9CDV{/P# \d \p{Nd} .xF}# \D [^\d] G.xF}# \w [#x0000-#x10FFFF]-[\ p{P}\p{Z}\p{C}] %JV{,|(BP charProperty `p:V8"jG" {EM}V# \W [^\w] G%JV{,|(BP charProperty `p:jc"Vt {0d{# \p{charProperty} 8(3v`pPD3vV{#`pP>Zm 40 P# \P{charProperty} 8(V{`pD9d?V#`pP>Zm 40 P# m 40. charProperty D\'V5 charProperty `p hv L V8 yPV8 Lu V8 s4 Z 6 B}rmo= 199 m 40. charProperty D\'V5 (x) charProperty `p hv Ll V8 !4 Lt V8 jb Lm V8 ^N{ Lo V8 d{ M jG yPjG Mn jG Gdt Mc jGdtiO Me jG bU N }V yP}V Nd }V .xF} Nl }VV8 q }V d{ P jc yPjc Pc jc ,S{ Pd jc ,V{ Ps jc s Pe jc R Pi jc u<}E(y]C(,P*==`F Ps r Pe) Pf jc nU}E(y]C(,P*==`F Ps r Pe) Po jc d{ Z Vt{ yPVt{ Zs Vt{ Uq Zl Vt{ P Zp Vt{ N S {E yP{E Sm {E }' Sc {E uR Sk {E ^N{ So {E d{ C d{yPd{ Cc d{ XF Cf d{ q= Co d{ (C Cn d{ 48( ":9C~xFHO4%d}rmo=#;9C1!{m# 200 XQuery N< Z 7 B ^F DB2 XQuery fZs!M}]`M=fD^F# XQuery }]`MD^F >wbj6X( DB2 XQuery }]`MJmD5D6'# m 41. XQuery }V}]`MD^F }]`M n!5 ns5 d{^F xs:float -3.4028234663852886e+38 +3.4028234663852886e+38 n ! } 5 : +1.1754943508222875e-38 n s : 5:-1.1754943508222875e-38 xs:double -1.7976931348623158e+308 +1.7976931348623158e+308 n ! } 5 : +2.2250738585072014e-308 n s : 5 : +2.2250738585072014e-308 xs:decimal ;IC ;IC ns.xF+H:31 ; xs:integer -9 223 372 036 854 775 808 +9 223 372 036 854 775 807 xs:nonPositiveInteger -9 223 372 036 854 775 808 0 xs:negativeInteger -9 223 372 036 854 775 808 -1 xs:long -9 223 372 036 854 775 808 9 223 372 036 854 775 807 xs:int -2 147 483 648 +2 147 483 647 xs:short -32 768 +32767 xs:byte -128 +127 xs:nonNegativeInteger 0 +9 223 372 036 854 775 807 xs:unsignedLong 0 +9 223 372 036 854 775 807 xs:unsignedInt 0 4 294 967 295 xs:unsignedShort 0 +65 535 xs:unsignedByte 0 +255 xs:positiveInteger +1 +9 223 372 036 854 775 807 m 42. XQuery UZ"1dMVx1d}]`MD^F }]`M n!5 ns5 xs:duration -P83333333333333Y3M11574074074DT1H46M39.999999S P83333333333333Y3M11574074074DT1H46M39.999999S xdt:yearMonthDuration -P83333333333333Y3M P83333333333333Y3M xdt:dayTimeDuration -P11574074074DT1H46M39.999999S P11574074074DT1H46M39.999999S xs:dateTime 0001-01-01T00:00:00.000000Z 9999-12-31T23:59:59.999999Z xs:date 0001-01-01Z 9999-12-31Z xs:time 00:00:00Z 23:59:59Z xs:gDay 01Z 31Z © Copyright IBM Corp. 2006, 2013 201 m 42. XQuery UZ"1dMVx1d}]`MD^F (x) }]`M n!5 ns5 xs:gMonth 01Z 12Z xs:gYear 0001Z 9999Z xs:gYearMonth 0001-01Z 9999-12Z xs:gMonthDay 01-01Z 12-31Z ":DB2 XQuery ;'V:UZr:1d# s!^F DB2 XQuery DV{.DVMi/fZs!^F# V{.DVDs!^F* 32672 vVZ# i/$HDs!^F* 2 097 152 VZ# 202 XQuery N< =< A. DB2 Lr – LL v DB2 i. – PDF D~(IBX) – PDF D~(Z DB2 PDF DVD P) – !"fi. v |nPoz – |noz – {"oz ":DB2 E"PDwbD|B5JH PDF i.r2=4i.D|B5J_#*q!n BE",k20ICDD5|Br_ND ibm.com OD DB2 E"PD# zITZ_CJ ibm.com ODd{ DB2 c:http:// www.ibm.com/software/data/sw-library/# D54! RGG#XSzT DB2 D5D4!#g{zkMgNDF DB2 D5av(i,kr db2docs@ca.ibm.com "MgSJ~#DB2 D5!i+DAzDyP4!,+^(1S xzp4#k!I\a)_eD>},byRGE\|CXKbzyXDDJb#g {z*a)PX_ewbrozD~D4!,kSOjbM URL# k;*9CTOgSJ~X7k DB2 M''Vz9*5#g{zv=D5^(bvD DB2 M-kf># !\b)mj6i.P!"f,+I\4ZzyZzRrXxa)# ?N|BVa1,m%EDVaDnBf># ":DB2 E"PDD|B5JH PDF r2=4i.D|B5J_# © Copyright IBM Corp. 2006, 2013 203 m 43. DB2 SQL 4,oz DB2 z7kTI\d1 SQL oda{Du~5X SQLSTATE 5#SQLSTATE oz 5w SQL 4,M SQL 4,`zkD,e# }L *t/ SQL 4,oz,kr*|nP&mw"dk: ? sqlstate or ? class code =< A. DB2 P'D 5 ; SQL 4,,class code m>C SQL 4,D0 2 ;# }g,? 08003 T> 08003 SQL 4,Doz,x ?08T> 08 `zkDoz# CJ;,f>D DB2 E"PD zITZ ibm.com® OD;,E"PDPR=d{f> DB2 z7DD5# XZKNq TZ DB2 V10.1 wb,DB2 E"PD URL G http://publib.boulder.ibm.com/infocenter/ db2luw/v10r1# TZ DB2 V9.8 wb,DB2 E"PD URL G http://publib.boulder.ibm.com/infocenter/ db2luw/v9r8/# TZ DB2 V9.7 wb,DB2 E"PD URL G http://publib.boulder.ibm.com/infocenter/ db2luw/v9r7/# TZ DB2 V9.5 wb,DB2 E"PD URL G http://publib.boulder.ibm.com/infocenter/ db2luw/v9r5# TZ DB2 V9.1 wb,DB2 E"PD URL G http://publib.boulder.ibm.com/infocenter/ db2luw/v9/# TZ DB2 V8 wb,k*A DB2 E"PD URL:http://publib.boulder.ibm.com/infocenter/ db2luw/v8/# |B20ZFczrZ?x~qwOD DB2 E"PD 20Z>XD DB2 E"PDXk(ZxP|B# *<.0 XkQ20 DB2 V10.1 E"PD#PXj8E",kND20 DB2 ~qwPD“9C DB2 20r<420 DB2 E"PD”wb#yPJCZ20E"PDDHvu~M^ F,yJCZ|BE"PD# XZKNq ITT/rV/|BVPD DB2 E"PD: v T/|B+|BVPDE"PD&\?~MoT#T/|BD;vEcG,kV/ |B`H,E"PDD;IC1dOL#mb,T/|BIhC*w*(ZKPD d{z&mw5D;?VKP# v IT9CV/|B=(4|BVPDE"PD&\?~MoT#T/|BITuL |B}LPD#z1d,+g{zkmS&\?~roT,G4Xk4PV/} L#}g,g{>XE"PDnu20DG"oM(of,xVZ9*20Bo f;G4V/|B+20Bof,"|BVPE"PDD&\MoT#+G,V/ |B*szV/#9"|BMXBt/E"PD#Z{v|B}LZdE"PD; IC#ZT/|B}LP,E"PDvZ|BjIs#9$wTXBt/E"P D# 206 XQuery N< Kwbj85wKT/|BD}L#PXV/|BD8>E",kND“V/|B20 ZzDFczrZ?x~qwOD DB2 E"PD”wb# }L *T/|B20ZFczrZ?x~qwOD DB2 E"PD: 1. Z Linux Yw53O, a. /@AE"PDD20;C#1!ivB,DB2 E"PD20Z /opt/ibm/ db2ic/V10.1 ?: update-ic 2. Z Windows Yw53O, a. r*|n0Z# b. /@AE"PDD20;C#1!ivB,DB2 E"PD20Z \IBM\DB2 Information Center\V10.1 ? m > Program Files ?BDT0|BsD wb#g{E"PD|B;IC,G4aZU>PmS{"#U>D~;Z doc\ eclipse\configuration ?D~{FGfzzID`E#}g, 1239053440785.log# V/|B20ZFczrZ?x~qwOD DB2 E"PD g{zQZ>X20 DB2 E"PD,G4IS IBM q!D5|B"xP20# XZKNq V/|B20Z>XD DB2 E"PD*sz: 1. #9FczOD DB2 E"PD,;sT@"==XBt/E"PD#g{T@"= =KPE"PD,G4xgODd{C'+^(CJE"PD,rxzIT&C| B#DB2 E"PDD$w>f>\GT@"==KP# 2. 9C“|B”&\?~4i4ICD|B#g{PzXk20D|B,G4k9C“ |B”&\?~4q!"20b)|B# ":g{zD73*sZ;(4,SArXxDzwO20 DB2 E"PD|B,k 9C;(Q,SArXx"Q20 DB2 E"PDDzw+|B>c5qA>XD~ 53#g{xgPPm`C'+20D5|B,G4IT(}Z>X2*|B>c Fw5q"*|B>c4(zm4uL?vK4P|Byh*D1d# g{a)K|B|,k9C“|B”&\?~4q!b)|B|#+G,;PZ%z ==BE\9C“|B”&\?~# =< A. DB2 O,TsP>ZK?VD|nXk w*\m1KP#*r*_P+f\m1X(D|na>{r XFfe > \m$_ > ~q#R|%w DB2 E "PD~q,"!q#9# v Z Linux O,dkTB|n: /etc/init.d/db2icdv10 stop 2. T@"==t/E"PD# v Z Windows O: a. r*|n0Z# b. / @ A E " P D D 2 0 ; C # 1 ! i v B , DB2 E " P D 2 0 Z Program_Files\IBM\DB2 Information Center\V10.1 ? Program Files ?: help_start 531! Web /@w+r*TT>@"E"PD# 3. %w|B4%( )#(XkZ/@wPtC JavaScript#) ZE"PDDR_f eO,%wiR|B# +T>VPD5D|BPm# 4. *t/20}L,kliz*20D!n,;s%w20|B# 5. Z20xLjIs,k%wjI# 6. *#9@"E"PD,k4PBPYw: v Z Windows O,/@A20?: help_end 208 XQuery N< ":help_end E>|,2+X#99C help_start E>t/DxLyhD|n# ;*9CNNd{=(4#9 help_start E># 7. XBt/ DB2 E"PD# v Z Windows O,%w*< > XFfe > \m$_ > ~q#R|%w DB2 E "PD~q,"!qt/# v Z Linux O,dkTB|n: /etc/init.d/db2icdv10 start a{ |BsD DB2 E"PD+T>BDT0|BsDwb# DB2 LL DB2 LLozzKb DB2 }]bz7Dwv=f#b)NLa)Kp=8>E"# *<.0 zITZE"PDPi4 XHTML fDLL:http://publib.boulder.ibm.com/infocenter/ db2luw/v10r1/# 3)NL9CKy>}]rzk#PXdX(NqDNNHvu~Dhv,kNDL L# DB2 LL *i4LL,k%wjb# pureXML 8OPD:pureXML®; hC DB2 }]bTf" XML }]T0T>z XML }]f"w4Py>Y w# DB2 JOoOE" RGa)KwVwyDJOoOMJb7(E"4ozz9C DB2 }]bz7# DB2 D5 zITZ6JOoOMw{}]bT\7r_ DB2 E"PDD“}]by!”? VPR=JOoOE",b)E"|,TBZ]: v PXgN9C DB2 oO$_M5CLr4tkM7(JbDE"# v ;)n#{JbDbv=8# v ca)K8rnB DB2 vfo"x7*:http://www.ibm.com/support/entry/portal/Overview/ Software/Information_Management/DB2_for_Linux,_UNIX_and_Windows =< A. DB2 cD9Cun0TBunMu~# vK9C:;*#tyPD(P(yw,zMIT*vK"GL59C4Fb)vf o#4- IBM w7,b,z;ITV""9>rFwb)vfordPNN?VD] ow7# L59C:;*#tyPD(P(yw,zMITvZs5Z4F"V"M9>b) vfo#4- IBM w7,b,z;ITFwb)vfoD]ow7,r_ZzDs5 b?4F"V"r9>b)vfordPDNN?V# ({:}G>mI(Pw7Zh,qr;CZhTb)vfordP|,DNNE ""}]"m~rd{*6z(DNNmI("mI$r({,^[Gw>D9G5 ,D# IBM #ty]TmDPO,O*TvfoD9Cp&K IBM D(f(I IBM Tm7 ()r4}7q-TO8>E"1,7XK&yZh(^D({# ;Pzj+q-yPJCD(IM(f,|(yPD@zvZ(IM(f,zEIT BX"vZrYvZCE"# IBM Tb)vfoDZ];wNN#$#b)vfo“4V4”a),;=PNNV`D (^[Gw>D9G5,D)#$,|(+;^Z5,DXZJzMJCZ3VX( C>D#$# IBM® Lj: IBM" IBM UjM ibm.com G International Business Machines Corp., Z+rm`\=xr"aDLjr"aLj#d{z7M~q{FI\G IBM rd{ +>DLj#10D IBM LjPm,IS Web >c www.ibm.com/legal/ copytrade.shtmlqC 210 XQuery N< =< B. yw >E"G*Z@za)Dz7M~q`4D#PXG IBM z7DE"GyZWNvf KD51DIqE"Raf1|B# IBM I\Zd{zRrXx;a)>D5PV[Dz7"~qr&\XT#PXz10 yZxrDz7M~qDE",krz1XD IBM zmI/#NNT IBM z7"L rr~qD}C"GbZw>r5>;\9C IBM Dz7"Lrr~q#;*;V8 IBM D*6z(,NN,H&\Dz7"Lrr~q,I\Q5Pr}Zjkk>D5Z]PXDwn({#a)>D5"4ZhC '9Cb)({DNNmI#zITCif==+mIi/Dy: IBM Director of Licensing IBM Corporation North Castle Drive Armonk, NY 10504-1785 U.S.A. PX+VZV{/ (DBCS) E"DmIi/,kkzyZzRrXxD IBM *6z( ?E*5,rCif==+i/Dy: Intellectual Property Licensing Legal and Intellectual Property Law IBM Japan, Ltd. 1623-14, Shimotsuruma, Yamato-shi Kanagawa 242-8502 Japan >un;JC"zrNNbyDunk1X(I;;BDzRrXx:International Busi- ness Machines Corporation“4V4”a)>vfo,;=PNNV`D(^[Gw>D9 G5,D)#$,|(+;^Z5,DPXGV("JzMJCZ3VX(C>D# $#3)zRrXxZ3);WP;Jmb}w>r5,D#$#rK>unI\; JCZz# >E"PI\|,JODBf>P#IBM ITf1T>JOPhvDz7M/rLrxPD xM/r|D,x;mP(*# >E"PTG IBM Web >cDNN}C<;G*K=cp{Ea)D,;TNN== d1TG) Web >cD#$#G) Web >cPDJO;GK IBM z7JOD;? V,9CG) Web >cx4DgU+IzTPP## IBM IT4|O*J1DNN==9CrV"zya)DNNE"x^kTzP#NN pN# © Copyright IBM Corp. 2006, 2013 211 >LrD;mI=g{*KbPXLrDE"To=gB?D:(i) JmZ@"4(DL rMd{Lr(|(>Lr).dxPE";;,T0 (ii) JmTQ-;;DE"xP `%9C,kkBPX7*5: IBM Canada Limited U59/3600 3600 Steeles Avenue East Markham, Ontario L3R 9Z7 CANADA ;*qXJ1DunMu~,|(3)iNBD;(}?D6Q,JOPhvDmILr0dyPICDmIJOyI IBM @] IBM M'-i"IBM zJm~mI-irNN,H-iPDuna)# K&|,DNNT\}]D5DC'&1i$dX(73DJC}]# f0G IBM z7DE"ISb)z7D)&L"dvf5wrd{I+*qCDJO Pq!#IBM ;PTb)z7xPbT,2^(7OdT\D+7T"f]TrNNd {XZG IBM z7Dyw#PXG IBM z7T\DJb&1rb)z7D)&La v# yPXZ IBM 44=rrbrDywK?jMb8xQ# >E"I\|,ZU#5qYwP9CD}]M(fD>}#*K!I\j{X5w b)>},>}PI\a|(vK"+>"7FMz7D{F#yPb){FE"|(4oTN=Dy>&CLr,b)y>5w;,Yw=(OD`L=(# g{G*4UZ`4y>LrDYw=(OD&CLr`LSZ (API) xP&CLrD *""9C"-zrV",zITNNN=Tb)y>LrxP4F"^D"V", x^kr IBM 6Q#b)>}"4ZyPu~Bw+fbT#rK,IBM ;\##r 5>b)LrDI?T"I,$Tr&\#Ky>Lr“4V4”a),R;=PNN V`D#$#TZ9CKy>Lry}pDNNp5,IBM +;P#pN# 2b)y>LrD?]=4rdNN?VrNN\zz7,Dy>Lr\zv4D# © Copyright IBM Corp. _enter the year or years_. All rights reserved. Lj IBM Lj:IBM" IBM UjM ibm.com G International Business Machines Corp., Z +rm`\=xr"aDLjr"aLj#d{z7M~q{FI\G IBM rd{+ 212 XQuery N< >DLj#10D IBM LjPm,IS Web >c www.ibm.com/legal/ copytrade.shtml O“f(MLjE"”?Vq!# BPwnGd{+>DLjr"aLj v Linux G Linus Torvalds Z@zM/rd{zRrXxD"aLj# v Java™ MyPyZ Java DLjMUjG Oracle M/rdS+>DLjr"aLj# v UNIX G The Open Group Z@zMd{zRrXxD"aLj# v Intel"Intel Uj"Intel Inside"Intel Inside Uj"Celeron"Intel SpeedStep"Itanium M Pentium G Intel Corporation rdS+>Z@zMd{zRrXxDLjr"a Lj# v Microsoft"Windows"Windows NT M Windows UjG Microsoft Corporation Z@ zM/rd{zRrXxDLj# d{+>"z7r~q{FI\Gd{+>DLjr~qjG# =< B. yw 213 214 XQuery N< w} [B] f>yw 39 oz SQL od 205 HOmo= #f 69 Ev 67 Zc 71 5 67 _gUq yw 40 1S*X9l/} 78 _gUqyw 40 d;mo= j8E" 104 d? }C 54 Z for M let SdDwCrP 90 for SdPD;C 87 mo= HO #f 69 Ev 67 Zc 71 5 67 ek 107 X|{ 110 &m 47 (? 97 /,OBD 47 6' 63 |B XML }] 101 |B XML }]1Dms 101 9l/} &m8n 83 Ev 73 Fc&m8n 84 FctT 81 Fc*X 81 Fc"M 85 {FUdywtT 77 {FUdwCr 79 D>Zc 83 D5Zc 82 1S&m8n 84 1S*X 74 1S"M 85 9lrP 63 }K 64 O"ZcrP 64 mo= (x) 9c 47 a{3r 48 I*M 99 (Z9l/}P 73 `Ma} 51 76 Ev 56 u4o( 60 o( 56 _- 72 ?F`M*; 98 s5 47 >} 106 cu 65 f; 113 u~ 96 =J 62 rP 63 EH3r 47 P'<{5 51 -S/ 50 w* d?}C 54 x(E 54 Ev 52 /}wC 55 OBDn 55 5e}C 53 DV 52 V{}C 54 S`Mf; 51 FLWOR Ev 85 >} 93 o( 86 for M let SdHO 89 for M let Sdd?wCr 90 for M let SdEv 87 for M let Sd;p 89 for Sd 87 let Sd 88 order by Sd 91 return Sd 93 where Sd 90 transform 104 mo=D/,OBD 47 mo=D9c 47 mo=DOBD 47 <{5/} XQuery 117 © Copyright IBM Corp. 2006, 2013 215 [C] bT XQuery P5D?F`M*; 99 ekmo= 107 i/ a9 1 i/oT xVs!4 12 "M 13 XML }] 2 #fHO 69 Vx1d/} XQuery 117 Vx1d}]`M 17 X|{mo= 110 X|{Zc 110 &m3r 91 &m8nZc 9l 83 hv 9 ms XQuery |B 101 [D] x(Emo= 54 Z9l/}P 73 (?mo= 97 [E] ~xF}]`M 17 [F] 6'mo= 63 8za 58 4F{FUdyw 41 [G] |B DB2 E"PD 206, 207 |Bmo= iO 101 9l/} &m8n 83 x(Emo= 73 Fc&m8n 84 FctT 81 Fc*X 81 Fc"M 85 {FUdywtT 77 {FUdwCr 79 9l/} (x) ZC`M 21 tT 81 D>Zc 83 D5Zc 82 1S&m8n 84 1S*X 74 1S"M 85 XML 73 9lyw 40 JOoO LL 209 *zE" 209 f6 XQuery 14 f6/Vx1dq= dayTimeDuration }]`M 27 duration }]`M 28 yearMonthDuration }]`M 37 }Kmo= 64 [H] /} DB2 XQuery U 140 fr 169 }] 135 abs 126 avg 127 boolean 128 ceiling 129 codepoints-to-string 130 compare 130 concat 131 contains 131 count 132 current-date 133 current-dateTime 133 current-local-date 133 current-local-dateTime 134 current-local-time 134 current-time 134 dateTime 135 deep-equal 138 default-collation 139 distinct-values 140 ends-with 141 exactly-one 141 exists 142 false 143 floor 143 implicit-timezone 146 index-of 147 insert-before 147 in-scope-prefixes 146 216 XQuery N< /} (x) DB2 XQuery (x) last 148 local-name 148 local-name-from-QName 149 local-timezone 150 lower-case 150 matches 151 max 152 min 153 name 158 namespace-uri 159 namespace-uri-for-prefix 160 namespace-uri-from-QName 160 node-name 161 normalize-space 161 normalize-unicode 162 not 163 number 163 one-or-more 164 position 165 QName 165 remove 166 replace 167 resolve-QName 168 root 170 round 170 round-half-to-even 171 sqlquery 174 starts-with 177 string 177 string-join 178 string-length 179 string-to-codepoints 179 subsequence 180 substring 180 substring-after 181 substring-before 182 sum 183 timezone-from-dateTime 184 tokenize 186 translate 187 true 188 unordered 188 upper-case 189 xmlcolumn 190 zero-or-one 193 XQuery 4`pP> 117 <{`p 117 Vx1d`p 117 Zc`p 117 d{`p 117 UZ`p 117 1d`p 117 }V`p 117 /} (x) XQuery (x) rP`p 117 V{.`p 117 adjust-dateTime-to-timezone 123 adjust-date-to-timezone 122 adjust-time-to-timezone 125 days-from-duration 137 day-from-date 136 day-from-dateTime 136 hours-from-dateTime 144 hours-from-duration 144 hours-from-time 145 minutes-from-dateTime 154 minutes-from-duration 155 minutes-from-time 156 months-from-duration 157 month-from-date 156 month-from-dateTime 157 QName `p 117 seconds-from-dateTime 172 seconds-from-duration 173 seconds-from-time 174 timezone-from-date 184 timezone-from-dateTime 184 timezone-from-time 185 years-from-duration 192 year-from-date 191 year-from-dateTime 191 /}wC DB2 XQuery 55 szrTma 58 sza 58 [J] y>`M*; 21 Fc9l/} &m8n 84 Ev 73 tT 81 *X 81 comment 85 LL JOoO 209 Pm 209 Jb7( 209 pureXML 209 Zc HO 71 j6 10 cNa9 9 X4 10 }% 106 &m8n 9l 83 w} 217 Zc (x) &m8n (x) hv 9 Ev 5, 7 O"rP 64 `M5 10 >} 106 tT 7, 8 D5 9l 82 hv 7 *X 8 V{.5 10 comment 9l,Ev 85 Fc9l/} 85 hv 9 1S9l/} 85 text 9l 83 hv 9 XQuery ek 107 XQuery /} 117 ZcbT 59 ZcDj6 10 ZcDcNa9 9 ZcD`M5 10 ZcDV{.5 10 ZcMZc5,f; 113 Zc{ |D 110 a{ mo=3r 48 a{3r 48 2,Q*{FUd 79 [K] I*Mmo= 99 Uq _g 40 hv 13 Z1S*X9l/}P 78 UEryw 43 UrP Er 43 )9 QName j8E" 11 *; 168 [L] `M kND}]`M 17 `McNa9 15 `Ma} 51 `M*; 21 76mo= hv 56 u4MGu4o( 60 o( 56 a=h 58 _-mo= 72 [M] {FbT 59 {FUd s(0: 77 /}1!5 42 1!*X/`M 42, 77 hC1!5 77 yw 44 wCr 79 XML 11 {FUdyw 44 {FUdywtT 77 {FUdwCr 79 [N] ZC/} XQuery 117 ZC}]`M 9l/} 21 fra 58 [P] Er==yw 43 [Q] ?F`M*; }]`M 21 XQuery ?F`M*;mo= 99 ?F`M*;mo= 98 xVs!4 i/oT 12 1!/}{FUdyw 42 1!*X/`M{FUdyw 42 [R] UZ/} XQuery 117 UZ}]`M Ev 17 218 XQuery N< [S] >}mo= 106 OBDnmo= 55 yw 211 f> 39 _gUd 40 4F{FUd 41 9l 40 UEr 43 {FUd 44 Er== 43 1!/}{FUd 42 1!*X/`M{FUdyw 42 rT 39 1d/} XQuery 117 1d}]`M 17 1x,~= 146 5e}C 53 9C XQuery |B XML }] 101 }]`M cNa9 15 ~xF 17 Ev 15 `p 17 Pm 17 ZC 21 ?F`M*; 21 UZ"1dMVx1d 17 a} 51 f; 51 ^F 201 boolean 17 generic 17 numeric DB2 XQuery 17 string 17 untyped 17 xdt: 37 xdt:anyAtomicType 24 xdt:dayTimeDuration 27 xdt:untyped 37 xdt:untypedAtomic 37 XQuery ?F`M*; 99 xs:anySimpleType 24 xs:anyType 24 xs:anyURI 24 xs:base64Binary 24 xs:boolean 25 xs:byte 25 xs:date 25 xs:dateTime 26 xs:decimal 28 xs:double 28 }]`M (x) xs:duration 28 xs:ENTITY 30 xs:float 30 xs:gDay 30 xs:gMonth 31 xs:gMonthDay 31 xs:gYear 31 xs:gYearMonth 32 xs:hexBinary 32 xs:ID 32 xs:IDREF 32 xs:int 33 xs:integer 33 xs:language 33 xs:long 33 xs:Name 33 xs:NCName 33 xs:negativeInteger 34 xs:NMTOKEN 34 xs:nonNegativeInteger 34 xs:nonPositiveInteger 34 xs:normalizedString 34 xs:NOTATION 34 xs:positiveInteger 35 xs:QName 35 xs:short 35 xs:string 35 xs:time 35 xs:token 36 xs:unsignedByte 36 xs:unsignedInt 36 xs:unsignedLong 36 xs:unsignedShort 37 }]#M XQuery M XPath 4 tT 9l 81 Fc9l/} 81 {FUdyw 77 tTZc 8 tTa 58 }V/} 117 }V}]`M DB2 XQuery 17 }V=J 62 }VDV 52 cumo= 65 u4o( 60 [T] f;mo= 113 f;ZcMZc5 113 u~mo= 96 w} 219 unMu~ vfo 210 (C}]`M 17 [W] =J Zmo=P 62 ;C=J 62 D>Zc 9l 83 hv 9 D5 Ev 203 9CunMu~ 210 !"f 203 PDF D~ 203 D5Zc 9l 82 j8E" 7 D53r 9 DV DB2 XQuery 52 Jb7( LL 209 ICDE" 209 ^`M}]`M 17 [X] ^({F(QName) Ev 11 )9,*; 168 ^F s! 202 XQuery }]`M 201 rP 9l 63 Zc iO 64 U 43 hv 4 P'<{5 51 -S/ 50 XQuery /} 117 rPmo= 63 rP/ XML }] 10 rPPDn 4 rT f>yw 39 _gUqyw 40 4F{FUdyw 41 9lyw 40 rT (x) UEryw 43 {FUdyw 44 Er==yw 43 1!/}{FUdyw 42 1!*X/`M{FUdyw 42 o( 39 [Y] EH3r Kc{Mmo= 47 P'<{5 51 o( u4 60 FLWOR mo= 86 2(E,KcDEH3r 47 *X Fc9l/} 81 {FUdwCr 79 1S9l/} 74 *XZc 8 -S/ 50 -S`M 15 -S5 5 Kc{ EH3r 47 [Z] }ra 58 }rmo= j8E" 195 5HO 67 1S9l/} &m8n 84 hv 73 *X 74 *XPDUq 78 comment 85 5,-S 5 V`bT 59 a u4o( 60 Z76mo=P 58 a=h ZcbT 59 Z76mo=P 58 wmo= 52 "M i/oT 13 9l 85 Fc9l/} 85 1S9l/} 85 "MZc 9 220 XQuery N< J4 XQuery 14 S`Mf; 51 Sa 58 V{. /} XQuery 117 V{.}]`M 17 V{.DV 52 V{}C 54 Tma 58 A abs /} 126 adjust-dateTime-to-timezone /} 123 adjust-date-to-timezone /} 122 adjust-time-to-timezone /} 125 and Kc{ 72 anyAtomicType }]`M 24 anySimpleType }]`M 24 anyType }]`M 24 anyURI }]`M 24 avg /} 127 B base64Binary }]`M 24 boolean /} 128 boolean }]`M 17, 25 byte }]`M 25 C ceiling /} 129 codepoints-to-string /} 130 compare /} 130 concat /} 131 contains /} 131 count /} 132 current-date /} 133 current-dateTime /} 133 current-local-date /} 133 current-local-dateTime /} 134 current-local-time /} 134 current-time /} 134 D data /} 135 date }]`M 25 dateTime /} 135 dateTime }]`M 26 days-from-duration /} 137 dayTimeDuration }]`M 27 day-from-date /} 136 day-from-dateTime /} 136 DB2 (eD/} 117 DB2 E"PD f> 206 |B 206, 207 DB2 XQuery /} U 140 fr 169 }] 135 f; 167 abs 126 avg 127 boolean 128 ceiling 129 codepoints-to-string 130 compare 130 concat 131 contains 131 count 132 current-date 133 current-dateTime 133 current-local-date 133 current-local-dateTime 134 current-local-time 134 current-time 134 dateTime 135 deep-equal 138 default-collation 139 distinct-values 140 ends-with 141 exactly-one 141 exists 142 false 143 floor 143 implicit-timezone 146 index-of 147 insert-before 147 in-scope-prefixes 146 last 148 local-name 148 local-name-from-QName 149 local-timezone 150 lower-case 150 matches 151 max 152 min 153 name 158 namespace-uri 159 namespace-uri-for-prefix 160 namespace-uri-from-QName 160 node-name 161 normalize-space 161 normalize-unicode 162 not 163 number 163 w} 221 DB2 XQuery /} (x) one-or-more 164 position 165 QName 165 remove 166 resolve-QName 168 root 170 round 170 round-half-to-even 171 sqlquery 174 starts-with 177 string 177 string-join 178 string-length 179 string-to-codepoints 179 subsequence 180 substring 180 substring-after 181 substring-before 182 sum 183 timezone-from-dateTime 184 tokenize 186 translate 187 true 188 unordered 188 upper-case 189 xmlcolumn 3, 190 zero-or-one 193 decimal }]`M 28 deep-equal /} 138 default-collation /} 139 distinct-values /} 140 double }]`M 28 duration }]`M 28 E empty /} 140 ends-with /} 141 ENTITY }]`M 30 exactly-one /} 141 exists /} 142 F false /} 143 float }]`M 30 floor /} 143 FLWOR mo= Ev 85 >} 93 o( 86 for Sd d?wCr 90 Ev 87 FLWOR mo= (x) for Sd (x) j8E" 87 k let SdZ,;vmo=P 89 let SdHO 89 let Sd d?wCr 90 Ev 87 j8E" 88 k for SdZ,;vmo=P 89 for SdHO 89 order by Sd 91 return Sd 93 where Sd 90 for Sd j8E" 87 G gDay }]`M 30 gMonth }]`M 31 gMonthDay }]`M 31 gYear }]`M 31 gYearMonth }]`M 32 H hexBinary }]`M 32 hours-from-dateTime /} 144 hours-from-duration /} 144 hours-from-time /} 145 I ID }]`M 32 IDREF }]`M 32 if-then-else mo= j8E" 96 implicit-timezone /} 146 index-of /} 147 insert-before /} 147 int }]`M 33 integer }]`M 33 in-scope-prefixes /} 146 L language }]`M 33 last /} 148 let Sd j8E" 88 local-name /} 148 local-name-from-QName /} 149 local-timezone /} j8E" 150 222 XQuery N< long }]`M 33 lower-case /} 150 M matches /} 151 max /} 152 min /} 153 minutes-from-dateTime /} 154 minutes-from-duration /} 155 minutes-from-time /} 156 modify Sd 104 months-from-duration /} 157 month-from-date /} 156 month-from-dateTime /} 157 N name /} 158 Name }]`M 33 namespace-uri /} 159 namespace-uri-for-prefix /} 160 namespace-uri-from-QName /} 160 NCName }]`M 33 negativeInteger }]`M 34 NMTOKEN }]`M 34 node-name /} 161 nonNegativeInteger }]`M 34 nonPositiveInteger }]`M 34 normalizedString }]`M 34 normalize-space /} 161 normalize-unicode /} 162 not /} 163 NOTATION }]`M 34 number /} 163 O one-or-more /} 164 or Kc{ 72 order by Sd 91 P position /} 165 positiveInteger }]`M 35 Q QName Ev 11 QName(^({F) Ev 11 )9,*; 168 QName /} 117, 165 QName }]`M 35 R remove /} 166 replace /} 167 resolve-QName /} 168 return Sd d;mo= 104 j8E" 93 reverse /} 169 root /} 170 round /} 170 round-half-to-even /} 171 S seconds-from-dateTime /} 172 seconds-from-duration /} 173 seconds-from-time /} 174 setter,rT 39 short }]`M DB2 XQuery 35 SQL od oz T> 205 sqlquery /} 174 starts-with /} 177 string /} 177 string }]`M 35 string-join /} 178 string-length /} 179 string-to-codepoints /} 179 subsequence /} 180 substring /} 180 substring-after /} 181 substring-before /} 182 sum /} 183 T time }]`M 35 timezone-from-date /} 184 timezone-from-dateTime /} 184 timezone-from-time /} 185 token }]`M 36 tokenize /} 186 translate /} 187 true /} 188 U Unicode V{ 54 unordered /} 188 w} 223 unsignedByte }]`M 36 unsignedInt }]`M 36 unsignedLong }]`M 36 unsignedShort }]`M 37 untyped }]`M 37 untypedAtomic }]`M 37 upper-case /} 189 URI s({FUd0: 77 W where Sd hv 90 X XDM,kND XQuery M XPath }]#M 4 XML }] rP/ 10 Z DB2 }]bPi/ 2 xmlcolumn /} 3, 190 XMLEXISTS /} 2 XMLQUERY /} 2 XMLTABLE /} 2 XQuery S SQL wC 2 s!M}]`M^F 201 Ev 1 |Bmo= 101 2,Q*{FUd 12 oT<( 12 J4 14 iO|Bmo= 101 XQuery mo= Ev 47 |Bmo= 101, 106 XQuery (eD/} 117 XQuery |B ms 101 XQuery /} 4`pP> 117 <{`p 117 Vx1d`p 117 Zc`p 117 d{`p 117 UZ`p 117 1d`p 117 }V`p 117 rP`p 117 V{.`p 117 adjust-dateTime-to-timezone 123 adjust-date-to-timezone 122 adjust-time-to-timezone 125 days-from-duration 137 XQuery /} (x) day-from-date 136 day-from-dateTime 136 hours-from-dateTime 144 hours-from-duration 144 hours-from-time 145 minutes-from-dateTime 154 minutes-from-duration 155 minutes-from-time 156 months-from-duration 157 month-from-date 156 month-from-dateTime 157 QName `p 117 seconds-from-dateTime 172 seconds-from-duration 173 seconds-from-time 174 timezone-from-date 184 timezone-from-dateTime 184 timezone-from-time 185 years-from-duration 192 year-from-date 191 year-from-dateTime 191 XQuery M XPath }]#M 4 XQuery }CEv vii Y yearMonthDuration }]`M 37 years-from-duration /} 192 year-from-date /} 191 year-from-dateTime /} 191 Z zero-or-one /} 193 224 XQuery N<  Printed in China S151-1774-01 Spine information: IBM DB2 10.1 for Linux, UNIX, and Windows XQuery N< 
还剩236页未读

继续阅读

pdf贡献者

yulewo123

贡献于2016-11-07

下载需要 10 金币 [金币充值 ]
亲,您也可以通过 分享原创pdf 来获得金币奖励!