WD-xquery-sx-10-20100408
243 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
<?xml version="1.0" encoding="utf-8"?>
<!--XSLT Processor: SAXON 8.9.0.4 from Saxonica SAXON SA 8.9.0.4-->
<!--This document was created at 20100406 1336-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 14 February 2006), see www.w3.org" />
<title>XQuery Scripting Extension 1.0</title>
<style type="text/css">
/*<![CDATA[*/
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
div.issue
p.title { margin-left: -2em; }
ol.enumar { list-style-type: decimal; }
ol.enumla { list-style-type: lower-alpha; }
ol.enumlr { list-style-type: lower-roman; }
ol.enumua { list-style-type: upper-alpha; }
ol.enumur { list-style-type: upper-roman; }
li p { margin-top: 0.3em;
margin-bottom: 0.3em; }
sup small { font-style: italic;
color: #8F8F8F;
}
div.exampleInner pre { margin-left: 1em;
margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
border-top-width: 4px;
border-top-style: double;
border-top-color: #d3d3d3;
border-bottom-width: 4px;
border-bottom-style: double;
border-bottom-color: #d3d3d3;
padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
margin: 4px}
div.issue { border-bottom-color: black;
border-bottom-style: solid;
border-bottom-width: 1pt;
margin-bottom: 20pt;
}
th.issue-toc-head { border-bottom-color: black;
border-bottom-style: solid;
border-bottom-width: 1pt;
}
table.small { font-size: x-small; }
a.judgment:visited, a.judgment:link { font-family: sans-serif;
color: black;
text-decoration: none }
a.processing:visited, a.processing:link { color: black;
text-decoration: none }
a.env:visited, a.env:link { color: black;
text-decoration: none }
/*]]>*/
</style>
<link rel="stylesheet" type="text/css" href=
"http://www.w3.org/StyleSheets/TR/W3C-WD.css" />
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img src=
"http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width=
"72" /></a></p>
<h1><a name="title" id="title"></a>XQuery Scripting Extension
1.0</h1>
<h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C Working Draft 8
April 2010</h2>
<dl>
<dt>This version:</dt>
<dd><a href=
"http://www.w3.org/TR/2010/WD-xquery-sx-10-20100408">http://www.w3.org/TR/2010/WD-xquery-sx-10-20100408</a></dd>
<dt>Latest version:</dt>
<dd><a href=
"http://www.w3.org/TR/xquery-sx-10/">http://www.w3.org/TR/xquery-sx-10/</a></dd>
<dt>Previous versions:</dt>
<dd><a href=
"http://www.w3.org/TR/2008/WD-xquery-sx-10-20081203">http://www.w3.org/TR/2008/WD-xquery-sx-10-20081203</a>
<a href=
"http://www.w3.org/TR/2008/WD-xquery-sx-10-20080328/">http://www.w3.org/TR/2008/WD-xquery-sx-10-20080328/</a></dd>
<dt>Editors:</dt>
<dd><span><a href="http://snelson.org.uk/john">John
Snelson</a></span>, Oracle Corporation <a href=
"mailto:john.snelson@oracle.com"><john.snelson@oracle.com></a></dd>
<dd>Don Chamberlin, IBM Almaden Research Center, via <a href=
"http://www.almaden.ibm.com/cs/people/chamberlin/">http://www.almaden.ibm.com/cs/people/chamberlin/</a></dd>
<dd>Daniel Engovatov, W3C invited expert</dd>
<dd>Dana Florescu, Oracle Corporation <a href=
"mailto:dana.florescu@oracle.com"><dana.florescu@oracle.com></a></dd>
<dd>Giorgio Ghelli, University of Pisa <a href=
"mailto:ghelli@di.unipi.it"><ghelli@di.unipi.it></a></dd>
<dd>Jim Melton, Oracle Corporation <a href=
"mailto:jim.melton@acm.org"><jim.melton@acm.org></a></dd>
<dd>Jérôme Siméon, IBM T.J. Watson Research Center <a href=
"mailto:simeon@us.ibm.com"><simeon@us.ibm.com></a></dd>
</dl>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2010 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><acronym title=
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.eu/"><acronym title=
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
W3C <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href=
"http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
</div>
<hr />
<div>
<h2><a name="abstract" id="abstract"></a>Abstract</h2>
<p>This specification defines an extension to <a href=
"#XQ10">[XQuery 1.0]</a> and <a href="#XQueryUpdate">[XQuery Update
Facility]</a>. Expressions can be evaluated in a specific order,
with later expressions seeing the effects of the expressions that
came before them. This specification introduces several new kinds
of expression, including the apply, assignment, while, and exit
expression, and a block expression with local variable
declarations.</p>
</div>
<div>
<h2><a name="status" id="status"></a>Status of this Document</h2>
<p><em>This section describes the status of this document at the
time of its publication. Other documents may supersede this
document. A list of current W3C publications and the latest
revision of this technical report can be found in the <a href=
"http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This is a <a href=
"http://www.w3.org/2005/10/Process-20051014/tr.html#maturity-levels">
Working Draft</a> as described in the <a href=
"http://www.w3.org/2005/10/Process-20051014/tr.html">Process
Document</a>. It has been developed by the W3C <a href=
"http://www.w3.org/XML/Query/">XML Query Working Group</a>, which
is part of the <a href="http://www.w3.org/XML/Activity">XML
Activity</a>. The Working Group expects to advance this
specification to <a href=
"http://www.w3.org/2005/10/Process-20051014/tr.html#RecsW3C">Recommendation</a>
Status.</p>
<p>This is the last version of XQuery Scripting Extension that is
aligned with XQuery Update Facility 1.0. In future versions of this
document, the Working Group intends to reposition XQuery Scripting
Extension 1.0 against the <a href="#XQ11">[XQuery 1.1]</a> set of
specifications, and remove it from the <a href="#XQ10">[XQuery
1.0]</a> publication track.</p>
<p>No implementation report currently exists. However, a Test Suite
for XQuery Scripting Extension 1.0 is under development.</p>
<p>This document incorporates changes made against the previous
publication of the Working Draft of 3 December 2008. Changes to
this document since the previous publication of the Working Draft
are detailed in <a href="#id-revisions-log"><b>[G Revision
Log]</b></a>.</p>
<p>Please report errors in this document using W3C's <a href=
"http://www.w3.org/Bugs/Public/">public Bugzilla system</a>
(instructions can be found at <a href=
"http://www.w3.org/XML/2005/04/qt-bugzilla">http://www.w3.org/XML/2005/04/qt-bugzilla</a>).
If access to that system is not feasible, you may send your
comments to the W3C XSLT/XPath/XQuery public comments mailing list,
<a href=
"mailto:public-qt-comments@w3.org">public-qt-comments@w3.org</a>.
It will be very helpful if you include the string “[SX]” in the
subject line of your report, whether made in Bugzilla or in email.
Please use multiple Bugzilla entries (or, if necessary, multiple
email messages) if you have more than one comment to make. Archives
of the comments and responses are available at <a href=
"http://lists.w3.org/Archives/Public/public-qt-comments/">http://lists.w3.org/Archives/Public/public-qt-comments/</a>.</p>
<p>Publication as a Working Draft does not imply endorsement by the
W3C Membership. This is a draft document and may be updated,
replaced or obsoleted by other documents at any time. It is
inappropriate to cite this document as other than work in
progress.</p>
<p>This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
February 2004 W3C Patent Policy</a>. W3C maintains a <a href=
"http://www.w3.org/2004/01/pp-impl/18797/status#disclosures">public
list of any patent disclosures</a> made in connection with the
deliverables of the group; that page also includes instructions for
disclosing a patent. An individual who has actual knowledge of a
patent which the individual believes contains <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">
Essential Claim(s)</a> must disclose the information in accordance
with <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">
section 6 of the W3C Patent Policy</a>.</p>
</div>
<div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2>
<p class="toc">1 <a href="#Introduction">Introduction</a><br />
2 <a href="#id-extensions-to-processing-model">Extensions to the
Processing Model</a><br />
    2.1 <a href=
"#id-evaluation-order">Evaluation Order</a><br />
    2.2 <a href="#id-snapshot-scope">Snapshot
and Execution Scope</a><br />
    2.3 <a href=
"#id-variable-revalidation">Variable Binding Revalidation</a><br />
    2.4 <a href=
"#id-updating-constraint">Updating Expression Constraints</a><br />
    2.5 <a href="#id-sequential">Sequential
Expressions</a><br />
3 <a href="#id-extensions-to-static-context">Extensions to the
Static Context</a><br />
    3.1 <a href="#id-namespace">Predefined
Namespace</a><br />
    3.2 <a href="#id-query-mode">Query
Mode</a><br />
4 <a href="#id-extensions-to-prolog">Extensions to the
Prolog</a><br />
    4.1 <a href=
"#id-assignable-global-var">Assignable Global Variables</a><br />
    4.2 <a href="#id-function-decl">Function
Declarations</a><br />
    4.3 <a href="#id-query-mode-option">Query
Mode Option</a><br />
5 <a href="#id-new-exprs">New Kinds of Expressions</a><br />
    5.1 <a href="#id-apply">Apply
Expression</a><br />
    5.2 <a href="#id-block">Block
Expressions</a><br />
    5.3 <a href="#id-assignment">Assignment
Expression</a><br />
    5.4 <a href="#id-while">While
Expression</a><br />
    5.5 <a href="#id-exit">Exit
Expression</a><br />
    5.6 <a href="#id-query-mode-pragma">Query
Mode Pragma</a><br />
6 <a href="#id-existing-exprs">Changes to Existing
Expressions</a><br />
    6.1 <a href=
"#id-parenthesized-expr">Parentheses</a><br />
    6.2 <a href="#id-function-call">Function
Calls</a><br />
    6.3 <a href="#id-path-expr">Path
Expressions</a><br />
    6.4 <a href=
"#id-predicate">Predicates</a><br />
    6.5 <a href="#id-concat-expr">Concatenation
Expressions</a><br />
    6.6 <a href="#id-node-constructors">Direct
and Computed Node Constructors</a><br />
    6.7 <a href="#id-FLWOR-expr">FLWOR
Expressions</a><br />
    6.8 <a href=
"#id-conditional-expr">Conditional Expressions</a><br />
    6.9 <a href=
"#id-quantified-expr">Quantified Expressions</a><br />
    6.10 <a href=
"#id-typeswitch-expr">Typeswitch Expressions</a><br />
    6.11 <a href="#id-update-expr">Insert,
Delete, Replace, and Rename Expressions</a><br />
    6.12 <a href="#id-transform-expr">Transform
Expressions</a><br />
    6.13 <a href="#id-other-expr">Other
Expressions</a><br />
7 <a href="#id-example">Example</a><br /></p>
<h3><a name="appendices" id="appendices"></a>Appendices</h3>
<p class="toc">A <a href="#id-grammar">EBNF for XQuery 1.0 Grammar
with Scripting Extensions</a><br />
    A.1 <a href="#id-terminal-symbols">Terminal
Symbols</a><br />
    A.2 <a href=
"#id-extra-grammatical-constraints">Extra-grammatical
Constraints</a><br />
B <a href="#id-xqsx-xqueryx">XML Syntax (XQueryX) for XQuery
Scripting Extension 1.0</a><br />
    B.1 <a href=
"#id-xqsx-xqueryx-schema">Schema</a><br />
    B.2 <a href=
"#id-xqsx-xqueryx-stylesheet">Stylesheet</a><br />
    B.3 <a href=
"#id-xqsx-xqueryx-examples">Example</a><br />
        B.3.1 <a href=
"#id-xqsx-xqueryx-xq-rep">XQuery Representation</a><br />
        B.3.2 <a href=
"#id-xqsx-xqueryx-xqx-rep">XQueryX Representation</a><br />
        B.3.3 <a href=
"#id-xqsx-xqueryx-transformed-rep">Transformed XQuery
Representation</a><br />
C <a href="#id-implementation-defined-items">Implementation-Defined
Items</a><br />
D <a href="#id-references">References</a><br />
E <a href="#id-errors">Error Conditions</a><br />
    E.1 <a href="#id-new-error-codes">New Error
Codes</a><br />
    E.2 <a href=
"#id-amended-error-codes">Amendments to Existing Error
Codes</a><br />
F <a href="#id-glossary">Glossary</a> (Non-Normative)<br />
G <a href="#id-revisions-log">Revision Log</a>
(Non-Normative)<br />
    G.1 <a href="#id-log-20081203">Since the 3
December 2008 Working Draft</a><br />
    G.2 <a href="#id-log-20080328">Since the 28
March 2008 Working Draft</a><br /></p>
</div>
<hr />
<div class="body">
<div class="div1">
<h2><a name="Introduction" id="Introduction"></a>1
Introduction</h2>
<p>XQuery Scripting Extension extends <a href="#XQ10">[XQuery
1.0]</a>, enabling it to serve as a scripting language in order to
satisfy <a href="#ScriptingRequirements">[XQuery Scripting
Requirements]</a>. A prerequisite for this extension is <a href=
"#XQueryUpdate">[XQuery Update Facility]</a>. The following
abbreviations are used in this specification: [<a name="dt-xquf"
id="dt-xquf" title="XQUF">Definition</a>: <b>XQUF</b> is an
abbreviation for <a href="#XQueryUpdate">[XQuery Update
Facility]</a>.] [<a name="dt-xqsx" id="dt-xqsx" title=
"XQSX">Definition</a>: <b>XQSX</b> is an abbreviation for XQuery
Scripting Extension.]</p>
<p>In this document, examples and material labeled as "Note" are
provided for explanatory purposes and are not normative.</p>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> has the following
properties:</p>
<ul>
<li>
<p>It is a strict superset of <a title="XQUF" href=
"#dt-xquf">XQUF</a>, in the sense that all valid <a title="XQUF"
href="#dt-xquf">XQUF</a> expressions are also valid <a title="XQSX"
href="#dt-xqsx">XQSX</a> expressions and have the same meaning. (In
the same sense, <a title="XQUF" href="#dt-xquf">XQUF</a> is a
strict superset of <a href="#XQ10">[XQuery 1.0]</a>.)</p>
</li>
<li>
<p>It does not introduce any "modes" that affect the semantics of
expressions.</p>
</li>
<li>
<p>As in <a title="XQUF" href="#dt-xquf">XQUF</a>, the result of an
expression consists of an <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and a <a title=
"pending update list" href="#dt-pul">pending update list</a>.
[<a name="dt-xdm-instance" id="dt-xdm-instance" title=
"XDM instance">Definition</a>: An <b>XDM instance</b> is an
unconstrained sequence of zero or more nodes and/or atomic values,
as defined in <a href="#XDM">[XQuery Data Model]</a>.] [<a name=
"dt-pul" id="dt-pul" title="pending update list">Definition</a>: A
<b>pending update list</b> is an unordered collection of update
primitives, representing node state changes that have not yet been
applied, as defined in <a href="#XQueryUpdate">[XQuery Update
Facility]</a>.]</p>
</li>
</ul>
</div>
<div class="div1">
<h2><a name="id-extensions-to-processing-model" id=
"id-extensions-to-processing-model"></a>2 Extensions to the
Processing Model</h2>
<p>Expressions in XQSX may have side-effects that are visible to
subsequent expressions (according to their <a title=
"evaluation order" href="#dt-eval-order">evaluation order</a>).
This requires a number of extensions to the <a href="#XQ10">[XQuery
1.0]</a>and <a href="#XQueryUpdate">[XQuery Update Facility]</a>
processing model.</p>
<div class="div2">
<h3><a name="id-evaluation-order" id="id-evaluation-order"></a>2.1
Evaluation Order</h3>
<p>[<a name="dt-eval-order" id="dt-eval-order" title=
"evaluation order">Definition</a>: <a title="XQSX" href=
"#dt-xqsx">XQSX</a> defines an <b>evaluation order</b> on many
kinds of XQuery expressions, which is the order that operand
expressions must be evaluated in order to determine what
side-effects are visible to later expressions.] An implementation
may use any execution strategy as long as the result complies with
the semantics of this ordering.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Since none of the XQuery expressions existing before <a title=
"XQSX" href="#dt-xqsx">XQSX</a> has any immediate side-effects, no
ordering is effectively imposed on the evaluation of any expression
unless it contains one of the new <span>sequential</span>
expressions introduced by <a title="XQSX" href=
"#dt-xqsx">XQSX</a>.</p>
</div>
</div>
<div class="div2">
<h3><a name="id-snapshot-scope" id="id-snapshot-scope"></a>2.2
Snapshot <span>and Execution</span> Scope</h3>
<p>The term <b>snapshot</b> is defined in <a href=
"#XQueryUpdate">[XQuery Update Facility]</a> as follows: [<a name=
"dt-snapshot" id="dt-snapshot" title="snapshot">Definition</a>: A
<b>snapshot</b> is a scope within which expressions are evaluated
with respect to a fixed <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and updates are held pending.]
A snapshot is terminated by invocation of the
<code>upd:applyUpdates</code> operation. Unlike <a title="XQUF"
href="#dt-xquf">XQUF</a>, <a title="XQSX" href="#dt-xqsx">XQSX</a>
permits a query to contain more than one snapshot.</p>
<p><a href="#FO">[XQuery 1.0 and XPath 2.0 Functions and
Operators]</a> defines certain functions as <a href=
"http://www.w3.org/TR/xpath-functions/#stable">stable</a><sup><small>FO</small></sup>.
Stable functions such as <code>fn:current-time</code> and
<code>fn:doc</code> are defined to return the same result given the
same arguments within an <a href=
"http://www.w3.org/TR/xpath-functions/#execution-scope">execution
scope</a><sup><small>FO</small></sup>. <a title="XQSX" href=
"#dt-xqsx">XQSX</a> redefines the extent of an execution scope, so
that a top level query can contain many execution scopes.</p>
<p>In XQSX, each of the following expressions is <span>both</span>
a snapshot <span>and execution scope</span>:</p>
<ul>
<li>
<p>each ConcatExpr within an ApplyExpr</p>
</li>
<li>
<p>each initialization expression in a BlockVarDecl</p>
</li>
<li>
<p>the expression on the right-hand side of an AssignmentExpr</p>
</li>
<li>
<p>the expression in an ExitExpr</p>
</li>
<li>
<p>the test expression in a WhileExpr</p>
</li>
</ul>
</div>
<div class="div2">
<h3><a name="id-variable-revalidation" id=
"id-variable-revalidation"></a>2.3 Variable Binding
Revalidation</h3>
<p>To ensure type soundness, variable bindings are revalidated at
the end of each scope to check that any updates applied have not
made them invalid with repect to their declared types. It is a
dynamic error [<a href="#ERRSXDY0003" title=
"err:SXDY0003">err:SXDY0003</a>] if, after applying a pending
update list (using <code>upd:applyUpdates</code>), the XDM instance
bound to any in-scope variable does not match the static type of
that variable according to SequenceType matching rules.</p>
</div>
<div class="div2">
<h3><a name="id-updating-constraint" id=
"id-updating-constraint"></a>2.4 Updating Expression
Constraints</h3>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> relaxes the constraints
on the placement of <a title="updating expression" href=
"#dt-updating-expr">updating expressions</a>, so that a non-empty
<a title="XDM instance" href="#dt-xdm-instance">XDM instance</a>
can be returned by an expression as well as a non-empty <a title=
"pending update list" href="#dt-pul">pending update list</a>. In
order to allow this, new rules to determine the category and
resulting <a title="pending update list" href="#dt-pul">pending
update list</a> are added to every existing expression, following
certain principles:</p>
<ul>
<li>
<p>An <a title="updating expression" href=
"#dt-updating-expr">updating expression</a> is allowed anywhere a
<a title="simple expression" href="#dt-simple-expr">simple
expression</a> is allowed. If an operand of an expression is an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a>, the expression itself is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>An expression may not be both <a title="sequential expression"
href="#dt-sequential-expr">sequential</a> and <a title=
"updating expression" href="#dt-updating-expr">updating</a>. If an
<a title="updating expression" href=
"#dt-updating-expr">updating</a> expression contains or uses a
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a> (or vice versa), an
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>].</p>
</li>
<li>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> that results from any given expression is the result of
calling <code>upd:mergeUpdates</code> on the <a title=
"pending update list" href="#dt-pul">pending update lists</a> from
the result of all of its operand expressions. No <a title=
"pending update list" href="#dt-pul">pending update list</a> is
ever discarded.</p>
</li>
</ul>
</div>
<div class="div2">
<h3><a name="id-sequential" id="id-sequential"></a>2.5 Sequential
Expressions</h3>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> introduces a new
expression category called <a title="sequential expression" href=
"#dt-sequential-expr">sequential expressions</a>. The simple and
updating expression categories introduced by <a title="XQUF" href=
"#dt-xquf">XQUF</a> are retained, but the vacuous expression
category no longer has significance. Informal definitions of all
the expression categories are summarized here. For normative
definitions of the categories, see the "Category Rules" that are
specified for each kind of expression in <a href=
"#id-new-exprs"><b>[5 New Kinds of Expressions]</b></a> and
<a href="#id-existing-exprs"><b>[6 Changes to Existing
Expressions]</b></a>.</p>
<ol class="enumar">
<li>
<p>[<a name="dt-updating-expr" id="dt-updating-expr" title=
"updating expression">Definition</a>: An <b>updating expression</b>
is an expression that can return a non-empty <a title=
"pending update list" href="#dt-pul">pending update list</a>.]
Updating expressions include insert, delete, replace, rename, and
calls to updating functions, as well as certain other expressions
that contain nested updating expressions. An updating expression
may return a non-empty <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> as well as a non-empty
<a title="pending update list" href="#dt-pul">pending update
list</a> - however note that it does not actually apply any
updates.</p>
</li>
<li>
<p>[<a name="dt-sequential-expr" id="dt-sequential-expr" title=
"sequential expression">Definition</a>: A <b>sequential
expression</b> is an expression that can have side effects other
than constructing a new node or raising an error.] Side effects
include applying updates to an <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a>, altering the dynamic context,
or affecting the flow of control. Sequential expressions include
apply expressions, assignment, exit, while, and calls to sequential
functions, as well as certain other expressions that contain nested
sequential expressions. The side effects of a sequential expression
are immediately effective and are visible to subsequent
expressions. Because of their side effects, sequential expressions
must be evaluated in a well-defined order. In addition to its side
effects, a sequential expression may return a non-empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a>, but it
never returns a non-empty <a title="pending update list" href=
"#dt-pul">pending update list</a>.</p>
</li>
<li>
<p>[<a name="dt-simple-expr" id="dt-simple-expr" title=
"simple expression">Definition</a>: A <b>simple expression</b> is
an expression that is neither an <a title="updating expression"
href="#dt-updating-expr">updating expression</a> nor a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.] A simple expression may return an <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a>, and it may
construct a node or raise an error.</p>
</li>
</ol>
<p>The classification of each expression into one of the above
categories is performed by static analysis. For each kind of
expression, <a title="XQSX" href="#dt-xqsx">XQSX</a> provides rules
that specify the required categories of the operand expressions and
the category of the expression itself.</p>
<p>Note that <a title="simple expression" href=
"#dt-simple-expr">simple expressions</a>, <a title=
"updating expression" href="#dt-updating-expr">updating
expressions</a>, and <a title="sequential expression" href=
"#dt-sequential-expr">sequential expressions</a> are disjoint
categories. The kinds of values that can be returned by the various
expression categories are summarized in the following table:</p>
<table border="1">
<tbody>
<tr>
<th align="center"><em>Expression category</em></th>
<th align="center"><em>Can return non-empty XDM instance?</em></th>
<th align="center"><em>Can return non-empty PUL?</em></th>
<th align="center"><em>Can have immediate side-effects?</em></th>
</tr>
<tr>
<td align="center">Simple</td>
<td align="center">YES</td>
<td align="center">NO</td>
<td align="center">NO</td>
</tr>
<tr>
<td align="center">Updating</td>
<td align="center">YES</td>
<td align="center">YES</td>
<td align="center">NO</td>
</tr>
<tr>
<td align="center">Sequential</td>
<td align="center">YES</td>
<td align="center">NO</td>
<td align="center">YES</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="div1">
<h2><a name="id-extensions-to-static-context" id=
"id-extensions-to-static-context"></a>3 Extensions to the Static
Context</h2>
<div class="div2">
<h3><a name="id-namespace" id="id-namespace"></a>3.1 Predefined
Namespace</h3>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> adds the pair
(<code>xqsx</code>,
<code>http://www.w3.org/2008/xquery-sx-10</code>) as a predefined
namespace to the statically known namespaces.</p>
</div>
<div class="div2">
<h3><a name="id-query-mode" id="id-query-mode"></a>3.2 Query
Mode</h3>
<p>[<a name="dt-query-mode" id="dt-query-mode" title=
"query mode">Definition</a>: The <b>query mode</b> governs the
composability of <a title="updating expression" href=
"#dt-updating-expr">updating</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>. Valid values are <code>sequential</code> and
<code>simple</code>.] The default initial value of query mode is
<code>sequential</code>, but it can be overwritten by an
implementation. Query mode has a lexical scope, and can be modified
at both the module and expression level.</p>
<p>In particular, query mode affects the category rules for
<a href="#id-path-expr"><b>[6.3 Path Expressions]</b></a>, <a href=
"#id-predicate"><b>[6.4 Predicates]</b></a>, <a href=
"#id-FLWOR-expr"><b>[6.7 FLWOR Expressions]</b></a>, and <a href=
"#id-quantified-expr"><b>[6.9 Quantified Expressions]</b></a>.</p>
</div>
</div>
<div class="div1">
<h2><a name="id-extensions-to-prolog" id=
"id-extensions-to-prolog"></a>4 Extensions to the Prolog</h2>
<div class="div2">
<h3><a name="id-assignable-global-var" id=
"id-assignable-global-var"></a>4.1 Assignable Global Variables</h3>
<h5><a name="d7e707" id="d7e707"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-VarDecl" id=
"doc-xquery-VarDecl"></a>[<small>24</small>]   </td>
<td><code><a href="#prod-xquery-VarDecl"></a><a href=
"#prod-xquery-VarDecl">VarDecl</a></code></td>
<td>   ::=   </td>
<td><code>"declare" ("unassignable"? | "assignable") "variable" "$"
<a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ((":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>) | "external")</code></td>
</tr>
</tbody>
</table>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> allows the qualifiers
<code>assignable</code> and <code>unassignable</code> to be used in
a Prolog variable declaration. [<a name="dt-assignable" id=
"dt-assignable" title="assignable">Definition</a>: Prolog variables
declared as <b>assignable</b> may have their value changed by an
<a href="#id-assignment"><b>[5.3 Assignment Expression]</b></a>.]
If an assignment qualifier is not used, the default is
<code>unassignable</code>.</p>
<p>The semantics of assignable variables are the same as the
semantics of unassignable variables, except that the static type of
an assignable variable without a declared type is always
<code>item()*</code>.</p>
<p>The initializing expression of a prolog variable (whether
assignable or not) must be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a> [<a href="#ERRXUST0001"
title="err:XUST0001">err:XUST0001</a>].</p>
</div>
<div class="div2">
<h3><a name="id-function-decl" id="id-function-decl"></a>4.2
Function Declarations</h3>
<h5><a name="d7e784" id="d7e784"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FunctionDecl" id=
"doc-xquery-FunctionDecl"></a>[<small>26</small>]   </td>
<td><code><a href="#prod-xquery-FunctionDecl"></a><a href=
"#prod-xquery-FunctionDecl">FunctionDecl</a></code></td>
<td>   ::=   </td>
<td><code>("declare" ("simple"? | "updating") "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#prod-xquery-EnclosedExpr">EnclosedExpr</a> | "external"))<br />
| ("declare" "sequential" "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#doc-xquery-Block">Block</a> | "external"))</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Definitions:</dt>
<dd>
<p>[<a name="dt-simple-function" id="dt-simple-function" title=
"simple function">Definition</a>: A <b>simple function</b> is a
function whose declaration specifies neither <code>updating</code>
nor <code>sequential</code>. A <a title="simple function" href=
"#dt-simple-function">simple function</a> may optionally specify
the keyword <code>simple</code>.]</p>
<p>[<a name="dt-updating-function" id="dt-updating-function" title=
"updating function">Definition</a>: An <b>updating function</b> is
a function whose declaration specifies the keyword
<code>updating</code>.]</p>
<p>[<a name="dt-sequential-function" id="dt-sequential-function"
title="sequential function">Definition</a>: A <b>sequential
function</b> is a function whose declaration specifies the keyword
<code>sequential</code>.]</p>
</dd>
<dt class="label">Category Rules:</dt>
<dd>
<ul>
<li>
<p>If the body of a <a title="simple function" href=
"#dt-simple-function">simple function</a> is an EnclosedExpr, it
must be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a>.</p>
</li>
<li>
<p>If the body of an <a title="updating function" href=
"#dt-updating-function">updating function</a> is an EnclosedExpr,
it must be either an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expression</a>.</p>
</li>
<li>
<p>If the body of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is a Block it
must be either a <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
<li>
<p>If the body of a function violates the category rules for it's
declared category, [<a href="#ERRSXST0008" title=
"err:SXST0008">err:SXST0008</a>] is raised.</p>
</li>
</ul>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The semantics of <a title="simple function" href=
"#dt-simple-function">simple functions</a> are defined in <a href=
"#XQueryUpdate">[XQuery Update Facility]</a> and <a href=
"#XQ10">[XQuery 1.0]</a>, and remain unchanged in <a title="XQSX"
href="#dt-xqsx">XQSX</a>.</p>
<p>The semantics of <a title="updating function" href=
"#dt-updating-function">updating functions</a> as originally
defined in <a href="#XQueryUpdate">[XQuery Update Facility]</a> are
extended as follows:</p>
<ul>
<li>
<p>A return type is permitted.</p>
</li>
<li>
<p>If <code>external</code> is specified, the external function may
return both a non-empty <a title="pending update list" href=
"#dt-pul">pending update list</a> and a non-empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a>.</p>
</li>
<li>
<p>If the result of an <a title="updating function" href=
"#dt-updating-function">updating function</a> does not match its
declared result type (after applying function conversion rules as
specified in <a href=
"http://www.w3.org/TR/xquery#id-function-calls">Section 3.1.5
Function Calls</a><sup><small>XQ</small></sup>), a type error is
raised [<a href="http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>. The
default result type of an <a title="updating function" href=
"#dt-updating-function">updating function</a> is
<code>item()*</code>.</p>
</li>
</ul>
<p>The semantics of <a title="sequential function" href=
"#dt-sequential-function">sequential functions</a> are as
follows:</p>
<ul>
<li>
<p>The result of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is determined by
the first <a href="#id-exit"><b>[5.5 Exit Expression]</b></a>
encountered during evaluation of the Block. If no exit expression
is encountered, the result of the function is the value returned by
the Block that comprises its body.</p>
</li>
<li>
<p>If the result of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> does not match
its declared result type (after applying function conversion rules
as specified in <a href=
"http://www.w3.org/TR/xquery#id-function-calls">Section 3.1.5
Function Calls</a><sup><small>XQ</small></sup>), a type error is
raised [<a href="http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>. The
default result type of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is
<code>item()*</code>.</p>
</li>
<li>
<p>If a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is declared
<code>external</code>, its implementation is outside the XQuery
environment. The means by which parameters are passed to an
external function and its result is returned to the calling
expression are implementation-defined. An external sequential
function may not return a non-empty <a title="pending update list"
href="#dt-pul">pending update list</a> [<a href="#ERRSXDY0004"
title="err:SXDY0004">err:SXDY0004</a>].</p>
</li>
</ul>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-query-mode-option" id=
"id-query-mode-option"></a>4.3 Query Mode Option</h3>
<h5><a name="d7e1014" id="d7e1014"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OptionDecl" id=
"doc-xquery-OptionDecl"></a>[<small>13</small>]   </td>
<td><code><a href="#prod-xquery-OptionDecl"></a><a href=
"#prod-xquery-OptionDecl">OptionDecl</a></code></td>
<td>   ::=   </td>
<td><code>"declare" "option" <a href="#prod-xquery-QName">QName</a>
<a href="#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
</table>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> defines the QName
<code>xqsx:query-mode</code> as a well-known option name for use in
an OptionDecl, which sets the <a title="query mode" href=
"#dt-query-mode">query mode</a> in the static context for the
module to the value specified. A static error is raised [<a href=
"#ERRSXST0009" title="err:SXST0009">err:SXST0009</a>] if the value
for a <code>xqsx:query-mode</code> option is not either
<code>sequential</code> or <code>simple</code>.</p>
<p>Implementations of <a title="XQSX" href="#dt-xqsx">XQSX</a> must
recognize the option namespace URI
<code>http://www.w3.org/2008/xquery-sx-10</code>, and the option
<code>xqsx:query-mode</code>.</p>
</div>
</div>
<div class="div1">
<h2><a name="id-new-exprs" id="id-new-exprs"></a>5 New Kinds of
Expressions</h2>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> extends the XQuery 1.0
syntax by adding several new kinds of expressions. The effect of
these new expressions on the XQuery grammar is as follows:</p>
<h5><a name="d7e1067" id="d7e1067"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1015.doc-xquery-Expr" id=
"noid_d4e1015.doc-xquery-Expr"></a>[<small>31</small>]   </td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-ApplyExpr">ApplyExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1016.doc-xquery-ApplyExpr" id=
"noid_d4e1016.doc-xquery-ApplyExpr"></a>[<small>32</small>]   </td>
<td><code><a href=
"#prod-xquery-ApplyExpr">ApplyExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-ConcatExpr">ConcatExpr</a> (";"
(<a href="#doc-xquery-ConcatExpr">ConcatExpr</a>
";")*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1017.doc-xquery-ConcatExpr" id=
"noid_d4e1017.doc-xquery-ConcatExpr"></a>[<small>33</small>]   </td>
<td><code><a href=
"#prod-xquery-ConcatExpr">ConcatExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> (","
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1018.doc-xquery-ExprSingle" id=
"noid_d4e1018.doc-xquery-ExprSingle"></a>[<small>34</small>]   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-FLWORExpr">FLWORExpr</a><br />
| <a href="#doc-xquery-QuantifiedExpr">QuantifiedExpr</a><br />
| <a href="#doc-xquery-TypeswitchExpr">TypeswitchExpr</a><br />
| <a href="#doc-xquery-IfExpr">IfExpr</a><br />
| <a href="#doc-xquery-InsertExpr">InsertExpr</a><br />
| <a href="#doc-xquery-DeleteExpr">DeleteExpr</a><br />
| <a href="#doc-xquery-RenameExpr">RenameExpr</a><br />
| <a href="#doc-xquery-ReplaceExpr">ReplaceExpr</a><br />
| <a href="#doc-xquery-TransformExpr">TransformExpr</a><br />
| <a href="#doc-xquery-BlockExpr">BlockExpr</a><br />
| <a href="#doc-xquery-AssignmentExpr">AssignmentExpr</a><br />
| <a href="#doc-xquery-ExitExpr">ExitExpr</a><br />
| <a href="#doc-xquery-WhileExpr">WhileExpr</a><br />
| <a href="#prod-xquery-OrExpr">OrExpr</a></code></td>
</tr>
</tbody>
</table>
<div class="div2">
<h3><a name="id-apply" id="id-apply"></a>5.1 Apply Expression</h3>
<h5><a name="d7e1159" id="d7e1159"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ApplyExpr" id=
"doc-xquery-ApplyExpr"></a>[<small>32</small>]   </td>
<td><code><a href="#prod-xquery-ApplyExpr"></a><a href=
"#prod-xquery-ApplyExpr">ApplyExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-ConcatExpr">ConcatExpr</a> (";"
(<a href="#doc-xquery-ConcatExpr">ConcatExpr</a>
";")*)?</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>[<a name="dt-apply-expr" id="dt-apply-expr" title=
"apply expression">Definition</a>: An <b>apply expression</b> is a
list of semicolon-terminated ConcatExpr productions, called operand
expressions. An ApplyExpr consisting of a single ConcatExpr with no
semicolon is not an apply expression.] An apply expression is a
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
<p>The operands of the apply expression may be an expression of any
category.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The operand expressions <span>of an <a title="apply expression"
href="#dt-apply-expr">apply expression</a></span> are evaluated in
the order they appear. After the evaluation of each operand
expression, the <a title="pending update list" href=
"#dt-pul">pending update list</a> returned by the expression is
applied (by <code>upd:applyUpdates</code>). The <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> returned by
all expressions other than the last one is discarded. The side
effects of each expression are visible during the evaluation of
subsequent expressions.</p>
<p>The result of the apply expression is the <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> returned by
the last operand expression, and an empty <a title=
"pending update list" href="#dt-pul">pending update list</a>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-block" id="id-block"></a>5.2 Block Expressions</h3>
<h5><a name="d7e1227" id="d7e1227"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockExpr" id=
"doc-xquery-BlockExpr"></a>[<small>153</small>]   </td>
<td><code><a href="#prod-xquery-BlockExpr"></a><a href=
"#prod-xquery-BlockExpr">BlockExpr</a></code></td>
<td>   ::=   </td>
<td><code>"block" <a href="#doc-xquery-Block">Block</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-Block" id=
"doc-xquery-Block"></a>[<small>154</small>]   </td>
<td><code><a href="#prod-xquery-Block"></a><a href=
"#prod-xquery-Block">Block</a></code></td>
<td>   ::=   </td>
<td><code>"{" <a href="#doc-xquery-BlockDecls">BlockDecls</a>
<a href="#doc-xquery-BlockBody">BlockBody</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockDecls" id=
"doc-xquery-BlockDecls"></a>[<small>155</small>]   </td>
<td><code><a href="#prod-xquery-BlockDecls"></a><a href=
"#prod-xquery-BlockDecls">BlockDecls</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#doc-xquery-BlockVarDecl">BlockVarDecl</a>
";")*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockVarDecl" id=
"doc-xquery-BlockVarDecl"></a>[<small>156</small>]   </td>
<td><code><a href="#prod-xquery-BlockVarDecl"></a><a href=
"#prod-xquery-BlockVarDecl">BlockVarDecl</a></code></td>
<td>   ::=   </td>
<td><code>"declare" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)? ("," "$"
<a href="#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)?)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockBody" id=
"doc-xquery-BlockBody"></a>[<small>157</small>]   </td>
<td><code><a href="#prod-xquery-BlockBody"></a><a href=
"#prod-xquery-BlockBody">BlockBody</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>[<a name="dt-initializing-expr" id="dt-initializing-expr" title=
"initializing expression">Definition</a>: The expression on the
right-hand side of a block variable declaration is called an
<b>initializing expression</b>.] <a title="initializing expression"
href="#dt-initializing-expr">Initializing expressions</a> may be in
any category.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Block variable declarations, unlike Prolog variable
declarations, permit their <a title="initializing expression" href=
"#dt-initializing-expr">initializing expressions</a> to be
<a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>.</p>
</div>
<p>If a BlockExpr contains <a title="initializing expression" href=
"#dt-initializing-expr">initializing expressions</a> that are
either <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, then the BlockExpr is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>. In this case the BlockBody must be either a
<a title="simple expression" href="#dt-simple-expr">simple</a> or
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, otherwise a static
error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised.</p>
<p>If a BlockExpr only contains <a title="initializing expression"
href="#dt-initializing-expr">initializing expressions</a> that are
<a title="simple expression" href="#dt-simple-expr">simple
expressions</a> (or contains no initializing expressions), then the
BlockBody may be an expression of any category. In this case the
BlockExpr has the same category as the BlockBody.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>A block consists of zero or more block variable declarations
followed by a body. Each block variable declaration defines a
modifiable local variable whose scope is the remainder of the block
(not including its <a title="initializing expression" href=
"#dt-initializing-expr">initializing expression</a>). The variable
defined in a block variable declaration occludes (hides) any
variable of the same name that is in scope at the location where
the block appears.</p>
<p>It is a static error [<a href="#ERRSXST0005" title=
"err:SXST0005">err:SXST0005</a>] if two or more variables declared
in the same block have the same expanded QName.</p>
<p>The type of each declared variable is added to <em>in-scope
variables</em> in the <em>static context</em>. <span>If no explicit
type is declared, the type of the variable is
<code>item()*</code>.</span> If a variable has both an explicit
type declaration and an <a title="initializing expression" href=
"#dt-initializing-expr">initializing expression</a>, the value of
the <a title="initializing expression" href=
"#dt-initializing-expr">initializing expression</a> must match the
declared type according to SequenceType matching rules; otherwise a
type error is raised [<a href=
"http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>.</p>
<p>The block variable declarations are evaluated in the order
written. The block variable declaration evaluates its <a title=
"initializing expression" href="#dt-initializing-expr">initializing
expression</a> and adds the resulting <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> to the <em>variable values</em>
in the <em>dynamic context</em>. Any <a title="pending update list"
href="#dt-pul">pending update list</a> returned is applied using
<code>upd:applyUpdates</code>. If no <a title=
"initializing expression" href="#dt-initializing-expr">initializing
expression</a> is present, the variable has no initial value. A
reference to a variable, other than on the left-hand side of an
assignment expression, is an error if the variable has no value in
<em>variable values</em> when the reference is evaluated [<a href=
"#ERRSXTY0006" title="err:SXTY0006">err:SXTY0006</a>].</p>
<p>After all the block variable declarations have been evaluated,
the BlockBody expression is evaluated. The result of the block
expression is the <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and <a title=
"pending update list" href="#dt-pul">pending update list</a>
returned by the BlockBody.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-assignment" id="id-assignment"></a>5.3 Assignment
Expression</h3>
<h5><a name="d7e1429" id="d7e1429"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-AssignmentExpr" id=
"doc-xquery-AssignmentExpr"></a>[<small>158</small>]   </td>
<td><code><a href="#prod-xquery-AssignmentExpr"></a><a href=
"#prod-xquery-AssignmentExpr">AssignmentExpr</a></code></td>
<td>   ::=   </td>
<td><code>"$" <a href="#prod-xquery-VarName">VarName</a> ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>An assignment expression is a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The variable on the left-hand side of the assignment must have
been declared in one of the following ways, otherwise a static
error [<a href="#ERRSXST0007" title=
"err:SXST0007">err:SXST0007</a>] is raised:</p>
<ul>
<li>
<p>By a block variable declaration</p>
</li>
<li>
<p>As a parameter to a sequential function</p>
</li>
<li>
<p>By a variable declaration in the Prolog <span>declared as
<a title="assignable" href=
"#dt-assignable">assignable</a></span></p>
</li>
</ul>
<p>In all cases the variable must be in the in-scope variables,
otherwise a static error is raised [<a href=
"http://www.w3.org/TR/xquery#ERRXPST0008" title=
"err:XPST0008">err:XPST0008</a>]<sup><small>XQ</small></sup>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Variables bound in FLWOR, typeswitch, or quantified expressions
may not appear on the left-hand side of an assignment.</p>
</div>
<p>The expression on the right-hand side is evaluated, resulting in
an <a title="XDM instance" href="#dt-xdm-instance">XDM instance</a>
and a <a title="pending update list" href="#dt-pul">pending update
list</a>.</p>
<p>If the <a title="XDM instance" href="#dt-xdm-instance">XDM
instance</a> returned by the expression on the right-hand side does
not match the declared type of the variable according to
SequenceType matching rules, a type error is raised [<a href=
"http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>. If
the types match, the <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> returned by the expression is
bound to the variable (added to <em>variable values</em> in the
<em>dynamic context</em>.)</p>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the expression on the right-hand side is
applied using <code>upd:applyUpdates</code>.</p>
<p>The result of an Assignment Expression is an empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> and an
empty <a title="pending update list" href="#dt-pul">pending update
list</a>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-while" id="id-while"></a>5.4 While Expression</h3>
<h5><a name="d7e1522" id="d7e1522"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-WhileExpr" id=
"doc-xquery-WhileExpr"></a>[<small>160</small>]   </td>
<td><code><a href="#prod-xquery-WhileExpr"></a><a href=
"#prod-xquery-WhileExpr">WhileExpr</a></code></td>
<td>   ::=   </td>
<td><code>"while" "(" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ")" <a href=
"#doc-xquery-WhileBody">WhileBody</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-WhileBody" id=
"doc-xquery-WhileBody"></a>[<small>161</small>]   </td>
<td><code><a href="#prod-xquery-WhileBody"></a><a href=
"#prod-xquery-WhileBody">WhileBody</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-Block">Block</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>[<a name="dt-test-expr" id="dt-test-expr" title=
"test expression">Definition</a>: The expression enclosed in the
parentheses of a while expression is called a <b>test
expression</b>.] The <a title="test expression" href=
"#dt-test-expr">test expression</a> may be in any category.</p>
<p>A static error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised if the WhileBody is an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
<p>A while expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The while expression is used for conditional iteration. It is
evaluated as follows:</p>
<p>The <a title="test expression" href="#dt-test-expr">test
expression</a> is evaluated, resulting in an <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> and a
<a title="pending update list" href="#dt-pul">pending update
list</a>. The <a title="pending update list" href="#dt-pul">pending
update list</a> returned by the <a title="test expression" href=
"#dt-test-expr">test expression</a> is applied using
<code>upd:applyUpdates</code>.</p>
<p>If the effective Boolean value of the <a title="test expression"
href="#dt-test-expr">test expression</a> is false, the block is not
evaluated. If the effective Boolean value of the <a title=
"test expression" href="#dt-test-expr">test expression</a> is true,
the block is evaluated repeatedly. Each evaluation of the block may
cause side effects that affect the result of re-evaluating the
<a title="test expression" href="#dt-test-expr">test
expression</a>. The <a title="test expression" href=
"#dt-test-expr">test expression</a> is re-evaluated after each
evaluation of the block. This process continues until the effective
Boolean value of the <a title="test expression" href=
"#dt-test-expr">test expression</a> is evaluated to be false.</p>
<p>The result of a while expression is an empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> and an
empty <a title="pending update list" href="#dt-pul">pending update
list</a>.</p>
</dd>
<dt class="label">Example:</dt>
<dd>
<p>In the following query, a while expression is used to compute a
sequence containing all the Fibonacci numbers that are less than
100.</p>
<div class="exampleInner">
<pre>
block {
declare $a as xs:integer := 0;
declare $b as xs:integer := 1;
declare $c as xs:integer := $a + $b;
declare $fibseq as xs:integer* := ($a, $b);
while ($c < 100) {
$fibseq := ($fibseq, $c);
$a := $b;
$b := $c;
$c := $a + $b;
};
$fibseq;
}
</pre></div>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-exit" id="id-exit"></a>5.5 Exit Expression</h3>
<h5><a name="d7e1631" id="d7e1631"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ExitExpr" id=
"doc-xquery-ExitExpr"></a>[<small>159</small>]   </td>
<td><code><a href="#prod-xquery-ExitExpr"></a><a href=
"#prod-xquery-ExitExpr">ExitExpr</a></code></td>
<td>   ::=   </td>
<td><code>"exit" "returning" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The operand of an exit expression may be an expression of any
category.</p>
<p>An exit expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>An exit expression serves to define the result of the enclosing
function or query body.</p>
<p>The operand expression of the exit expression is evaluated,
resulting in an <a title="XDM instance" href="#dt-xdm-instance">XDM
instance</a> and a <a title="pending update list" href=
"#dt-pul">pending update list</a>. The <a title=
"pending update list" href="#dt-pul">pending update list</a>
returned by the operand expression is applied using
<code>upd:applyUpdates</code>.</p>
<p>If an exit expression is evaluated within the body of a
function, further evaluation of the function body is interrupted
and the <a title="XDM instance" href="#dt-xdm-instance">XDM
instance</a> returned by the operand expression is returned as the
result of the function call.</p>
<p>If an exit expression is evaluated within a query body (i.e.,
not within the body of a function), further evaluation of the query
is interrupted and the <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> returned by the operand
expression is returned as the result of the query.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>An exit expression in a block terminates evaluation of the
enclosing function body or query, not just the immediately
enclosing block.</p>
</div>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-query-mode-pragma" id=
"id-query-mode-pragma"></a>5.6 Query Mode Pragma</h3>
<h5><a name="d7e1688" id="d7e1688"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ExtensionExpr" id=
"doc-xquery-ExtensionExpr"></a>[<small>67</small>]   </td>
<td><code><a href="#prod-xquery-ExtensionExpr"></a><a href=
"#prod-xquery-ExtensionExpr">ExtensionExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-Pragma">Pragma</a>+ "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-Pragma" id=
"doc-xquery-Pragma"></a>[<small>68</small>]   </td>
<td><code><a href="#prod-xquery-Pragma"></a><a href=
"#prod-xquery-Pragma">Pragma</a></code></td>
<td>   ::=   </td>
<td><code>"(#" <a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-QName">QName</a> (<a href="#prod-xquery-S">S</a>
<a href="#doc-xquery-PragmaContents">PragmaContents</a>)?
"#)"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PragmaContents" id=
"doc-xquery-PragmaContents"></a>[<small>69</small>]   </td>
<td><code><a href="#prod-xquery-PragmaContents"></a><a href=
"#prod-xquery-PragmaContents">PragmaContents</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* '#)'
Char*))</code></td>
</tr>
</tbody>
</table>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> defines the QName
<code>xqsx:query-mode</code> as a well-known pragma name for use in
an ExtensionExpr, which sets the <a title="query mode" href=
"#dt-query-mode">query mode</a> in the static context for the
enclosed expression to the value specified. A static error is
raised [<a href="#ERRSXST0009" title=
"err:SXST0009">err:SXST0009</a>] if the value for a
<code>xqsx:query-mode</code> pragma is not either
<code>sequential</code> or <code>simple</code>.</p>
<p>Implementations of <a title="XQSX" href="#dt-xqsx">XQSX</a> must
recognize the pragma namespace URI
<code>http://www.w3.org/2008/xquery-sx-10</code>, and the pragma
name <code>xqsx:query-mode</code>.</p>
</div>
</div>
<div class="div1">
<h2><a name="id-existing-exprs" id="id-existing-exprs"></a>6
Changes to Existing Expressions</h2>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> imposes new category
rules, evaluation order and additional semantics on top of existing
<a href="#XQ10">[XQuery 1.0]</a> and <a href=
"#XQueryUpdate">[XQuery Update Facility]</a> expressions, detailed
in this section.</p>
<div class="div2">
<h3><a name="id-parenthesized-expr" id=
"id-parenthesized-expr"></a>6.1 Parentheses</h3>
<h5><a name="d7e1774" id="d7e1774"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ParenthesizedExpr" id=
"doc-xquery-ParenthesizedExpr"></a>[<small>91</small>]   </td>
<td><code><a href="#prod-xquery-ParenthesizedExpr"></a><a href=
"#prod-xquery-ParenthesizedExpr">ParenthesizedExpr</a></code></td>
<td>   ::=   </td>
<td><code>"(" <a href="#prod-xquery-Expr">Expr</a>? ")"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>An expression of any category may be enclosed in parentheses;
the resulting expression has the same category as the original
expression. An empty parenthesized expression <code>( )</code> is a
<a title="simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-function-call" id="id-function-call"></a>6.2
Function Calls</h3>
<h5><a name="d7e1800" id="d7e1800"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FunctionCall" id=
"doc-xquery-FunctionCall"></a>[<small>95</small>]   </td>
<td><code><a href="#prod-xquery-FunctionCall"></a><a href=
"#prod-xquery-FunctionCall">FunctionCall</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a> "(" (<a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*)? ")"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>If the function called is a <a title="simple function" href=
"#dt-simple-function">simple function</a>, the argument expressions
<span>can either be all <a title="simple expression" href=
"#dt-simple-expr">simple</a> and <a title="updating expression"
href="#dt-updating-expr">updating expressions</a>, or all <a title=
"simple expression" href="#dt-simple-expr">simple</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>.</span> If the argument expressions contain an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a> then the function call is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, <span>if they contain a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a> then the function call is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>,</span> otherwise it is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
<p>If the function called is an <a title="updating function" href=
"#dt-updating-function">updating function</a>, the argument
expressions must be <a title="simple expression" href=
"#dt-simple-expr">simple expressions</a> or <a title=
"updating expression" href="#dt-updating-expr">updating
expressions</a>. The function call is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
<p>If the function called is a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a>, the argument
expressions must be <a title="simple expression" href=
"#dt-simple-expr">simple expressions</a> <span>or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a></span> . The function call expression is a
<a title="updating expression" href="#dt-updating-expr">sequential
expression</a>.</p>
<p>If the arguments of a function call violate the category rules
for the function's category, [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised.</p>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Argument expressions are evaluated from left to right, then the
function is invoked.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
lists</a> returned by the argument expressions are merged with the
<a title="pending update list" href="#dt-pul">pending update
list</a> returned by the function itself by calling
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-path-expr" id="id-path-expr"></a>6.3 Path
Expressions</h3>
<h5><a name="d7e1926" id="d7e1926"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PathExpr" id=
"doc-xquery-PathExpr"></a>[<small>70</small>]   </td>
<td><code><a href="#prod-xquery-PathExpr"></a><a href=
"#prod-xquery-PathExpr">PathExpr</a></code></td>
<td>   ::=   </td>
<td><code>("/" <a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a>?)<br />
| ("//" <a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a>)<br />
| <a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-RelativePathExpr" id=
"doc-xquery-RelativePathExpr"></a>[<small>71</small>]   </td>
<td><code><a href="#prod-xquery-RelativePathExpr"></a><a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-StepExpr">StepExpr</a> (("/" |
"//") <a href="#prod-xquery-StepExpr">StepExpr</a>)*</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a path expression is determined by the following
rules:</p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if any StepExpr in the
RelativePathExpr is an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>If any StepExpr in the RelativePathExpr is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, then all StepExpr must be <a title=
"updating expression" href="#dt-updating-expr">updating</a> or
<a title="simple expression" href="#dt-simple-expr">simple
expressions</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. In this
case, the path expression is an <a title="updating expression"
href="#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any StepExpr in the RelativePathExpr is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, then all StepExpr must be <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>
or <a title="simple expression" href="#dt-simple-expr">simple
expressions</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. In this
case, the path expression is a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the path expression is a <a title="simple expression"
href="#dt-simple-expr">simple expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>StepExpr are evaluated in order from left to right.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
lists</a> returned by each of the StepExpr are merged by calling
<code>upd:mergeUpdates</code>, and returned as part of the result
of the path expression.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-predicate" id="id-predicate"></a>6.4
Predicates</h3>
<h5><a name="d7e2041" id="d7e2041"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-AxisStep" id=
"doc-xquery-AxisStep"></a>[<small>73</small>]   </td>
<td><code><a href="#prod-xquery-AxisStep"></a><a href=
"#prod-xquery-AxisStep">AxisStep</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-ReverseStep">ReverseStep</a> |
<a href="#prod-xquery-ForwardStep">ForwardStep</a>) <a href=
"#doc-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FilterExpr" id=
"doc-xquery-FilterExpr"></a>[<small>83</small>]   </td>
<td><code><a href="#prod-xquery-FilterExpr"></a><a href=
"#prod-xquery-FilterExpr">FilterExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-PrimaryExpr">PrimaryExpr</a>
<a href="#doc-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PredicateList" id=
"doc-xquery-PredicateList"></a>[<small>84</small>]   </td>
<td><code><a href="#prod-xquery-PredicateList"></a><a href=
"#prod-xquery-PredicateList">PredicateList</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#doc-xquery-Predicate">Predicate</a>*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-Predicate" id=
"doc-xquery-Predicate"></a>[<small>85</small>]   </td>
<td><code><a href="#prod-xquery-Predicate"></a><a href=
"#prod-xquery-Predicate">Predicate</a></code></td>
<td>   ::=   </td>
<td><code>"[" <a href="#prod-xquery-Expr">Expr</a> "]"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a FilterExpr or AxisStep is determined by the
following rules:</p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if the primary
expression or a predicate expression of any FilterExpr or AxisStep
is an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>If either the primary expression or any predicate expression of
a FilterExpr or AxisStep is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all such
expressions must be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the FilterExpr or
AxisStep is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If either the primary expression or any predicate expression of
a FilterExpr or AxisStep is a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>, then all such
expressions must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the FilterExpr or
AxisStep is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the FilterExpr or AxisStep is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>First the reverse step, forward step or primary expression is
evaluated, then predicates are evaluated from left to right. Each
predicate expression must be evaluated to completion before the
next is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the primary expression is merged with the
<a title="pending update list" href="#dt-pul">pending update
lists</a> returned by the predicate expressions by calling
<code>upd:mergeUpdates</code>. The resulting pending update list is
returned as part of the result of the FilterExpr or AxisStep.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-concat-expr" id="id-concat-expr"></a>6.5
Concatenation Expressions</h3>
<h5><a name="d7e2169" id="d7e2169"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ConcatExpr" id=
"doc-xquery-ConcatExpr"></a>[<small>33</small>]   </td>
<td><code><a href="#prod-xquery-ConcatExpr"></a><a href=
"#prod-xquery-ConcatExpr">ConcatExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> (","
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a concatenation expression is determined by the
following rules:</p>
<ul>
<li>
<p>If any operand is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all operands must
be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the concatenation
expression is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any operand is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, then all operands
must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the concatenation
expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the concatenation expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Operand expressions are evaluated once, from left to right. Side
effects of each sequential operand expression are visible to
subsequent operand expressions.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The concatenation expression evaluates each of its operands and
concatenates the resulting <a title="XDM instance" href=
"#dt-xdm-instance">XDM instances</a> and <a title=
"pending update list" href="#dt-pul">pending update lists</a>, in
order. <a title="pending update list" href="#dt-pul">Pending update
lists</a> are concatenated by the <code>upd:mergeUpdates</code>
operation.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-node-constructors" id=
"id-node-constructors"></a>6.6 Direct and Computed Node
Constructors</h3>
<h5><a name="d7e2256" id="d7e2256"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirElemConstructor" id=
"doc-xquery-DirElemConstructor"></a>[<small>98</small>]   </td>
<td><code><a href="#prod-xquery-DirElemConstructor"></a><a href=
"#prod-xquery-DirElemConstructor">DirElemConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"<" <a href="#prod-xquery-QName">QName</a> <a href=
"#doc-xquery-DirAttributeList">DirAttributeList</a> ("/>" |
(">" <a href="#prod-xquery-DirElemContent">DirElemContent</a>*
"</" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-S">S</a>? ">"))</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirAttributeList" id=
"doc-xquery-DirAttributeList"></a>[<small>99</small>]   </td>
<td><code><a href="#prod-xquery-DirAttributeList"></a><a href=
"#prod-xquery-DirAttributeList">DirAttributeList</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-S">S</a> (<a href=
"#prod-xquery-QName">QName</a> <a href="#prod-xquery-S">S</a>? "="
<a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-DirAttributeValue">DirAttributeValue</a>)?)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CDataSection" id=
"doc-xquery-CDataSection"></a>[<small>109</small>]   </td>
<td><code><a href="#prod-xquery-CDataSection"></a><a href=
"#prod-xquery-CDataSection">CDataSection</a></code></td>
<td>   ::=   </td>
<td><code>"<![CDATA[" <a href=
"#prod-xquery-CDataSectionContents">CDataSectionContents</a>
"]]>"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirPIConstructor" id=
"doc-xquery-DirPIConstructor"></a>[<small>107</small>]   </td>
<td><code><a href="#prod-xquery-DirPIConstructor"></a><a href=
"#prod-xquery-DirPIConstructor">DirPIConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"<?" <a href="#prod-xquery-PITarget">PITarget</a>
(<a href="#prod-xquery-S">S</a> <a href=
"#prod-xquery-DirPIContents">DirPIContents</a>)?
"?>"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirCommentConstructor" id=
"doc-xquery-DirCommentConstructor"></a>[<small>105</small>]   </td>
<td><code><a href="#prod-xquery-DirCommentConstructor"></a><a href=
"#prod-xquery-DirCommentConstructor">DirCommentConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"<!--" <a href=
"#prod-xquery-DirCommentContents">DirCommentContents</a>
"-->"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompElemConstructor" id=
"doc-xquery-CompElemConstructor"></a>[<small>113</small>]   </td>
<td><code><a href="#prod-xquery-CompElemConstructor"></a><a href=
"#prod-xquery-CompElemConstructor">CompElemConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"element" (<a href="#prod-xquery-QName">QName</a> | ("{"
<a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-ContentExpr">ContentExpr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompAttrConstructor" id=
"doc-xquery-CompAttrConstructor"></a>[<small>115</small>]   </td>
<td><code><a href="#prod-xquery-CompAttrConstructor"></a><a href=
"#prod-xquery-CompAttrConstructor">CompAttrConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"attribute" (<a href="#prod-xquery-QName">QName</a> |
("{" <a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompDocConstructor" id=
"doc-xquery-CompDocConstructor"></a>[<small>112</small>]   </td>
<td><code><a href="#prod-xquery-CompDocConstructor"></a><a href=
"#prod-xquery-CompDocConstructor">CompDocConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"document" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompTextConstructor" id=
"doc-xquery-CompTextConstructor"></a>[<small>116</small>]   </td>
<td><code><a href="#prod-xquery-CompTextConstructor"></a><a href=
"#prod-xquery-CompTextConstructor">CompTextConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"text" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompPIConstructor" id=
"doc-xquery-CompPIConstructor"></a>[<small>118</small>]   </td>
<td><code><a href="#prod-xquery-CompPIConstructor"></a><a href=
"#prod-xquery-CompPIConstructor">CompPIConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"processing-instruction" (<a href=
"#prod-xquery-NCName">NCName</a> | ("{" <a href=
"#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompCommentConstructor" id=
"doc-xquery-CompCommentConstructor"></a>[<small>117</small>]   </td>
<td><code><a href=
"#prod-xquery-CompCommentConstructor"></a><a href="#prod-xquery-CompCommentConstructor">CompCommentConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"comment" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a node constructor is determined by the
following rules:</p>
<ul>
<li>
<p>If any operand is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all operands must
be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the node
constructor is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any operand is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, then all operands
must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the node
constructor is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the node constructor is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<ol class="enumar">
<li>
<p>The name expression is evaluated (computed
element/attribute/processing-instruction constructors only).</p>
</li>
<li>
<p>The direct attribute constructors are evaluated from left to
right (direct element constructors only).</p>
</li>
<li>
<p>The child or value expressions are evaluated from left to
right.</p>
</li>
</ol>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
lists</a> from each operand expression are concatenated by the
<code>upd:mergeUpdates</code> operation, producing the resulting
pending update list.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-FLWOR-expr" id="id-FLWOR-expr"></a>6.7 FLWOR
Expressions</h3>
<h5><a name="d7e2472" id="d7e2472"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FLWORExpr" id=
"doc-xquery-FLWORExpr"></a>[<small>35</small>]   </td>
<td><code><a href="#prod-xquery-FLWORExpr"></a><a href=
"#prod-xquery-FLWORExpr">FLWORExpr</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#doc-xquery-ForClause">ForClause</a> | <a href=
"#doc-xquery-LetClause">LetClause</a>)+ <a href=
"#doc-xquery-WhereClause">WhereClause</a>? <a href=
"#doc-xquery-OrderByClause">OrderByClause</a>? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ForClause" id=
"doc-xquery-ForClause"></a>[<small>36</small>]   </td>
<td><code><a href="#prod-xquery-ForClause"></a><a href=
"#prod-xquery-ForClause">ForClause</a></code></td>
<td>   ::=   </td>
<td><code>"for" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>?
<a href="#doc-xquery-PositionalVar">PositionalVar</a>? "in"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? <a href=
"#doc-xquery-PositionalVar">PositionalVar</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PositionalVar" id=
"doc-xquery-PositionalVar"></a>[<small>37</small>]   </td>
<td><code><a href="#prod-xquery-PositionalVar"></a><a href=
"#prod-xquery-PositionalVar">PositionalVar</a></code></td>
<td>   ::=   </td>
<td><code>"at" "$" <a href=
"#prod-xquery-VarName">VarName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-LetClause" id=
"doc-xquery-LetClause"></a>[<small>38</small>]   </td>
<td><code><a href="#prod-xquery-LetClause"></a><a href=
"#prod-xquery-LetClause">LetClause</a></code></td>
<td>   ::=   </td>
<td><code>"let" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-WhereClause" id=
"doc-xquery-WhereClause"></a>[<small>39</small>]   </td>
<td><code><a href="#prod-xquery-WhereClause"></a><a href=
"#prod-xquery-WhereClause">WhereClause</a></code></td>
<td>   ::=   </td>
<td><code>"where" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderByClause" id=
"doc-xquery-OrderByClause"></a>[<small>40</small>]   </td>
<td><code><a href="#prod-xquery-OrderByClause"></a><a href=
"#prod-xquery-OrderByClause">OrderByClause</a></code></td>
<td>   ::=   </td>
<td><code>(("order" "by") | ("stable" "order" "by")) <a href=
"#doc-xquery-OrderSpecList">OrderSpecList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderSpecList" id=
"doc-xquery-OrderSpecList"></a>[<small>41</small>]   </td>
<td><code><a href="#prod-xquery-OrderSpecList"></a><a href=
"#prod-xquery-OrderSpecList">OrderSpecList</a></code></td>
<td>   ::=   </td>
<td><code><a href="#doc-xquery-OrderSpec">OrderSpec</a> (","
<a href="#doc-xquery-OrderSpec">OrderSpec</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderSpec" id=
"doc-xquery-OrderSpec"></a>[<small>42</small>]   </td>
<td><code><a href="#prod-xquery-OrderSpec"></a><a href=
"#prod-xquery-OrderSpec">OrderSpec</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> <a href=
"#doc-xquery-OrderModifier">OrderModifier</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderModifier" id=
"doc-xquery-OrderModifier"></a>[<small>43</small>]   </td>
<td><code><a href="#prod-xquery-OrderModifier"></a><a href=
"#prod-xquery-OrderModifier">OrderModifier</a></code></td>
<td>   ::=   </td>
<td><code>("ascending" | "descending")? ("empty" ("greatest" |
"least"))? ("collation" <a href=
"#prod-xquery-URILiteral">URILiteral</a>)?</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The <code>for</code>, <code>let</code>, <code>where</code>, and
<code>order by</code> clauses <span>can either be all <a title=
"simple expression" href="#dt-simple-expr">simple</a></span>
<span>and <a title="updating expression" href=
"#dt-updating-expr">updating expressions</a>, or all <a title=
"simple expression" href="#dt-simple-expr">simple</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>.</span></p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if any <code>for</code>,
<code>let</code>, <code>where</code>, or <code>order by</code>
clause is an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>If the above clauses contain an <a title="updating expression"
href="#dt-updating-expr">updating expression</a>, then all clauses
must either be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a> or an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. The FLWOR
expression itself is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If the above clauses contain a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>, then all
clauses must either be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a> or an <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. The FLWOR
expression itself is an <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>If the above clauses do not contain an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a> <span>or a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a></span>, then the
<code>return</code> clause may be an expression of any category.
The category of the FLWOR expression is the same as the category of
the expression in its <code>return</code> clause.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<ul>
<li>
<p><em>For Clause:</em> The associated expression is evaluated
first to produce the binding sequnce, then the next clause is
evaluated once for each item in the binding sequence. Any side
effects in the associated expression are visible to the evaluation
of the next clause.</p>
</li>
<li>
<p><em>Let Clause:</em> The associated expression is evaluated
first to produce the binding sequnce, then the next clause is
evaluated. Any side effects in the associated expression are
visible to the evaluation of the next clause.</p>
</li>
<li>
<p><em>Where Clause:</em> The where expression is evaluated once,
then the next clause is evaluated. Any side effects in the where
expression are visible to the evaluation of the next clause.</p>
</li>
<li>
<p><em>Order By Clause:</em> The orderspecs are evaluated from left
to right on each tuple in the tuple stream. The tuple stream is
reordered, then the next clause is evaluated.</p>
</li>
<li>
<p><em>Return Clause:</em> The return expresion is evaluated
once.</p>
</li>
</ul>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The result of a FLWOR expression is the concatenation of the
<a title="XDM instance" href="#dt-xdm-instance">XDM instances</a>
or <a title="pending update list" href="#dt-pul">pending update
lists</a> returned by successive evaluations of the
<code>return</code> clause in evaluation order, as well as the
<a title="pending update list" href="#dt-pul">pending update
lists</a> returned by any of the other FLWOR clauses. <a title=
"pending update list" href="#dt-pul">Pending update lists</a> are
concatenated by the <code>upd:mergeUpdates</code> operation.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-conditional-expr" id="id-conditional-expr"></a>6.8
Conditional Expressions</h3>
<h5><a name="d7e2785" id="d7e2785"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-IfExpr" id=
"doc-xquery-IfExpr"></a>[<small>47</small>]   </td>
<td><code><a href="#prod-xquery-IfExpr"></a><a href=
"#prod-xquery-IfExpr">IfExpr</a></code></td>
<td>   ::=   </td>
<td><code>"if" "(" <a href="#prod-xquery-Expr">Expr</a> ")" "then"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> "else" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The test, then and else expressions can be of any type. An error
[<a href="#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>] is
raised if one of the expressions is <a title="updating expression"
href="#dt-updating-expr">updating</a> and another is <a title=
"sequential expression" href=
"#dt-sequential-expr">sequential</a>.</p>
<ul>
<li>
<p>If the test, then or else expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, the conditional expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>If the test, then or else expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, the conditional expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>Otherise, the conditional expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>The test expression is evaluated first. Next either the then
expression or the else expression (but not both) is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the conditional expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the test expression and the executed branch
of the conditional expression using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-quantified-expr" id="id-quantified-expr"></a>6.9
Quantified Expressions</h3>
<h5><a name="d7e2914" id="d7e2914"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-QuantifiedExpr" id=
"doc-xquery-QuantifiedExpr"></a>[<small>44</small>]   </td>
<td><code><a href="#prod-xquery-QuantifiedExpr"></a><a href=
"#prod-xquery-QuantifiedExpr">QuantifiedExpr</a></code></td>
<td>   ::=   </td>
<td><code>("some" | "every") "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "satisfies" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a quantified expression is determined by the
following rules:</p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if any quantified
expression clause or the satisfies expression is an <a title=
"updating expression" href="#dt-updating-expr">updating</a> or
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>If any quantified expression clause or the satisfies expression
is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all such
expressions must be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the quantified
expression is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any quantified expression clause or the satisfies expression
is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, then all such
expressions must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the quantified
expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the quantified expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>The quantified expression clauses are initially evaluated as
specified by <a href="#XQ10">[XQuery 1.0]</a>, generating a tuple
stream. Then the satisfies clause is evaluated once for each tuple
in the tuple stream, in order. If the satisfies clause contains a
sequential expression, the side effects of each iteration are
visible to subsequent evaluations of the return clause.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the quantified expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the quantified expression clauses and the
satisfies expression using <code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-typeswitch-expr" id="id-typeswitch-expr"></a>6.10
Typeswitch Expressions</h3>
<h5><a name="d7e3034" id="d7e3034"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-TypeswitchExpr" id=
"doc-xquery-TypeswitchExpr"></a>[<small>45</small>]   </td>
<td><code><a href="#prod-xquery-TypeswitchExpr"></a><a href=
"#prod-xquery-TypeswitchExpr">TypeswitchExpr</a></code></td>
<td>   ::=   </td>
<td><code>"typeswitch" "(" <a href="#prod-xquery-Expr">Expr</a> ")"
<a href="#prod-xquery-CaseClause">CaseClause</a>+ "default" ("$"
<a href="#prod-xquery-VarName">VarName</a>)? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The operand, case and default expressions can be of any type. An
error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised if one of the
expressions is <a title="updating expression" href=
"#dt-updating-expr">updating</a> and another is <a title=
"sequential expression" href=
"#dt-sequential-expr">sequential</a>.</p>
<ul>
<li>
<p>If an operand, case or default expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, the typeswitch expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>If an operand, case or default expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, the typeswitch expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>Otherise, the typeswitch expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>The operand expression is evaluated first. Then, exactly one of
the return expressions is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the typeswitch expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the operand expression and the executed
branch of the typeswitch expression using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-update-expr" id="id-update-expr"></a>6.11 Insert,
Delete, Replace, and Rename Expressions</h3>
<h5><a name="d7e3172" id="d7e3172"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-InsertExpr" id=
"doc-xquery-InsertExpr"></a>[<small>145</small>]   </td>
<td><code><a href="#prod-xquery-InsertExpr"></a><a href=
"#prod-xquery-InsertExpr">InsertExpr</a></code></td>
<td>   ::=   </td>
<td><code>"insert" ("node" | "nodes") <a href=
"#doc-xquery-SourceExpr">SourceExpr</a> <a href=
"#doc-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a>
<a href="#doc-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-InsertExprTargetChoice" id=
"doc-xquery-InsertExprTargetChoice"></a>[<small>144</small>]   </td>
<td><code><a href=
"#prod-xquery-InsertExprTargetChoice"></a><a href="#prod-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a></code></td>
<td>   ::=   </td>
<td><code>(("as" ("first" | "last"))? "into")<br />
| "after"<br />
| "before"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DeleteExpr" id=
"doc-xquery-DeleteExpr"></a>[<small>146</small>]   </td>
<td><code><a href="#prod-xquery-DeleteExpr"></a><a href=
"#prod-xquery-DeleteExpr">DeleteExpr</a></code></td>
<td>   ::=   </td>
<td><code>"delete" ("node" | "nodes") <a href=
"#doc-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ReplaceExpr" id=
"doc-xquery-ReplaceExpr"></a>[<small>147</small>]   </td>
<td><code><a href="#prod-xquery-ReplaceExpr"></a><a href=
"#prod-xquery-ReplaceExpr">ReplaceExpr</a></code></td>
<td>   ::=   </td>
<td><code>"replace" ("value" "of")? "node" <a href=
"#doc-xquery-TargetExpr">TargetExpr</a> "with" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-RenameExpr" id=
"doc-xquery-RenameExpr"></a>[<small>148</small>]   </td>
<td><code><a href="#prod-xquery-RenameExpr"></a><a href=
"#prod-xquery-RenameExpr">RenameExpr</a></code></td>
<td>   ::=   </td>
<td><code>"rename" "node" <a href=
"#doc-xquery-TargetExpr">TargetExpr</a> "as" <a href=
"#doc-xquery-NewNameExpr">NewNameExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-SourceExpr" id=
"doc-xquery-SourceExpr"></a>[<small>149</small>]   </td>
<td><code><a href="#prod-xquery-SourceExpr"></a><a href=
"#prod-xquery-SourceExpr">SourceExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-TargetExpr" id=
"doc-xquery-TargetExpr"></a>[<small>150</small>]   </td>
<td><code><a href="#prod-xquery-TargetExpr"></a><a href=
"#prod-xquery-TargetExpr">TargetExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-NewNameExpr" id=
"doc-xquery-NewNameExpr"></a>[<small>151</small>]   </td>
<td><code><a href="#prod-xquery-NewNameExpr"></a><a href=
"#prod-xquery-NewNameExpr">NewNameExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>Insert, delete, replace, and rename expressions are <a title=
"updating expression" href="#dt-updating-expr">updating
expressions</a>, and are extended to accept both <a title=
"updating expression" href="#dt-updating-expr">updating</a> and
<a title="simple expression" href="#dt-simple-expr">simple
expressions</a> as their operands. It is a static error [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>] for the
operand of one of these expressions to be a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Order of evaluation for insert, delete, replace, and rename
expressions is irrelevent since their operands cannot be sequential
expressions.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by insert, delete, replace, and rename
expressions is calculated by merging the <a title=
"pending update list" href="#dt-pul">pending update lists</a> from
the operands of the expression and the <a title=
"pending update list" href="#dt-pul">pending update list</a>
produced by the expression itself using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-transform-expr" id="id-transform-expr"></a>6.12
Transform Expressions</h3>
<h5><a name="d7e3289" id="d7e3289"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-TransformExpr" id=
"doc-xquery-TransformExpr"></a>[<small>152</small>]   </td>
<td><code><a href="#prod-xquery-TransformExpr"></a><a href=
"#prod-xquery-TransformExpr">TransformExpr</a></code></td>
<td>   ::=   </td>
<td><code>"copy" "$" <a href="#prod-xquery-VarName">VarName</a>
":=" <a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$"
<a href="#prod-xquery-VarName">VarName</a> ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "modify" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The copy, modify and return clauses of a transform expression
can be of any type. An error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised if one of the copy or
return clauses is <a title="updating expression" href=
"#dt-updating-expr">updating</a> and either the copy, modify or
return clauses is <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a>.</p>
<ul>
<li>
<p>If one of the copy or return clauses is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, the transform expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>If one of the copy, modify or return clauses is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, the transform expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>Otherise, the transform expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Copy clauses are evaluated in order, then the modify expression
is evaluated. Finally the return clause is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The semantics of a transform expression as defined in <a href=
"http://www.w3.org/TR/xquery-update-10/#id-transform">Section 2.4.5
Transform</a><sup><small>XU</small></sup> are extended as
follows:</p>
<ul>
<li>
<p>If the modify clause returns a non-empty <a title="XDM instance"
href="#dt-xdm-instance">XDM instance</a> it is discarded.</p>
</li>
<li>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the transform expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the copy clause and the return clause using
<code>upd:mergeUpdates</code>.</p>
</li>
</ul>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-other-expr" id="id-other-expr"></a>6.13 Other
Expressions</h3>
<p>All expressions not listed above are extended as follows. This
includes the following kinds of expressions:</p>
<ul>
<li>
<p>Range expressions</p>
</li>
<li>
<p>Union, intersect, and except expressions</p>
</li>
<li>
<p>Arithmetic, comparison, and logical expressions</p>
</li>
<li>
<p>Ordered and unordered expressions</p>
</li>
<li>
<p>Instance of, cast, castable, and treat expressions</p>
</li>
<li>
<p>Validate expressions</p>
</li>
<li>
<p>Extension expressions (pragmas)</p>
</li>
</ul>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>All other expressions are extended to accept any type of
expressions as their operands. An error [<a href="#ERRSXST0002"
title="err:SXST0002">err:SXST0002</a>] is raised if one of the
operands is <a title="updating expression" href=
"#dt-updating-expr">updating</a> and another is <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>.
If an operand of the expression is <a title="updating expression"
href="#dt-updating-expr">updating</a> then the expression itself is
<a title="updating expression" href=
"#dt-updating-expr">updating</a>, if an operand is <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>
then the expression itself is <a title="sequential expression"
href="#dt-sequential-expr">sequential</a>, otherwise it is
<a title="simple expression" href="#dt-simple-expr">simple</a>.</p>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Operand expressions are evaluated once, from left to right.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by any other expression is calculated by merging
the <a title="pending update list" href="#dt-pul">pending update
lists</a> from the operands of that expression using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
</div>
<div class="div1">
<h2><a name="id-example" id="id-example"></a>7 Example</h2>
<p>The following function returns <code>true</code> or
<code>false</code> according to whether its parameter is a known
user name, and logs the event:</p>
<div class="exampleInner">
<pre>
declare sequential function validate-and-log($username as xs:string)
as xs:boolean {
declare $log as document-node() := fn:doc("log.xml");
declare $entry as element() :=
<access-attempt>
<timestamp>{fn:current-dateTime()}</timestamp>
<user-name>{$username}</user-name>
<access-allowed/>
</access-attempt> ;
declare $result as xs:boolean;
if ($username = doc("users.xml")/current-users/user/name )
then (
replace value of node $entry/access-allowed with "Yes";
$result := true();
) else (
replace value of node $entry/access-allowed with "No";
$result := false();
);
insert node $entry as last into $log;
fn:put($log, "log.xml");
exit returning $result;
}
</pre></div>
</div>
</div>
<div class="back">
<div class="div1">
<h2><a name="id-grammar" id="id-grammar"></a>A EBNF for XQuery 1.0
Grammar with Scripting Extensions</h2>
<p>The EBNF in this document and in this section is aligned with
the current XML Query 1.0 grammar (see <a href="#XQ10">[XQuery
1.0]</a>).</p>
<h5><a name="d7e3564" id="d7e3564"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Module" id=
"prod-xquery-Module"></a>[<small>1</small>]   </td>
<td><code>Module</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-VersionDecl">VersionDecl</a>?
(<a href="#prod-xquery-LibraryModule">LibraryModule</a> | <a href=
"#prod-xquery-MainModule">MainModule</a>)</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VersionDecl" id=
"prod-xquery-VersionDecl"></a>[<small>2</small>]   </td>
<td><code>VersionDecl</code></td>
<td>   ::=   </td>
<td><code>"xquery" "version" <a href=
"#prod-xquery-StringLiteral">StringLiteral</a> ("encoding" <a href=
"#prod-xquery-StringLiteral">StringLiteral</a>)? <a href=
"#prod-xquery-Separator">Separator</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-MainModule" id=
"prod-xquery-MainModule"></a>[<small>3</small>]   </td>
<td><code>MainModule</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Prolog">Prolog</a> <a href=
"#prod-xquery-QueryBody">QueryBody</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-LibraryModule" id=
"prod-xquery-LibraryModule"></a>[<small>4</small>]   </td>
<td><code>LibraryModule</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ModuleDecl">ModuleDecl</a> <a href=
"#prod-xquery-Prolog">Prolog</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ModuleDecl" id=
"prod-xquery-ModuleDecl"></a>[<small>5</small>]   </td>
<td><code>ModuleDecl</code></td>
<td>   ::=   </td>
<td><code>"module" "namespace" <a href=
"#prod-xquery-NCName">NCName</a> "=" <a href=
"#prod-xquery-URILiteral">URILiteral</a> <a href=
"#prod-xquery-Separator">Separator</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Prolog" id=
"prod-xquery-Prolog"></a>[<small>6</small>]   </td>
<td><code>Prolog</code></td>
<td>   ::=   </td>
<td><code>((<a href=
"#prod-xquery-DefaultNamespaceDecl">DefaultNamespaceDecl</a> |
<a href="#prod-xquery-Setter">Setter</a> | <a href=
"#prod-xquery-NamespaceDecl">NamespaceDecl</a> | <a href=
"#prod-xquery-Import">Import</a>) <a href=
"#prod-xquery-Separator">Separator</a>)* ((<a href=
"#prod-xquery-VarDecl">VarDecl</a> | <a href=
"#prod-xquery-FunctionDecl">FunctionDecl</a> | <a href=
"#prod-xquery-OptionDecl">OptionDecl</a>) <a href=
"#prod-xquery-Separator">Separator</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Setter" id=
"prod-xquery-Setter"></a>[<small>7</small>]   </td>
<td><code>Setter</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-BoundarySpaceDecl">BoundarySpaceDecl</a> | <a href=
"#prod-xquery-DefaultCollationDecl">DefaultCollationDecl</a> |
<a href="#prod-xquery-BaseURIDecl">BaseURIDecl</a> | <a href=
"#prod-xquery-ConstructionDecl">ConstructionDecl</a> | <a href=
"#prod-xquery-OrderingModeDecl">OrderingModeDecl</a> | <a href=
"#prod-xquery-EmptyOrderDecl">EmptyOrderDecl</a> | <a href=
"#prod-xquery-RevalidationDecl">RevalidationDecl</a> | <a href=
"#prod-xquery-CopyNamespacesDecl">CopyNamespacesDecl</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Import" id=
"prod-xquery-Import"></a>[<small>8</small>]   </td>
<td><code>Import</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-SchemaImport">SchemaImport</a> |
<a href="#prod-xquery-ModuleImport">ModuleImport</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Separator" id=
"prod-xquery-Separator"></a>[<small>9</small>]   </td>
<td><code>Separator</code></td>
<td>   ::=   </td>
<td><code>";"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NamespaceDecl" id=
"prod-xquery-NamespaceDecl"></a>[<small>10</small>]   </td>
<td><code>NamespaceDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "namespace" <a href=
"#prod-xquery-NCName">NCName</a> "=" <a href=
"#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BoundarySpaceDecl" id=
"prod-xquery-BoundarySpaceDecl"></a>[<small>11</small>]   </td>
<td><code>BoundarySpaceDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "boundary-space" ("preserve" |
"strip")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DefaultNamespaceDecl" id=
"prod-xquery-DefaultNamespaceDecl"></a>[<small>12</small>]   </td>
<td><code>DefaultNamespaceDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "default" ("element" | "function") "namespace"
<a href="#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OptionDecl" id=
"prod-xquery-OptionDecl"></a>[<small>13</small>]   </td>
<td><code><a href="#doc-xquery-OptionDecl"></a><a href=
"#doc-xquery-OptionDecl">OptionDecl</a></code></td>
<td>   ::=   </td>
<td><code>"declare" "option" <a href="#prod-xquery-QName">QName</a>
<a href="#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderingModeDecl" id=
"prod-xquery-OrderingModeDecl"></a>[<small>14</small>]   </td>
<td><code>OrderingModeDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "ordering" ("ordered" |
"unordered")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EmptyOrderDecl" id=
"prod-xquery-EmptyOrderDecl"></a>[<small>15</small>]   </td>
<td><code>EmptyOrderDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "default" "order" "empty" ("greatest" |
"least")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CopyNamespacesDecl" id=
"prod-xquery-CopyNamespacesDecl"></a>[<small>16</small>]   </td>
<td><code>CopyNamespacesDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "copy-namespaces" <a href=
"#prod-xquery-PreserveMode">PreserveMode</a> "," <a href=
"#prod-xquery-InheritMode">InheritMode</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PreserveMode" id=
"prod-xquery-PreserveMode"></a>[<small>17</small>]   </td>
<td><code>PreserveMode</code></td>
<td>   ::=   </td>
<td><code>"preserve" | "no-preserve"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InheritMode" id=
"prod-xquery-InheritMode"></a>[<small>18</small>]   </td>
<td><code>InheritMode</code></td>
<td>   ::=   </td>
<td><code>"inherit" | "no-inherit"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DefaultCollationDecl" id=
"prod-xquery-DefaultCollationDecl"></a>[<small>19</small>]   </td>
<td><code>DefaultCollationDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "default" "collation" <a href=
"#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BaseURIDecl" id=
"prod-xquery-BaseURIDecl"></a>[<small>20</small>]   </td>
<td><code>BaseURIDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "base-uri" <a href=
"#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaImport" id=
"prod-xquery-SchemaImport"></a>[<small>21</small>]   </td>
<td><code>SchemaImport</code></td>
<td>   ::=   </td>
<td><code>"import" "schema" <a href=
"#prod-xquery-SchemaPrefix">SchemaPrefix</a>? <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("at" <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("," <a href=
"#prod-xquery-URILiteral">URILiteral</a>)*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaPrefix" id=
"prod-xquery-SchemaPrefix"></a>[<small>22</small>]   </td>
<td><code>SchemaPrefix</code></td>
<td>   ::=   </td>
<td><code>("namespace" <a href="#prod-xquery-NCName">NCName</a>
"=") | ("default" "element" "namespace")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ModuleImport" id=
"prod-xquery-ModuleImport"></a>[<small>23</small>]   </td>
<td><code>ModuleImport</code></td>
<td>   ::=   </td>
<td><code>"import" "module" ("namespace" <a href=
"#prod-xquery-NCName">NCName</a> "=")? <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("at" <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("," <a href=
"#prod-xquery-URILiteral">URILiteral</a>)*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VarDecl" id=
"prod-xquery-VarDecl"></a>[<small>24</small>]   </td>
<td><code><a href="#doc-xquery-VarDecl"></a><a href=
"#doc-xquery-VarDecl">VarDecl</a></code></td>
<td>   ::=   </td>
<td><code>"declare" ("unassignable"? | "assignable") "variable" "$"
<a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ((":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>) | "external")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ConstructionDecl" id=
"prod-xquery-ConstructionDecl"></a>[<small>25</small>]   </td>
<td><code>ConstructionDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "construction" ("strip" |
"preserve")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FunctionDecl" id=
"prod-xquery-FunctionDecl"></a>[<small>26</small>]   </td>
<td><code><a href="#doc-xquery-FunctionDecl"></a><a href=
"#doc-xquery-FunctionDecl">FunctionDecl</a></code></td>
<td>   ::=   </td>
<td><code>("declare" ("simple"? | "updating") "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#prod-xquery-EnclosedExpr">EnclosedExpr</a> | "external"))<br />
| ("declare" "sequential" "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#prod-xquery-Block">Block</a> | "external"))</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ParamList" id=
"prod-xquery-ParamList"></a>[<small>27</small>]   </td>
<td><code>ParamList</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Param">Param</a> ("," <a href=
"#prod-xquery-Param">Param</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Param" id=
"prod-xquery-Param"></a>[<small>28</small>]   </td>
<td><code>Param</code></td>
<td>   ::=   </td>
<td><code>"$" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EnclosedExpr" id=
"prod-xquery-EnclosedExpr"></a>[<small>29</small>]   </td>
<td><code>EnclosedExpr</code></td>
<td>   ::=   </td>
<td><code>"{" <a href="#prod-xquery-Expr">Expr</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QueryBody" id=
"prod-xquery-QueryBody"></a>[<small>30</small>]   </td>
<td><code>QueryBody</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Expr" id=
"prod-xquery-Expr"></a>[<small>31</small>]   </td>
<td><code>Expr</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ApplyExpr">ApplyExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ApplyExpr" id=
"prod-xquery-ApplyExpr"></a>[<small>32</small>]   </td>
<td><code><a href="#doc-xquery-ApplyExpr"></a><a href=
"#doc-xquery-ApplyExpr">ApplyExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ConcatExpr">ConcatExpr</a> (";"
(<a href="#prod-xquery-ConcatExpr">ConcatExpr</a>
";")*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ConcatExpr" id=
"prod-xquery-ConcatExpr"></a>[<small>33</small>]   </td>
<td><code><a href="#doc-xquery-ConcatExpr"></a><a href=
"#doc-xquery-ConcatExpr">ConcatExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> (","
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ExprSingle" id=
"prod-xquery-ExprSingle"></a>[<small>34</small>]   </td>
<td><code>ExprSingle</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-FLWORExpr">FLWORExpr</a><br />
| <a href="#prod-xquery-QuantifiedExpr">QuantifiedExpr</a><br />
| <a href="#prod-xquery-TypeswitchExpr">TypeswitchExpr</a><br />
| <a href="#prod-xquery-IfExpr">IfExpr</a><br />
| <a href="#prod-xquery-InsertExpr">InsertExpr</a><br />
| <a href="#prod-xquery-DeleteExpr">DeleteExpr</a><br />
| <a href="#prod-xquery-RenameExpr">RenameExpr</a><br />
| <a href="#prod-xquery-ReplaceExpr">ReplaceExpr</a><br />
| <a href="#prod-xquery-TransformExpr">TransformExpr</a><br />
| <a href="#prod-xquery-BlockExpr">BlockExpr</a><br />
| <a href="#prod-xquery-AssignmentExpr">AssignmentExpr</a><br />
| <a href="#prod-xquery-ExitExpr">ExitExpr</a><br />
| <a href="#prod-xquery-WhileExpr">WhileExpr</a><br />
| <a href="#prod-xquery-OrExpr">OrExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FLWORExpr" id=
"prod-xquery-FLWORExpr"></a>[<small>35</small>]   </td>
<td><code><a href="#doc-xquery-FLWORExpr"></a><a href=
"#doc-xquery-FLWORExpr">FLWORExpr</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-ForClause">ForClause</a> |
<a href="#prod-xquery-LetClause">LetClause</a>)+ <a href=
"#prod-xquery-WhereClause">WhereClause</a>? <a href=
"#prod-xquery-OrderByClause">OrderByClause</a>? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ForClause" id=
"prod-xquery-ForClause"></a>[<small>36</small>]   </td>
<td><code><a href="#doc-xquery-ForClause"></a><a href=
"#doc-xquery-ForClause">ForClause</a></code></td>
<td>   ::=   </td>
<td><code>"for" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>?
<a href="#prod-xquery-PositionalVar">PositionalVar</a>? "in"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? <a href=
"#prod-xquery-PositionalVar">PositionalVar</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PositionalVar" id=
"prod-xquery-PositionalVar"></a>[<small>37</small>]   </td>
<td><code><a href="#doc-xquery-PositionalVar"></a><a href=
"#doc-xquery-PositionalVar">PositionalVar</a></code></td>
<td>   ::=   </td>
<td><code>"at" "$" <a href=
"#prod-xquery-VarName">VarName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-LetClause" id=
"prod-xquery-LetClause"></a>[<small>38</small>]   </td>
<td><code><a href="#doc-xquery-LetClause"></a><a href=
"#doc-xquery-LetClause">LetClause</a></code></td>
<td>   ::=   </td>
<td><code>"let" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-WhereClause" id=
"prod-xquery-WhereClause"></a>[<small>39</small>]   </td>
<td><code><a href="#doc-xquery-WhereClause"></a><a href=
"#doc-xquery-WhereClause">WhereClause</a></code></td>
<td>   ::=   </td>
<td><code>"where" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderByClause" id=
"prod-xquery-OrderByClause"></a>[<small>40</small>]   </td>
<td><code><a href="#doc-xquery-OrderByClause"></a><a href=
"#doc-xquery-OrderByClause">OrderByClause</a></code></td>
<td>   ::=   </td>
<td><code>(("order" "by") | ("stable" "order" "by")) <a href=
"#prod-xquery-OrderSpecList">OrderSpecList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderSpecList" id=
"prod-xquery-OrderSpecList"></a>[<small>41</small>]   </td>
<td><code><a href="#doc-xquery-OrderSpecList"></a><a href=
"#doc-xquery-OrderSpecList">OrderSpecList</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-OrderSpec">OrderSpec</a> (","
<a href="#prod-xquery-OrderSpec">OrderSpec</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderSpec" id=
"prod-xquery-OrderSpec"></a>[<small>42</small>]   </td>
<td><code><a href="#doc-xquery-OrderSpec"></a><a href=
"#doc-xquery-OrderSpec">OrderSpec</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> <a href=
"#prod-xquery-OrderModifier">OrderModifier</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderModifier" id=
"prod-xquery-OrderModifier"></a>[<small>43</small>]   </td>
<td><code><a href="#doc-xquery-OrderModifier"></a><a href=
"#doc-xquery-OrderModifier">OrderModifier</a></code></td>
<td>   ::=   </td>
<td><code>("ascending" | "descending")? ("empty" ("greatest" |
"least"))? ("collation" <a href=
"#prod-xquery-URILiteral">URILiteral</a>)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QuantifiedExpr" id=
"prod-xquery-QuantifiedExpr"></a>[<small>44</small>]   </td>
<td><code><a href="#doc-xquery-QuantifiedExpr"></a><a href=
"#doc-xquery-QuantifiedExpr">QuantifiedExpr</a></code></td>
<td>   ::=   </td>
<td><code>("some" | "every") "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "satisfies" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TypeswitchExpr" id=
"prod-xquery-TypeswitchExpr"></a>[<small>45</small>]   </td>
<td><code><a href="#doc-xquery-TypeswitchExpr"></a><a href=
"#doc-xquery-TypeswitchExpr">TypeswitchExpr</a></code></td>
<td>   ::=   </td>
<td><code>"typeswitch" "(" <a href="#prod-xquery-Expr">Expr</a> ")"
<a href="#prod-xquery-CaseClause">CaseClause</a>+ "default" ("$"
<a href="#prod-xquery-VarName">VarName</a>)? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CaseClause" id=
"prod-xquery-CaseClause"></a>[<small>46</small>]   </td>
<td><code>CaseClause</code></td>
<td>   ::=   </td>
<td><code>"case" ("$" <a href="#prod-xquery-VarName">VarName</a>
"as")? <a href="#prod-xquery-SequenceType">SequenceType</a>
"return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-IfExpr" id=
"prod-xquery-IfExpr"></a>[<small>47</small>]   </td>
<td><code><a href="#doc-xquery-IfExpr"></a><a href=
"#doc-xquery-IfExpr">IfExpr</a></code></td>
<td>   ::=   </td>
<td><code>"if" "(" <a href="#prod-xquery-Expr">Expr</a> ")" "then"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> "else" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrExpr" id=
"prod-xquery-OrExpr"></a>[<small>48</small>]   </td>
<td><code>OrExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-AndExpr">AndExpr</a> ( "or"
<a href="#prod-xquery-AndExpr">AndExpr</a> )*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AndExpr" id=
"prod-xquery-AndExpr"></a>[<small>49</small>]   </td>
<td><code>AndExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ComparisonExpr">ComparisonExpr</a>
( "and" <a href="#prod-xquery-ComparisonExpr">ComparisonExpr</a>
)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ComparisonExpr" id=
"prod-xquery-ComparisonExpr"></a>[<small>50</small>]   </td>
<td><code>ComparisonExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-RangeExpr">RangeExpr</a> (
(<a href="#prod-xquery-ValueComp">ValueComp</a><br />
| <a href="#prod-xquery-GeneralComp">GeneralComp</a><br />
| <a href="#prod-xquery-NodeComp">NodeComp</a>) <a href=
"#prod-xquery-RangeExpr">RangeExpr</a> )?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RangeExpr" id=
"prod-xquery-RangeExpr"></a>[<small>51</small>]   </td>
<td><code>RangeExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-AdditiveExpr">AdditiveExpr</a> (
"to" <a href="#prod-xquery-AdditiveExpr">AdditiveExpr</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AdditiveExpr" id=
"prod-xquery-AdditiveExpr"></a>[<small>52</small>]   </td>
<td><code>AdditiveExpr</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-MultiplicativeExpr">MultiplicativeExpr</a> ( ("+" |
"-") <a href=
"#prod-xquery-MultiplicativeExpr">MultiplicativeExpr</a>
)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-MultiplicativeExpr" id=
"prod-xquery-MultiplicativeExpr"></a>[<small>53</small>]   </td>
<td><code>MultiplicativeExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-UnionExpr">UnionExpr</a> ( ("*" |
"div" | "idiv" | "mod") <a href=
"#prod-xquery-UnionExpr">UnionExpr</a> )*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-UnionExpr" id=
"prod-xquery-UnionExpr"></a>[<small>54</small>]   </td>
<td><code>UnionExpr</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-IntersectExceptExpr">IntersectExceptExpr</a> (
("union" | "|") <a href=
"#prod-xquery-IntersectExceptExpr">IntersectExceptExpr</a>
)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-IntersectExceptExpr" id=
"prod-xquery-IntersectExceptExpr"></a>[<small>55</small>]   </td>
<td><code>IntersectExceptExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-InstanceofExpr">InstanceofExpr</a>
( ("intersect" | "except") <a href=
"#prod-xquery-InstanceofExpr">InstanceofExpr</a> )*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InstanceofExpr" id=
"prod-xquery-InstanceofExpr"></a>[<small>56</small>]   </td>
<td><code>InstanceofExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-TreatExpr">TreatExpr</a> (
"instance" "of" <a href=
"#prod-xquery-SequenceType">SequenceType</a> )?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TreatExpr" id=
"prod-xquery-TreatExpr"></a>[<small>57</small>]   </td>
<td><code>TreatExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-CastableExpr">CastableExpr</a> (
"treat" "as" <a href="#prod-xquery-SequenceType">SequenceType</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CastableExpr" id=
"prod-xquery-CastableExpr"></a>[<small>58</small>]   </td>
<td><code>CastableExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-CastExpr">CastExpr</a> ( "castable"
"as" <a href="#prod-xquery-SingleType">SingleType</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CastExpr" id=
"prod-xquery-CastExpr"></a>[<small>59</small>]   </td>
<td><code>CastExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-UnaryExpr">UnaryExpr</a> ( "cast"
"as" <a href="#prod-xquery-SingleType">SingleType</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-UnaryExpr" id=
"prod-xquery-UnaryExpr"></a>[<small>60</small>]   </td>
<td><code>UnaryExpr</code></td>
<td>   ::=   </td>
<td><code>("-" | "+")* <a href=
"#prod-xquery-ValueExpr">ValueExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValueExpr" id=
"prod-xquery-ValueExpr"></a>[<small>61</small>]   </td>
<td><code>ValueExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ValidateExpr">ValidateExpr</a> |
<a href="#prod-xquery-PathExpr">PathExpr</a> | <a href=
"#prod-xquery-ExtensionExpr">ExtensionExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-GeneralComp" id=
"prod-xquery-GeneralComp"></a>[<small>62</small>]   </td>
<td><code>GeneralComp</code></td>
<td>   ::=   </td>
<td><code>"=" | "!=" | "<" | "<=" | ">" |
">="</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValueComp" id=
"prod-xquery-ValueComp"></a>[<small>63</small>]   </td>
<td><code>ValueComp</code></td>
<td>   ::=   </td>
<td><code>"eq" | "ne" | "lt" | "le" | "gt" | "ge"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NodeComp" id=
"prod-xquery-NodeComp"></a>[<small>64</small>]   </td>
<td><code>NodeComp</code></td>
<td>   ::=   </td>
<td><code>"is" | "<<" | ">>"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValidateExpr" id=
"prod-xquery-ValidateExpr"></a>[<small>65</small>]   </td>
<td><code>ValidateExpr</code></td>
<td>   ::=   </td>
<td><code>"validate" <a href=
"#prod-xquery-ValidationMode">ValidationMode</a>? "{" <a href=
"#prod-xquery-Expr">Expr</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValidationMode" id=
"prod-xquery-ValidationMode"></a>[<small>66</small>]   </td>
<td><code>ValidationMode</code></td>
<td>   ::=   </td>
<td><code>"lax" | "strict"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ExtensionExpr" id=
"prod-xquery-ExtensionExpr"></a>[<small>67</small>]   </td>
<td><code><a href="#doc-xquery-ExtensionExpr"></a><a href=
"#doc-xquery-ExtensionExpr">ExtensionExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Pragma">Pragma</a>+ "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Pragma" id=
"prod-xquery-Pragma"></a>[<small>68</small>]   </td>
<td><code><a href="#doc-xquery-Pragma"></a><a href=
"#doc-xquery-Pragma">Pragma</a></code></td>
<td>   ::=   </td>
<td><code>"(#" <a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-QName">QName</a> (<a href="#prod-xquery-S">S</a>
<a href="#prod-xquery-PragmaContents">PragmaContents</a>)?
"#)"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PragmaContents" id=
"prod-xquery-PragmaContents"></a>[<small>69</small>]   </td>
<td><code><a href="#doc-xquery-PragmaContents"></a><a href=
"#doc-xquery-PragmaContents">PragmaContents</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* '#)'
Char*))</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PathExpr" id=
"prod-xquery-PathExpr"></a>[<small>70</small>]   </td>
<td><code><a href="#doc-xquery-PathExpr"></a><a href=
"#doc-xquery-PathExpr">PathExpr</a></code></td>
<td>   ::=   </td>
<td><code>("/" <a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a>?)<br />
| ("//" <a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a>)<br />
| <a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-leading-lone-slash">gn:
leading-lone-slash</a><sup><small>XQ</small></sup></span>
*/</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RelativePathExpr" id=
"prod-xquery-RelativePathExpr"></a>[<small>71</small>]   </td>
<td><code><a href="#doc-xquery-RelativePathExpr"></a><a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-StepExpr">StepExpr</a> (("/" |
"//") <a href="#prod-xquery-StepExpr">StepExpr</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-StepExpr" id=
"prod-xquery-StepExpr"></a>[<small>72</small>]   </td>
<td><code>StepExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-FilterExpr">FilterExpr</a> |
<a href="#prod-xquery-AxisStep">AxisStep</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AxisStep" id=
"prod-xquery-AxisStep"></a>[<small>73</small>]   </td>
<td><code><a href="#doc-xquery-AxisStep"></a><a href=
"#doc-xquery-AxisStep">AxisStep</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-ReverseStep">ReverseStep</a> |
<a href="#prod-xquery-ForwardStep">ForwardStep</a>) <a href=
"#prod-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ForwardStep" id=
"prod-xquery-ForwardStep"></a>[<small>74</small>]   </td>
<td><code>ForwardStep</code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-ForwardAxis">ForwardAxis</a>
<a href="#prod-xquery-NodeTest">NodeTest</a>) | <a href=
"#prod-xquery-AbbrevForwardStep">AbbrevForwardStep</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ForwardAxis" id=
"prod-xquery-ForwardAxis"></a>[<small>75</small>]   </td>
<td><code>ForwardAxis</code></td>
<td>   ::=   </td>
<td><code>("child" "::")<br />
| ("descendant" "::")<br />
| ("attribute" "::")<br />
| ("self" "::")<br />
| ("descendant-or-self" "::")<br />
| ("following-sibling" "::")<br />
| ("following" "::")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AbbrevForwardStep" id=
"prod-xquery-AbbrevForwardStep"></a>[<small>76</small>]   </td>
<td><code>AbbrevForwardStep</code></td>
<td>   ::=   </td>
<td><code>"@"? <a href=
"#prod-xquery-NodeTest">NodeTest</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ReverseStep" id=
"prod-xquery-ReverseStep"></a>[<small>77</small>]   </td>
<td><code>ReverseStep</code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-ReverseAxis">ReverseAxis</a>
<a href="#prod-xquery-NodeTest">NodeTest</a>) | <a href=
"#prod-xquery-AbbrevReverseStep">AbbrevReverseStep</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ReverseAxis" id=
"prod-xquery-ReverseAxis"></a>[<small>78</small>]   </td>
<td><code>ReverseAxis</code></td>
<td>   ::=   </td>
<td><code>("parent" "::")<br />
| ("ancestor" "::")<br />
| ("preceding-sibling" "::")<br />
| ("preceding" "::")<br />
| ("ancestor-or-self" "::")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AbbrevReverseStep" id=
"prod-xquery-AbbrevReverseStep"></a>[<small>79</small>]   </td>
<td><code>AbbrevReverseStep</code></td>
<td>   ::=   </td>
<td><code>".."</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NodeTest" id=
"prod-xquery-NodeTest"></a>[<small>80</small>]   </td>
<td><code>NodeTest</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-KindTest">KindTest</a> | <a href=
"#prod-xquery-NameTest">NameTest</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NameTest" id=
"prod-xquery-NameTest"></a>[<small>81</small>]   </td>
<td><code>NameTest</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a> | <a href=
"#prod-xquery-Wildcard">Wildcard</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Wildcard" id=
"prod-xquery-Wildcard"></a>[<small>82</small>]   </td>
<td><code>Wildcard</code></td>
<td>   ::=   </td>
<td><code>"*"<br />
| (<a href="#prod-xquery-NCName">NCName</a> ":" "*")<br />
| ("*" ":" <a href="#prod-xquery-NCName">NCName</a>)</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FilterExpr" id=
"prod-xquery-FilterExpr"></a>[<small>83</small>]   </td>
<td><code><a href="#doc-xquery-FilterExpr"></a><a href=
"#doc-xquery-FilterExpr">FilterExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-PrimaryExpr">PrimaryExpr</a>
<a href="#prod-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PredicateList" id=
"prod-xquery-PredicateList"></a>[<small>84</small>]   </td>
<td><code><a href="#doc-xquery-PredicateList"></a><a href=
"#doc-xquery-PredicateList">PredicateList</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-Predicate">Predicate</a>*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Predicate" id=
"prod-xquery-Predicate"></a>[<small>85</small>]   </td>
<td><code><a href="#doc-xquery-Predicate"></a><a href=
"#doc-xquery-Predicate">Predicate</a></code></td>
<td>   ::=   </td>
<td><code>"[" <a href="#prod-xquery-Expr">Expr</a> "]"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PrimaryExpr" id=
"prod-xquery-PrimaryExpr"></a>[<small>86</small>]   </td>
<td><code>PrimaryExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Literal">Literal</a> | <a href=
"#prod-xquery-VarRef">VarRef</a> | <a href=
"#prod-xquery-ParenthesizedExpr">ParenthesizedExpr</a> | <a href=
"#prod-xquery-ContextItemExpr">ContextItemExpr</a> | <a href=
"#prod-xquery-FunctionCall">FunctionCall</a> | <a href=
"#prod-xquery-OrderedExpr">OrderedExpr</a> | <a href=
"#prod-xquery-UnorderedExpr">UnorderedExpr</a> | <a href=
"#prod-xquery-Constructor">Constructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Literal" id=
"prod-xquery-Literal"></a>[<small>87</small>]   </td>
<td><code>Literal</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-NumericLiteral">NumericLiteral</a>
| <a href=
"#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NumericLiteral" id=
"prod-xquery-NumericLiteral"></a>[<small>88</small>]   </td>
<td><code>NumericLiteral</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-IntegerLiteral">IntegerLiteral</a>
| <a href="#prod-xquery-DecimalLiteral">DecimalLiteral</a> |
<a href="#prod-xquery-DoubleLiteral">DoubleLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VarRef" id=
"prod-xquery-VarRef"></a>[<small>89</small>]   </td>
<td><code>VarRef</code></td>
<td>   ::=   </td>
<td><code>"$" <a href=
"#prod-xquery-VarName">VarName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VarName" id=
"prod-xquery-VarName"></a>[<small>90</small>]   </td>
<td><code>VarName</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ParenthesizedExpr" id=
"prod-xquery-ParenthesizedExpr"></a>[<small>91</small>]   </td>
<td><code><a href="#doc-xquery-ParenthesizedExpr"></a><a href=
"#doc-xquery-ParenthesizedExpr">ParenthesizedExpr</a></code></td>
<td>   ::=   </td>
<td><code>"(" <a href="#prod-xquery-Expr">Expr</a>? ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ContextItemExpr" id=
"prod-xquery-ContextItemExpr"></a>[<small>92</small>]   </td>
<td><code>ContextItemExpr</code></td>
<td>   ::=   </td>
<td><code>"."</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderedExpr" id=
"prod-xquery-OrderedExpr"></a>[<small>93</small>]   </td>
<td><code>OrderedExpr</code></td>
<td>   ::=   </td>
<td><code>"ordered" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-UnorderedExpr" id=
"prod-xquery-UnorderedExpr"></a>[<small>94</small>]   </td>
<td><code>UnorderedExpr</code></td>
<td>   ::=   </td>
<td><code>"unordered" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FunctionCall" id=
"prod-xquery-FunctionCall"></a>[<small>95</small>]   </td>
<td><code><a href="#doc-xquery-FunctionCall"></a><a href=
"#doc-xquery-FunctionCall">FunctionCall</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a> "(" (<a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*)? ")"</code></td>
<td><i>/* <a href="#parse-note-sx-reserved-function-names">gn:
sx-reserved-function-names</a> */</i></td>
</tr>
<tr>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-parens">gn:
parens</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Constructor" id=
"prod-xquery-Constructor"></a>[<small>96</small>]   </td>
<td><code>Constructor</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-DirectConstructor">DirectConstructor</a><br />
| <a href=
"#prod-xquery-ComputedConstructor">ComputedConstructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirectConstructor" id=
"prod-xquery-DirectConstructor"></a>[<small>97</small>]   </td>
<td><code>DirectConstructor</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-DirElemConstructor">DirElemConstructor</a><br />
| <a href=
"#prod-xquery-DirCommentConstructor">DirCommentConstructor</a><br />
| <a href=
"#prod-xquery-DirPIConstructor">DirPIConstructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirElemConstructor" id=
"prod-xquery-DirElemConstructor"></a>[<small>98</small>]   </td>
<td><code><a href="#doc-xquery-DirElemConstructor"></a><a href=
"#doc-xquery-DirElemConstructor">DirElemConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"<" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-DirAttributeList">DirAttributeList</a> ("/>" |
(">" <a href="#prod-xquery-DirElemContent">DirElemContent</a>*
"</" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-S">S</a>? ">"))</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirAttributeList" id=
"prod-xquery-DirAttributeList"></a>[<small>99</small>]   </td>
<td><code><a href="#doc-xquery-DirAttributeList"></a><a href=
"#doc-xquery-DirAttributeList">DirAttributeList</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-S">S</a> (<a href=
"#prod-xquery-QName">QName</a> <a href="#prod-xquery-S">S</a>? "="
<a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-DirAttributeValue">DirAttributeValue</a>)?)*</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirAttributeValue" id=
"prod-xquery-DirAttributeValue"></a>[<small>100</small>]   </td>
<td><code>DirAttributeValue</code></td>
<td>   ::=   </td>
<td><code>('"' (<a href="#prod-xquery-EscapeQuot">EscapeQuot</a> |
<a href=
"#prod-xquery-QuotAttrValueContent">QuotAttrValueContent</a>)*
'"')<br />
| ("'" (<a href="#prod-xquery-EscapeApos">EscapeApos</a> | <a href=
"#prod-xquery-AposAttrValueContent">AposAttrValueContent</a>)*
"'")</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QuotAttrValueContent" id=
"prod-xquery-QuotAttrValueContent"></a>[<small>101</small>]   </td>
<td><code>QuotAttrValueContent</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-QuotAttrContentChar">QuotAttrContentChar</a><br />
| <a href=
"#prod-xquery-CommonContent">CommonContent</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AposAttrValueContent" id=
"prod-xquery-AposAttrValueContent"></a>[<small>102</small>]   </td>
<td><code>AposAttrValueContent</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-AposAttrContentChar">AposAttrContentChar</a><br />
| <a href=
"#prod-xquery-CommonContent">CommonContent</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirElemContent" id=
"prod-xquery-DirElemContent"></a>[<small>103</small>]   </td>
<td><code>DirElemContent</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-DirectConstructor">DirectConstructor</a><br />
| <a href="#prod-xquery-CDataSection">CDataSection</a><br />
| <a href="#prod-xquery-CommonContent">CommonContent</a><br />
| <a href=
"#prod-xquery-ElementContentChar">ElementContentChar</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CommonContent" id=
"prod-xquery-CommonContent"></a>[<small>104</small>]   </td>
<td><code>CommonContent</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-PredefinedEntityRef">PredefinedEntityRef</a> |
<a href="#prod-xquery-CharRef">CharRef</a> | "{{" | "}}" | <a href=
"#prod-xquery-EnclosedExpr">EnclosedExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirCommentConstructor" id=
"prod-xquery-DirCommentConstructor"></a>[<small>105</small>]   </td>
<td><code><a href="#doc-xquery-DirCommentConstructor"></a><a href=
"#doc-xquery-DirCommentConstructor">DirCommentConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"<!--" <a href=
"#prod-xquery-DirCommentContents">DirCommentContents</a>
"-->"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirCommentContents" id=
"prod-xquery-DirCommentContents"></a>[<small>106</small>]   </td>
<td><code>DirCommentContents</code></td>
<td>   ::=   </td>
<td><code>((<a href="#prod-xquery-Char">Char</a> - '-') | ('-'
(<a href="#prod-xquery-Char">Char</a> - '-')))*</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirPIConstructor" id=
"prod-xquery-DirPIConstructor"></a>[<small>107</small>]   </td>
<td><code><a href="#doc-xquery-DirPIConstructor"></a><a href=
"#doc-xquery-DirPIConstructor">DirPIConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"<?" <a href="#prod-xquery-PITarget">PITarget</a>
(<a href="#prod-xquery-S">S</a> <a href=
"#prod-xquery-DirPIContents">DirPIContents</a>)?
"?>"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirPIContents" id=
"prod-xquery-DirPIContents"></a>[<small>108</small>]   </td>
<td><code>DirPIContents</code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* '?>'
Char*))</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CDataSection" id=
"prod-xquery-CDataSection"></a>[<small>109</small>]   </td>
<td><code><a href="#doc-xquery-CDataSection"></a><a href=
"#doc-xquery-CDataSection">CDataSection</a></code></td>
<td>   ::=   </td>
<td><code>"<![CDATA[" <a href=
"#prod-xquery-CDataSectionContents">CDataSectionContents</a>
"]]>"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CDataSectionContents" id=
"prod-xquery-CDataSectionContents"></a>[<small>110</small>]   </td>
<td><code>CDataSectionContents</code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* ']]>'
Char*))</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ComputedConstructor" id=
"prod-xquery-ComputedConstructor"></a>[<small>111</small>]   </td>
<td><code>ComputedConstructor</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-CompDocConstructor">CompDocConstructor</a><br />
| <a href=
"#prod-xquery-CompElemConstructor">CompElemConstructor</a><br />
| <a href=
"#prod-xquery-CompAttrConstructor">CompAttrConstructor</a><br />
| <a href=
"#prod-xquery-CompTextConstructor">CompTextConstructor</a><br />
| <a href=
"#prod-xquery-CompCommentConstructor">CompCommentConstructor</a><br />
| <a href=
"#prod-xquery-CompPIConstructor">CompPIConstructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompDocConstructor" id=
"prod-xquery-CompDocConstructor"></a>[<small>112</small>]   </td>
<td><code><a href="#doc-xquery-CompDocConstructor"></a><a href=
"#doc-xquery-CompDocConstructor">CompDocConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"document" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompElemConstructor" id=
"prod-xquery-CompElemConstructor"></a>[<small>113</small>]   </td>
<td><code><a href="#doc-xquery-CompElemConstructor"></a><a href=
"#doc-xquery-CompElemConstructor">CompElemConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"element" (<a href="#prod-xquery-QName">QName</a> | ("{"
<a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-ContentExpr">ContentExpr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ContentExpr" id=
"prod-xquery-ContentExpr"></a>[<small>114</small>]   </td>
<td><code>ContentExpr</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompAttrConstructor" id=
"prod-xquery-CompAttrConstructor"></a>[<small>115</small>]   </td>
<td><code><a href="#doc-xquery-CompAttrConstructor"></a><a href=
"#doc-xquery-CompAttrConstructor">CompAttrConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"attribute" (<a href="#prod-xquery-QName">QName</a> |
("{" <a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompTextConstructor" id=
"prod-xquery-CompTextConstructor"></a>[<small>116</small>]   </td>
<td><code><a href="#doc-xquery-CompTextConstructor"></a><a href=
"#doc-xquery-CompTextConstructor">CompTextConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"text" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompCommentConstructor" id=
"prod-xquery-CompCommentConstructor"></a>[<small>117</small>]   </td>
<td><code><a href="#doc-xquery-CompCommentConstructor"></a><a href=
"#doc-xquery-CompCommentConstructor">CompCommentConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"comment" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompPIConstructor" id=
"prod-xquery-CompPIConstructor"></a>[<small>118</small>]   </td>
<td><code><a href="#doc-xquery-CompPIConstructor"></a><a href=
"#doc-xquery-CompPIConstructor">CompPIConstructor</a></code></td>
<td>   ::=   </td>
<td><code>"processing-instruction" (<a href=
"#prod-xquery-NCName">NCName</a> | ("{" <a href=
"#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SingleType" id=
"prod-xquery-SingleType"></a>[<small>119</small>]   </td>
<td><code>SingleType</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-AtomicType">AtomicType</a>
"?"?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TypeDeclaration" id=
"prod-xquery-TypeDeclaration"></a>[<small>120</small>]   </td>
<td><code>TypeDeclaration</code></td>
<td>   ::=   </td>
<td><code>"as" <a href=
"#prod-xquery-SequenceType">SequenceType</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SequenceType" id=
"prod-xquery-SequenceType"></a>[<small>121</small>]   </td>
<td><code>SequenceType</code></td>
<td>   ::=   </td>
<td><code>("empty-sequence" "(" ")")<br />
| (<a href="#prod-xquery-ItemType">ItemType</a> <a href=
"#prod-xquery-OccurrenceIndicator">OccurrenceIndicator</a>?)</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OccurrenceIndicator" id=
"prod-xquery-OccurrenceIndicator"></a>[<small>122</small>]   </td>
<td><code>OccurrenceIndicator</code></td>
<td>   ::=   </td>
<td><code>"?" | "*" | "+"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-occurrence-indicators">gn:
occurrence-indicators</a><sup><small>XQ</small></sup></span>
*/</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ItemType" id=
"prod-xquery-ItemType"></a>[<small>123</small>]   </td>
<td><code>ItemType</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-KindTest">KindTest</a> | ("item"
"(" ")") | <a href=
"#prod-xquery-AtomicType">AtomicType</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AtomicType" id=
"prod-xquery-AtomicType"></a>[<small>124</small>]   </td>
<td><code>AtomicType</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-KindTest" id=
"prod-xquery-KindTest"></a>[<small>125</small>]   </td>
<td><code>KindTest</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-DocumentTest">DocumentTest</a><br />
| <a href="#prod-xquery-ElementTest">ElementTest</a><br />
| <a href="#prod-xquery-AttributeTest">AttributeTest</a><br />
| <a href=
"#prod-xquery-SchemaElementTest">SchemaElementTest</a><br />
| <a href=
"#prod-xquery-SchemaAttributeTest">SchemaAttributeTest</a><br />
| <a href="#prod-xquery-PITest">PITest</a><br />
| <a href="#prod-xquery-CommentTest">CommentTest</a><br />
| <a href="#prod-xquery-TextTest">TextTest</a><br />
| <a href="#prod-xquery-AnyKindTest">AnyKindTest</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AnyKindTest" id=
"prod-xquery-AnyKindTest"></a>[<small>126</small>]   </td>
<td><code>AnyKindTest</code></td>
<td>   ::=   </td>
<td><code>"node" "(" ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DocumentTest" id=
"prod-xquery-DocumentTest"></a>[<small>127</small>]   </td>
<td><code>DocumentTest</code></td>
<td>   ::=   </td>
<td><code>"document-node" "(" (<a href=
"#prod-xquery-ElementTest">ElementTest</a> | <a href=
"#prod-xquery-SchemaElementTest">SchemaElementTest</a>)?
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TextTest" id=
"prod-xquery-TextTest"></a>[<small>128</small>]   </td>
<td><code>TextTest</code></td>
<td>   ::=   </td>
<td><code>"text" "(" ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CommentTest" id=
"prod-xquery-CommentTest"></a>[<small>129</small>]   </td>
<td><code>CommentTest</code></td>
<td>   ::=   </td>
<td><code>"comment" "(" ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PITest" id=
"prod-xquery-PITest"></a>[<small>130</small>]   </td>
<td><code>PITest</code></td>
<td>   ::=   </td>
<td><code>"processing-instruction" "(" (<a href=
"#prod-xquery-NCName">NCName</a> | <a href=
"#prod-xquery-StringLiteral">StringLiteral</a>)? ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttributeTest" id=
"prod-xquery-AttributeTest"></a>[<small>131</small>]   </td>
<td><code>AttributeTest</code></td>
<td>   ::=   </td>
<td><code>"attribute" "(" (<a href=
"#prod-xquery-AttribNameOrWildcard">AttribNameOrWildcard</a> (","
<a href="#prod-xquery-TypeName">TypeName</a>)?)? ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttribNameOrWildcard" id=
"prod-xquery-AttribNameOrWildcard"></a>[<small>132</small>]   </td>
<td><code>AttribNameOrWildcard</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-AttributeName">AttributeName</a> |
"*"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaAttributeTest" id=
"prod-xquery-SchemaAttributeTest"></a>[<small>133</small>]   </td>
<td><code>SchemaAttributeTest</code></td>
<td>   ::=   </td>
<td><code>"schema-attribute" "(" <a href=
"#prod-xquery-AttributeDeclaration">AttributeDeclaration</a>
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttributeDeclaration" id=
"prod-xquery-AttributeDeclaration"></a>[<small>134</small>]   </td>
<td><code>AttributeDeclaration</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-AttributeName">AttributeName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementTest" id=
"prod-xquery-ElementTest"></a>[<small>135</small>]   </td>
<td><code>ElementTest</code></td>
<td>   ::=   </td>
<td><code>"element" "(" (<a href=
"#prod-xquery-ElementNameOrWildcard">ElementNameOrWildcard</a> (","
<a href="#prod-xquery-TypeName">TypeName</a> "?"?)?)?
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementNameOrWildcard" id=
"prod-xquery-ElementNameOrWildcard"></a>[<small>136</small>]   </td>
<td><code>ElementNameOrWildcard</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-ElementName">ElementName</a> |
"*"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaElementTest" id=
"prod-xquery-SchemaElementTest"></a>[<small>137</small>]   </td>
<td><code>SchemaElementTest</code></td>
<td>   ::=   </td>
<td><code>"schema-element" "(" <a href=
"#prod-xquery-ElementDeclaration">ElementDeclaration</a>
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementDeclaration" id=
"prod-xquery-ElementDeclaration"></a>[<small>138</small>]   </td>
<td><code>ElementDeclaration</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ElementName">ElementName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttributeName" id=
"prod-xquery-AttributeName"></a>[<small>139</small>]   </td>
<td><code>AttributeName</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementName" id=
"prod-xquery-ElementName"></a>[<small>140</small>]   </td>
<td><code>ElementName</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TypeName" id=
"prod-xquery-TypeName"></a>[<small>141</small>]   </td>
<td><code>TypeName</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-URILiteral" id=
"prod-xquery-URILiteral"></a>[<small>142</small>]   </td>
<td><code>URILiteral</code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RevalidationDecl" id=
"prod-xquery-RevalidationDecl"></a>[<small>143</small>]   </td>
<td><code>RevalidationDecl</code></td>
<td>   ::=   </td>
<td><code>"declare" "revalidation" ("strict" | "lax" |
"skip")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InsertExprTargetChoice" id=
"prod-xquery-InsertExprTargetChoice"></a>[<small>144</small>]   </td>
<td><code><a href="#doc-xquery-InsertExprTargetChoice"></a><a href=
"#doc-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a></code></td>
<td>   ::=   </td>
<td><code>(("as" ("first" | "last"))? "into")<br />
| "after"<br />
| "before"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InsertExpr" id=
"prod-xquery-InsertExpr"></a>[<small>145</small>]   </td>
<td><code><a href="#doc-xquery-InsertExpr"></a><a href=
"#doc-xquery-InsertExpr">InsertExpr</a></code></td>
<td>   ::=   </td>
<td><code>"insert" ("node" | "nodes") <a href=
"#prod-xquery-SourceExpr">SourceExpr</a> <a href=
"#prod-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a>
<a href="#prod-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DeleteExpr" id=
"prod-xquery-DeleteExpr"></a>[<small>146</small>]   </td>
<td><code><a href="#doc-xquery-DeleteExpr"></a><a href=
"#doc-xquery-DeleteExpr">DeleteExpr</a></code></td>
<td>   ::=   </td>
<td><code>"delete" ("node" | "nodes") <a href=
"#prod-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ReplaceExpr" id=
"prod-xquery-ReplaceExpr"></a>[<small>147</small>]   </td>
<td><code><a href="#doc-xquery-ReplaceExpr"></a><a href=
"#doc-xquery-ReplaceExpr">ReplaceExpr</a></code></td>
<td>   ::=   </td>
<td><code>"replace" ("value" "of")? "node" <a href=
"#prod-xquery-TargetExpr">TargetExpr</a> "with" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RenameExpr" id=
"prod-xquery-RenameExpr"></a>[<small>148</small>]   </td>
<td><code><a href="#doc-xquery-RenameExpr"></a><a href=
"#doc-xquery-RenameExpr">RenameExpr</a></code></td>
<td>   ::=   </td>
<td><code>"rename" "node" <a href=
"#prod-xquery-TargetExpr">TargetExpr</a> "as" <a href=
"#prod-xquery-NewNameExpr">NewNameExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SourceExpr" id=
"prod-xquery-SourceExpr"></a>[<small>149</small>]   </td>
<td><code><a href="#doc-xquery-SourceExpr"></a><a href=
"#doc-xquery-SourceExpr">SourceExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TargetExpr" id=
"prod-xquery-TargetExpr"></a>[<small>150</small>]   </td>
<td><code><a href="#doc-xquery-TargetExpr"></a><a href=
"#doc-xquery-TargetExpr">TargetExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NewNameExpr" id=
"prod-xquery-NewNameExpr"></a>[<small>151</small>]   </td>
<td><code><a href="#doc-xquery-NewNameExpr"></a><a href=
"#doc-xquery-NewNameExpr">NewNameExpr</a></code></td>
<td>   ::=   </td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TransformExpr" id=
"prod-xquery-TransformExpr"></a>[<small>152</small>]   </td>
<td><code><a href="#doc-xquery-TransformExpr"></a><a href=
"#doc-xquery-TransformExpr">TransformExpr</a></code></td>
<td>   ::=   </td>
<td><code>"copy" "$" <a href="#prod-xquery-VarName">VarName</a>
":=" <a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$"
<a href="#prod-xquery-VarName">VarName</a> ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "modify" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockExpr" id=
"prod-xquery-BlockExpr"></a>[<small>153</small>]   </td>
<td><code><a href="#doc-xquery-BlockExpr"></a><a href=
"#doc-xquery-BlockExpr">BlockExpr</a></code></td>
<td>   ::=   </td>
<td><code>"block" <a href=
"#prod-xquery-Block">Block</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Block" id=
"prod-xquery-Block"></a>[<small>154</small>]   </td>
<td><code><a href="#doc-xquery-Block"></a><a href=
"#doc-xquery-Block">Block</a></code></td>
<td>   ::=   </td>
<td><code>"{" <a href="#prod-xquery-BlockDecls">BlockDecls</a>
<a href="#prod-xquery-BlockBody">BlockBody</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockDecls" id=
"prod-xquery-BlockDecls"></a>[<small>155</small>]   </td>
<td><code><a href="#doc-xquery-BlockDecls"></a><a href=
"#doc-xquery-BlockDecls">BlockDecls</a></code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-BlockVarDecl">BlockVarDecl</a>
";")*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockVarDecl" id=
"prod-xquery-BlockVarDecl"></a>[<small>156</small>]   </td>
<td><code><a href="#doc-xquery-BlockVarDecl"></a><a href=
"#doc-xquery-BlockVarDecl">BlockVarDecl</a></code></td>
<td>   ::=   </td>
<td><code>"declare" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)? ("," "$"
<a href="#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)?)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockBody" id=
"prod-xquery-BlockBody"></a>[<small>157</small>]   </td>
<td><code><a href="#doc-xquery-BlockBody"></a><a href=
"#doc-xquery-BlockBody">BlockBody</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AssignmentExpr" id=
"prod-xquery-AssignmentExpr"></a>[<small>158</small>]   </td>
<td><code><a href="#doc-xquery-AssignmentExpr"></a><a href=
"#doc-xquery-AssignmentExpr">AssignmentExpr</a></code></td>
<td>   ::=   </td>
<td><code>"$" <a href="#prod-xquery-VarName">VarName</a> ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ExitExpr" id=
"prod-xquery-ExitExpr"></a>[<small>159</small>]   </td>
<td><code><a href="#doc-xquery-ExitExpr"></a><a href=
"#doc-xquery-ExitExpr">ExitExpr</a></code></td>
<td>   ::=   </td>
<td><code>"exit" "returning" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-WhileExpr" id=
"prod-xquery-WhileExpr"></a>[<small>160</small>]   </td>
<td><code><a href="#doc-xquery-WhileExpr"></a><a href=
"#doc-xquery-WhileExpr">WhileExpr</a></code></td>
<td>   ::=   </td>
<td><code>"while" "(" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ")" <a href=
"#prod-xquery-WhileBody">WhileBody</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-WhileBody" id=
"prod-xquery-WhileBody"></a>[<small>161</small>]   </td>
<td><code><a href="#doc-xquery-WhileBody"></a><a href=
"#doc-xquery-WhileBody">WhileBody</a></code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Block">Block</a></code></td>
</tr>
</tbody>
</table>
<div class="div2">
<h3><a name="id-terminal-symbols" id="id-terminal-symbols"></a>A.1
Terminal Symbols</h3>
<h5><a name="d7e5434" id="d7e5434"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-IntegerLiteral" id=
"prod-xquery-IntegerLiteral"></a>[<small>162</small>]   </td>
<td><code>IntegerLiteral</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Digits">Digits</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DecimalLiteral" id=
"prod-xquery-DecimalLiteral"></a>[<small>163</small>]   </td>
<td><code>DecimalLiteral</code></td>
<td>   ::=   </td>
<td><code>("." <a href="#prod-xquery-Digits">Digits</a>) |
(<a href="#prod-xquery-Digits">Digits</a> "." [0-9]*)</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DoubleLiteral" id=
"prod-xquery-DoubleLiteral"></a>[<small>164</small>]   </td>
<td><code>DoubleLiteral</code></td>
<td>   ::=   </td>
<td><code>(("." <a href="#prod-xquery-Digits">Digits</a>) |
(<a href="#prod-xquery-Digits">Digits</a> ("." [0-9]*)?)) [eE]
[+-]? <a href="#prod-xquery-Digits">Digits</a></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-StringLiteral" id=
"prod-xquery-StringLiteral"></a>[<small>165</small>]   </td>
<td><code>StringLiteral</code></td>
<td>   ::=   </td>
<td><code>('"' (<a href=
"#prod-xquery-PredefinedEntityRef">PredefinedEntityRef</a> |
<a href="#prod-xquery-CharRef">CharRef</a> | <a href=
"#prod-xquery-EscapeQuot">EscapeQuot</a> | [^"&])* '"') | ("'"
(<a href="#prod-xquery-PredefinedEntityRef">PredefinedEntityRef</a>
| <a href="#prod-xquery-CharRef">CharRef</a> | <a href=
"#prod-xquery-EscapeApos">EscapeApos</a> | [^'&])*
"'")</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PredefinedEntityRef" id=
"prod-xquery-PredefinedEntityRef"></a>[<small>166</small>]   </td>
<td><code>PredefinedEntityRef</code></td>
<td>   ::=   </td>
<td><code>"&" ("lt" | "gt" | "amp" | "quot" | "apos")
";"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EscapeQuot" id=
"prod-xquery-EscapeQuot"></a>[<small>167</small>]   </td>
<td><code>EscapeQuot</code></td>
<td>   ::=   </td>
<td><code>'""'</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EscapeApos" id=
"prod-xquery-EscapeApos"></a>[<small>168</small>]   </td>
<td><code>EscapeApos</code></td>
<td>   ::=   </td>
<td><code>"''"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementContentChar" id=
"prod-xquery-ElementContentChar"></a>[<small>169</small>]   </td>
<td><code>ElementContentChar</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Char">Char</a> -
[{}<&]</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QuotAttrContentChar" id=
"prod-xquery-QuotAttrContentChar"></a>[<small>170</small>]   </td>
<td><code>QuotAttrContentChar</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Char">Char</a> -
["{}<&]</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AposAttrContentChar" id=
"prod-xquery-AposAttrContentChar"></a>[<small>171</small>]   </td>
<td><code>AposAttrContentChar</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xquery-Char">Char</a> -
['{}<&]</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Comment" id=
"prod-xquery-Comment"></a>[<small>172</small>]   </td>
<td><code>Comment</code></td>
<td>   ::=   </td>
<td><code>"(:" (<a href=
"#prod-xquery-CommentContents">CommentContents</a> | <a href=
"#prod-xquery-Comment">Comment</a>)* ":)"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
<tr>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-comments">gn:
comments</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PITarget" id=
"prod-xquery-PITarget"></a>[<small>173</small>]   </td>
<td><code>PITarget</code></td>
<td>   ::=   </td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-PITarget">[http://www.w3.org/TR/REC-xml#NT-PITarget]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CharRef" id=
"prod-xquery-CharRef"></a>[<small>174</small>]   </td>
<td><code>CharRef</code></td>
<td>   ::=   </td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-CharRef">[http://www.w3.org/TR/REC-xml#NT-CharRef]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QName" id=
"prod-xquery-QName"></a>[<small>175</small>]   </td>
<td><code>QName</code></td>
<td>   ::=   </td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml-names/#NT-QName">[http://www.w3.org/TR/REC-xml-names/#NT-QName]</a><sup><small>Names</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NCName" id=
"prod-xquery-NCName"></a>[<small>176</small>]   </td>
<td><code>NCName</code></td>
<td>   ::=   </td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml-names/#NT-NCName">[http://www.w3.org/TR/REC-xml-names/#NT-NCName]</a><sup><small>Names</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-S" id=
"prod-xquery-S"></a>[<small>177</small>]   </td>
<td><code>S</code></td>
<td>   ::=   </td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-S">[http://www.w3.org/TR/REC-xml#NT-S]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Char" id=
"prod-xquery-Char"></a>[<small>178</small>]   </td>
<td><code>Char</code></td>
<td>   ::=   </td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-Char">[http://www.w3.org/TR/REC-xml#NT-Char]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
</table>
<p>The following symbols are used only in the definition of
terminal symbols; they are not terminal symbols in the grammar of
<a href="#id-grammar"><b>[A EBNF for XQuery 1.0 Grammar with
Scripting Extensions]</b></a>.</p>
<h5><a name="d7e5626" id="d7e5626"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Digits" id=
"prod-xquery-Digits"></a>[<small>179</small>]   </td>
<td><code>Digits</code></td>
<td>   ::=   </td>
<td><code>[0-9]+</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CommentContents" id=
"prod-xquery-CommentContents"></a>[<small>180</small>]   </td>
<td><code>CommentContents</code></td>
<td>   ::=   </td>
<td><code>(<a href="#prod-xquery-Char">Char</a>+ - (Char* ('(:' |
':)') Char*))</code></td>
</tr>
</tbody>
</table>
</div>
<div class="div2">
<h3><a name="id-extra-grammatical-constraints" id=
"id-extra-grammatical-constraints"></a>A.2 Extra-grammatical
Constraints</h3>
<p>This section contains XQuery SX specific constraints on the EBNF
productions, which are required to parse legal sentences. The notes
below are referenced from the right side of the production, with
the notation: <em>/* gn: <id> */</em>.</p>
<div class="constraint">
<p class="prefix"><a name="parse-note-sx-reserved-function-names"
id="parse-note-sx-reserved-function-names"></a><b>Constraint:
sx-reserved-function-names</b></p>
<p>XQuery SX adds the term "while" to the list of names in <a href=
"http://www.w3.org/TR/xquery#id-reserved-fn-names">Section A.3
Reserved Function Names</a><sup><small>XQ</small></sup>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>This is a backwards incompatibility with <a href="#XQ10">[XQuery
1.0]</a>.</p>
</div>
</div>
</div>
</div>
<div class="div1">
<h2><a name="id-xqsx-xqueryx" id="id-xqsx-xqueryx"></a>B XML Syntax
(XQueryX) for XQuery Scripting Extension 1.0</h2>
<p><a href="#XQX10">[XML Syntax for XQuery 1.0]</a> defines an XML
representation of <a href="#XQ10">[XQuery 1.0]</a>. <a href=
"#ScriptingRequirements">[XQuery Scripting Requirements]</a> states
"The syntax for updates MAY have more than one syntax binding. One
syntax MUST be convenient for humans to read and write. One syntax
MUST be expressed in XML in a way that reflects the underlying
structure of the operations." This appendix specifies an XML Schema
that defines the XML representation of XQuery Scripting Extension
1.0 by representing the abstract syntax found in <a href=
"#id-grammar"><b>[A EBNF for XQuery 1.0 Grammar with Scripting
Extensions]</b></a>. This XML representation for XQuery Scripting
Extension 1.0 integrates with the XML representation for XQuery 1.0
and that for the XQuery Update Facility 1.0.</p>
<p>The XML Schema specified in this appendix accomplishes its
integration by importing the XML Schema defined for XQueryX in
<a href="#XQueryUpdate">[XQuery Update Facility]</a>, incorporating
all of its type and element definitions. It then extends that
schema by adding definitions of new types and elements in a
namespace belonging to the XQuery Scripting Extension 1.0
specification.</p>
<div class="div2">
<h3><a name="id-xqsx-xqueryx-schema" id=
"id-xqsx-xqueryx-schema"></a>B.1 Schema</h3>
<p>This section specifies the XML Schema that defines the complex
types and elements for XQueryX in support of XQuery Scripting
Extension 1.0, including changes to the prolog and the addition of
several new expressions. It also specifies a second XML Schema that
redefines an element defined in XQueryX 1.0. Copies of these two
schemata can be found at <a href=
"http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsd">http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsd</a>.
and <a href=
"http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx-redef.xsd">
http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx-redef.xsd</a>.
Please note that the content of these schemata are subject to
change at any time before this document is published as a
Recommendation.</p>
<div class="exampleInner">
<pre>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
xmlns:xqxsx="http://www.w3.org/2008/xquery-sx-10"
targetNamespace="http://www.w3.org/2008/xquery-sx-10"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<!-- Initial creation 2008-03-01: Jim Melton -->
<!-- Added FunctionDecl redefinition 2008-03-11: Jim Melton -->
<!-- Updated to new WD grammar 2008-11-25: Jim Melton -->
<!-- Reviewed, cleaned, corrections 2009-08-17: Jim Melton -->
<!-- Updated to recent grammar changes 2010-02-15: Jim Melton -->
<xsd:import namespace="http://www.w3.org/2005/XQueryX"
schemaLocation="http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx-redef.xsd"/>
<!-- Declare new type for constant declarations -->
<!-- Corresponds to the following grammar productions: -->
<!-- VarDecl ::= "declare" ([un]assignable variable) -->
<!-- "$" QName TypeDeclaration? -->
<!-- ((":=" ExprSingle) | "external") -->
<xsd:complexType name="constDecl">
<xsd:sequence>
<xsd:element name="constName" type="xqx:QName"/>
<xsd:element ref="typeDeclaration" minOccurs="0"/>
<xsd:choice>
<xsd:element name="varValue" type="exprWrapper"/>
<xsd:element name="external" type="emptyContent"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="constDecl" type="xqxsx:constDecl"
substitutionGroup="xqx:prologPartTwoItem"/>
<!-- Create substitution grp for scripting extension exprs -->
<xsd:complexType name="expr">
<xsd:complexContent>
<xsd:extension base="xqx:expr"/>
</xsd:complexContent>
</xsd:complexType>
<!-- Make scripting extension subst grp part of expr grp -->
<xsd:element name="expr" type="xqxsx:expr" abstract="true"
substitutionGroup="xqx:expr"/>
<!-- AssignmentExpr: -->
<!-- AssignmentExpr ::= "$" VarName ":=" ExprSingle -->
<xsd:complexType name="assignmentExpr">
<xsd:complexContent>
<xsd:extension base="xqxsx:expr">
<xsd:sequence>
<xsd:element ref="xqx:positionalVariableBinding"/>
<xsd:element name="assignedExpr" type="xqx:exprWrapper"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="assignmentExpr" type="xqxsx:assignmentExpr"
substitutionGroup="xqxsx:expr"/>
<!-- Block (1 of 3): -->
<!-- BlockExpr ::= "block" Block -->
<!-- Block ::= "{" BlockDecls BlockBody "}" -->
<!-- BlockDecls ::= (BlockVarDecl ";")* -->
<xsd:complexType name="block">
<xsd:complexContent>
<xsd:extension base="xqxsx:expr">
<xsd:sequence>
<xsd:element ref="xqxsx:blockVarDecl"
minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="xqxsx:blockBody"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="block" type="xqxsx:block"
substitutionGroup="xqxsx:expr"/>
<!-- Block (2 of 3): -->
<!-- BlockVarDecl ::= -->
<!-- "declare" "$" VarName TypeDeclaration? -->
<!-- (":=" ExprSingle)? -->
<!-- ("," "$" VarName TypeDeclaration? -->
<!-- (":=" ExprSingle)? )* -->
<xsd:complexType name="blockVarDecl">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="varName" type="xqx:QName"/>
<xsd:element ref="xqx:typeDeclaration" minOccurs="0"/>
<xsd:element name="varValue" type="xqx:exprWrapper"
minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="blockVarDecl" type="xqxsx:blockVarDecl"/>
<!-- Block (3 of 3): -->
<!-- BlockBody ::= Expr -->
<xsd:complexType name="blockBody">
<xsd:sequence>
<xsd:element name="blockExpr" type="xqx:exprWrapper"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="blockBody" type="xqxsx:blockBody"/>
<!-- ExitExpr: -->
<!-- ExitExpr ::= "exit" "returning" ExprSingle -->
<xsd:element name="exitExpr" type="xqxsx:expr"
substitutionGroup="xqxsx:expr"/>
<!-- WhileExpr: -->
<!-- WhileExpr ::= "while" "(" ExprSingle ")" WhileBody -->
<!-- WhileBody ::= Block -->
<xsd:complexType name="whileExpr">
<xsd:complexContent>
<xsd:extension base="xqxsx:expr">
<xsd:sequence>
<xsd:element name="whileTest" type="xqx:exprWrapper"/>
<xsd:element ref="xqxsx:block"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="whileExpr" type="xqxsx:whileExpr"
substitutionGroup="xqxsx:expr"/>
<!-- ApplyExpr: -->
<!-- ApplyExpr ::= (ConcatExpr ";")+ -->
<xsd:complexType name="applyExpr">
<xsd:complexContent>
<xsd:extension base="xqxsx:expr">
<xsd:sequence>
<xsd:element name="applyExprs" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="xqxsx:expr" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="applyExpr" type="xqxsx:applyExpr"
substitutionGroup="xqxsx:expr"/>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/2005/XQueryX"
targetNamespace="http://www.w3.org/2005/XQueryX"
elementFormDefault="qualified" attributeFormDefault="qualified">
<!-- Redefine one or more components of the XQueryX XML Schema -->
<!-- The redefinition starts with XQuery Update Facility 1.0 -->
<!-- XQueryX instead of XQueryX 1.0 -->
<xsd:redefine schemaLocation="http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx-redef.xsd">
<!-- Redefine the functionDecl complex type -->
<xsd:complexType name="functionDecl">
<xsd:complexContent>
<xsd:extension base="functionDecl">
<xsd:attribute name="simpleFunction"
type="xsd:boolean" default="true"/>
<xsd:attribute name="sequentialFunction"
type="xsd:boolean" default="false"/>
<xsd:attribute name="sequentialFunction"
type="xsd:boolean" default="false"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:redefine>
</xsd:schema>
</pre></div>
</div>
<div class="div2">
<h3><a name="id-xqsx-xqueryx-stylesheet" id=
"id-xqsx-xqueryx-stylesheet"></a>B.2 Stylesheet</h3>
<p>This section specifies the XSLT stylesheet that defines the
semantics of XQueryX in support of XQuery Scripting Extension 1.0.
It imports the XSLT stylesheet defined in <a href=
"#XQueryUpdate">[XQuery Update Facility]</a>, and provides
additional templates that define the semantics of the XQueryX
representation of XQuery Scripting Extension 1.0 by transforming
that XQueryX representation into the human readable syntax of
XQuery Scripting Extension 1.0. A copy of this stylesheet is
located at <a href=
"http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsl">http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsl</a>.
Please note that the content of this stylesheet is subject to
change at any time before this document is published as a
Recommendation.</p>
<div class="exampleInner">
<pre>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
xmlns:xqxsx="http://www.w3.org/2008/xquery-sx-10">
<!-- Initial creation 2008-03-01: Jim Melton -->
<!-- Reviewed, cleaned, corrections 2009-08-17: Jim Melton -->
<!-- Updated to recent grammar changes 2010-02-15: Jim Melton -->
<xsl:import href="http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsl"/>
<!-- constDecl -->
<!-- 2010-02-15: "constant" is now "unassignable variable" -->
<xsl:template match="xqxsx:constDecl">
<xsl:value-of select="$NEWLINE"/>
<xsl:text>declare unassignable variable </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xqxsx:constName">
<xsl:apply-templates/>
</xsl:template>
<!-- Over-ride the template for varDecl in XQueryX.xsd -->
<!-- 2010-02-15: "variable" is now "assignable variable" -->
<xsl:template match="xqx:varDecl" priority="200">
<xsl:text>declare assignable variable </xsl:text>
<xsl:value-of select="$DOLLAR"/>
<xsl:apply-templates select="xqx:varName"/>
<xsl:apply-templates select="xqx:typeDeclaration"/>
<xsl:if test="xqx:external">
<xsl:text> external </xsl:text>
</xsl:if>
<xsl:if test="xqx:varValue">
<xsl:value-of select="$ASSIGN"/>
<xsl:apply-templates select="xqx:varValue"/>
</xsl:if>
</xsl:template>
<!-- assignmentExpr -->
<!-- 2010-02-15: Remove 'set' keyword -->
<xsl:template match="xqxsx:assignmentExpr">
<xsl:value-of select="$NEWLINE"/>
<xsl:apply-templates select="xqx:positionalVariableBinding"/>
<xsl:text> := </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xqxsx:assignedExpr">
<xsl:apply-templates/>
</xsl:template>
<!-- block -->
<!-- 2010-02-15: Added 'block' keyword -->
<xsl:template match="xqxsx:block">
<xsl:value-of select="$NEWLINE"/>
<xsl:text>block </xsl:text>
<xsl:value-of select="$LBRACE"/>
<xsl:value-of select="$SPACE"/>
<xsl:apply-templates/>
<xsl:value-of select="$SPACE"/>
<xsl:value-of select="$RBRACE"/>
<xsl:value-of select="$SPACE"/>
</xsl:template>
<!-- blockVarDecl -->
<xsl:template match="xqxsx:blockVarDecl[position()=1 and position()=last()]">
<xsl:text>declare </xsl:text>
<xsl:apply-templates select="xqxsx:varName"/>
<xsl:if test="xqx:typeDeclaration">
<xsl:apply-templates select="xqx:typeDeclaration"/>
</xsl:if>
<xsl:if test="xqxsx:varValue">
<xsl:text> := </xsl:text>
<xsl:apply-templates select="xqxsx:varValue"/>
</xsl:if>
<xsl:value-of select="$SEMICOLON"/>
</xsl:template>
<xsl:template match="xqxsx:blockVarDecl[position()=1 and position()!=last()]">
<xsl:text>declare </xsl:text>
<xsl:apply-templates select="xqxsx:varName"/>
<xsl:if test="xqx:typeDeclaration">
<xsl:apply-templates select="xqx:typeDeclaration"/>
</xsl:if>
<xsl:if test="xqxsx:varValue">
<xsl:text> := </xsl:text>
<xsl:apply-templates select="xqxsx:varValue"/>
</xsl:if>
</xsl:template>
<xsl:template match="xqxsx:blockVarDecl[position()>1 and position()&lt;last()]">
<xsl:value-of select="$COMMA"/>
<xsl:value-of select="$NEWLINE"/>
<xsl:apply-templates select="xqxsx:varName"/>
<xsl:if test="xqx:typeDeclaration">
<xsl:apply-templates select="xqx:typeDeclaration"/>
</xsl:if>
<xsl:if test="xqxsx:varValue">
<xsl:text> := </xsl:text>
<xsl:apply-templates select="xqxsx:varValue"/>
</xsl:if>
</xsl:template>
<xsl:template match="xqxsx:blockVarDecl[position()>1 and position()=last()]">
<xsl:value-of select="$COMMA"/>
<xsl:value-of select="$NEWLINE"/>
<xsl:apply-templates select="xqxsx:varName"/>
<xsl:if test="xqx:typeDeclaration">
<xsl:apply-templates select="xqx:typeDeclaration"/>
</xsl:if>
<xsl:if test="xqxsx:varValue">
<xsl:text> := </xsl:text>
<xsl:apply-templates select="xqxsx:varValue"/>
</xsl:if>
<xsl:value-of select="$SEMICOLON"/>
</xsl:template>
<xsl:template match="xqxsx:varName">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xqxsx:varValue">
<xsl:apply-templates/>
</xsl:template>
<!-- blockBody -->
<xsl:template match="xqxsx:blockBody">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xqxsx:blockExpr">
<xsl:apply-templates/>
</xsl:template>
<!-- exitExpr -->
<xsl:template match="xqxsx:exitExpr">
<xsl:value-of select="$NEWLINE"/>
<xsl:text>exit returning </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<!-- whileExpr -->
<xsl:template match="xqxsx:whileExpr">
<xsl:value-of select="$NEWLINE"/>
<xsl:text>while </xsl:text>
<xsl:value-of select="$LPAREN"/>
<xsl:value-of select="$SPACE"/>
<xsl:apply-templates select="xqxsx:whileTest"/>
<xsl:value-of select="$SPACE"/>
<xsl:value-of select="$RPAREN"/>
<xsl:value-of select="$NEWLINE"/>
<xsl:apply-templates select="xqxsx:block"/>
<xsl:value-of select="$NEWLINE"/>
</xsl:template>
<xsl:template match="xqxsx:whileTest">
<xsl:apply-templates/>
</xsl:template>
<!-- applyExpr -->
<xsl:template match="xqxsx:applyExpr">
<xsl:value-of select="$NEWLINE"/>
<xsl:apply-templates select="xqxsx:applyExprs"/>
<xsl:value-of select="$NEWLINE"/>
</xsl:template>
<xsl:template match="xqxsx:applyExprs">
<xsl:apply-templates/>
<xsl:value-of select="$SEMICOLON"/>
</xsl:template>
<!-- Over-ride the template for functionDecl in XQuery -->
<!-- Update Facility xquery-update-10-xqueryx-redef.xsd -->
<xsl:template match="xqx:functionDecl" priority="200">
<xsl:text>declare </xsl:text>
<xsl:choose>
<xsl:when test="@xqx:updatingFunction and
@xqx:updatingFunction = 'true'">
<xsl:text>updating </xsl:text>
</xsl:when>
<xsl:when test="@xqx:sequentialFunction and
@xqx:sequentialFunction = 'true'">
<xsl:text>sequential </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>simple </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>function </xsl:text>
<xsl:apply-templates select="xqx:functionName"/>
<xsl:apply-templates select="xqx:paramList"/>
<xsl:apply-templates select="xqx:typeDeclaration"/>
<xsl:apply-templates select="xqx:functionBody"/>
<xsl:if test="xqx:externalDefinition">
<xsl:text> external </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
</pre></div>
</div>
<div class="div2">
<h3><a name="id-xqsx-xqueryx-examples" id=
"id-xqsx-xqueryx-examples"></a>B.3 Example</h3>
<p>The following example is based on the data and queries in the
use cases in <a href="#ScriptingUseCases">[XQuery Scripting Use
Cases]</a>. In this example, we show the English description of the
query, the XQuery Scripting Extension solution given in <a href=
"#ScriptingUseCases">[XQuery Scripting Use Cases]</a>, an XQueryX
solution, and the XQuery Update Facility expression that results
from applying the Update Facility XQueryX-to-XQuery Update Facility
transformation defined by the stylesheet in <a href=
"#id-xqsx-xqueryx-stylesheet"><b>[B.2 Stylesheet]</b></a> to the
Scripting Extension XQueryX solution. The XQuery Scripting
Extension expression that is produced is presented only as a
sanity-check—the intent of the stylesheet is not to recreate the
original XQuery expression, but to produce <em>a</em> valid XQuery
expression with the same semantics. The semantics of the Scripting
Extension XQueryX solution are determined by the semantics of the
XQuery Update Facility expression that results from that
transformation. The "correctness" of that transformation is
determined by asking the following the question: Can some Scripting
Extension XQueryX processor QX process some Scripting Extension
XQueryX document D1 to produce results R1, after which the
stylesheet is used to translate D1 into an XQuery Scripting
Extension expression E1 that, when processed by some XQuery
Scripting Extension processor Q, produces results R2 that are
equivalent (under some meaningful definition of "equivalent") to
results R1?</p>
<p>Comparison of the results of the Scripting Extension
XQueryX-to-XQuery Scripting Extension transformation given in this
document with the XQuery Scripting Extension solutions in <a href=
"#ScriptingUseCases">[XQuery Scripting Use Cases]</a> may be
helpful in evaluating the correctness of the Update Facility
XQueryX solution in each example.</p>
<p>The XQuery Scripting Extension Use Cases solution given for each
example is provided only to assist readers of this document in
understanding the Scripting Extension XQueryX solution. There is no
intent to imply that this document specifies a "compilation" or
"transformation" of XQuery Scripting Extension syntax into
Scripting Extension XQueryX syntax.</p>
<p>In the following example, note that path expressions are
expanded to show their structure. Also, note that the prefix syntax
for binary operators like "and" makes the precedence explicit. In
general, humans find it easier to read an XML representation that
does not expand path expressions, but it is less convenient for
programmatic representation and manipulation. XQueryX is designed
as a language that is convenient for production and modification by
software, and not as a convenient syntax for humans to read and
write.</p>
<p>Finally, please note that white space, including new lines, have
been added to some of the Scripting Extension XQueryX documents and
XQuery Scripting Extension expressions for readability. That
additional white space is not produced by the Scripting Extension
XQueryX-to-XQuery Scripting Extension transformation.</p>
<p>This example is based on query "Q2" from <a href=
"#ScriptingUseCases">[XQuery Scripting Use Cases]</a>, use case
"R": "Scripting Relational Data":</p>
<div class="div3">
<h4><a name="id-xqsx-xqueryx-xq-rep" id=
"id-xqsx-xqueryx-xq-rep"></a>B.3.1 XQuery Representation</h4>
<div class="exampleInner">
<pre>
let $uid := doc("users.xml")/users/user_tuple[name = "Roger Smith"]/userid
let $topbid := max(doc("bids.xml")/bids/bid_tuple[itemno = 1007]/bid)
let $newbid := $topbid * 1.1
return
if($newbid <= 240) then {
insert nodes
<bid_tuple>
<userid>{ data($uid) }</userid>
<itemno>1002</itemno>
<bid>{ $newbid }</bid>
<bid_date>1999-03-03</bid_date>
</bid_tuple>
into doc("bids.xml")/bids;
exit returning <new_bid>{ $newbid }</new_bid>;
} else {
exit returning <top_bid>{ $topbid }</top_bid>;
}
</pre></div>
</div>
<div class="div3">
<h4><a name="id-xqsx-xqueryx-xqx-rep" id=
"id-xqsx-xqueryx-xqx-rep"></a>B.3.2 XQueryX Representation</h4>
<div class="exampleInner">
<pre>
<?xml version="1.0"?>
<!--
let $uid := doc("users.xml")/users/user_tuple[name = "Roger Smith"]/userid
let $topbid := max(doc("bids.xml")/bids/bid_tuple[itemno = 1007]/bid)
let $newbid := $topbid * 1.1
return
if($newbid <= 240) then {
insert nodes
<bid_tuple>
<userid>{ data($uid) }</userid>
<itemno>1002</itemno>
<bid>{ $newbid }</bid>
<bid_date>1999-03-03</bid_date>
</bid_tuple>
into doc("bids.xml")/bids;
exit returning <new_bid>{ $newbid }</new_bid>;
} else {
exit returning <top_bid>{ $topbid }</top_bid>;
}
-->
<xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
xmlns:xqxsx="http://www.w3.org/2008/xquery-sx-10"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/XQueryX
http://www.w3.org/2005/XQueryX/xqueryx.xsd
http://www.w3.org/2007/xquery-update-10
http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd
http://www.w3.org/2008/xquery-sx-10
http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsd">
<xqx:queryBody>
<xqx:flworExpr>
<!-- let $uid := doc("users.xml")/users/user_tuple[name = "Roger Smith"]/userid -->
<xqx:letClause>
<xqx:letClauseItem>
<xqx:typedVariableBinding>
<xqx:varName>uid</xqx:varName>
</xqx:typedVariableBinding>
<xqx:letExpr>
<xqx:pathExpr>
<xqx:stepExpr>
<xqx:filterExpr>
<xqx:functionCallExpr>
<xqx:functionName
xqx:prefix="fn">doc</xqx:functionName>
<xqx:arguments>
<xqx:stringConstantExpr>
<xqx:value>users.xml</xqx:value>
</xqx:stringConstantExpr>
</xqx:arguments>
</xqx:functionCallExpr>
</xqx:filterExpr>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>users</xqx:nameTest>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>user-tuple</xqx:nameTest>
<xqx:predicates>
<xqx:equalOp>
<xqx:firstOperand>
<xqx:pathExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>name</xqx:nameTest>
</xqx:stepExpr>
</xqx:pathExpr>
</xqx:firstOperand>
<xqx:secondOperand>
<xqx:stringConstantExpr>
<xqx:value>Roger Smith</xqx:value>
</xqx:stringConstantExpr>
</xqx:secondOperand>
</xqx:equalOp>
</xqx:predicates>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>userid</xqx:nameTest>
</xqx:stepExpr>
</xqx:pathExpr>
</xqx:letExpr>
</xqx:letClauseItem>
</xqx:letClause>
<!-- let $topbid := max(doc("bids.xml")/bids/bid_tuple[itemno = 1007]/bid) -->
<xqx:letClause>
<xqx:letClauseItem>
<xqx:typedVariableBinding>
<xqx:varName>topbid</xqx:varName>
</xqx:typedVariableBinding>
<xqx:letExpr>
<xqx:pathExpr>
<xqx:stepExpr>
<xqx:filterExpr>
<xqx:functionCallExpr>
<xqx:functionName
xqx:prefix="fn">max</xqx:functionName>
<xqx:arguments>
<xqx:pathExpr>
<xqx:stepExpr>
<xqx:filterExpr>
<xqx:functionCallExpr>
<xqx:functionName
xqx:prefix="fn">doc</xqx:functionName>
<xqx:arguments>
<xqx:stringConstantExpr>
<xqx:value>bids.xml</xqx:value>
</xqx:stringConstantExpr>
</xqx:arguments>
</xqx:functionCallExpr>
</xqx:filterExpr>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>bids</xqx:nameTest>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>bid-tuple</xqx:nameTest>
<xqx:predicates>
<xqx:equalOp>
<xqx:firstOperand>
<xqx:pathExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>itemno</xqx:nameTest>
</xqx:stepExpr>
</xqx:pathExpr>
</xqx:firstOperand>
<xqx:secondOperand>
<xqx:integerConstantExpr>
<xqx:value>1007</xqx:value>
</xqx:integerConstantExpr>
</xqx:secondOperand>
</xqx:equalOp>
</xqx:predicates>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>bid</xqx:nameTest>
</xqx:stepExpr>
</xqx:pathExpr>
</xqx:arguments>
</xqx:functionCallExpr>
</xqx:filterExpr>
</xqx:stepExpr>
</xqx:pathExpr>
</xqx:letExpr>
</xqx:letClauseItem>
</xqx:letClause>
<!-- let $newbid := $topbid * 1.1 -->
<xqx:letClause>
<xqx:letClauseItem>
<xqx:typedVariableBinding>
<xqx:varName>newbid</xqx:varName>
</xqx:typedVariableBinding>
<xqx:letExpr>
<xqx:multiplyOp>
<xqx:firstOperand>
<xqx:varRef>
<xqx:name>topbid</xqx:name>
</xqx:varRef>
</xqx:firstOperand>
<xqx:secondOperand>
<xqx:decimalConstantExpr>
<xqx:value>1.1</xqx:value>
</xqx:decimalConstantExpr>
</xqx:secondOperand>
</xqx:multiplyOp>
</xqx:letExpr>
</xqx:letClauseItem>
</xqx:letClause>
<!-- return -->
<xqx:returnClause>
<!-- if($newbid <= 240) -->
<xqx:ifThenElseExpr>
<xqx:ifClause>
<xqx:lessThanOrEqualOp>
<xqx:firstOperand>
<xqx:varRef>
<xqx:name>newbid</xqx:name>
</xqx:varRef>
</xqx:firstOperand>
<xqx:secondOperand>
<xqx:integerConstantExpr>
<xqx:value>240</xqx:value>
</xqx:integerConstantExpr>
</xqx:secondOperand>
</xqx:lessThanOrEqualOp>
</xqx:ifClause>
<!-- then { -->
<xqx:thenClause>
<xqxsx:block>
<xqxsx:blockBody>
<xqxsx:blockExpr>
<!-- insert nodes -->
<xqxuf:insertExpr>
<xqxuf:sourceExpr>
<!-- <bid_tuple> -->
<xqx:elementConstructor>
<xqx:tagName>bid_tuple</xqx:tagName>
<xqx:elementContent>
<!-- <userid>{ data($uid) }</userid> -->
<xqx:elementConstructor>
<xqx:tagName>userid</xqx:tagName>
<xqx:elementContent>
<xqx:functionCallExpr>
<xqx:functionName
xqx:prefix="fn">data</xqx:functionName>
<xqx:arguments>
<xqx:exprList>
<xqx:expr>
<xqx:varRef>
<xqx:name>uid</xqx:name>
</xqx:varRef>
</xqx:expr>
</xqx:exprList>
</xqx:arguments>
</xqx:functionCallExpr>
</xqx:elementContent>
</xqx:elementConstructor>
<!-- <itemno>1002</itemno> -->
<xqx:elementConstructor>
<xqx:tagName>itemno</xqx:tagName>
<xqx:elementContent>
<xqx:integerConstantExpr>
<xqx:value>1002</xqx:value>
</xqx:integerConstantExpr>
</xqx:elementContent>
</xqx:elementConstructor>
<!-- <bid>{ $newbid }</bid> -->
<xqx:elementConstructor>
<xqx:tagName>bid</xqx:tagName>
<xqx:elementContent>
<xqx:varRef>
<xqx:name>bid</xqx:name>
</xqx:varRef>
</xqx:elementContent>
</xqx:elementConstructor>
<!-- <bid_date>1999-03-03</bid_date> -->
<xqx:elementConstructor>
<xqx:tagName>bid_date</xqx:tagName>
<xqx:elementContent>
<xqx:stringConstantExpr>
<xqx:value>1999-03-03</xqx:value>
</xqx:stringConstantExpr>
</xqx:elementContent>
</xqx:elementConstructor>
</xqx:elementContent>
</xqx:elementConstructor>
</xqxuf:sourceExpr>
<!-- into doc("bids.xml")/bids; -->
<xqxuf:insertInto/>
<xqxuf:targetExpr>
<xqx:pathExpr>
<xqx:stepExpr>
<xqx:filterExpr>
<xqx:functionCallExpr>
<xqx:functionName
xqx:prefix="fn">doc</xqx:functionName>
<xqx:arguments>
<xqx:stringConstantExpr>
<xqx:value>bids.xml</xqx:value>
</xqx:stringConstantExpr>
</xqx:arguments>
</xqx:functionCallExpr>
</xqx:filterExpr>
</xqx:stepExpr>
<xqx:stepExpr>
<xqx:xpathAxis>child</xqx:xpathAxis>
<xqx:nameTest>bids</xqx:nameTest>
</xqx:stepExpr>
</xqx:pathExpr>
</xqxuf:targetExpr>
</xqxuf:insertExpr>
</xqxsx:blockExpr>
<!-- exit returning <new_bid>{ $newbid }</new_bid>; -->
<xqxsx:blockExpr>
<xqxsx:exitExpr>
<xqx:elementConstructor>
<xqx:tagName>new_bid</xqx:tagName>
<xqx:elementContent>
<xqx:varRef>
<xqx:name>newbid</xqx:name>
</xqx:varRef>
</xqx:elementContent>
</xqx:elementConstructor>
</xqxsx:exitExpr>
</xqxsx:blockExpr>
</xqxsx:blockBody>
</xqxsx:block>
</xqx:thenClause>
<!-- } else { -->
<xqx:elseClause>
<!-- exit returning <top_bid>{ $topbid }</top_bid>; -->
<xqxsx:block>
<xqxsx:blockBody>
<xqxsx:blockExpr>
<xqxsx:exitExpr>
<xqx:elementConstructor>
<xqx:tagName>top_bid</xqx:tagName>
<xqx:elementContent>
<xqx:varRef>
<xqx:name>topbid</xqx:name>
</xqx:varRef>
</xqx:elementContent>
</xqx:elementConstructor>
</xqxsx:exitExpr>
</xqxsx:blockExpr>
</xqxsx:blockBody>
</xqxsx:block>
</xqx:elseClause>
</xqx:ifThenElseExpr>
</xqx:returnClause>
<!-- } -->
</xqx:flworExpr>
</xqx:queryBody>
</xqx:module>
</pre></div>
</div>
<div class="div3">
<h4><a name="id-xqsx-xqueryx-transformed-rep" id=
"id-xqsx-xqueryx-transformed-rep"></a>B.3.3 Transformed XQuery
Representation</h4>
<p>Application of the stylesheet in <a href=
"#id-xqsx-xqueryx-stylesheet"><b>[B.2 Stylesheet]</b></a> to the
Update Facility XQueryX representation results in the following
XQuery representation:</p>
<div class="exampleInner">
<pre>
( let $uid:=fn:doc("users.xml")/child::users/
child::user-tuple[(child::name = "Roger Smith")]/
child::userid
let $topbid:=fn:max(fn:doc("bids.xml")/
child::bids/child::bid-tuple[(child::itemno = 1007)]/
child::bid)
let $newbid:=($topbid*1.1)
return
( if (($newbid <= 240)) then {
insert nodes
<bid_tuple>
<userid>{fn:data($uid)}</userid>
<itemno>{1002}</itemno>
<bid>{$bid}</bid>
<bid_date>{"1999-03-03"}</bid_date>
</bid_tuple>
into
fn:doc("bids.xml")/child::bids
exit returning <new_bid>{$newbid}</new_bid> }
else {
exit returning <top_bid>{$topbid}</top_bid> } )
)
</pre></div>
</div>
</div>
</div>
<div class="div1">
<h2><a name="id-implementation-defined-items" id=
"id-implementation-defined-items"></a>C Implementation-Defined
Items</h2>
<p>The following items in this specification are
implementation-defined:</p>
<ol class="enumar">
<li>
<p>The effects of <a title="snapshot" href="#dt-snapshot">snapshot
semantics</a> on persistent storage. For example, it is
implementation-defined whether the effects of an
<code>fn:put</code> function are visible to an <code>fn:doc</code>,
<code>fn:doc-available</code>, or <code>fn:collection</code>
function executed in a subsequent <a title="snapshot" href=
"#dt-snapshot">snapshot</a>.</p>
</li>
<li>
<p>The mechanism (if any) by which the XQuery environment exchanges
parameters and results with an external function.</p>
</li>
</ol>
</div>
<div class="div1">
<h2><a name="id-references" id="id-references"></a>D
References</h2>
<dl>
<dt class="label"><span><a name="XQ10" id="XQ10"></a>XQuery
1.0</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery/">XQuery 1.0: An XML
Query Language</a>, W3C Recommendation, 23 January 2007.</div>
</dd>
<dt class="label"><span><a name="XQX10" id="XQX10"></a>XML Syntax
for XQuery 1.0</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xqueryx/">XML Syntax for XQuery
1.0</a>, W3C Recommendation, 23 January 2007.</div>
</dd>
<dt class="label"><span><a name="XDM" id="XDM"></a>XQuery Data
Model</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xpath-datamodel/">XQuery 1.0 and
XPath 2.0 Data Model (XDM)</a>, W3C Recommendation, 23 January
2007.</div>
</dd>
<dt class="label"><span><a name="FO" id="FO"></a>XQuery 1.0 and
XPath 2.0 Functions and Operators</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xpath-functions/">XQuery 1.0 and
XPath 2.0 Functions and Operators</a>, W3C Recommendation, 23
January 2007.</div>
</dd>
<dt class="label"><span><a name="XQueryUpdate" id=
"XQueryUpdate"></a>XQuery Update Facility</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-update-10/">XQuery Update
Facility 1.0</a>, W3C Candidate Recommendation, March 2008.</div>
</dd>
<dt class="label"><span><a name="ScriptingRequirements" id=
"ScriptingRequirements"></a>XQuery Scripting
Requirements</span></dt>
<dd>
<div><a href=
"http://www.w3.org/TR/xquery-sx-10-requirements/">XQuery Scripting
Extension 1.0 Requirements</a>, W3C Working Draft, 23 March
2007.</div>
</dd>
<dt class="label"><span><a name="ScriptingUseCases" id=
"ScriptingUseCases"></a>XQuery Scripting Use Cases</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-sx-10-use-cases/">XQuery
Scripting Extension 1.0 Use Cases</a>, W3C Working Draft 23 March
2007.</div>
</dd>
<dt class="label"><span><a name="XQ11" id="XQ11"></a>XQuery
1.1</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-11/">XQuery 1.1: An XML
Query Language</a>, W3C Working Draft, 15 December 2009.</div>
</dd>
</dl>
</div>
<div class="div1">
<h2><a name="id-errors" id="id-errors"></a>E Error Conditions</h2>
<div class="div2">
<h3><a name="id-new-error-codes" id="id-new-error-codes"></a>E.1
New Error Codes</h3>
<dl>
<dt><a name="ERRSXST0002" id="ERRSXST0002"></a>err:SXST0002</dt>
<dd>
<p>It is a static error to mix both <a title="updating expression"
href="#dt-updating-expr">updating</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>
operands in an expression.</p>
</dd>
<dt><a name="ERRSXDY0003" id="ERRSXDY0003"></a>err:SXDY0003</dt>
<dd>
<p>It is a dynamic error if, after applying a pending update list
(using <code>upd:applyUpdates</code>), the XDM instance bound to
any in-scope variable does not match the static type of that
variable according to SequenceType matching rules.</p>
</dd>
<dt><a name="ERRSXDY0004" id="ERRSXDY0004"></a>err:SXDY0004</dt>
<dd>
<p>It is an dynamic error for an external sequential function to
return a non-empty <a title="pending update list" href=
"#dt-pul">pending update list</a>.</p>
</dd>
<dt><a name="ERRSXST0005" id="ERRSXST0005"></a>err:SXST0005</dt>
<dd>
<p>It is a static error if two or more variables declared in the
same block expression have the same expanded QName.</p>
</dd>
<dt><a name="ERRSXTY0006" id="ERRSXTY0006"></a>err:SXTY0006</dt>
<dd>
<p>A reference to a variable, other than on the left-hand side of
an assignment expression, is an error if the variable has no value
in <em>variable values</em> when the reference is evaluated.</p>
</dd>
<dt><a name="ERRSXST0007" id="ERRSXST0007"></a>err:SXST0007</dt>
<dd>
<p>The variable on the left-hand side of an assignment must have
been declared in one of the following ways:</p>
<ul>
<li>
<p>By a block variable declaration</p>
</li>
<li>
<p>As a parameter to a sequential function</p>
</li>
<li>
<p>By a variable declaration in the Prolog <span>declared as
<a title="assignable" href=
"#dt-assignable">assignable</a></span></p>
</li>
</ul>
</dd>
<dt><a name="ERRSXST0008" id="ERRSXST0008"></a>err:SXST0008</dt>
<dd>
<p>It is a static error if the body of a function violates the
category rules for it's declared category.</p>
</dd>
<dt><a name="ERRSXST0009" id="ERRSXST0009"></a>err:SXST0009</dt>
<dd>
<p>A static error is raised if the value for a
<code>xqsx:query-mode</code> option or pragma is not either
<code>sequential</code> or <code>simple</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-amended-error-codes" id=
"id-amended-error-codes"></a>E.2 Amendments to Existing Error
Codes</h3>
<dl>
<dt><a name="ERRXUST0001" id="ERRXUST0001"></a>err:XUST0001</dt>
<dd>
<p>It is a static error for an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a> to occur in the following places:</p>
<ol class="enumar">
<li>
<p>As the initializing expression of a prolog variable.</p>
</li>
<li>
<p>As a StepExpr in a RelativePathExpr when <a title="query mode"
href="#dt-query-mode">query mode</a> is <code>simple</code>.</p>
</li>
<li>
<p>As the primary expression or a predicate expression of a
FilterExpr or AxisStep when <a title="query mode" href=
"#dt-query-mode">query mode</a> is <code>simple</code>.</p>
</li>
<li>
<p>In the <code>for</code>, <code>let</code>, <code>where</code>,
or <code>order by</code> clauses of a FLWOR expression when
<a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>.</p>
</li>
<li>
<p>In a quantified expression clause or as the satisfies expression
of a quantified expression when <a title="query mode" href=
"#dt-query-mode">query mode</a> is <code>simple</code>.</p>
</li>
</ol>
</dd>
</dl>
</div>
</div>
<div class="div1">
<h2><a name="id-glossary" id="id-glossary"></a>F Glossary
(Non-Normative)</h2>
<dl>
<dt><a name="GLdt-xdm-instance" id="GLdt-xdm-instance"></a>XDM
instance</dt>
<dd>
<p>An <b>XDM instance</b> is an unconstrained sequence of zero or
more nodes and/or atomic values, as defined in <a href=
"#XDM">[XQuery Data Model]</a>.</p>
</dd>
<dt><a name="GLdt-xqsx" id="GLdt-xqsx"></a>XQSX</dt>
<dd>
<p><b>XQSX</b> is an abbreviation for XQuery Scripting
Extension.</p>
</dd>
<dt><a name="GLdt-xquf" id="GLdt-xquf"></a>XQUF</dt>
<dd>
<p><b>XQUF</b> is an abbreviation for <a href=
"#XQueryUpdate">[XQuery Update Facility]</a>.</p>
</dd>
<dt><a name="GLdt-apply-expr" id="GLdt-apply-expr"></a>apply
expression</dt>
<dd>
<p>An <b>apply expression</b> is a list of semicolon-terminated
ConcatExpr productions, called operand expressions. An ApplyExpr
consisting of a single ConcatExpr with no semicolon is not an apply
expression.</p>
</dd>
<dt><a name="GLdt-assignable" id=
"GLdt-assignable"></a>assignable</dt>
<dd>
<p>Prolog variables declared as <b>assignable</b> may have their
value changed by an <a href="#id-assignment"><b>[5.3 Assignment
Expression]</b></a>.</p>
</dd>
<dt><a name="GLdt-constant" id="GLdt-constant"></a>constant</dt>
<dd>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> allows the keyword
<code>constant</code> to be used in place of <code>variable</code>
in a Prolog declaration. A variable declared in this way is called
a <b>constant</b>.</p>
</dd>
<dt><a name="GLdt-eval-order" id="GLdt-eval-order"></a>evaluation
order</dt>
<dd>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> defines an
<b>evaluation order</b> on many kinds of XQuery expressions, which
is the order that operand expressions must be evaluated in order to
determine what side-effects are visible to later expressions.</p>
</dd>
<dt><a name="GLdt-initializing-expr" id=
"GLdt-initializing-expr"></a>initializing expression</dt>
<dd>
<p>The expression on the right-hand side of a block variable
declaration is called an <b>initializing expression</b>.</p>
</dd>
<dt><a name="GLdt-pul" id="GLdt-pul"></a>pending update list</dt>
<dd>
<p>A <b>pending update list</b> is an unordered collection of
update primitives, representing node state changes that have not
yet been applied, as defined in <a href="#XQueryUpdate">[XQuery
Update Facility]</a>.</p>
</dd>
<dt><a name="GLdt-query-mode" id="GLdt-query-mode"></a>query
mode</dt>
<dd>
<p>The <b>query mode</b> governs the composability of <a title=
"updating expression" href="#dt-updating-expr">updating</a> and
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expressions</a>. Valid values are
<code>sequential</code> and <code>simple</code>.</p>
</dd>
<dt><a name="GLdt-sequential-expr" id=
"GLdt-sequential-expr"></a>sequential expression</dt>
<dd>
<p>A <b>sequential expression</b> is an expression that can have
side effects other than constructing a new node or raising an
error.</p>
</dd>
<dt><a name="GLdt-sequential-function" id=
"GLdt-sequential-function"></a>sequential function</dt>
<dd>
<p>A <b>sequential function</b> is a function whose declaration
specifies the keyword <code>sequential</code>.</p>
</dd>
<dt><a name="GLdt-simple-expr" id="GLdt-simple-expr"></a>simple
expression</dt>
<dd>
<p>A <b>simple expression</b> is an expression that is neither an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a> nor a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt><a name="GLdt-simple-function" id=
"GLdt-simple-function"></a>simple function</dt>
<dd>
<p>A <b>simple function</b> is a function whose declaration
specifies neither <code>updating</code> nor
<code>sequential</code>. A <a title="simple function" href=
"#dt-simple-function">simple function</a> may optionally specify
the keyword <code>simple</code>.</p>
</dd>
<dt><a name="GLdt-snapshot" id="GLdt-snapshot"></a>snapshot</dt>
<dd>
<p>A <b>snapshot</b> is a scope within which expressions are
evaluated with respect to a fixed <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and updates are held
pending.</p>
</dd>
<dt><a name="GLdt-test-expr" id="GLdt-test-expr"></a>test
expression</dt>
<dd>
<p>The expression enclosed in the parentheses of a while expression
is called a <b>test expression</b>.</p>
</dd>
<dt><a name="GLdt-updating-expr" id=
"GLdt-updating-expr"></a>updating expression</dt>
<dd>
<p>An <b>updating expression</b> is an expression that can return a
non-empty <a title="pending update list" href="#dt-pul">pending
update list</a>.</p>
</dd>
<dt><a name="GLdt-updating-function" id=
"GLdt-updating-function"></a>updating function</dt>
<dd>
<p>An <b>updating function</b> is a function whose declaration
specifies the keyword <code>updating</code>.</p>
</dd>
</dl>
</div>
<div class="div1">
<h2><a name="id-revisions-log" id="id-revisions-log"></a>G Revision
Log (Non-Normative)</h2>
<p>This log records the substantive changes that have been made to
this document. Minor editorial changes are not included in this
log.</p>
<p>This document was built from files checked in on $Date:
2010/04/05 22:10:44 $.</p>
<div class="div2">
<h3><a name="id-log-20081203" id="id-log-20081203"></a>G.1 Since
the 3 December 2008 Working Draft</h3>
<ul>
<li>
<p>Changed "exit with" to "exit returning"</p>
</li>
<li>
<p>Relaxed restrictions on where sequential expressions can
occur.</p>
</li>
<li>
<p>The type of a block variable is never inferred from it's
initializing expression.</p>
</li>
<li>
<p>Removed the "set" keyword from an assignment expression.</p>
</li>
<li>
<p>Changed "variable"/"constant" to "unassignable variable" and
"assignable variable".</p>
</li>
<li>
<p>Made execution scope and snapshot scope analogous, so stable
functions can change value in subsequent snapshots.</p>
</li>
<li>
<p>Added query mode to the static context, along with an option and
pragma to change it.</p>
</li>
<li>
<p>Added error codes for all error conditions.</p>
</li>
</ul>
</div>
<div class="div2">
<h3><a name="id-log-20080328" id="id-log-20080328"></a>G.2 Since
the 28 March 2008 Working Draft</h3>
<ul>
<li>
<p>Relaxed the restrictions on where updating expressions can occur
to a superset of those allowed by <a href="#XQueryUpdate">[XQuery
Update Facility]</a>.</p>
</li>
<li>
<p>Re-check the SequenceType of bound variables after
upd:applyUpdates is invoked.</p>
</li>
<li>
<p>Added the "block" keyword to the grammer for block
expressions.</p>
</li>
<li>
<p>Removed the break and continue expressions.</p>
</li>
<li>
<p>Added the semi-colon (apply) expression to apply updates,
removing the semi-colon separated list from block expressions.</p>
</li>
<li>
<p>Added the ability to set the value of parameters to sequential
functions.</p>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>