index.html 192 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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN">
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 14 February 2006), see www.w3.org" />
<title>XML Syntax for XQuery 1.0 (XQueryX) (Second Edition)</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 type="text/css" rel="stylesheet" href=
"http://www.w3.org/StyleSheets/TR/W3C-REC.css" />
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img width="72" height="48" alt=
"W3C" src="http://www.w3.org/Icons/w3c_home" /></a></p>
<h1><a id="title" name="title"></a>XML Syntax for XQuery 1.0
(XQueryX) (Second Edition)</h1>
<h2><a id="w3c-doctype" name="w3c-doctype"></a>W3C Recommendation
14 December 2010</h2>
<dl>
<dt>This version:</dt>
<dd><a href=
"http://www.w3.org/TR/2010/REC-xqueryx-20101214/">http://www.w3.org/TR/2010/REC-xqueryx-20101214/</a></dd>
<dt>Latest version:</dt>
<dd><a href=
"http://www.w3.org/TR/xqueryx/">http://www.w3.org/TR/xqueryx/</a></dd>
<dt>Previous versions:</dt>
<dd><a href=
"http://www.w3.org/TR/2009/PER-xqueryx-20090421/">http://www.w3.org/TR/2009/PER-xqueryx-20090421/,</a>
<a href=
"http://www.w3.org/TR/2007/REC-xqueryx-20070123/">http://www.w3.org/TR/2007/REC-xqueryx-20070123/</a></dd>
<dt>Editors:</dt>
<dd>Jim Melton, Oracle <a href=
"mailto:jim.melton@oracle.com">&lt;jim.melton@oracle.com&gt;</a></dd>
<dd>Subramanian Muralidhar, Microsoft</dd>
</dl>
<p>Please refer to the <a href=
"http://www.w3.org/XML/2010/qt-errata/xqueryx-errata2e.html"><strong>
errata</strong></a> for this document, which may include some
normative corrections.</p>
<p>See also <a href=
"http://www.w3.org/2003/03/Translations/byTechnology?technology=xqueryx">
<strong>translations</strong></a>.</p>
<p>This document is also available in these non-normative formats:
<a href=
"http://www.w3.org/TR/2010/REC-xqueryx-20101214/xqueryx-20101214.xml">
XML</a> and&#160;<a href=
"http://www.w3.org/TR/2010/REC-xqueryx-20101214/xqueryx-diff-from-REC20070123.html">Change
markings relative to first edition</a>.</p>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>&#160;©&#160;2010&#160;<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 id="abstract" name="abstract"></a>Abstract</h2>
<p>This document defines an XML Syntax for <a href=
"#xquery">[XQuery 1.0: An XML Query Language (Second
Edition)]</a>.</p>
</div>
<div>
<h2><a id="status" name="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 one document in a set of eight documents that are being
progressed to Edited Recommendation together (XPath 2.0, XQuery
1.0, XQueryX 1.0, XSLT 2.0, Data Model (XDM), Functions and
Operators, Formal Semantics, Serialization).</p>
<p>This document, published on 14 December 2010, is an Edited
<a href=
"http://www.w3.org/2004/02/Process-20040205/tr.html#RecsW3C">Recommendation</a>
of the W3C. It supersedes the previous W3C Recommendation of 23
January 2007. This second edition is not a new version of this
specification; its purpose is to clarify a number of issues that
have become apparent since the first edition was published. All of
these clarifications (excepting trivial editorial fixes) have been
published in a separate errata document, and published in a
<a href="http://www.w3.org/2004/02/Process-20040205/tr.html#ProposedEditedRec">
Proposed Edited Recommendation</a> in April 2009. The changes are
summarized in an appendix. This document 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>.</p>
<p>This document has been reviewed by W3C Members, by software
developers, and by other W3C groups and interested parties, and is
endorsed by the Director as a W3C Recommendation. It is a stable
document and may be used as reference material or cited from
another document. W3C's role in making the Recommendation is to
draw attention to the specification and to promote its widespread
deployment. This enhances the functionality and interoperability of
the Web.</p>
<p>This document incorporates changes made against the <a href=
"http://www.w3.org/2004/02/Process-20040205/tr.html#RecsW3C">Recommendation</a>
of 23 January 2007 that resolve all errata known at the date of
publication. Changes to this document since the first edition are
detailed in the <a href="#changelog"><b>D Changes since the First
Edition</b></a>. This document supersedes the <a href=
"http://www.w3.org/TR/2007/REC-xqueryx-20070123/">first
edition</a>.</p>
<p>An implementation report is available at <a href=
"http://www.w3.org/XML/Query/test-suite/XQTSReport.html">http://www.w3.org/XML/Query/test-suite/XQTSReport.html</a>.</p>
<p>Please report errors in and submit comments on 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 “[XQX]” in the
subject line of your report, whether made in Bugzilla or in email.
Each Bugzilla entry and email message should contain only one error
report. 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>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 id="contents" name="contents"></a>Table of Contents</h2>
<p class="toc">1 <a href="#Introduction">Introduction</a><br />
2 <a href="#Mapping">Mapping the XQuery Syntax</a><br />
3 <a href="#Examples">Examples from the XML Query Use Cases in XML
Syntax</a><br />
&#160;&#160;&#160;&#160;3.1 <a href="#Example1">Example 1</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.1.1 <a href=
"#Example1-XQuery">XQuery solution in XQuery Use Cases:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.1.2 <a href=
"#Example1-XQueryX">A Solution in XQueryX:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.1.3 <a href=
"#Example1-Transformation">Transformation of XQueryX Solution into
XQuery</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.1.4 <a href=
"#Example1-Abstract">Corresponding Grammar Abstract Parse
Tree</a><br />
&#160;&#160;&#160;&#160;3.2 <a href="#Example2">Example 2</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.2.1 <a href=
"#Example2-XQuery">XQuery solution in XQuery Use Cases:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.2.2 <a href=
"#Example2-XQueryX">A solution in XQueryX:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.2.3 <a href=
"#Example2-Transformation">Transformation of XQueryX Solution into
XQuery</a><br />
&#160;&#160;&#160;&#160;3.3 <a href="#Example3">Example 3</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.3.1 <a href=
"#Example3-XQuery">XQuery solution in XQuery Use Cases:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.3.2 <a href=
"#Example3-XQueryX">A solution in XQueryX:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.3.3 <a href=
"#Example3-Transformation">Transformation of XQueryX Solution into
XQuery</a><br />
&#160;&#160;&#160;&#160;3.4 <a href="#Example4">Example 4</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.4.1 <a href=
"#Example4-XQuery">XQuery solution in XQuery Use Cases:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.4.2 <a href=
"#Example4-XQueryX">A solution in XQueryX:</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.4.3 <a href=
"#Example4-Transformation">Transformation of XQueryX Solution into
XQuery</a><br />
4 <a href="#Schema">An XML Schema for the XQuery XML
Syntax</a><br />
5 <a href="#xqx_conformance">Conformance</a><br /></p>
<h3><a id="appendices" name="appendices"></a>Appendices</h3>
<p class="toc">A <a href="#biblio">References</a><br />
B <a href="#Stylesheet">Transforming XQueryX to XQuery</a><br />
C <a href="#xqueryx-id-mime-type">The application/xquery+xml Media
Type</a><br />
&#160;&#160;&#160;&#160;C.1 <a href=
"#xqueryx-mime-introduction">Introduction</a><br />
&#160;&#160;&#160;&#160;C.2 <a href=
"#xqueryx-mime-registration">Registration of MIME Media Type
application/xquery+xml</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.1 <a href=
"#xqueryx-mime-encoding">Encoding Considerations</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.2 <a href=
"#xqueryx-mime-security">Security Considerations</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.3 <a href=
"#xqueryx-mime-interoperability">Interoperability
Considerations</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.4 <a href=
"#xqueryx-mime-pubspec">Published specification</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.5 <a href=
"#xqueryx-mime-applications">Applications That Use This Media
Type</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.6 <a href=
"#xqueryx-mime-additional">Additional Information</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.6.1
<a href="#xqueryx-mime-recognizing">Recognizing XQuery Files
("Magic Numbers")</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.6.2
<a href="#xqueryx-mime-extensions">File Extensions</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.6.3
<a href="#xqueryx-mime-macfiletype">Macintosh File Type
Code(s)</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.7 <a href=
"#xqueryx-mime-author">Person and Email Address to Contact For
Further Information</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.8 <a href=
"#xqueryx-mime-intended-usage">Intended Usage</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.9 <a href=
"#xqueryx-mime-restrictions">Restrictions on usage</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.10 <a href=
"#xqueryx-mime-owner">Author/Change Controller</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;C.2.11 <a href=
"#xqueryx-mime-fragments">Fragment Identifiers</a><br />
D <a href="#changelog">Changes since the First Edition</a>
(Non-Normative)<br /></p>
</div>
<hr />
<div class="body">
<div class="div1">
<h2><a id="Introduction" name="Introduction"></a>1
Introduction</h2>
<p>The <a href="#xquery-requirements">[XML Query 1.0
Requirements]</a> states that "The XML Query Language MAY have more
than one syntax binding. One query language syntax MUST be
convenient for humans to read and write. One query language syntax
MUST be expressed in XML in a way that reflects the underlying
structure of the query."</p>
<p>XQueryX is an XML representation of an XQuery. It was created by
mapping the productions of the XQuery grammar into XML productions.
The result is not particularly convenient for humans to read and
write, but it is easy for programs to parse, and because XQueryX is
represented in XML, standard XML tools can be used to create,
interpret, or modify queries.</p>
<p>In this document, examples and material labeled as "Note" are
provided for explanatory purposes and are not normative.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Because the two syntaxes are merely different grammars that
express the same query semantics, they share all aspects of an
XQuery processing system except for the component that recognizes
and translates the source representation of a query (that is, the
parser). The aspects that are shared include both the static
context and the dynamic context that are defined in <a href=
"#xquery">[XQuery 1.0: An XML Query Language (Second
Edition)]</a>.</p>
</div>
<p>There are several environments in which XQueryX may be
useful:</p>
<ul>
<li>
<p><em>Parser Reuse.</em> In heterogeneous environments, a variety
of systems may be used to execute a query. One parser can generate
XQueryX for all of these systems.</p>
</li>
<li>
<p><em>Queries on Queries.</em> Because XQueryX is represented in
XML, queries can be queried and can be transformed into new
queries. For instance, a query can be performed against a set of
XQueryX queries to determine which queries use FLWOR expressions to
range over a set of invoices.</p>
</li>
<li>
<p><em>Generating Queries.</em> In some XML-oriented programming
environments, it may be more convenient to build a query in its
XQueryX representation than in the corresponding XQuery
representation, since ordinary XML tools can be used.</p>
</li>
<li>
<p><em>Embedding Queries in XML.</em> XQueryX can be embedded
directly in an XML document.</p>
</li>
</ul>
<p>The most recent versions of the XQueryX XML Schema and the
XQueryX XSLT stylesheet are available at <a href=
"http://www.w3.org/2005/XQueryX/xqueryx.xsd">http://www.w3.org/2005/XQueryX/xqueryx.xsd</a>
and <a href=
"http://www.w3.org/2005/XQueryX/xqueryx.xsl">http://www.w3.org/2005/XQueryX/xqueryx.xsl</a>,
respectively.</p>
</div>
<div class="div1">
<h2><a id="Mapping" name="Mapping"></a>2 Mapping the XQuery
Syntax</h2>
<p>XQueryX is an XML representation of the abstract syntax found in
Appendix A of <a href="#xquery">[XQuery 1.0: An XML Query Language
(Second Edition)]</a>. The XQueryX syntax is defined by the XQueryX
Schema, which is specified in <a href="#Schema"><b>4 An XML Schema
for the XQuery XML Syntax</b></a>. The XQueryX semantics are
defined by a stylesheet that maps an instance of XQueryX to an
instance of XQuery; see <a href="#Stylesheet"><b>B Transforming
XQueryX to XQuery</b></a>.</p>
<p>The main data structure in the XQueryX Schema is the set of
types that describe expressions. We have chosen to model
expressions using substitution groups, with an "expr" abstract base
class and a number of intermediate abstract classes.</p>
<p>Consider the following productions from the abstract syntax:</p>
<div class="exampleInner">
<pre>

FLWORExpr    ::=    (ForClause  | LetClause)+ WhereClause? OrderByClause? "return" ExprSingle 
ForClause    ::=    "for" "$" VarName TypeDeclaration? PositionalVar? "in" 
                    ExprSingle ("," "$" VarName TypeDeclaration? PositionalVar? 
                    "in" ExprSingle)* 
LetClause    ::=    "let" "$" VarName TypeDeclaration? ":=" ExprSingle
                    ("," "$" VarName TypeDeclaration? ":=" ExprSingle)*
WhereClause  ::=    "where" ExprSingle
</pre></div>
<p>The following XQueryX Schema definitions reflect the structure
of those productions from that abstract syntax:</p>
<div class="exampleInner">
<pre>


  
&lt;!-- The base class --&gt;
  &lt;xsd:complexType name="expr"/&gt;
  &lt;xsd:element name="expr" type="expr" abstract="true"/&gt;
  
  &lt;!-- Simple wrapper class --&gt;
  &lt;xsd:complexType name="exprWrapper"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="expr"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  
  &lt;xsd:complexType name="flworExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:choice maxOccurs="unbounded"&gt;
            &lt;xsd:element ref="forClause"/&gt;
            &lt;xsd:element ref="letClause"/&gt;
          &lt;/xsd:choice&gt;
          &lt;xsd:element name="whereClause" minOccurs="0"/&gt;
          &lt;xsd:element name="orderByClause" minOccurs="0"/&gt;
          &lt;xsd:element name="returnClause"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="flworExpr" type="flworExpr" substitutionGroup="expr"/&gt;

  &lt;xsd:element name="forClause"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element ref="forClauseItem" maxOccurs="unbounded"/&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;

  &lt;xsd:element name="forClauseItem"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element ref="typedVariableBinding"/&gt;
        &lt;xsd:element ref="positionalVariableBinding" minOccurs="0"/&gt;
        &lt;xsd:element name="forExpr" type="exprWrapper"/&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;

  &lt;xsd:element name="letClause"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element ref="letClauseItem" maxOccurs="unbounded"/&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;

  &lt;xsd:element name="letClauseItem"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element ref="typedVariableBinding"/&gt;
        &lt;xsd:element name="letExpr" type="exprWrapper"/&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;

  &lt;xsd:element name="whereClause" type="exprWrapper"/&gt;

  &lt;xsd:element name="returnClause" type="exprWrapper"/&gt;
</pre></div>
<p>Since XQuery uses the expression production liberally to allow
expressions to be flexibly combined, XQueryX uses the exprWrapper
type in embedded contexts to allow all expression types to
occur.</p>
</div>
<div class="div1">
<h2><a id="Examples" name="Examples"></a>3 Examples from the XML
Query Use Cases in XML Syntax</h2>
<p>Three of following examples are based on the data and queries in
the XMP (Experiences and Exemplars) use case in <a href=
"#xquery-use-cases">[XML Query Use Cases]</a>, while a fourth
example is based on the data and queries in the NS (Queries Using
Namespaces) use case. For each example, we show the English
description of the query, the XQuery solution given in <a href=
"#xquery-use-cases">[XML Query Use Cases]</a>, an XQueryX solution,
and the XQuery that results from applying the XQueryX-to-XQuery
transformation defined by the stylesheet in <a href=
"#Stylesheet"><b>B Transforming XQueryX to XQuery</b></a> to the
XQueryX solution. That produced XQuery is presented only as a
sanity-check — the intent of the stylesheet is not to create the
identical XQuery expression given in <a href=
"#xquery-use-cases">[XML Query Use Cases]</a>, but to produce
<em>a</em> valid XQuery expression with the same semantics. The
semantics of the XQueryX solution are determined by the semantics
of the XQuery expression that results from that transformation. The
"correctness" of that transformation is determined by asking the
following the question: Can some XQueryX processor QX process some
XQueryX document D1 to produce results R1, after which the
stylesheet is used to translate D1 into an XQuery expression E1
that, when processed by some XQuery 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 XQueryX-to-XQuery
transformation given in this document with the XQuery solutions in
the <a href="#xquery-use-cases">[XML Query Use Cases]</a> may be
helpful in evaluating the correctness of the XQueryX solution in
each example.</p>
<p>The XQuery Use Cases solution given for each example is provided
only to assist readers of this document in understanding the
XQueryX solution. There is no intent to imply that this document
specifies a "compilation" or "transformation" of XQuery syntax into
XQueryX syntax.</p>
<p>In the following examples, 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 XQueryX documents and XQuery expressions
for readability. That additional white space is not produced by the
XQueryX-to-XQuery transformation.</p>
<div class="div2">
<h3><a id="Example1" name="Example1"></a>3.1 Example 1</h3>
<p>Here is Q1 from the <a href="#xquery-use-cases">[XML Query Use
Cases]</a>, use case XMP (Experiences and Exemplars): "List books
published by Addison-Wesley after 1991, including their year and
title."</p>
<div class="div3">
<h4><a id="Example1-XQuery" name="Example1-XQuery"></a>3.1.1 XQuery
solution in XQuery Use Cases:</h4>
<div class="exampleInner">
<pre>
&lt;bib&gt;
 {
  for $b in doc("http://bstore1.example.com/bib.xml")/bib/book
  where $b/publisher = "Addison-Wesley" and $b/@year &gt; 1991
  return
    &lt;book year="{ $b/@year }"&gt;
     { $b/title }
    &lt;/book&gt;
 }
&lt;/bib&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example1-XQueryX" name="Example1-XQueryX"></a>3.1.2 A
Solution in XQueryX:</h4>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            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"&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:elementConstructor&gt;
        &lt;xqx:tagName&gt;bib&lt;/xqx:tagName&gt;
        &lt;xqx:elementContent&gt;
          &lt;xqx:flworExpr&gt;
            &lt;xqx:forClause&gt;
              &lt;xqx:forClauseItem&gt;
                &lt;xqx:typedVariableBinding&gt;
                  &lt;xqx:varName&gt;b&lt;/xqx:varName&gt;
                &lt;/xqx:typedVariableBinding&gt;
                &lt;xqx:forExpr&gt;
                  &lt;xqx:pathExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
                        &lt;xqx:functionCallExpr&gt;
                          &lt;xqx:functionName&gt;doc&lt;/xqx:functionName&gt;
                          &lt;xqx:arguments&gt;
                            &lt;xqx:stringConstantExpr&gt;
                              &lt;xqx:value&gt;http://bstore1.example.com/bib.xml&lt;/xqx:value&gt;
                            &lt;/xqx:stringConstantExpr&gt;
                          &lt;/xqx:arguments&gt;
                        &lt;/xqx:functionCallExpr&gt;
                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:nameTest&gt;bib&lt;/xqx:nameTest&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:nameTest&gt;book&lt;/xqx:nameTest&gt;
                    &lt;/xqx:stepExpr&gt;
                  &lt;/xqx:pathExpr&gt;
                &lt;/xqx:forExpr&gt;
              &lt;/xqx:forClauseItem&gt;
            &lt;/xqx:forClause&gt;
            &lt;xqx:whereClause&gt;
              &lt;xqx:andOp&gt;
                &lt;xqx:firstOperand&gt;
                  &lt;xqx:equalOp&gt;
                    &lt;xqx:firstOperand&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;publisher&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:firstOperand&gt;
                    &lt;xqx:secondOperand&gt;
                      &lt;xqx:stringConstantExpr&gt;
                        &lt;xqx:value&gt;Addison-Wesley&lt;/xqx:value&gt;
                      &lt;/xqx:stringConstantExpr&gt;
                    &lt;/xqx:secondOperand&gt;
                  &lt;/xqx:equalOp&gt;
                &lt;/xqx:firstOperand&gt;
                &lt;xqx:secondOperand&gt;
                  &lt;xqx:greaterThanOp&gt;
                    &lt;xqx:firstOperand&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;attribute&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;year&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:firstOperand&gt;
                    &lt;xqx:secondOperand&gt;
                      &lt;xqx:integerConstantExpr&gt;
                        &lt;xqx:value&gt;1991&lt;/xqx:value&gt;
                      &lt;/xqx:integerConstantExpr&gt;
                    &lt;/xqx:secondOperand&gt;
                  &lt;/xqx:greaterThanOp&gt;
                &lt;/xqx:secondOperand&gt;
              &lt;/xqx:andOp&gt;
            &lt;/xqx:whereClause&gt;
            &lt;xqx:returnClause&gt;
              &lt;xqx:elementConstructor&gt;
                &lt;xqx:tagName&gt;book&lt;/xqx:tagName&gt;
                &lt;xqx:attributeList&gt;
                  &lt;xqx:attributeConstructor&gt;
                    &lt;xqx:attributeName&gt;year&lt;/xqx:attributeName&gt;
                    &lt;xqx:attributeValueExpr&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;attribute&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;year&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:attributeValueExpr&gt;
                  &lt;/xqx:attributeConstructor&gt;
                &lt;/xqx:attributeList&gt;
                &lt;xqx:elementContent&gt;
                  &lt;xqx:pathExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
                        &lt;xqx:varRef&gt;
                          &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                        &lt;/xqx:varRef&gt;
                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:nameTest&gt;title&lt;/xqx:nameTest&gt;
                    &lt;/xqx:stepExpr&gt;
                  &lt;/xqx:pathExpr&gt;
                &lt;/xqx:elementContent&gt;
              &lt;/xqx:elementConstructor&gt;
            &lt;/xqx:returnClause&gt;
          &lt;/xqx:flworExpr&gt;
        &lt;/xqx:elementContent&gt;
      &lt;/xqx:elementConstructor&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example1-Transformation" name=
"Example1-Transformation"></a>3.1.3 Transformation of XQueryX
Solution into XQuery</h4>
<p>Application of the stylesheet in <a href="#Stylesheet"><b>B
Transforming XQueryX to XQuery</b></a> to the XQueryX solution
results in:</p>
<div class="exampleInner">
<pre>
  
&lt;bib&gt;{
 for $b in doc("http://bstore1.example.com/bib.xml")/child::bib/child::book
 where (($b/child::publisher = "Addison-Wesley") and ($b/attribute::year &gt; 1991))
 return &lt;book year="{$b/attribute::year}"&gt;{$b/child::title}&lt;/book&gt;
}&lt;/bib&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example1-Abstract" name="Example1-Abstract"></a>3.1.4
Corresponding Grammar Abstract Parse Tree</h4>
<p>For comparison, here is the abstract parse tree corresponding to
the XQuery for Example 1, as produced by the XQuery grammar applets
found at <a href=
"http://www.w3.org/2007/01/applets/">http://www.w3.org/2007/01/applets/</a>.</p>
<div class="exampleInner">
<pre>
XPath2
  QueryList
    Module
      MainModule
        Prolog
        QueryBody
          Expr
            PathExpr
              Constructor
                DirectConstructor
                  DirElemConstructor &gt;
                    LessThanOpOrTagO &lt;
                    TagQName bib
                    DirAttributeList
                    StartTagClose &gt;
                    DirElemContent
                      ElementContentChar 
                    DirElemContent
                      ElementContentChar  
                    DirElemContent
                      CommonContent
                        EnclosedExpr
                          Lbrace {
                          Expr
                            FLWORExpr
                              ForClause
                                VarName
                                  QName b
                                PathExpr
                                  FunctionCall
                                    FunctionQName doc
                                    PathExpr
                                      StringLiteral "http://bstore1.example.com/bib.xml"
                                  StepExpr
                                    AbbrevForwardStep
                                      NodeTest
                                        NameTest
                                          QName bib
                                  StepExpr
                                    AbbrevForwardStep
                                      NodeTest
                                        NameTest
                                          QName book
                              WhereClause
                                AndExpr and
                                  ComparisonExpr =
                                    PathExpr
                                      VarName
                                        QName b
                                      StepExpr
                                        AbbrevForwardStep
                                          NodeTest
                                            NameTest
                                              QName publisher
                                    PathExpr
                                      StringLiteral "Addison-Wesley"
                                  ComparisonExpr &gt;
                                    PathExpr
                                      VarName
                                        QName b
                                      StepExpr
                                        AbbrevForwardStep @
                                          NodeTest
                                            NameTest
                                              QName year
                                    PathExpr
                                      IntegerLiteral 1991
                              PathExpr
                                Constructor
                                  DirectConstructor
                                    DirElemConstructor &gt;
                                      LessThanOpOrTagO &lt;
                                      TagQName book
                                      DirAttributeList
                                        S  
                                        TagQName year
                                        ValueIndicator =
                                        DirAttributeValue
                                          OpenQuot "
                                          QuotAttrValueContent
                                            CommonContent
                                              EnclosedExpr
                                                Lbrace {
                                                Expr
                                                  PathExpr
                                                    VarName
                                                      QName b
                                                    StepExpr
                                                      AbbrevForwardStep @
                                                        NodeTest
                                                          NameTest
                                                            QName year
                                                Rbrace }
                                          CloseQuot "
                                      StartTagClose &gt;
                                      DirElemContent
                                        ElementContentChar 
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        CommonContent
                                          EnclosedExpr
                                            Lbrace {
                                            Expr
                                              PathExpr
                                                VarName
                                                  QName b
                                                StepExpr
                                                  AbbrevForwardStep
                                                    NodeTest
                                                      NameTest
                                                        QName title
                                            Rbrace }
                                      DirElemContent
                                        ElementContentChar 
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent
                                        ElementContentChar  
                                      DirElemContent &lt;/
                                        ElementContentChar  
                          Rbrace }
                    DirElemContent &lt;/
                      ElementContentChar 
</pre></div>
</div>
</div>
<div class="div2">
<h3><a id="Example2" name="Example2"></a>3.2 Example 2</h3>
<p>Here is Q4 from the <a href="#xquery-use-cases">[XML Query Use
Cases]</a>, use case XMP (Experiences and Exemplars): "For each
author in the bibliography, list the author's name and the titles
of all books by that author, grouped inside a "result"
element."</p>
<div class="div3">
<h4><a id="Example2-XQuery" name="Example2-XQuery"></a>3.2.1 XQuery
solution in XQuery Use Cases:</h4>
<div class="exampleInner">
<pre>
&lt;results&gt;
  {
    let $a := doc("http://bstore1.example.com/bib/bib.xml")//author
    for $last in distinct-values($a/last),
        $first in distinct-values($a[last=$last]/first)
    order by $last, $first
    return
        &lt;result&gt;
            &lt;author&gt;
               &lt;last&gt;{ $last }&lt;/last&gt;
               &lt;first&gt;{ $first }&lt;/first&gt;
            &lt;/author&gt;
            {
                for $b in doc("http://bstore1.example.com/bib.xml")/bib/book
                where some $ba in $b/author 
                      satisfies ($ba/last = $last and $ba/first=$first)
                return $b/title
            }
        &lt;/result&gt;
  }
&lt;/results&gt; 
</pre></div>
</div>
<div class="div3">
<h4><a id="Example2-XQueryX" name="Example2-XQueryX"></a>3.2.2 A
solution in XQueryX:</h4>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            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"&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:elementConstructor&gt;
        &lt;xqx:tagName&gt;results&lt;/xqx:tagName&gt;
        &lt;xqx:elementContent&gt;
          &lt;xqx:flworExpr&gt;
            &lt;xqx:letClause&gt;
              &lt;xqx:letClauseItem&gt;
                &lt;xqx:typedVariableBinding&gt;
                  &lt;xqx:varName&gt;a&lt;/xqx:varName&gt;
                &lt;/xqx:typedVariableBinding&gt;
                &lt;xqx:letExpr&gt;
                 &lt;xqx:pathExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:filterExpr&gt;
                       &lt;xqx:functionCallExpr&gt;
                         &lt;xqx:functionName&gt;doc&lt;/xqx:functionName&gt;
                         &lt;xqx:arguments&gt;
                           &lt;xqx:stringConstantExpr&gt;
                             &lt;xqx:value&gt;http://bstore1.example.com/bib.xml&lt;/xqx:value&gt;
                           &lt;/xqx:stringConstantExpr&gt;
                         &lt;/xqx:arguments&gt;
                       &lt;/xqx:functionCallExpr&gt;
                     &lt;/xqx:filterExpr&gt;
                   &lt;/xqx:stepExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:xpathAxis&gt;descendant-or-self&lt;/xqx:xpathAxis&gt;
                     &lt;xqx:anyKindTest/&gt;
                   &lt;/xqx:stepExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                     &lt;xqx:nameTest&gt;author&lt;/xqx:nameTest&gt;
                   &lt;/xqx:stepExpr&gt;
                 &lt;/xqx:pathExpr&gt;
                &lt;/xqx:letExpr&gt;
              &lt;/xqx:letClauseItem&gt;
            &lt;/xqx:letClause&gt;
            &lt;xqx:forClause&gt;
              &lt;xqx:forClauseItem&gt;
                &lt;xqx:typedVariableBinding&gt;
                  &lt;xqx:varName&gt;last&lt;/xqx:varName&gt;
                &lt;/xqx:typedVariableBinding&gt;
                &lt;xqx:forExpr&gt;
                  &lt;xqx:functionCallExpr&gt;
                    &lt;xqx:functionName&gt;distinct-values&lt;/xqx:functionName&gt;
                    &lt;xqx:arguments&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;a&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;last&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:arguments&gt;
                  &lt;/xqx:functionCallExpr&gt;
                &lt;/xqx:forExpr&gt;
              &lt;/xqx:forClauseItem&gt;
              &lt;xqx:forClauseItem&gt;
                &lt;xqx:typedVariableBinding&gt;
                  &lt;xqx:varName&gt;first&lt;/xqx:varName&gt;
                &lt;/xqx:typedVariableBinding&gt;
                &lt;xqx:forExpr&gt;
                  &lt;xqx:functionCallExpr&gt;
                    &lt;xqx:functionName&gt;distinct-values&lt;/xqx:functionName&gt;
                    &lt;xqx:arguments&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;a&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                          &lt;xqx:predicates&gt;
                            &lt;xqx:equalOp&gt;
                              &lt;xqx:firstOperand&gt;
                                &lt;xqx:pathExpr&gt;
                                  &lt;xqx:stepExpr&gt;
                                    &lt;xqx:filterExpr&gt;
                                      &lt;xqx:contextItemExpr/&gt;
                                    &lt;/xqx:filterExpr&gt;
                                  &lt;/xqx:stepExpr&gt;
                                  &lt;xqx:stepExpr&gt;
                                    &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                    &lt;xqx:nameTest&gt;last&lt;/xqx:nameTest&gt;
                                  &lt;/xqx:stepExpr&gt;
                                &lt;/xqx:pathExpr&gt;
                              &lt;/xqx:firstOperand&gt;
                              &lt;xqx:secondOperand&gt;
                                &lt;xqx:varRef&gt;
                                  &lt;xqx:name&gt;last&lt;/xqx:name&gt;
                                &lt;/xqx:varRef&gt;
                              &lt;/xqx:secondOperand&gt;
                            &lt;/xqx:equalOp&gt;
                          &lt;/xqx:predicates&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;first&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:arguments&gt;
                  &lt;/xqx:functionCallExpr&gt;
                &lt;/xqx:forExpr&gt;
              &lt;/xqx:forClauseItem&gt;
            &lt;/xqx:forClause&gt;
            &lt;xqx:orderByClause&gt;
              &lt;xqx:orderBySpec&gt;
                &lt;xqx:orderByExpr&gt;
                  &lt;xqx:varRef&gt;
                    &lt;xqx:name&gt;last&lt;/xqx:name&gt;
                  &lt;/xqx:varRef&gt;
                &lt;/xqx:orderByExpr&gt;
              &lt;/xqx:orderBySpec&gt;
              &lt;xqx:orderBySpec&gt;
                &lt;xqx:orderByExpr&gt;
                  &lt;xqx:varRef&gt;
                    &lt;xqx:name&gt;first&lt;/xqx:name&gt;
                  &lt;/xqx:varRef&gt;
                &lt;/xqx:orderByExpr&gt;
              &lt;/xqx:orderBySpec&gt;
            &lt;/xqx:orderByClause&gt;
            &lt;xqx:returnClause&gt;
              &lt;xqx:elementConstructor&gt;
                &lt;xqx:tagName&gt;result&lt;/xqx:tagName&gt;
                &lt;xqx:elementContent&gt;
                  &lt;xqx:elementConstructor&gt;
                    &lt;xqx:tagName&gt;author&lt;/xqx:tagName&gt;
                    &lt;xqx:elementContent&gt;
                      &lt;xqx:elementConstructor&gt;
                        &lt;xqx:tagName&gt;last&lt;/xqx:tagName&gt;
                        &lt;xqx:elementContent&gt;
                          &lt;xqx:varRef&gt;
                            &lt;xqx:name&gt;last&lt;/xqx:name&gt;
                          &lt;/xqx:varRef&gt;
                        &lt;/xqx:elementContent&gt;
                      &lt;/xqx:elementConstructor&gt;
                      &lt;xqx:elementConstructor&gt;
                        &lt;xqx:tagName&gt;first&lt;/xqx:tagName&gt;
                        &lt;xqx:elementContent&gt;
                          &lt;xqx:varRef&gt;
                            &lt;xqx:name&gt;first&lt;/xqx:name&gt;
                          &lt;/xqx:varRef&gt;
                        &lt;/xqx:elementContent&gt;
                      &lt;/xqx:elementConstructor&gt;
                    &lt;/xqx:elementContent&gt;
                  &lt;/xqx:elementConstructor&gt;
                    &lt;xqx:flworExpr&gt;
                      &lt;xqx:forClause&gt;
                        &lt;xqx:forClauseItem&gt;
                          &lt;xqx:typedVariableBinding&gt;
                            &lt;xqx:varName&gt;b&lt;/xqx:varName&gt;
                          &lt;/xqx:typedVariableBinding&gt;
                          &lt;xqx:forExpr&gt;
                            &lt;xqx:pathExpr&gt;
                              &lt;xqx:stepExpr&gt;
                                &lt;xqx:filterExpr&gt;
                                  &lt;xqx:functionCallExpr&gt;
                                    &lt;xqx:functionName&gt;doc&lt;/xqx:functionName&gt;
                                    &lt;xqx:arguments&gt;
                                      &lt;xqx:stringConstantExpr&gt;
                                        &lt;xqx:value&gt;http://bstore1.example.com/bib.xml&lt;/xqx:value&gt;
                                      &lt;/xqx:stringConstantExpr&gt;
                                    &lt;/xqx:arguments&gt;
                                  &lt;/xqx:functionCallExpr&gt;
                                &lt;/xqx:filterExpr&gt;
                              &lt;/xqx:stepExpr&gt;
                              &lt;xqx:stepExpr&gt;
                                &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                &lt;xqx:nameTest&gt;bib&lt;/xqx:nameTest&gt;
                              &lt;/xqx:stepExpr&gt;
                              &lt;xqx:stepExpr&gt;
                                &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                &lt;xqx:nameTest&gt;book&lt;/xqx:nameTest&gt;
                              &lt;/xqx:stepExpr&gt;
                            &lt;/xqx:pathExpr&gt;
                          &lt;/xqx:forExpr&gt;
                        &lt;/xqx:forClauseItem&gt;
                      &lt;/xqx:forClause&gt;
                      &lt;xqx:whereClause&gt;
                        &lt;xqx:quantifiedExpr&gt;
                          &lt;xqx:quantifier&gt;some&lt;/xqx:quantifier&gt;
                          &lt;xqx:quantifiedExprInClause&gt;
                            &lt;xqx:typedVariableBinding&gt;
                              &lt;xqx:varName&gt;ba&lt;/xqx:varName&gt;
                            &lt;/xqx:typedVariableBinding&gt;
                            &lt;xqx:sourceExpr&gt;
                              &lt;xqx:pathExpr&gt;
                                &lt;xqx:stepExpr&gt;
                                  &lt;xqx:filterExpr&gt;
                                    &lt;xqx:varRef&gt;
                                      &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                                    &lt;/xqx:varRef&gt;
                                  &lt;/xqx:filterExpr&gt;
                                &lt;/xqx:stepExpr&gt;
                                &lt;xqx:stepExpr&gt;
                                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                  &lt;xqx:nameTest&gt;author&lt;/xqx:nameTest&gt;
                                &lt;/xqx:stepExpr&gt;
                              &lt;/xqx:pathExpr&gt;
                            &lt;/xqx:sourceExpr&gt;
                          &lt;/xqx:quantifiedExprInClause&gt;
                          &lt;xqx:predicateExpr&gt;
                            &lt;xqx:andOp&gt;
                              &lt;xqx:firstOperand&gt;
                                &lt;xqx:equalOp&gt;
                                  &lt;xqx:firstOperand&gt;
                                    &lt;xqx:pathExpr&gt;
                                      &lt;xqx:stepExpr&gt;
                                        &lt;xqx:filterExpr&gt;
                                          &lt;xqx:varRef&gt;
                                            &lt;xqx:name&gt;ba&lt;/xqx:name&gt;
                                          &lt;/xqx:varRef&gt;
                                        &lt;/xqx:filterExpr&gt;
                                      &lt;/xqx:stepExpr&gt;
                                      &lt;xqx:stepExpr&gt;
                                        &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                        &lt;xqx:nameTest&gt;last&lt;/xqx:nameTest&gt;
                                      &lt;/xqx:stepExpr&gt;
                                    &lt;/xqx:pathExpr&gt;
                                  &lt;/xqx:firstOperand&gt;
                                  &lt;xqx:secondOperand&gt;
                                    &lt;xqx:varRef&gt;
                                      &lt;xqx:name&gt;last&lt;/xqx:name&gt;
                                    &lt;/xqx:varRef&gt;
                                  &lt;/xqx:secondOperand&gt;
                                &lt;/xqx:equalOp&gt;
                              &lt;/xqx:firstOperand&gt;
                              &lt;xqx:secondOperand&gt;
                                &lt;xqx:equalOp&gt;
                                  &lt;xqx:firstOperand&gt;
                                    &lt;xqx:pathExpr&gt;
                                      &lt;xqx:stepExpr&gt;
                                        &lt;xqx:filterExpr&gt;
                                          &lt;xqx:varRef&gt;
                                            &lt;xqx:name&gt;ba&lt;/xqx:name&gt;
                                          &lt;/xqx:varRef&gt;
                                        &lt;/xqx:filterExpr&gt;
                                      &lt;/xqx:stepExpr&gt;
                                      &lt;xqx:stepExpr&gt;
                                        &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                        &lt;xqx:nameTest&gt;first&lt;/xqx:nameTest&gt;
                                      &lt;/xqx:stepExpr&gt;
                                    &lt;/xqx:pathExpr&gt;
                                  &lt;/xqx:firstOperand&gt;
                                  &lt;xqx:secondOperand&gt;
                                    &lt;xqx:varRef&gt;
                                      &lt;xqx:name&gt;first&lt;/xqx:name&gt;
                                    &lt;/xqx:varRef&gt;
                                  &lt;/xqx:secondOperand&gt;
                                &lt;/xqx:equalOp&gt;
                              &lt;/xqx:secondOperand&gt;
                            &lt;/xqx:andOp&gt;
                          &lt;/xqx:predicateExpr&gt;
                        &lt;/xqx:quantifiedExpr&gt;
                      &lt;/xqx:whereClause&gt;
                      &lt;xqx:returnClause&gt;
                        &lt;xqx:pathExpr&gt;
                          &lt;xqx:stepExpr&gt;
                            &lt;xqx:filterExpr&gt;
                              &lt;xqx:varRef&gt;
                                &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                              &lt;/xqx:varRef&gt;
                            &lt;/xqx:filterExpr&gt;
                          &lt;/xqx:stepExpr&gt;
                          &lt;xqx:stepExpr&gt;
                            &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                            &lt;xqx:nameTest&gt;title&lt;/xqx:nameTest&gt;
                          &lt;/xqx:stepExpr&gt;
                        &lt;/xqx:pathExpr&gt;
                      &lt;/xqx:returnClause&gt;
                    &lt;/xqx:flworExpr&gt;
                &lt;/xqx:elementContent&gt;
              &lt;/xqx:elementConstructor&gt;
            &lt;/xqx:returnClause&gt;
          &lt;/xqx:flworExpr&gt;
        &lt;/xqx:elementContent&gt;
      &lt;/xqx:elementConstructor&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example2-Transformation" name=
"Example2-Transformation"></a>3.2.3 Transformation of XQueryX
Solution into XQuery</h4>
<p>Application of the stylesheet in <a href="#Stylesheet"><b>B
Transforming XQueryX to XQuery</b></a> to the XQueryX solution
results in:</p>
<div class="exampleInner">
<pre>
  
&lt;results&gt;{
 let $a:=doc("http://bstore1.example.com/bib.xml")/descendant-or-self::node()/child::author
 for $last in distinct-values($a/child::last), $first in distinct-values($a[(./child::last = $last)]/child::first)
 order by $last , $first 
 return &lt;result&gt;&lt;author&gt;&lt;last&gt;{$last}&lt;/last&gt;&lt;first&gt;{$first}&lt;/first&gt;&lt;/author&gt;{
 for $b in doc("http://bstore1.example.com/bib.xml")/child::bib/child::book
 where (some $ba in $b/child::author satisfies (($ba/child::last = $last) and ($ba/child::first = $first)))
 return $b/child::title
}&lt;/result&gt;
}&lt;/results&gt;
</pre></div>
</div>
</div>
<div class="div2">
<h3><a id="Example3" name="Example3"></a>3.3 Example 3</h3>
<p>Here is Q7 from the <a href="#xquery-use-cases">[XML Query Use
Cases]</a>, use case XMP (Experiences and Exemplars): "List the
titles and years of all books published by Addison-Wesley after
1991, in alphabetic order."</p>
<div class="div3">
<h4><a id="Example3-XQuery" name="Example3-XQuery"></a>3.3.1 XQuery
solution in XQuery Use Cases:</h4>
<div class="exampleInner">
<pre>
&lt;bib&gt;
  {
    for $b in doc("http://bstore1.example.com/bib.xml")//book
    where $b/publisher = "Addison-Wesley" and $b/@year &gt; 1991
    order by $b/title
    return
        &lt;book&gt;
            { $b/@year }
            { $b/title }
        &lt;/book&gt;
  }
&lt;/bib&gt; 
</pre></div>
</div>
<div class="div3">
<h4><a id="Example3-XQueryX" name="Example3-XQueryX"></a>3.3.2 A
solution in XQueryX:</h4>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            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"&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:elementConstructor&gt;
        &lt;xqx:tagName&gt;bib&lt;/xqx:tagName&gt;
        &lt;xqx:elementContent&gt;
          &lt;xqx:flworExpr&gt;
            &lt;xqx:forClause&gt;
              &lt;xqx:forClauseItem&gt;
                &lt;xqx:typedVariableBinding&gt;
                  &lt;xqx:varName&gt;b&lt;/xqx:varName&gt;
                &lt;/xqx:typedVariableBinding&gt;
                &lt;xqx:forExpr&gt;
                  &lt;xqx:pathExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
                        &lt;xqx:functionCallExpr&gt;
                          &lt;xqx:functionName&gt;doc&lt;/xqx:functionName&gt;
                          &lt;xqx:arguments&gt;
                            &lt;xqx:stringConstantExpr&gt;
                              &lt;xqx:value&gt;http://bstore1.example.com/bib.xml&lt;/xqx:value&gt;
                            &lt;/xqx:stringConstantExpr&gt;
                          &lt;/xqx:arguments&gt;
                        &lt;/xqx:functionCallExpr&gt;
                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;descendant-or-self&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:anyKindTest/&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:nameTest&gt;book&lt;/xqx:nameTest&gt;
                    &lt;/xqx:stepExpr&gt;
                  &lt;/xqx:pathExpr&gt;
                &lt;/xqx:forExpr&gt;
              &lt;/xqx:forClauseItem&gt;
            &lt;/xqx:forClause&gt;
            &lt;xqx:whereClause&gt;
              &lt;xqx:andOp&gt;
                &lt;xqx:firstOperand&gt;
                  &lt;xqx:equalOp&gt;
                    &lt;xqx:firstOperand&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;publisher&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:firstOperand&gt;
                    &lt;xqx:secondOperand&gt;
                      &lt;xqx:stringConstantExpr&gt;
                        &lt;xqx:value&gt;Addison-Wesley&lt;/xqx:value&gt;
                      &lt;/xqx:stringConstantExpr&gt;
                    &lt;/xqx:secondOperand&gt;
                  &lt;/xqx:equalOp&gt;
                &lt;/xqx:firstOperand&gt;
                &lt;xqx:secondOperand&gt;
                  &lt;xqx:greaterThanOp&gt;
                    &lt;xqx:firstOperand&gt;
                      &lt;xqx:pathExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:filterExpr&gt;
                            &lt;xqx:varRef&gt;
                              &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                            &lt;/xqx:varRef&gt;
                          &lt;/xqx:filterExpr&gt;
                        &lt;/xqx:stepExpr&gt;
                        &lt;xqx:stepExpr&gt;
                          &lt;xqx:xpathAxis&gt;attribute&lt;/xqx:xpathAxis&gt;
                          &lt;xqx:nameTest&gt;year&lt;/xqx:nameTest&gt;
                        &lt;/xqx:stepExpr&gt;
                      &lt;/xqx:pathExpr&gt;
                    &lt;/xqx:firstOperand&gt;
                    &lt;xqx:secondOperand&gt;
                      &lt;xqx:integerConstantExpr&gt;
                        &lt;xqx:value&gt;1991&lt;/xqx:value&gt;
                      &lt;/xqx:integerConstantExpr&gt;
                    &lt;/xqx:secondOperand&gt;
                  &lt;/xqx:greaterThanOp&gt;
                &lt;/xqx:secondOperand&gt;
              &lt;/xqx:andOp&gt;
            &lt;/xqx:whereClause&gt;
            &lt;xqx:orderByClause&gt;
              &lt;xqx:orderBySpec&gt;
                &lt;xqx:orderByExpr&gt;
                  &lt;xqx:pathExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
                        &lt;xqx:varRef&gt;
                          &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                        &lt;/xqx:varRef&gt;
                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:nameTest&gt;title&lt;/xqx:nameTest&gt;
                    &lt;/xqx:stepExpr&gt;
                  &lt;/xqx:pathExpr&gt;
                &lt;/xqx:orderByExpr&gt;
              &lt;/xqx:orderBySpec&gt;
            &lt;/xqx:orderByClause&gt;
            &lt;xqx:returnClause&gt;
             &lt;xqx:elementConstructor&gt;
               &lt;xqx:tagName&gt;book&lt;/xqx:tagName&gt;
               &lt;xqx:elementContent&gt;
                 &lt;xqx:pathExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:filterExpr&gt;
                       &lt;xqx:varRef&gt;
                         &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                       &lt;/xqx:varRef&gt;
                     &lt;/xqx:filterExpr&gt;
                   &lt;/xqx:stepExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:xpathAxis&gt;attribute&lt;/xqx:xpathAxis&gt;
                     &lt;xqx:nameTest&gt;year&lt;/xqx:nameTest&gt;
                   &lt;/xqx:stepExpr&gt;
                 &lt;/xqx:pathExpr&gt;
                 &lt;xqx:pathExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:filterExpr&gt;
                       &lt;xqx:varRef&gt;
                         &lt;xqx:name&gt;b&lt;/xqx:name&gt;
                       &lt;/xqx:varRef&gt;
                     &lt;/xqx:filterExpr&gt;
                   &lt;/xqx:stepExpr&gt;
                   &lt;xqx:stepExpr&gt;
                     &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                     &lt;xqx:nameTest&gt;title&lt;/xqx:nameTest&gt;
                   &lt;/xqx:stepExpr&gt;
                 &lt;/xqx:pathExpr&gt;
               &lt;/xqx:elementContent&gt;
             &lt;/xqx:elementConstructor&gt;
            &lt;/xqx:returnClause&gt;
          &lt;/xqx:flworExpr&gt;
        &lt;/xqx:elementContent&gt;
      &lt;/xqx:elementConstructor&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example3-Transformation" name=
"Example3-Transformation"></a>3.3.3 Transformation of XQueryX
Solution into XQuery</h4>
<p>Application of the stylesheet in <a href="#Stylesheet"><b>B
Transforming XQueryX to XQuery</b></a> to the XQueryX solution
results in:</p>
<div class="exampleInner">
<pre>
  
&lt;bib&gt;{
 for $b in doc("http://bstore1.example.com/bib.xml")/descendant-or-self::node()/child::book
 where (($b/child::publisher = "Addison-Wesley") and ($b/attribute::year &gt; 1991))
 order by $b/child::title 
 return &lt;book&gt;{$b/attribute::year}{$b/child::title}&lt;/book&gt;
}&lt;/bib&gt;
</pre></div>
</div>
</div>
<div class="div2">
<h3><a id="Example4" name="Example4"></a>3.4 Example 4</h3>
<p>Here is Q8 from the <a href="#xquery-use-cases">[XML Query Use
Cases]</a>, use case NS (Queries Using Namespaces): "Select all
traders (either seller or high bidder) without negative
comments."</p>
<div class="div3">
<h4><a id="Example4-XQuery" name="Example4-XQuery"></a>3.4.1 XQuery
solution in XQuery Use Cases:</h4>
<div class="exampleInner">
<pre>
declare namespace ma = "http://www.example.com/AuctionWatch";
&lt;Q8 xmlns:ma="http://www.example.com/AuctionWatch"
    xmlns:eachbay="http://www.example.com/auctioneers#eachbay" 
    xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
  {
    for $s in doc("auction.xml")//ma:Trading_Partners/(ma:Seller | ma:High_Bidder)
    where $s/*:NegativeComments = 0
    return $s
  }
&lt;/Q8&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example4-XQueryX" name="Example4-XQueryX"></a>3.4.2 A
solution in XQueryX:</h4>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;!--  ================================================================================  --&gt;
&lt;!--  Errata applied:                                                                   --&gt;
&lt;!--    XQX.E2 - Editorial (Bugzilla Bug 4963)                                          --&gt;
&lt;!--  ================================================================================  --&gt;
&lt;xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            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"&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:prolog&gt;
      &lt;xqx:namespaceDecl&gt;
        &lt;xqx:prefix&gt;ma&lt;/xqx:prefix&gt;
        &lt;xqx:uri&gt;http://www.example.com/AuctionWatch&lt;/xqx:uri&gt;
      &lt;/xqx:namespaceDecl&gt;
    &lt;/xqx:prolog&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:elementConstructor&gt;
        &lt;xqx:tagName&gt;Q8&lt;/xqx:tagName&gt;
        &lt;xqx:attributeList&gt;
          &lt;xqx:namespaceDeclaration&gt;
            &lt;xqx:prefix&gt;ma&lt;/xqx:prefix&gt;
            &lt;xqx:uri&gt;http://www.example.com/AuctionWatch&lt;/xqx:uri&gt;
          &lt;/xqx:namespaceDeclaration&gt;
          &lt;xqx:namespaceDeclaration&gt;
            &lt;xqx:prefix&gt;eachbay&lt;/xqx:prefix&gt;
            &lt;xqx:uri&gt;http://www.example.com/auctioneers#eachbay&lt;/xqx:uri&gt;
          &lt;/xqx:namespaceDeclaration&gt;
          &lt;xqx:namespaceDeclaration&gt;
            &lt;xqx:prefix&gt;xlink&lt;/xqx:prefix&gt;
            &lt;xqx:uri&gt;http://www.w3.org/1999/xlink&lt;/xqx:uri&gt;
          &lt;/xqx:namespaceDeclaration&gt;
        &lt;/xqx:attributeList&gt;
        &lt;xqx:elementContent&gt;
          &lt;xqx:flworExpr&gt;
            &lt;xqx:forClause&gt;
              &lt;xqx:forClauseItem&gt;
                &lt;xqx:typedVariableBinding&gt;
                  &lt;xqx:varName&gt;s&lt;/xqx:varName&gt;
                &lt;/xqx:typedVariableBinding&gt;
                &lt;xqx:forExpr&gt;
                  &lt;xqx:pathExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
                        &lt;xqx:functionCallExpr&gt;
                          &lt;xqx:functionName xqx:prefix="fn"&gt;doc&lt;/xqx:functionName&gt;
                          &lt;xqx:arguments&gt;
                            &lt;xqx:stringConstantExpr&gt;
                              &lt;xqx:value&gt;auction.xml&lt;/xqx:value&gt;
                            &lt;/xqx:stringConstantExpr&gt;
                          &lt;/xqx:arguments&gt;
                        &lt;/xqx:functionCallExpr&gt;
                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;descendant-or-self&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:anyKindTest/&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:nameTest xqx:prefix="ma"&gt;Trading_Partners&lt;/xqx:nameTest&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
<span>                        &lt;xqx:sequenceExpr&gt;
                          &lt;xqx:unionOp&gt;
                            &lt;xqx:firstOperand&gt;
                              &lt;xqx:pathExpr&gt;
                                &lt;xqx:stepExpr&gt;
                                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                  &lt;xqx:nameTest xqx:prefix="ma"&gt;Seller&lt;/xqx:nameTest&gt;
                                &lt;/xqx:stepExpr&gt;
                              &lt;/xqx:pathExpr&gt;
                            &lt;/xqx:firstOperand&gt;
                            &lt;xqx:secondOperand&gt;
                              &lt;xqx:pathExpr&gt;
                                &lt;xqx:stepExpr&gt;
                                  &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                                  &lt;xqx:nameTest xqx:prefix="ma"&gt;High_Bidder&lt;/xqx:nameTest&gt;
                                &lt;/xqx:stepExpr&gt;
                              &lt;/xqx:pathExpr&gt;
                            &lt;/xqx:secondOperand&gt;
                          &lt;/xqx:unionOp&gt;
                        &lt;/xqx:sequenceExpr&gt;
</span>                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                  &lt;/xqx:pathExpr&gt;
                &lt;/xqx:forExpr&gt;
              &lt;/xqx:forClauseItem&gt;
            &lt;/xqx:forClause&gt;
            &lt;xqx:whereClause&gt;
              &lt;xqx:equalOp&gt;
                &lt;xqx:firstOperand&gt;
                  &lt;xqx:pathExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:filterExpr&gt;
                        &lt;xqx:varRef&gt;
                          &lt;xqx:name&gt;s&lt;/xqx:name&gt;
                        &lt;/xqx:varRef&gt;
                      &lt;/xqx:filterExpr&gt;
                    &lt;/xqx:stepExpr&gt;
                    &lt;xqx:stepExpr&gt;
                      &lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
                      &lt;xqx:Wildcard&gt;
                        &lt;xqx:star/&gt;
                        &lt;xqx:NCName&gt;NegativeComments&lt;/xqx:NCName&gt;
                      &lt;/xqx:Wildcard&gt;
                    &lt;/xqx:stepExpr&gt;
                  &lt;/xqx:pathExpr&gt;
                &lt;/xqx:firstOperand&gt;
                &lt;xqx:secondOperand&gt;
                  &lt;xqx:integerConstantExpr&gt;
                    &lt;xqx:value&gt;0&lt;/xqx:value&gt;
                  &lt;/xqx:integerConstantExpr&gt;
                &lt;/xqx:secondOperand&gt;
              &lt;/xqx:equalOp&gt;
            &lt;/xqx:whereClause&gt;
            &lt;xqx:returnClause&gt;
              &lt;xqx:varRef&gt;
                &lt;xqx:name&gt;s&lt;/xqx:name&gt;
              &lt;/xqx:varRef&gt;
            &lt;/xqx:returnClause&gt;
          &lt;/xqx:flworExpr&gt;
        &lt;/xqx:elementContent&gt;
      &lt;/xqx:elementConstructor&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;
</pre></div>
</div>
<div class="div3">
<h4><a id="Example4-Transformation" name=
"Example4-Transformation"></a>3.4.3 Transformation of XQueryX
Solution into XQuery</h4>
<p>Application of the stylesheet in <a href="#Stylesheet"><b>B
Transforming XQueryX to XQuery</b></a> to the XQueryX solution
results in:</p>
<div class="exampleInner">
<pre>
  
declare namespace ma="http://www.example.com/AuctionWatch";
&lt;Q8 xmlns:ma="http://www.example.com/AuctionWatch"
    xmlns:eachbay="http://www.example.com/auctioneers#eachbay"
    xmlns:xlink="http://www.w3.org/1999/xlink"&gt;{
 for $s in fn:doc("auction.xml")/descendant-or-self::node()/
                                 child::ma:Trading_Partners/
                                 ((child::ma:Seller union child::ma:High_Bidder))
 where ($s/child::*:NegativeComments = 0)
 return $s
}&lt;/Q8&gt;
</pre></div>
</div>
</div>
</div>
<div class="div1">
<h2><a id="Schema" name="Schema"></a>4 An XML Schema for the XQuery
XML Syntax</h2>
<p>Here is the XML Schema against which XQueryX documents must be
valid.</p>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;!--
  Changes from Recommendation (edition 1):
  * Element def'ns using anonymous complex types changed to use named types (bug #4924)
  * In Example 4, replaced xqx:parentheziedExpr with xqx:sequenceExpr (bug #4963)
  * In XSLT stylesheet, deleted template for xqx:parenthesizedExpr (bug #4963)
  * Replaced link to grammar applet with correct link (bug #5323)
  * In XSLT stylesheet, corrected template for xqx:namespaceDeclaration (bug #5343)
--&gt;
&lt;!--  ================================================================================  --&gt;
&lt;!--  NOTES TO READERS OF THIS SCHEMA:                                                  --&gt;
&lt;!--  The default value for both minOccurs and maxOccurs is "1".                        --&gt;
&lt;!--  The XQueryX schema has been designed to provide the ability to extend definitions --&gt;
&lt;!--    of top-level elements in extensions such as Full-Text and the Update Facility.  --&gt;
&lt;!--    The nature of the modification is to define named complex types and redefine    --&gt;
&lt;!--    those top-level elements in terms of the named complex types.                   --&gt;
&lt;!--  ================================================================================  --&gt;
&lt;!--  Errata applied:                                                                   --&gt;
&lt;!--    XQX.E1 - Editorial (Bugzilla Bug 4924)                                          --&gt;
&lt;!--  ================================================================================  --&gt;

&lt;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"&gt;


&lt;!-- A few helper declarations                                                          --&gt;
  &lt;xsd:complexType name="emptyContent"/&gt;

  &lt;xsd:element name="NCName" type="xsd:NCName"/&gt;

  &lt;xsd:complexType name="QName"&gt;
    &lt;xsd:simpleContent&gt;
      &lt;xsd:extension base="xsd:NCName"&gt;
        &lt;xsd:attribute name="prefix" type="xsd:NCName" use="optional"/&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:simpleContent&gt;
  &lt;/xsd:complexType&gt;


&lt;!-- The base expression class                                                          --&gt;
  &lt;xsd:complexType name="expr"/&gt;

  &lt;xsd:element name="expr" type="expr" abstract="true"/&gt;


&lt;!-- A list of expressions                                                              --&gt;
  &lt;xsd:complexType name="exprList"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="expr" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

&lt;!-- A type to be used by elements that comprise an optional expr                       --&gt;
  &lt;xsd:complexType name="exprWrapperOptional"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="expr" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

&lt;!-- Simple wrapper class                                                               --&gt;
  &lt;xsd:complexType name="exprWrapper"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="expr"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

&lt;!-- constant expressions. We have 4 different subclasses for this                      --&gt;
  &lt;xsd:complexType name="constantExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="value" type="xsd:anyType"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="constantExpr" type="constantExpr" abstract="true"
               substitutionGroup="expr"/&gt;


  &lt;xsd:complexType name="integerConstantExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:restriction base="constantExpr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="value" type="xsd:integer"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:restriction&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="integerConstantExpr" type="integerConstantExpr"
               substitutionGroup="constantExpr"/&gt;


  &lt;xsd:complexType name="decimalConstantExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:restriction base="constantExpr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="value" type="xsd:decimal"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:restriction&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="decimalConstantExpr" type="decimalConstantExpr"
               substitutionGroup="constantExpr"/&gt;


  &lt;xsd:complexType name="doubleConstantExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:restriction base="constantExpr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="value" type="xsd:double"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:restriction&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="doubleConstantExpr" type="doubleConstantExpr"
               substitutionGroup="constantExpr"/&gt;


  &lt;xsd:complexType name="stringConstantExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:restriction base="constantExpr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="value" type="xsd:string"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:restriction&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="stringConstantExpr" type="stringConstantExpr"
               substitutionGroup="constantExpr"/&gt;


&lt;!-- Variables                                                                          --&gt;
  &lt;xsd:complexType name="varRef"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="name" type="QName"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="varRef" type="varRef" substitutionGroup="expr"/&gt;


&lt;!-- root and context-item expressions                                                  --&gt;
&lt;!-- rootExpr deleted per Bugzilla Bug #2523                                            --&gt;
  &lt;xsd:complexType name="contextItemExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"/&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="contextItemExpr" type="contextItemExpr"
               substitutionGroup="expr"/&gt;

<span>
&lt;!-- Pragmas and extension expressions                                                  --&gt;
  &lt;xsd:complexType name="pragma"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="pragmaName" type="QName"/&gt;
      &lt;xsd:element name="pragmaContents" type="xsd:string"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="pragma" type="pragma"/&gt;
</span>

  &lt;xsd:complexType name="extensionExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element ref="pragma" maxOccurs="unbounded"/&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="extensionExpr" type="extensionExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- Function call expressions                                                          --&gt;
  &lt;xsd:complexType name="functionCallExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="functionName" type="QName"/&gt;
          &lt;xsd:element name="arguments" type="exprList" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="functionCallExpr" type="functionCallExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- Constructor functions                                                              --&gt;
  &lt;xsd:complexType name="constructorFunctionExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="typeName" type="QName"/&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="constructorFunctionExpr" type="constructorFunctionExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- Sequence expressions                                                               --&gt;
  &lt;xsd:complexType name="sequenceExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element ref="expr" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="sequenceExpr" type="sequenceExpr" substitutionGroup="expr"/&gt;


  &lt;xsd:complexType name="rangeSequenceExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="startExpr" type="exprWrapper"/&gt;
          &lt;xsd:element name="endExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="rangeSequenceExpr" type="rangeSequenceExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- Builtin operator expressions                                                       --&gt;
  &lt;xsd:complexType name="operatorExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"/&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;


  &lt;xsd:complexType name="unaryOperatorExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="operatorExpr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="operand" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;


  &lt;xsd:complexType name="binaryOperatorExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="operatorExpr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="firstOperand" type="exprWrapper"/&gt;
          &lt;xsd:element name="secondOperand" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;


  &lt;xsd:element name="operatorExpr" type="operatorExpr"
               abstract="true" substitutionGroup="expr"/&gt;

  &lt;xsd:element name="arithmeticOp" type="operatorExpr"
               abstract="true" substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="addOp" type="binaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="subtractOp" type="binaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="multiplyOp" type="binaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="divOp" type="binaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="idivOp" type="binaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="modOp" type="binaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="unaryMinusOp" type="unaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="unaryPlusOp" type="unaryOperatorExpr"
               substitutionGroup="arithmeticOp"/&gt;

  &lt;xsd:element name="comparisonOp" type="binaryOperatorExpr" abstract="true"
               substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="valueComparisonOp" type="binaryOperatorExpr" abstract="true"
               substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="eqOp" type="binaryOperatorExpr"
               substitutionGroup="valueComparisonOp"/&gt;

  &lt;xsd:element name="neOp" type="binaryOperatorExpr"
               substitutionGroup="valueComparisonOp"/&gt;

  &lt;xsd:element name="gtOp" type="binaryOperatorExpr"
               substitutionGroup="valueComparisonOp"/&gt;

  &lt;xsd:element name="geOp" type="binaryOperatorExpr"
               substitutionGroup="valueComparisonOp"/&gt;

  &lt;xsd:element name="ltOp" type="binaryOperatorExpr"
               substitutionGroup="valueComparisonOp"/&gt;

  &lt;xsd:element name="leOp" type="binaryOperatorExpr"
               substitutionGroup="valueComparisonOp"/&gt;

  &lt;xsd:element name="generalComparisonOp" type="binaryOperatorExpr" abstract="true"
               substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="equalOp" type="binaryOperatorExpr"
               substitutionGroup="generalComparisonOp"/&gt;

  &lt;xsd:element name="notEqualOp" type="binaryOperatorExpr"
               substitutionGroup="generalComparisonOp"/&gt;

  &lt;xsd:element name="lessThanOp" type="binaryOperatorExpr"
               substitutionGroup="generalComparisonOp"/&gt;

  &lt;xsd:element name="lessThanOrEqualOp" type="binaryOperatorExpr"
               substitutionGroup="generalComparisonOp"/&gt;

  &lt;xsd:element name="greaterThanOp" type="binaryOperatorExpr"
               substitutionGroup="generalComparisonOp"/&gt;

  &lt;xsd:element name="greaterThanOrEqualOp" type="binaryOperatorExpr"
               substitutionGroup="generalComparisonOp"/&gt;

  &lt;xsd:element name="nodeComparisonOp" type="binaryOperatorExpr" abstract="true"
               substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="isOp" type="binaryOperatorExpr"
               substitutionGroup="nodeComparisonOp"/&gt;

  &lt;xsd:element name="orderComparisonOp" type="binaryOperatorExpr" abstract="true"
               substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="nodeBeforeOp" type="binaryOperatorExpr"
               substitutionGroup="orderComparisonOp"/&gt;

  &lt;xsd:element name="nodeAfterOp" type="binaryOperatorExpr"
               substitutionGroup="orderComparisonOp"/&gt;

  &lt;xsd:element name="logicalOp" type="binaryOperatorExpr" abstract="true"
               substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="andOp" type="binaryOperatorExpr"
               substitutionGroup="logicalOp"/&gt;

  &lt;xsd:element name="orOp" type="binaryOperatorExpr"
               substitutionGroup="logicalOp"/&gt;

  &lt;xsd:element name="setOp" type="binaryOperatorExpr"
               abstract="true" substitutionGroup="operatorExpr"/&gt;

  &lt;xsd:element name="unionOp" type="binaryOperatorExpr"
               substitutionGroup="setOp"/&gt;

  &lt;xsd:element name="intersectOp" type="binaryOperatorExpr"
               substitutionGroup="setOp"/&gt;

  &lt;xsd:element name="exceptOp" type="binaryOperatorExpr"
               substitutionGroup="setOp"/&gt;


&lt;!-- Basic typenames                                                                    --&gt;
  &lt;xsd:element name="atomicType" type="QName" substitutionGroup="itemType"/&gt;

<span>
&lt;!-- Used in castable expression and cast expression                                    --&gt;
  &lt;xsd:complexType name="singleType"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="atomicType"/&gt;
      &lt;xsd:element name="optional" type="emptyContent" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="singleType" type="singleType"/&gt;
</span>

&lt;!-- Item type schema types and elements                                                --&gt;
  &lt;xsd:element name="itemType" abstract="true"/&gt;


  &lt;xsd:complexType name="emptyItemTypeContent"/&gt;

  &lt;xsd:element name="anyItemType" type="emptyItemTypeContent"
               substitutionGroup="itemType"/&gt;


  &lt;xsd:simpleType name="occurrenceIndicator"&gt;
    &lt;xsd:restriction base="xsd:string"&gt;
      &lt;xsd:enumeration value="?"/&gt;
      &lt;xsd:enumeration value="*"/&gt;
      &lt;xsd:enumeration value="+"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;


&lt;!-- Sequence type                                                                      --&gt;
  &lt;xsd:complexType name="sequenceType"&gt;
    &lt;xsd:choice&gt;
      &lt;xsd:element name="voidSequenceType" type="emptyContent"/&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element ref="itemType"/&gt;
        &lt;xsd:element name="occurrenceIndicator" type="occurrenceIndicator"
                     minOccurs="0"/&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:choice&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="sequenceType" type="sequenceType"/&gt;

  &lt;xsd:element name="typeDeclaration" type="sequenceType"/&gt;

<span>
&lt;!-- Represents a "typed" variable (for clause, let clause etc)                         --&gt;
  &lt;xsd:complexType name="typedVariableBinding"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="varName" type="QName"/&gt;
      &lt;xsd:element ref="typeDeclaration" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="typedVariableBinding" type="typedVariableBinding"/&gt;
</span>

&lt;!-- Represents an untyped variable for the "at" clause in a for clause                 --&gt;
  &lt;xsd:element name="positionalVariableBinding" type="QName"/&gt;

  &lt;xsd:element name="variableBinding" type="QName"/&gt;


&lt;!-- Represents all variable bindings in a for or let clause except typed and           --&gt;
&lt;!--   positional variable bindings                                                     --&gt;
  &lt;xsd:element name="forLetClauseItemExtensions" abstract="true"/&gt;


&lt;!-- Major syntax productions: FLWOR clause components                                  --&gt;
&lt;!-- for clause                                                                         --&gt;
  &lt;xsd:complexType name="forClauseItem"&gt;
    &lt;xsd:sequence&gt;
          &lt;xsd:element ref="typedVariableBinding"/&gt;
            &lt;xsd:element ref="positionalVariableBinding" minOccurs="0" maxOccurs="1"/&gt;
      &lt;xsd:element ref="forLetClauseItemExtensions" minOccurs="0"
                   maxOccurs="unbounded"/&gt;
      &lt;xsd:element name="forExpr" type="exprWrapper"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="forClauseItem" type="forClauseItem"/&gt;

<span>
  &lt;xsd:complexType name="forClause"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="forClauseItem" minOccurs="1" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="forClause" type="forClause"/&gt;


&lt;!-- let clause                                                                         --&gt;
  &lt;xsd:complexType name="letClauseItem"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:choice&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element ref="typedVariableBinding"/&gt;
          &lt;xsd:element ref="forLetClauseItemExtensions"
                       minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xsd:sequence&gt;
        &lt;xsd:element ref="forLetClauseItemExtensions"
                     minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xsd:choice&gt;
      &lt;xsd:element name="letExpr" type="exprWrapper"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="letClauseItem" type="letClauseItem"/&gt;


  &lt;xsd:complexType name="letClause"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="letClauseItem" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="letClause" type="letClause"/&gt;
</span>

&lt;!-- whereClause (part of FLWOR expression)                                             --&gt;
  &lt;xsd:element name="whereClause" type="exprWrapper"/&gt;



&lt;!-- order by clause                                                                    --&gt;
  &lt;xsd:simpleType name="emptyOrderingMode"&gt;
    &lt;xsd:restriction base="xsd:string"&gt;
      &lt;xsd:enumeration value="empty greatest"/&gt;
      &lt;xsd:enumeration value="empty least"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

  &lt;xsd:simpleType name="orderingKind"&gt;
    &lt;xsd:restriction base="xsd:string"&gt;
      &lt;xsd:enumeration value="ascending"/&gt;
      &lt;xsd:enumeration value="descending"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

<span>
  &lt;xsd:complexType name="orderModifier"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="orderingKind" type="orderingKind" minOccurs="0"/&gt;
      &lt;xsd:element name="emptyOrderingMode" type="emptyOrderingMode" minOccurs="0"/&gt;
      &lt;xsd:element name="collation" type="xsd:string" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="orderModifier" type="orderModifier"/&gt;


  &lt;xsd:complexType name="orderBySpec"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="orderByExpr" type="exprWrapper"/&gt;
      &lt;xsd:element ref="orderModifier" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="orderBySpec" type="orderBySpec"/&gt;


  &lt;xsd:complexType name="orderByClause"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="stable" type="emptyContent" minOccurs="0"/&gt;
      &lt;xsd:element ref="orderBySpec" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="orderByClause" type="orderByClause"/&gt;
</span>
<span>
&lt;!-- return clause                                                                      --&gt;
  &lt;xsd:element name="returnClause" type="exprWrapper"/&gt;
</span>
  &lt;!-- This is the flwor expression --&gt;
  &lt;xsd:complexType name="flworExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:choice maxOccurs="unbounded"&gt;
            &lt;xsd:element ref="forClause"/&gt;
            &lt;xsd:element ref="letClause"/&gt;
          &lt;/xsd:choice&gt;
          &lt;xsd:element ref="whereClause" minOccurs="0"/&gt;
          &lt;xsd:element ref="orderByClause" minOccurs="0"/&gt;
          &lt;xsd:element ref="returnClause"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="flworExpr" type="flworExpr" substitutionGroup="expr"/&gt;


&lt;!-- conditional expressions                                                            --&gt;
  &lt;xsd:complexType name="ifThenElseExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="ifClause" type="exprWrapper"/&gt;
          &lt;xsd:element name="thenClause" type="exprWrapper"/&gt;
          &lt;xsd:element name="elseClause" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="ifThenElseExpr" type="ifThenElseExpr" 
               substitutionGroup="expr"/&gt;


&lt;!-- The following clauses describe quantified expressions                              --&gt;
  &lt;xsd:simpleType name="quantifier"&gt;
    &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
      &lt;xsd:enumeration value="some"/&gt;
      &lt;xsd:enumeration value="every"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

<span>
  &lt;xsd:complexType name="quantifiedExprInClause"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="typedVariableBinding"/&gt;
      &lt;xsd:element name="sourceExpr" type="exprWrapper"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="quantifiedExprInClause" type="quantifiedExprInClause"/&gt;
</span>

  &lt;xsd:complexType name="quantifiedExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="quantifier" type="quantifier"/&gt;
          &lt;xsd:element ref="quantifiedExprInClause" maxOccurs="unbounded"/&gt;
          &lt;xsd:element name="predicateExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="quantifiedExpr" type="quantifiedExpr"
               substitutionGroup="expr"/&gt;

<span>
  &lt;!-- handle the typeswitch construct                                                    --&gt;
&lt;!-- Note: no substitutionGroup as we cannot use this anywhere                          --&gt;
  &lt;xsd:complexType name="typeswitchExprCaseClause"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element ref="variableBinding" minOccurs="0"/&gt;
          &lt;xsd:element ref="sequenceType"/&gt;
          &lt;xsd:element name="resultExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="typeswitchExprCaseClause"
               type="typeswitchExprCaseClause"/&gt;


&lt;!-- Note: no substitutionGroup as we cannot use this anywhere                          --&gt;
  &lt;xsd:complexType name="typeswitchExprDefaultClause"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element ref="variableBinding" minOccurs="0"/&gt;
          &lt;xsd:element name="resultExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="typeswitchExprDefaultClause"
               type="typeswitchExprDefaultClause"/&gt;
</span>

  &lt;xsd:complexType name="typeswitchExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
          &lt;xsd:element ref="typeswitchExprCaseClause" maxOccurs="unbounded"/&gt;
          &lt;xsd:element ref="typeswitchExprDefaultClause"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="typeswitchExpr" type="typeswitchExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- instance-of expressions                                                            --&gt;
  &lt;xsd:complexType name="instanceOfExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
          &lt;xsd:element ref="sequenceType"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="instanceOfExpr" type="instanceOfExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- treat-as expressions                                                               --&gt;
  &lt;xsd:complexType name="treatExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
          &lt;xsd:element ref="sequenceType"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="treatExpr" type="treatExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- castable and cast expressions                                                      --&gt;
  &lt;xsd:complexType name="castableExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
          &lt;xsd:element ref="singleType"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="castableExpr" type="castableExpr"
               substitutionGroup="expr"/&gt;


  &lt;xsd:complexType name="castExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
          &lt;xsd:element ref="singleType"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="castExpr" type="castExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- Validate expressions                                                               --&gt;
  &lt;xsd:simpleType name="validationMode"&gt;
    &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
      &lt;xsd:enumeration value="lax"/&gt;
      &lt;xsd:enumeration value="strict"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

  &lt;xsd:complexType name="validateExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="validationMode" type="validationMode" minOccurs="0"/&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="validateExpr" type="validateExpr"
               substitutionGroup="expr"/&gt;


&lt;!-- Direct constructors. Only elementConstructor for now                               --&gt;
&lt;!-- Note the absence of constructors corresponding to                                  --&gt;
&lt;!-- the directCommentConstructor and the directPIConstructor                           --&gt;
&lt;!-- productions in the XQuery grammar. This is because they are                        --&gt;
&lt;!-- trivially identical to the computed variants                                       --&gt;

&lt;!-- attributeConstructor is no longer a subclass of expr                               --&gt;
  &lt;xsd:complexType name="attributeConstructor"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="attributeName" type="QName"/&gt;
      &lt;xsd:choice&gt;
        &lt;xsd:element name="attributeValueExpr" type="exprList"/&gt;
        &lt;xsd:element name="attributeValue" type="xsd:string"/&gt;
      &lt;/xsd:choice&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:complexType name="namespaceDeclaration"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="prefix" type="xsd:NCName" minOccurs="0"/&gt;
      &lt;xsd:element name="uri" type="xsd:string"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

<span>
&lt;!-- element constructors                                                               --&gt;
  &lt;xsd:complexType name="attributeList"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:choice maxOccurs="unbounded"&gt;
        &lt;xsd:element name="attributeConstructor" type="attributeConstructor"/&gt;
        &lt;xsd:element name="namespaceDeclaration" type="namespaceDeclaration"/&gt;
      &lt;/xsd:choice&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="attributeList" type="attributeList"/&gt;
</span>

  &lt;xsd:element name="elementContent" type="exprList"/&gt;


  &lt;xsd:complexType name="elementConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="tagName" type="QName"/&gt;
          &lt;xsd:element ref="attributeList" minOccurs="0"/&gt;
          &lt;xsd:element ref="elementContent" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="elementConstructor" type="elementConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- computed constructors                                                              --&gt;
&lt;!-- computed element constructor                                                       --&gt;
  &lt;xsd:complexType name="computedElementConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:choice&gt;
            &lt;xsd:element name="tagName" type="QName"/&gt;
            &lt;xsd:element name="tagNameExpr" type="exprWrapper"/&gt;
          &lt;/xsd:choice&gt;
          &lt;xsd:element name="contentExpr" type="exprWrapper" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="computedElementConstructor" type="computedElementConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- computed attribute constructor                                                     --&gt;
  &lt;xsd:complexType name="computedAttributeConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:choice&gt;
            &lt;xsd:element name="tagName" type="QName"/&gt;
            &lt;xsd:element name="tagNameExpr" type="exprWrapper"/&gt;
          &lt;/xsd:choice&gt;
          &lt;xsd:element name="valueExpr" type="exprWrapper" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="computedAttributeConstructor" type="computedAttributeConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- computed document constructor                                                      --&gt;
  &lt;xsd:complexType name="computedDocumentConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="computedDocumentConstructor" type="computedDocumentConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- computed text constructor                                                          --&gt;
  &lt;xsd:complexType name="computedTextConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="computedTextConstructor" type="computedTextConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- computed comment constructor                                                       --&gt;
  &lt;xsd:complexType name="computedCommentConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="computedCommentConstructor" type="computedCommentConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- computed processing instruction constructor                                        --&gt;
  &lt;xsd:complexType name="computedPIConstructor"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:choice&gt;
            &lt;xsd:element name="piTarget" type="xsd:NCName"/&gt;
            &lt;xsd:element name="piTargetExpr" type="exprWrapper"/&gt;
          &lt;/xsd:choice&gt;
          &lt;xsd:element name="piValueExpr" type="exprWrapper" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="computedPIConstructor" type="computedPIConstructor"
               substitutionGroup="expr"/&gt;


&lt;!-- ordered and unordered expressions                                                  --&gt;
  &lt;xsd:complexType name="unorderedExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="unorderedExpr" type="unorderedExpr" substitutionGroup="expr"/&gt;


  &lt;xsd:complexType name="orderedExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="argExpr" type="exprWrapper"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="orderedExpr" type="orderedExpr" substitutionGroup="expr"/&gt;


&lt;!-- wildcards                                                                          --&gt;
  &lt;xsd:complexType name="simpleWildcard"&gt;
    &lt;xsd:choice&gt;
      &lt;xsd:element name="QName" type="QName"/&gt;
      &lt;xsd:element name="star" type="emptyContent"/&gt;
    &lt;/xsd:choice&gt;
  &lt;/xsd:complexType&gt;

<span>
  &lt;xsd:complexType name="Wildcard"&gt;
    &lt;xsd:all&gt;
      &lt;xsd:element name="star" type="emptyContent" minOccurs="0"/&gt;
      &lt;xsd:element ref="NCName" minOccurs="0"/&gt;
    &lt;/xsd:all&gt;
  &lt;/xsd:complexType&gt;


  &lt;xsd:element name="Wildcard" type="Wildcard"/&gt;


&lt;!-- tests (name and/or type)                                                           --&gt;
  &lt;xsd:element name="schemaAttributeTest" type="QName"
               substitutionGroup="kindTest"/&gt;


  &lt;xsd:complexType name="attributeTest"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="emptyItemTypeContent"&gt;
        &lt;xsd:sequence minOccurs="0"&gt;
          &lt;xsd:element name="attributeName" type="simpleWildcard"/&gt;
          &lt;xsd:element name="typeName" type="QName" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="attributeTest" type="attributeTest"
               substitutionGroup="kindTest"/&gt;
</span>

  &lt;xsd:element name="anyElementTest" abstract="true"
               substitutionGroup="kindTest"/&gt;


  &lt;xsd:element name="schemaElementTest" type="QName"
               substitutionGroup="anyElementTest"/&gt;

<span>
  &lt;xsd:complexType name="elementTest"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="emptyItemTypeContent"&gt;
        &lt;xsd:sequence minOccurs="0"&gt;
          &lt;xsd:element name="elementName" type="simpleWildcard"/&gt;
          &lt;xsd:sequence minOccurs="0"&gt;
            &lt;xsd:element name="typeName" type="QName"/&gt;
            &lt;xsd:element name="nillable" type="emptyContent" minOccurs="0"/&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="elementTest" type="elementTest"
               substitutionGroup="anyElementTest"/&gt;


  &lt;xsd:complexType name="documentTest"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="emptyItemTypeContent"&gt;
        &lt;xsd:sequence&gt;
           &lt;xsd:element ref="anyElementTest" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="documentTest" type="documentTest"
               substitutionGroup="kindTest"/&gt;


  &lt;xsd:complexType name="piTest"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="emptyItemTypeContent"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="piTarget" type="xsd:NCName" minOccurs="0"/&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="piTest" type="piTest" substitutionGroup="kindTest"/&gt;
</span>

  &lt;xsd:element name="nameTest" type="QName"/&gt;

  &lt;xsd:element name="kindTest" substitutionGroup="itemType"/&gt;

  &lt;xsd:element name="textTest" type="emptyItemTypeContent"
               substitutionGroup="kindTest"/&gt;

  &lt;xsd:element name="commentTest" type="emptyItemTypeContent"
               substitutionGroup="kindTest"/&gt;

  &lt;xsd:element name="anyKindTest" type="emptyItemTypeContent"
               substitutionGroup="kindTest"/&gt;

<span>
&lt;!-- XPath axes                                                                         --&gt;
  &lt;xsd:simpleType name="xpathAxis"&gt;
    &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
      &lt;xsd:enumeration value="child"/&gt;
      &lt;xsd:enumeration value="attribute"/&gt;
      &lt;xsd:enumeration value="self"/&gt;
      &lt;xsd:enumeration value="parent"/&gt;
      &lt;xsd:enumeration value="descendant-or-self"/&gt;
      &lt;xsd:enumeration value="descendant"/&gt;
      &lt;xsd:enumeration value="following"/&gt;
      &lt;xsd:enumeration value="following-sibling"/&gt;
      &lt;xsd:enumeration value="ancestor"/&gt;
      &lt;xsd:enumeration value="ancestor-or-self"/&gt;
      &lt;xsd:enumeration value="preceding"/&gt;
      &lt;xsd:enumeration value="preceding-sibling"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

  &lt;xsd:element name="xpathAxis" type="xpathAxis"/&gt;
</span>

&lt;!-- filter expressions                                                                 --&gt;
  &lt;xsd:group name="filterExpr"&gt;
    &lt;xsd:choice&gt;
      &lt;xsd:element ref="constantExpr"/&gt;
      &lt;xsd:element ref="varRef"/&gt;
      &lt;xsd:element ref="contextItemExpr"/&gt;
      &lt;xsd:element ref="functionCallExpr"/&gt;
      &lt;xsd:element ref="sequenceExpr"/&gt;
      &lt;xsd:element ref="elementConstructor"/&gt;
      &lt;xsd:element ref="computedElementConstructor"/&gt;
      &lt;xsd:element ref="computedAttributeConstructor"/&gt;
      &lt;xsd:element ref="computedDocumentConstructor"/&gt;
      &lt;xsd:element ref="computedTextConstructor"/&gt;
      &lt;xsd:element ref="computedCommentConstructor"/&gt;
      &lt;xsd:element ref="computedPIConstructor"/&gt;
      &lt;xsd:element ref="orderedExpr"/&gt;
      &lt;xsd:element ref="unorderedExpr"/&gt;
    &lt;/xsd:choice&gt;
  &lt;/xsd:group&gt;

<span>
&lt;!-- step expression                                                                    --&gt;
&lt;!-- removed nameTest and Wildcard outer choices per Bugzilla Bug #2523                 --&gt;
  &lt;xsd:complexType name="stepExpr"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:choice&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element ref="xpathAxis"/&gt;
          &lt;xsd:choice&gt;
            &lt;xsd:element ref="kindTest"/&gt;
            &lt;xsd:element ref="nameTest"/&gt;
            &lt;xsd:element ref="Wildcard"/&gt;
          &lt;/xsd:choice&gt;
        &lt;/xsd:sequence&gt;
        &lt;xsd:element name="filterExpr"&gt;
          &lt;xsd:complexType&gt;
            &lt;xsd:sequence&gt;
              &lt;xsd:group ref="filterExpr"/&gt;
            &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
        &lt;/xsd:element&gt;
      &lt;/xsd:choice&gt;
      &lt;xsd:element name="predicates" type="exprList" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="stepExpr" type="stepExpr"/&gt;
</span>

&lt;!-- path expression                                                                    --&gt;
&lt;!-- rewrote pathExpr definition per Bugzilla Bug #2523                                 --&gt;
  &lt;xsd:complexType name="pathExpr"&gt;
    &lt;xsd:complexContent&gt;
      &lt;xsd:extension base="expr"&gt;
        &lt;xsd:choice&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:element name="rootExpr" type="emptyContent"/&gt;
            &lt;xsd:element ref="stepExpr" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;/xsd:sequence&gt;
          &lt;xsd:element ref="stepExpr" maxOccurs="unbounded"/&gt;
        &lt;/xsd:choice&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:complexContent&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="pathExpr" type="pathExpr" substitutionGroup="expr"/&gt;

<span>
&lt;!-- The following constructs deal with the query prolog                                --&gt;
  &lt;xsd:complexType name="module"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="versionDecl" minOccurs="0"/&gt;
      &lt;xsd:choice&gt;
        &lt;xsd:element ref="mainModule"/&gt;
        &lt;xsd:element ref="libraryModule"/&gt;
      &lt;/xsd:choice&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="module" type="module"/&gt;


  &lt;xsd:complexType name="mainModule"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="prolog" minOccurs="0"/&gt;
      &lt;xsd:element name="queryBody" type="exprWrapper"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="mainModule" type="mainModule"/&gt;


  &lt;xsd:complexType name="libraryModule"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="moduleDecl"/&gt;
      &lt;xsd:element ref="prolog" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="libraryModule" type="libraryModule"/&gt;


  &lt;xsd:complexType name="versionDecl"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="version" type="xsd:string"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="versionDecl" type="versionDecl"/&gt;


  &lt;xsd:complexType name="prolog"&gt;
    &lt;xsd:sequence&gt;
            &lt;xsd:element ref="prologPartOneItem" minOccurs="0" maxOccurs="unbounded"/&gt;
            &lt;xsd:element ref="prologPartTwoItem" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:complexType&gt;

  &lt;xsd:element name="prolog" type="prolog"/&gt;
</span>

  &lt;xsd:element name="prologPartOneItem" abstract="true"/&gt;


  &lt;xsd:element name="prologPartTwoItem" abstract="true"/&gt;


  &lt;xsd:element name="defaultCollationDecl" type="xsd:string"
               substitutionGroup="prologPartOneItem"/&gt;

  &lt;xsd:element name="baseUriDecl" type="xsd:string"
               substitutionGroup="prologPartOneItem"/&gt;

<span>
  &lt;xsd:simpleType name="constructionDecl"&gt;
    &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
      &lt;xsd:enumeration value="strip"/&gt;
      &lt;xsd:enumeration value="preserve"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

  &lt;xsd:element name="constructionDecl" type="constructionDecl"
               substitutionGroup="prologPartOneItem"/&gt;


  &lt;xsd:simpleType name="orderingModeDecl"&gt;
    &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
      &lt;xsd:enumeration value="ordered"/&gt;
      &lt;xsd:enumeration value="unordered"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;

  &lt;xsd:element name="orderingModeDecl" type="orderingModeDecl"
               substitutionGroup="prologPartOneItem"/&gt;
</span>

  &lt;xsd:element name="emptyOrderingDecl" type="emptyOrderingMode"
               substitutionGroup="prologPartOneItem"/&gt;

<span>
  &lt;xsd:complexType name="copyNamespacesDecl"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="preserveMode"&gt;
        &lt;xsd:simpleType&gt;
          &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
            &lt;xsd:enumeration value="preserve"/&gt;
            &lt;xsd:enumeration value="no-preserve"/&gt;
          &lt;/xsd:restriction&gt;
        &lt;/xsd:simpleType&gt;
      &lt;/xsd:element&gt;
      &lt;xsd:element name="inheritMode"&gt;
        &lt;xsd:simpleType&gt;
          &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
            &lt;xsd:enumeration value="inherit"/&gt;
            &lt;xsd:enumeration value="no-inherit"/&gt;
          &lt;/xsd:restriction&gt;
        &lt;/xsd:simpleType&gt;
      &lt;/xsd:element&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="copyNamespacesDecl" type="copyNamespacesDecl"
               substitutionGroup="prologPartOneItem"/&gt;
</span>

  &lt;xsd:simpleType name="defaultNamespaceCategory"&gt;
    &lt;xsd:restriction base="xsd:NMTOKEN"&gt;
      &lt;xsd:enumeration value="function"/&gt;
      &lt;xsd:enumeration value="element"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;
<span>
  &lt;xsd:complexType name="defaultNamespaceDecl"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="defaultNamespaceCategory" type="defaultNamespaceCategory"/&gt;
      &lt;xsd:element name="uri" type="xsd:string"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="defaultNamespaceDecl" type="defaultNamespaceDecl"
               substitutionGroup="prologPartOneItem"/&gt;
</span>

  &lt;xsd:complexType name="namespaceDeclType"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="prefix" type="xsd:NCName"/&gt;
      &lt;xsd:element name="uri" type="xsd:string"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="namespaceDecl" type="namespaceDeclType"
               substitutionGroup="prologPartOneItem"/&gt;


  &lt;xsd:element name="moduleDecl" type="namespaceDeclType"/&gt;

<span>
  &lt;xsd:complexType name="schemaImport"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:choice minOccurs="0"&gt;
        &lt;xsd:element name="namespacePrefix" type="xsd:NCName"/&gt;
        &lt;xsd:element name="defaultElementNamespace" type="emptyContent"/&gt;
      &lt;/xsd:choice&gt;
      &lt;xsd:element name="targetNamespace" type="xsd:string"/&gt;
      &lt;xsd:element name="targetLocation" type="xsd:string"
                   minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="schemaImport" type="schemaImport"
               substitutionGroup="prologPartOneItem"/&gt;


  &lt;xsd:complexType name="moduleImport"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="namespacePrefix" type="xsd:NCName" minOccurs="0"/&gt;
      &lt;xsd:element name="targetNamespace" type="xsd:string"/&gt;
      &lt;xsd:element name="targetLocation" type="xsd:string"
                   minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="moduleImport" type="moduleImport"
               substitutionGroup="prologPartOneItem"/&gt;


  &lt;xsd:complexType name="varDecl"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="varName" type="QName"/&gt;
      &lt;xsd:element ref="typeDeclaration" minOccurs="0"/&gt;
      &lt;xsd:choice&gt;
        &lt;xsd:element name="varValue" type="exprWrapper"/&gt;
        &lt;xsd:element name="external" type="emptyContent"/&gt;
      &lt;/xsd:choice&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="varDecl" type="varDecl"
               substitutionGroup="prologPartTwoItem"/&gt;


  &lt;xsd:complexType name="optionDecl"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="optionName" type="QName"/&gt;
      &lt;xsd:element name="optionContents" type="xsd:string"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="optionDecl" type="optionDecl"
               substitutionGroup="prologPartTwoItem"/&gt;


  &lt;xsd:complexType name="functionDecl"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="functionName" type="QName"/&gt;
      &lt;xsd:element ref="paramList"/&gt;
      &lt;xsd:element ref="typeDeclaration" minOccurs="0"/&gt;
      &lt;xsd:choice&gt;
        &lt;xsd:element name="functionBody" type="exprWrapper"/&gt;
        &lt;xsd:element name="externalDefinition" type="emptyContent"/&gt;
      &lt;/xsd:choice&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="functionDecl" type="functionDecl"
               substitutionGroup="prologPartTwoItem"/&gt;


  &lt;xsd:complexType name="param"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="varName" type="QName"/&gt;
      &lt;xsd:element ref="typeDeclaration" minOccurs="0"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="param" type="param"/&gt;


  &lt;xsd:complexType name="paramList"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;

  &lt;xsd:element name="paramList" type="paramList"/&gt;
</span>

&lt;/xsd:schema&gt;
</pre></div>
</div>
<div class="div1">
<h2><a id="xqx_conformance" name="xqx_conformance"></a>5
Conformance</h2>
<p>This section defines the conformance criteria for an XQueryX
processor (see Figure 1, "Processing Model Overview", in <a href=
"#xquery">[XQuery 1.0: An XML Query Language (Second Edition)]</a>,
<a href="http://www.w3.org/TR/xquery/#id-processing-model">Section
2.2 Processing Model</a><sup><small>XQ</small></sup>.</p>
<p>In this section, the following terms are used to indicate the
requirement levels defined in <a href="#RFC2119">[RFC 2119]</a>.
[Definition: MUST means that the item is an absolute requirement of
the specification.] [Definition: SHOULD means that there may exist
valid reasons in particular circumstances to ignore a particular
item, but the full implications must be understood and carefully
weighed before choosing a different course.] [Definition: MAY means
that an item is truly optional.]</p>
<p>An XQueryX processor that claims to conform to this
specification MUST implement the XQueryX syntax as defined in
<a href="#Schema"><b>4 An XML Schema for the XQuery XML
Syntax</b></a> of this specification and include a claim of Minimal
Conformance as defined in <a href="#xquery">[XQuery 1.0: An XML
Query Language (Second Edition)]</a>, <a href=
"http://www.w3.org/TR/xquery/#id-minimal-conformance">Section 5.1
Minimal Conformance</a><sup><small>XQ</small></sup>. In addition to
a claim of Minimal Conformance, it MAY claim conformance to one or
more optional features defined in <a href="#xquery">[XQuery 1.0: An
XML Query Language (Second Edition)]</a>, <a href=
"http://www.w3.org/TR/xquery/#id-conform-optional-features">Section
5.2 Optional Features</a><sup><small>XQ</small></sup>.</p>
</div>
</div>
<div class="back">
<div class="div1">
<h2><a id="biblio" name="biblio"></a>A References</h2>
<dl>
<dt class="label"><span><a id="xquery-requirements" name=
"xquery-requirements"></a>XML Query 1.0 Requirements</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-requirements/"><cite>XML
Query (XQuery) Requirements</cite></a>, Don Chamberlin, Peter
Fankhauser, Massimo Marchiori, and Jonathan Robie, Editors. World
Wide Web Consortium, 3&#160;Jun&#160;2005. This version is
http://www.w3.org/TR/2005/WD-xquery-requirements-20050603/. The
<a href="http://www.w3.org/TR/xquery-requirements/">latest
version</a> is available at
http://www.w3.org/TR/xquery-requirements/.</div>
</dd>
<dt class="label"><span><a id="xquery" name="xquery"></a>XQuery
1.0: An XML Query Language (Second Edition)</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery/"><cite>XQuery 1.0: An
XML Query Language (Second Edition)</cite></a>, Don Chamberlin,
Jonathan Robie, Anders Berglund, Scott Boag, <em>et. al.</em>,
Editors. World Wide Web Consortium, 14 December 2010. This version
is http://www.w3.org/TR/2010/REC-xquery-20101214/. The <a href=
"http://www.w3.org/TR/xquery/">latest version</a> is available at
http://www.w3.org/TR/xquery/.</div>
</dd>
<dt class="label"><span><a id="xquery-use-cases" name=
"xquery-use-cases"></a>XML Query Use Cases</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-use-cases/"><cite>XML
Query Use Cases</cite></a>, Jonathan Robie, Don Chamberlin, Peter
Fankhauser, <em>et. al.</em>, Editors. World Wide Web Consortium, 8
Jun 2006. This version is
http://www.w3.org/TR/2006/WD-xquery-use-cases-20060608/. The
<a href="http://www.w3.org/TR/xquery-use-cases/">latest version</a>
is available at http://www.w3.org/TR/xquery-use-cases/.</div>
</dd>
<dt class="label"><span><a id="xquery-semantics" name=
"xquery-semantics"></a>XQuery 1.0 and XPath 2.0 Formal Semantics
(Second Edition)</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-semantics/"><cite>XQuery
1.0 and XPath 2.0 Formal Semantics (Second Edition)</cite></a>,
Jérôme Siméon, Michael Dyck, Denise Draper, Peter Frankhauser,
<em>et. al.</em>, Editors. World Wide Web Consortium, 14 December
2010. This version is
http://www.w3.org/TR/2010/REC-xquery-semantics-20101214/. The
<a href="http://www.w3.org/TR/xquery-semantics/">latest version</a>
is available at http://www.w3.org/TR/xquery-semantics/.</div>
</dd>
<dt class="label"><span><a id="RFC2119" name="RFC2119"></a>RFC
2119</span></dt>
<dd>
<div>S. Bradner. <em>Key Words for use in RFCs to Indicate
Requirement Levels.</em> IETF RFC 2119. See <a href=
"http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>.</div>
</dd>
<dt class="label"><span><a id="RFC3023" name="RFC3023"></a>RFC
3023</span></dt>
<dd>
<div>M. Murata, S. St. Laurent, and D. Kohn. <em>XML Media
Types</em> IETF RFC 3023 or its successors. See <a href=
"http://www.ietf.org/rfc/rfc3023.txt">http://www.ietf.org/rfc/rfc3023.txt</a>.</div>
</dd>
</dl>
</div>
<div class="div1">
<h2><a id="Stylesheet" name="Stylesheet"></a>B Transforming XQueryX
to XQuery</h2>
<p>The following stylesheet converts from XQueryX syntax to XML
Query syntax. Note the intent of the stylesheet is to produce
<em>a</em> valid XQuery with the same semantics (see <a href=
"#xquery-semantics">[XQuery 1.0 and XPath 2.0 Formal Semantics
(Second Edition)]</a>) as the input XQueryX.</p>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;!--  ================================================================================  --&gt;
&lt;!--  Errata applied:                                                                   --&gt;
&lt;!--    XQX.E3 - Editorial (Bugzilla Bug 4963)                                          --&gt;
&lt;!--    XQX.E5 - Editorial (Bugzilla Bug 5343)                                          --&gt;
&lt;!--  ================================================================================  --&gt;
&lt;xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xqx="http://www.w3.org/2005/XQueryX"&gt;

&lt;!-- Note that this stylesheet frequently invokes templates for
     specified elements, even when there are no templates in the
     stylesheet whose match="" attribute identifies those elements.
     In such case, the default template's element matching template
     is invoked, which merely invokes xsl:apply-templates --&gt;

  &lt;xsl:output method="text"/&gt;
  &lt;xsl:strip-space elements="*"/&gt;
  &lt;xsl:preserve-space elements="xqx:value xqx:attributeValue xqx:pragmaContents
                                xqx:optionContents xqx:xquery"/&gt;

  &lt;xsl:variable name="DOT" select="'.'"/&gt;
  &lt;xsl:variable name="SPACE" select="' '"/&gt;
  &lt;xsl:variable name="SLASH" select="'/'"/&gt;
  &lt;xsl:variable name="SLASH_SLASH" select="'//'"/&gt;
  &lt;xsl:variable name="LESSTHAN" select="'&amp;lt;'"/&gt;
  &lt;xsl:variable name="GREATERTHAN" select="'&amp;gt;'"/&gt;
  &lt;xsl:variable name="LPAREN" select="'('"/&gt;
  &lt;xsl:variable name="RPAREN" select="')'"/&gt;
  &lt;xsl:variable name="NEWLINE"&gt;&lt;xsl:text&gt;
&lt;/xsl:text&gt;&lt;/xsl:variable&gt;
  &lt;xsl:variable name="COMMA" select="','"/&gt;
  &lt;xsl:variable name="COMMA_SPACE" select="', '"/&gt;
  &lt;xsl:variable name="COMMA_NEWLINE"&gt;&lt;xsl:text&gt;,
&lt;/xsl:text&gt;&lt;/xsl:variable&gt;
  &lt;xsl:variable name="QUOTE"&gt;&lt;xsl:text&gt;'&lt;/xsl:text&gt;&lt;/xsl:variable&gt;
  &lt;xsl:variable name="DOUBLEQUOTE"&gt;&lt;xsl:text&gt;"&lt;/xsl:text&gt;&lt;/xsl:variable&gt;
  &lt;xsl:variable name="TO" select="' to '"/&gt;
  &lt;xsl:variable name="LBRACE" select="'{'"/&gt;
  &lt;xsl:variable name="RBRACE" select="'}'"/&gt;
  &lt;xsl:variable name="LBRACKET" select="'['"/&gt;
  &lt;xsl:variable name="RBRACKET" select="']'"/&gt;
  &lt;xsl:variable name="DOLLAR" select="'$'"/&gt;
  &lt;xsl:variable name="MINUS" select="'-'"/&gt;
  &lt;xsl:variable name="PLUS" select="'+'"/&gt;
  &lt;xsl:variable name="EQUAL" select="'='"/&gt;
  &lt;xsl:variable name="COLON" select="':'"/&gt;
  &lt;xsl:variable name="DOUBLE_COLON" select="'::'"/&gt;
  &lt;xsl:variable name="SEMICOLON" select="';'"/&gt;
  &lt;xsl:variable name="AT" select="'@'"/&gt;
  &lt;xsl:variable name="STAR" select="'*'"/&gt;
  &lt;xsl:variable name="QUESTIONMARK" select="'?'"/&gt;
  &lt;xsl:variable name="ASSIGN" select="':='"/&gt;
  &lt;xsl:variable name="SEPARATOR" select="';'"/&gt;
  &lt;xsl:variable name="PRAGMA_BEGIN" select="'(# '"/&gt;
  &lt;xsl:variable name="PRAGMA_END" select="' #)'"/&gt;


  &lt;xsl:template name="delimitedList"&gt;
    &lt;xsl:param name="delimiter" /&gt;
    &lt;xsl:param name="leftEncloser"/&gt;
    &lt;xsl:param name="rightEncloser" /&gt;
    &lt;xsl:param name="selector"/&gt;

    &lt;xsl:value-of select="$leftEncloser"/&gt;
    &lt;xsl:for-each select="*"&gt;
      &lt;xsl:apply-templates select="."/&gt;
      &lt;xsl:if test="not (position()=last())"&gt;        
        &lt;xsl:value-of select="$delimiter"/&gt;
      &lt;/xsl:if&gt;       
    &lt;/xsl:for-each&gt;
    &lt;xsl:value-of select="$rightEncloser"/&gt;
  &lt;/xsl:template&gt;   


  &lt;xsl:template name="parenthesizedList"&gt;
    &lt;xsl:param name="delimiter" select="$COMMA_SPACE"/&gt;
    &lt;xsl:call-template name="delimitedList"&gt;
      &lt;xsl:with-param name="delimiter" select="$delimiter" /&gt;
      &lt;xsl:with-param name="leftEncloser" select="$LPAREN"/&gt;
      &lt;xsl:with-param name="rightEncloser" select="$RPAREN"/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template name="commaSeparatedList"&gt;
    &lt;xsl:call-template name="delimitedList"&gt;
      &lt;xsl:with-param name="delimiter"&gt;
        &lt;xsl:value-of select="$COMMA_SPACE"/&gt;
      &lt;/xsl:with-param&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;!-- To resolve Bugzilla bug #3446, we now escape CR (#xD), NEL (#x85),
       and LINE SEPARATOR (#x2028) characters in text nodes and attribute values.
         Note that this template is invoked for a number of other purposes (e.g.,
       xqx:collation, xqx:namespaceDeclaration) where the presence of such
       characters would be invalid and thus are highly unlikely to appear. 
       If they do, then this template will happily escape them, deferring the
       error until the resulting XQuery expression is processed. --&gt;
  &lt;xsl:template name="quote"&gt;
    &lt;xsl:param name="item"/&gt;
    &lt;xsl:value-of select="$DOUBLEQUOTE"/&gt;
    &lt;xsl:call-template name="globalReplace"&gt;
      &lt;xsl:with-param name="stringToBeFixed"&gt;
        &lt;xsl:call-template name="globalReplace"&gt;
          &lt;xsl:with-param name="stringToBeFixed"&gt;
            &lt;xsl:call-template name="globalReplace"&gt;
              &lt;xsl:with-param name="stringToBeFixed"&gt;
                &lt;xsl:call-template name="globalReplace"&gt;
                  &lt;xsl:with-param name="stringToBeFixed"&gt;
                    &lt;xsl:call-template name="globalReplace"&gt;
                      &lt;xsl:with-param name="stringToBeFixed"&gt;
                        &lt;xsl:call-template name="globalReplace"&gt;
                          &lt;xsl:with-param name="stringToBeFixed"&gt;
                            &lt;xsl:value-of select="$item"/&gt;
                          &lt;/xsl:with-param&gt;
                          &lt;xsl:with-param name="toBeReplaced"&gt;&amp;amp;&lt;/xsl:with-param&gt;
                          &lt;xsl:with-param name="replacement"&gt;&amp;amp;amp;&lt;/xsl:with-param&gt;
                        &lt;/xsl:call-template&gt;
                                      &lt;/xsl:with-param&gt;
                      &lt;xsl:with-param name="toBeReplaced"&gt;&amp;lt;&lt;/xsl:with-param&gt;
                      &lt;xsl:with-param name="replacement"&gt;&amp;amp;lt;&lt;/xsl:with-param&gt;
                    &lt;/xsl:call-template&gt;
                  &lt;/xsl:with-param&gt;
                  &lt;xsl:with-param name="toBeReplaced" select="'&amp;#x85;'"/&gt;
                  &lt;xsl:with-param name="replacement"&gt;&amp;amp;#x85;&lt;/xsl:with-param&gt;
                &lt;/xsl:call-template&gt;
              &lt;/xsl:with-param&gt;
              &lt;xsl:with-param name="toBeReplaced" select="'&amp;#xD;'"/&gt;
              &lt;xsl:with-param name="replacement"&gt;&amp;amp;#xD;&lt;/xsl:with-param&gt;
            &lt;/xsl:call-template&gt;
          &lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="toBeReplaced" select="'&amp;#x2028;'"/&gt;
          &lt;xsl:with-param name="replacement"&gt;&amp;amp;#x2028;&lt;/xsl:with-param&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:with-param&gt;
      &lt;xsl:with-param name="toBeReplaced"&gt;&lt;xsl:text&gt;"&lt;/xsl:text&gt;&lt;/xsl:with-param&gt;
      &lt;xsl:with-param name="replacement"&gt;&lt;xsl:text&gt;""&lt;/xsl:text&gt;&lt;/xsl:with-param&gt;
    &lt;/xsl:call-template&gt;
    &lt;xsl:value-of select="$DOUBLEQUOTE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template name="globalReplace"&gt;
    &lt;xsl:param name="stringToBeFixed"/&gt;
    &lt;xsl:param name="toBeReplaced"/&gt;
    &lt;xsl:param name="replacement"/&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="contains($stringToBeFixed, $toBeReplaced)"&gt;
        &lt;xsl:value-of select="concat(substring-before($stringToBeFixed, $toBeReplaced), $replacement)"/&gt;
        &lt;xsl:call-template name="globalReplace"&gt;
          &lt;xsl:with-param name="stringToBeFixed" select="substring-after($stringToBeFixed, $toBeReplaced)"/&gt;
          &lt;xsl:with-param name="toBeReplaced" select="$toBeReplaced"/&gt;
          &lt;xsl:with-param name="replacement" select="$replacement"/&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:value-of select="$stringToBeFixed"/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:QName | xqx:pragmaName | xqx:typeName | xqx:varName |
                       xqx:functionName | xqx:optionName |
                       xqx:atomicType | xqx:tagName"&gt;
    &lt;xsl:if test="@xqx:prefix"&gt;
      &lt;xsl:value-of select="@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:attributeName"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="@xqx:prefix='xmlns'"&gt;
        &lt;xsl:message terminate="yes"&gt;Incorrect XQueryX: Attribute names are not permitted to
            have prefix 'xmlns'; use xqx:namespaceDeclaration to declare namespaces&lt;/xsl:message&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:when test="@xqx:prefix"&gt;
        &lt;xsl:value-of select="@xqx:prefix"/&gt;
        &lt;xsl:value-of select="$COLON"/&gt;
        &lt;xsl:value-of select="."/&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:when test=". = 'xmlns'"&gt;
        &lt;xsl:message terminate="yes"&gt;Incorrect XQueryX: Attribute names are not permitted to
           be 'xmlns'; use xqx:namespaceDeclaration to declare namespaces&lt;/xsl:message&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:value-of select="."/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:NCName"&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:rootExpr"&gt;
    &lt;xsl:value-of select="$SLASH"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:contextItemExpr"&gt;
    &lt;xsl:value-of select="$DOT"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:stringConstantExpr"&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:value"/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:integerConstantExpr
      | xqx:decimalConstantExpr
      | xqx:doubleConstantExpr"&gt;
    &lt;xsl:value-of select="xqx:value"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:varRef"&gt;
    &lt;xsl:value-of select="$DOLLAR"/&gt;
    &lt;xsl:if test="xqx:name/@xqx:prefix"&gt;
      &lt;xsl:value-of select="xqx:name/@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="xqx:name"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:pragma"&gt;
    &lt;xsl:value-of select="$PRAGMA_BEGIN"/&gt;
    &lt;xsl:apply-templates select="xqx:pragmaName"/&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:value-of select="xqx:pragmaContents"/&gt;
    &lt;xsl:value-of select="$PRAGMA_END"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:extensionExpr"&gt;
    &lt;xsl:apply-templates select="xqx:pragma"/&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;

&lt;!-- Response to Bugzilla bug #2528 --&gt;
   &lt;xsl:template match="xqx:functionCallExpr"&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="xqx:functionName/@xqx:prefix"&gt;
         &lt;xsl:value-of select="xqx:functionName/@xqx:prefix"/&gt;
         &lt;xsl:value-of select="$COLON"/&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:otherwise&gt;
         &lt;xsl:if test="xqx:functionName = 'node' or
                       xqx:functionName = 'document-node' or
                       xqx:functionName = 'element' or
                       xqx:functionName = 'attribute' or
                       xqx:functionName = 'schema-element' or
                       xqx:functionName = 'schema-attribute' or
                       xqx:functionName = 'processing-instruction' or
                       xqx:functionName = 'comment' or
                       xqx:functionName = 'text' or
                       xqx:functionName = 'item' or
                       xqx:functionName = 'if' or
                       xqx:functionName = 'typeswitch' or
                       xqx:functionName = 'empty-sequence'"&gt;
           &lt;xsl:variable name="message"&gt;&lt;xsl:text&gt;Incorrect XQueryX:&lt;/text&gt;
              &lt;xsl:text&gt;function calls must not use unqualified "reserved" name "&lt;/xsl:text&gt;
              &lt;xsl:value-of select="xqx:functionName"/&gt;&lt;xsl:text&gt;"&lt;/xsl:text&gt;&lt;/xsl:variable&gt;
           &lt;xsl:message terminate="yes"&gt;&lt;xsl:value-of select="$message"/&gt;&lt;/xsl:message&gt;
         &lt;/xsl:if&gt;
       &lt;/xsl:otherwise&gt;
     &lt;/xsl:choose&gt;
     &lt;xsl:value-of select="xqx:functionName"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="xqx:arguments"&gt;
         &lt;xsl:for-each select="xqx:arguments"&gt;
           &lt;xsl:call-template name="parenthesizedList"/&gt;
         &lt;/xsl:for-each&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:otherwise&gt;
         &lt;xsl:value-of select="$LPAREN"/&gt;
         &lt;xsl:value-of select="$RPAREN"/&gt;
       &lt;/xsl:otherwise&gt;
     &lt;/xsl:choose&gt;
   &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:constructorFunctionExpr"&gt;
    &lt;xsl:apply-templates select="xqx:typeName"/&gt;
    &lt;xsl:for-each select="xqx:argExpr"&gt;
      &lt;xsl:call-template name="parenthesizedList"/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:unaryMinusOp | xqx:unaryPlusOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:unaryPlusOp"&gt;&lt;xsl:value-of select="$PLUS"/&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:unaryMinusOp"&gt;&lt;xsl:value-of select="$MINUS"/&gt;&lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:operand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:addOp | xqx:subtractOp | xqx:multiplyOp
                     | xqx:divOp | xqx:idivOp | xqx:modOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:apply-templates select="xqx:firstOperand"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:addOp"&gt;&lt;xsl:value-of select="$PLUS"/&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:subtractOp"&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;xsl:value-of select="$MINUS"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:multiplyOp"&gt;&lt;xsl:value-of select="$STAR"/&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:divOp"&gt;&lt;xsl:text&gt; div &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:idivOp"&gt;&lt;xsl:text&gt; idiv &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:modOp"&gt;&lt;xsl:text&gt; mod &lt;/xsl:text&gt;&lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:secondOperand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:eqOp | xqx:neOp | xqx:ltOp
                     | xqx:gtOp | xqx:leOp | xqx:geOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:apply-templates select="xqx:firstOperand"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:eqOp"&gt;&lt;xsl:text&gt; eq &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:neOp"&gt;&lt;xsl:text&gt; ne &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:ltOp"&gt;&lt;xsl:text&gt; lt &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:gtOp"&gt;&lt;xsl:text&gt; gt &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:leOp"&gt;&lt;xsl:text&gt; le &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:geOp"&gt;&lt;xsl:text&gt; ge &lt;/xsl:text&gt;&lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:secondOperand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:equalOp | xqx:notEqualOp | xqx:lessThanOp
                     | xqx:greaterThanOp | xqx:lessThanOrEqualOp | xqx:greaterThanOrEqualOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:apply-templates select="xqx:firstOperand"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:equalOp"&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;xsl:value-of select="$EQUAL"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:notEqualOp"&gt;
         &lt;xsl:text&gt; !&lt;/xsl:text&gt;&lt;xsl:value-of select="$EQUAL"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:lessThanOp"&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;xsl:value-of select="$LESSTHAN"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:greaterThanOp"&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;xsl:value-of select="$GREATERTHAN"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:lessThanOrEqualOp"&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;xsl:value-of select="$LESSTHAN"/&gt;
         &lt;xsl:value-of select="$EQUAL"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:greaterThanOrEqualOp"&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;xsl:value-of select="$GREATERTHAN"/&gt;
         &lt;xsl:value-of select="$EQUAL"/&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
       &lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:secondOperand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:isOp | xqx:nodeBeforeOp | xqx:nodeAfterOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:apply-templates select="xqx:firstOperand"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:isOp"&gt;&lt;xsl:text&gt; is &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:nodeBeforeOp"&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
         &lt;xsl:value-of select="$LESSTHAN"/&gt;&lt;xsl:value-of select="$LESSTHAN"/&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:nodeAfterOp"&gt;&lt;xsl:text&gt; &lt;/xsl:text&gt;
         &lt;xsl:value-of select="$GREATERTHAN"/&gt;&lt;xsl:value-of select="$GREATERTHAN"/&gt;
         &lt;xsl:text&gt; &lt;/xsl:text&gt;&lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:secondOperand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:andOp | xqx:orOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:apply-templates select="xqx:firstOperand"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:andOp"&gt;&lt;xsl:text&gt; and &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:orOp"&gt;&lt;xsl:text&gt; or &lt;/xsl:text&gt;&lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:secondOperand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:unionOp | xqx:intersectOp | xqx:exceptOp"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
     &lt;xsl:apply-templates select="xqx:firstOperand"/&gt;
     &lt;xsl:choose&gt;
       &lt;xsl:when test="self::xqx:unionOp"&gt;&lt;xsl:text&gt; union &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:intersectOp"&gt;&lt;xsl:text&gt; intersect &lt;/xsl:text&gt;&lt;/xsl:when&gt;
       &lt;xsl:when test="self::xqx:exceptOp"&gt;&lt;xsl:text&gt; except &lt;/xsl:text&gt;&lt;/xsl:when&gt;
     &lt;/xsl:choose&gt;
    &lt;xsl:apply-templates select="xqx:secondOperand"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:sequenceExpr"&gt;
    &lt;xsl:for-each select="."&gt;
      &lt;xsl:call-template name="parenthesizedList"&gt;
        &lt;xsl:with-param name="delimiter" select="$COMMA_NEWLINE"/&gt;
      &lt;/xsl:call-template&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:rangeSequenceExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:startExpr"/&gt;
    &lt;xsl:value-of select="$TO"/&gt;
    &lt;xsl:apply-templates select="xqx:endExpr"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:forClause"&gt;
    &lt;xsl:text&gt; for &lt;/xsl:text&gt;
    &lt;xsl:call-template name="commaSeparatedList"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="xqx:forClauseItem"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="xqx:forExpr"&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
    &lt;xsl:text&gt;    in &lt;/xsl:text&gt;
        &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:letClause"&gt;
    &lt;xsl:text&gt; let &lt;/xsl:text&gt;
    &lt;xsl:call-template name="commaSeparatedList"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="xqx:letClauseItem"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="xqx:letExpr"&gt;
    &lt;xsl:value-of select="$ASSIGN"/&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:returnClause"&gt;
    &lt;xsl:text&gt; return &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:whereClause"&gt;
    &lt;xsl:text&gt; where &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:collation"&gt;
    &lt;xsl:text&gt; collation &lt;/xsl:text&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item"&gt;
        &lt;xsl:value-of select="."/&gt;
      &lt;/xsl:with-param&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:emptyOrderingMode"&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:orderingKind"&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:orderModifier"&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:orderBySpec"&gt;
    &lt;xsl:apply-templates select="xqx:orderByExpr"/&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:apply-templates select="xqx:orderModifier"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:orderByClause"&gt;
    &lt;xsl:if test="xqx:stable"&gt;
      &lt;xsl:text&gt; stable&lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:text&gt; order by &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:orderBySpec[1]"/&gt;
    &lt;xsl:for-each select="xqx:orderBySpec[position() &gt; 1]"&gt;
      &lt;xsl:value-of select="$COMMA_SPACE"/&gt;
      &lt;xsl:apply-templates select="."/&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;


&lt;!-- Surrounding FLWOR expressions with parentheses completes the set --&gt;
  &lt;xsl:template match="xqx:flworExpr"&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:ifThenElseExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:text&gt; if &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:ifClause"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
    &lt;xsl:text&gt; then &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:thenClause"/&gt;
    &lt;xsl:text&gt; else &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:elseClause"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:positionalVariableBinding"&gt;
    &lt;xsl:text&gt; at &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$DOLLAR"/&gt;
    &lt;xsl:if test="@xqx:prefix"&gt;
      &lt;xsl:value-of select="@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:variableBinding"&gt;
    &lt;xsl:value-of select="$DOLLAR"/&gt;
    &lt;xsl:if test="@xqx:prefix"&gt;
      &lt;xsl:value-of select="@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="."/&gt;
    &lt;xsl:if test="parent::xqx:typeswitchExprCaseClause"&gt;
      &lt;xsl:text&gt; as &lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:typedVariableBinding" name="typedVariableBinding"&gt;
    &lt;xsl:value-of select="$DOLLAR"/&gt;
    &lt;xsl:apply-templates select="xqx:varName"/&gt;
    &lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:quantifiedExprInClause"&gt;
    &lt;xsl:apply-templates select="xqx:typedVariableBinding"/&gt;
    &lt;xsl:text&gt; in &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:sourceExpr"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:quantifiedExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:value-of select="xqx:quantifier"/&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:apply-templates select="xqx:quantifiedExprInClause[1]"/&gt;
    &lt;xsl:for-each select="xqx:quantifiedExprInClause[position() &gt; 1]"&gt;
      &lt;xsl:value-of select="$COMMA_SPACE"/&gt;
      &lt;xsl:apply-templates select="."/&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:text&gt; satisfies &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:predicateExpr"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:instanceOfExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:text&gt; instance of &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:sequenceType"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:castExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:text&gt; cast as &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:singleType"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:castableExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:text&gt; castable as &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:singleType"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:treatExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:text&gt; treat as &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:sequenceType"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:typeswitchExprCaseClause"&gt;
    &lt;xsl:text&gt; case &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:variableBinding"/&gt;
    &lt;xsl:apply-templates select="xqx:sequenceType"/&gt;
    &lt;xsl:text&gt; return &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:resultExpr"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:typeswitchExprDefaultClause"&gt;
    &lt;xsl:text&gt; default &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:variableBinding"/&gt;
    &lt;xsl:text&gt; return &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:resultExpr"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:typeswitchExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:text&gt;typeswitch&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
    &lt;xsl:apply-templates select="xqx:typeswitchExprCaseClause"/&gt;
    &lt;xsl:apply-templates select="xqx:typeswitchExprDefaultClause"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:validateExpr"&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:text&gt; validate &lt;/xsl:text&gt;
    &lt;xsl:value-of select="xqx:validationMode"/&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="xqx:argExpr"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:xpathAxis"&gt;
    &lt;xsl:value-of select="."/&gt;
    &lt;xsl:value-of select="$DOUBLE_COLON"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:predicates"&gt;
    &lt;xsl:for-each select="*"&gt;
      &lt;xsl:value-of select="$LBRACKET"/&gt;
      &lt;xsl:apply-templates select="."/&gt;
      &lt;xsl:value-of select="$RBRACKET"/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:star"&gt;
    &lt;xsl:value-of select="$STAR"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:Wildcard[*]"&gt;
    &lt;xsl:apply-templates select="*[1]"/&gt;
    &lt;xsl:if test="*[2]"&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
      &lt;xsl:apply-templates select="*[2]"/&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:Wildcard[not(*)]"&gt;
    &lt;xsl:value-of select="$STAR"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template name="simpleWildcard" match="xqx:simpleWildcard"&gt;
    &lt;xsl:apply-templates select="xqx:star"/&gt;
    &lt;xsl:apply-templates select="xqx:QName"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:textTest"&gt;
    &lt;xsl:text&gt;text()&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:commentTest"&gt;
    &lt;xsl:text&gt;comment()&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:anyKindTest"&gt;
    &lt;xsl:text&gt;node()&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:piTest"&gt;
    &lt;xsl:text&gt;processing-instruction&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:value-of select="*"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:documentTest"&gt;
    &lt;xsl:text&gt;document-node&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:nameTest"&gt;
    &lt;xsl:if test="@xqx:prefix"&gt;
      &lt;xsl:value-of select="@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:attributeTest"&gt;
    &lt;xsl:text&gt;attribute&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:for-each select="xqx:attributeName"&gt;
      &lt;xsl:call-template name="simpleWildcard"/&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:if test="xqx:typeName"&gt;
      &lt;xsl:value-of select="$COMMA"/&gt;
      &lt;xsl:apply-templates select="xqx:typeName"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:elementTest"&gt;
    &lt;xsl:text&gt;element&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:for-each select="xqx:elementName"&gt;
      &lt;xsl:call-template name="simpleWildcard"/&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:if test="xqx:typeName"&gt;
      &lt;xsl:value-of select="$COMMA"/&gt;
      &lt;xsl:apply-templates select="xqx:typeName"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:if test="xqx:nillable"&gt;
      &lt;xsl:value-of select="$QUESTIONMARK"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:schemaElementTest"&gt;
    &lt;xsl:text&gt;schema-element&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:if test="@xqx:prefix"&gt;
      &lt;xsl:value-of select="@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="."/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:schemaAttributeTest"&gt;
    &lt;xsl:text&gt;schema-attribute&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LPAREN"/&gt;
    &lt;xsl:if test="@xqx:prefix"&gt;
      &lt;xsl:value-of select="@xqx:prefix"/&gt;
      &lt;xsl:value-of select="$COLON"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="."/&gt;
    &lt;xsl:value-of select="$RPAREN"/&gt;
  &lt;/xsl:template&gt;


  &lt;!-- rewrote test expression per Bugzilla Bug #2523 --&gt;
  &lt;xsl:template match="xqx:stepExpr"&gt;
    &lt;xsl:if test="preceding-sibling::xqx:stepExpr"&gt;
      &lt;xsl:value-of select="$SLASH"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


  &lt;!-- deleted xqx:parenthesizedExpr per Bugzilla Bug #4963 --&gt;

  &lt;xsl:template match="xqx:filterExpr"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;


  &lt;!-- rewrote pathExpr template per Bugzilla Bug #2523 --&gt;
  &lt;xsl:template match="xqx:pathExpr"&gt;
    &lt;xsl:apply-templates select="xqx:rootExpr | xqx:stepExpr"/&gt;
  &lt;/xsl:template&gt;


  &lt;!-- To resolve Bugzilla bug #3446, we now escape NL (#xA) and TAB (#x9)
       characters in attribute values --&gt;
  &lt;xsl:template match="xqx:attributeConstructor"&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:apply-templates select="xqx:attributeName"/&gt;
    &lt;xsl:value-of select="$EQUAL"/&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="xqx:attributeValue"&gt;
        &lt;xsl:call-template name="globalReplace"&gt;
          &lt;xsl:with-param name="stringToBeFixed"&gt;
            &lt;xsl:call-template name="globalReplace"&gt;
              &lt;xsl:with-param name="stringToBeFixed"&gt;
                &lt;xsl:call-template name="quote"&gt;
                  &lt;xsl:with-param name="item"&gt;
                    &lt;xsl:call-template name="globalReplace"&gt;
                      &lt;xsl:with-param name="stringToBeFixed"&gt;
                        &lt;xsl:call-template name="globalReplace"&gt;
                          &lt;xsl:with-param name="stringToBeFixed"&gt;
                            &lt;xsl:value-of select="xqx:attributeValue"/&gt;
                          &lt;/xsl:with-param&gt;
                          &lt;xsl:with-param name="toBeReplaced"&gt;&lt;xsl:text&gt;{&lt;/xsl:text&gt;&lt;/xsl:with-param&gt;
                          &lt;xsl:with-param name="replacement"&gt;&lt;xsl:text&gt;{{&lt;/xsl:text&gt;&lt;/xsl:with-param&gt;
                        &lt;/xsl:call-template&gt;
                      &lt;/xsl:with-param&gt;
                      &lt;xsl:with-param name="toBeReplaced"&gt;&lt;xsl:text&gt;}&lt;/xsl:text&gt;&lt;/xsl:with-param&gt;
                      &lt;xsl:with-param name="replacement"&gt;&lt;xsl:text&gt;}}&lt;/xsl:text&gt;&lt;/xsl:with-param&gt;
                    &lt;/xsl:call-template&gt;
                  &lt;/xsl:with-param&gt;
                &lt;/xsl:call-template&gt;
              &lt;/xsl:with-param&gt;
              &lt;xsl:with-param name="toBeReplaced" select="'&amp;#xA;'"/&gt;
              &lt;xsl:with-param name="replacement"&gt;&amp;amp;#xA;&lt;/xsl:with-param&gt;
            &lt;/xsl:call-template&gt;
          &lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="toBeReplaced" select="'&amp;#x9;'"/&gt;
          &lt;xsl:with-param name="replacement"&gt;&amp;amp;#x9;&lt;/xsl:with-param&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:value-of select="$DOUBLEQUOTE"/&gt;
        &lt;xsl:for-each select="./xqx:attributeValueExpr/xqx:*"&gt;
          &lt;xsl:value-of select="$LBRACE"/&gt;
            &lt;xsl:apply-templates select="."/&gt;
          &lt;xsl:value-of select="$RBRACE"/&gt;
        &lt;/xsl:for-each&gt;
        &lt;xsl:value-of select="$DOUBLEQUOTE"/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;


  &lt;!-- replaced xqx:namespaceDeclaration per Bugzilla Bug #5343 --&gt;
  &lt;xsl:template match="xqx:namespaceDeclaration"&gt;
    &lt;xsl:text&gt; xmlns&lt;/xsl:text&gt;
    &lt;xsl:if test="xqx:prefix"&gt;
      &lt;xsl:text&gt;:&lt;/xsl:text&gt;
      &lt;xsl:value-of select="xqx:prefix"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:value-of select="$EQUAL"/&gt;
    &lt;xsl:call-template name="quote"&gt;
<span>      &lt;xsl:with-param name="item"&gt;
        &lt;xsl:call-template name="globalReplace"&gt;
          &lt;xsl:with-param name="stringToBeFixed"&gt;
            &lt;xsl:call-template name="globalReplace"&gt;
              &lt;xsl:with-param name="stringToBeFixed"&gt;
                &lt;xsl:value-of select="xqx:uri"/&gt;
              &lt;/xsl:with-param&gt;
              &lt;xsl:with-param name="toBeReplaced"&gt;
                &lt;xsl:text&gt;{&lt;/xsl:text&gt;
              &lt;/xsl:with-param&gt;
              &lt;xsl:with-param name="replacement"&gt;
                &lt;xsl:text&gt;{{&lt;/xsl:text&gt;
              &lt;/xsl:with-param&gt;
            &lt;/xsl:call-template&gt;
          &lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="toBeReplaced"&gt;
            &lt;xsl:text&gt;}&lt;/xsl:text&gt;
          &lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="replacement"&gt;
            &lt;xsl:text&gt;}}&lt;/xsl:text&gt;
          &lt;/xsl:with-param&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:with-param&gt;
</span>    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:attributeList"&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:elementContent"&gt;
    &lt;xsl:for-each select="*"&gt;
      &lt;xsl:if test="not(self::xqx:elementConstructor)"&gt;
         &lt;xsl:value-of select="$LBRACE"/&gt;
      &lt;/xsl:if&gt;
      &lt;xsl:apply-templates select="."/&gt;
      &lt;xsl:if test="not(self::xqx:elementConstructor)"&gt;
         &lt;xsl:value-of select="$RBRACE"/&gt;
      &lt;/xsl:if&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:elementConstructor"&gt;
    &lt;xsl:value-of select="$LESSTHAN"/&gt;
    &lt;xsl:apply-templates select="xqx:tagName"/&gt;
    &lt;xsl:apply-templates select="xqx:attributeList"/&gt;
    &lt;xsl:value-of select="$GREATERTHAN"/&gt;
    &lt;xsl:apply-templates select="xqx:elementContent"/&gt;
    &lt;xsl:value-of select="$LESSTHAN"/&gt;
    &lt;xsl:value-of select="$SLASH"/&gt;
    &lt;xsl:apply-templates select="xqx:tagName"/&gt;
    &lt;xsl:value-of select="$GREATERTHAN"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:tagNameExpr"&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:computedElementConstructor"&gt;
    &lt;xsl:text&gt; element &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:tagName"/&gt;
    &lt;xsl:apply-templates select="xqx:tagNameExpr"/&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="xqx:contentExpr"/&gt;     
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:computedAttributeConstructor"&gt;
    &lt;xsl:text&gt; attribute &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:tagName"/&gt;
    &lt;xsl:apply-templates select="xqx:tagNameExpr"/&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="xqx:valueExpr"/&gt;     
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:computedDocumentConstructor"&gt;
    &lt;xsl:text&gt; document {&lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:text&gt; }&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:computedTextConstructor"&gt;
    &lt;xsl:text&gt; text&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:computedCommentConstructor"&gt;
    &lt;xsl:text&gt; comment&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:piTargetExpr"&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


&lt;!-- Move value braces into computedPIConstructor template from this template, Bugzilla bug #3442 --&gt;
  &lt;xsl:template match="xqx:piValueExpr"&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


&lt;!-- Move value braces into this template from piValueExpr template, Bugzilla bug #3442 --&gt;
  &lt;xsl:template match="xqx:computedPIConstructor"&gt;
    &lt;xsl:text&gt; processing-instruction &lt;/xsl:text&gt;
    &lt;xsl:value-of select="xqx:piTarget"/&gt;
    &lt;xsl:apply-templates select="xqx:piTargetExpr"/&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:apply-templates select="xqx:piValueExpr"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:unorderedExpr"&gt;
    &lt;xsl:text&gt; unordered&lt;/xsl:text&gt;
        &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:orderedExpr"&gt;
    &lt;xsl:text&gt; ordered&lt;/xsl:text&gt;
        &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:versionDecl"&gt;
    &lt;xsl:text&gt; xquery version &lt;/xsl:text&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:version"/&gt;
    &lt;/xsl:call-template&gt;
    &lt;xsl:value-of select="$SEPARATOR"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:namespaceDecl"&gt;
    &lt;xsl:text&gt;declare namespace &lt;/xsl:text&gt;
    &lt;xsl:value-of select="xqx:prefix"/&gt;
    &lt;xsl:value-of select="$EQUAL"/&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:uri"/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:defaultNamespaceDecl"&gt;
    &lt;xsl:text&gt;declare default &lt;/xsl:text&gt;
    &lt;xsl:value-of select="xqx:defaultNamespaceCategory"/&gt;
    &lt;xsl:text&gt; namespace &lt;/xsl:text&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:uri"/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:defaultCollationDecl"&gt;
    &lt;xsl:text&gt;declare default collation &lt;/xsl:text&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="."/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:baseUriDecl"&gt;
    &lt;xsl:text&gt;declare base-uri &lt;/xsl:text&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="."/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="xqx:constructionDecl"&gt;
    &lt;xsl:text&gt;declare construction &lt;/xsl:text&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:orderingModeDecl"&gt;
    &lt;xsl:text&gt;declare ordering &lt;/xsl:text&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:emptyOrderingDecl"&gt;
    &lt;xsl:text&gt;declare default order &lt;/xsl:text&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:copyNamespacesDecl"&gt;
    &lt;xsl:text&gt;declare copy-namespaces &lt;/xsl:text&gt;
    &lt;xsl:value-of select="xqx:preserveMode"/&gt;
    &lt;xsl:value-of select="$COMMA"/&gt;
    &lt;xsl:value-of select="xqx:inheritMode"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:optionDecl"&gt;
    &lt;xsl:text&gt;declare option &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:optionName"/&gt;
    &lt;xsl:value-of select="$SPACE"/&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:optionContents"/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:voidSequenceType"&gt;
    &lt;xsl:text&gt;empty-sequence()&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:occurrenceIndicator"&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:anyItemType"&gt;
    &lt;xsl:text&gt;item()&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:sequenceType"&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:singleType"&gt;
    &lt;xsl:apply-templates select="xqx:atomicType"/&gt;
    &lt;xsl:if test="xqx:optional"&gt;
      &lt;xsl:text&gt;?&lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:typeDeclaration"&gt;
    &lt;xsl:text&gt; as &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:varDecl"&gt;
    &lt;xsl:text&gt;declare variable &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$DOLLAR"/&gt;
    &lt;xsl:apply-templates select="xqx:varName"/&gt;
    &lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
    &lt;xsl:if test="xqx:external"&gt;
      &lt;xsl:text&gt; external &lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:if test="xqx:varValue"&gt;
      &lt;xsl:value-of select="$ASSIGN"/&gt;
      &lt;xsl:apply-templates select="xqx:varValue"/&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;


&lt;!-- Part of fix for Bugzilla bug #3520 --&gt;
  &lt;xsl:template match="xqx:targetLocation"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="position()=1"&gt; at &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;,&amp;#xD;  &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="."/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;


&lt;!-- Modified to fix Bugzilla bug #3520 --&gt;
  &lt;xsl:template match="xqx:schemaImport"&gt;
    &lt;xsl:text&gt; import schema &lt;/xsl:text&gt;
    &lt;xsl:if test="xqx:defaultElementNamespace"&gt;
      &lt;xsl:text&gt; default element namespace &lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:if test="xqx:namespacePrefix"&gt;
      &lt;xsl:text&gt; namespace &lt;/xsl:text&gt;
      &lt;xsl:value-of select="xqx:namespacePrefix"/&gt;
      &lt;xsl:value-of select="$EQUAL"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:targetNamespace"/&gt;
    &lt;/xsl:call-template&gt;
    &lt;xsl:apply-templates select="xqx:targetLocation"/&gt;
  &lt;/xsl:template&gt;


&lt;!-- Modified to fix Bugzilla bug #3520 --&gt;
  &lt;xsl:template match="xqx:moduleImport"&gt;
    &lt;xsl:text&gt; import module &lt;/xsl:text&gt;
    &lt;xsl:if test="xqx:namespacePrefix"&gt;
      &lt;xsl:text&gt; namespace &lt;/xsl:text&gt;
      &lt;xsl:value-of select="xqx:namespacePrefix"/&gt;
      &lt;xsl:value-of select="$EQUAL"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:targetNamespace"/&gt;
    &lt;/xsl:call-template&gt;
    &lt;xsl:apply-templates select="xqx:targetLocation"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:param"&gt;
    &lt;xsl:value-of select="$DOLLAR"/&gt;
    &lt;xsl:apply-templates select="xqx:varName"/&gt;
    &lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:paramList"&gt;
    &lt;xsl:call-template name="parenthesizedList"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:functionBody"&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
    &lt;xsl:value-of select="$LBRACE"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
    &lt;xsl:apply-templates/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
    &lt;xsl:value-of select="$RBRACE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:functionDecl"&gt;
    &lt;xsl:text&gt;declare function &lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="xqx:functionName"/&gt;
    &lt;xsl:apply-templates select="xqx:paramList"/&gt;
    &lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
    &lt;xsl:apply-templates select="xqx:functionBody"/&gt;
    &lt;xsl:if test="xqx:externalDefinition"&gt;
      &lt;xsl:text&gt; external &lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:queryBody"&gt;
    &lt;xsl:apply-templates select="*"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="xqx:moduleDecl"&gt;
    &lt;xsl:text&gt; module namespace &lt;/xsl:text&gt;
    &lt;xsl:value-of select="xqx:prefix"/&gt;
    &lt;xsl:value-of select="$EQUAL"/&gt;
    &lt;xsl:call-template name="quote"&gt;
      &lt;xsl:with-param name="item" select="xqx:uri" /&gt;
    &lt;/xsl:call-template&gt;
    &lt;xsl:value-of select="$SEPARATOR"/&gt;
    &lt;xsl:value-of select="$NEWLINE"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:prolog"&gt;
    &lt;xsl:for-each select="*"&gt;
      &lt;xsl:apply-templates select="."/&gt;
      &lt;xsl:value-of select="$SEPARATOR"/&gt;
      &lt;xsl:value-of select="$NEWLINE"/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:libraryModule"&gt;
    &lt;xsl:apply-templates select="xqx:moduleDecl"/&gt;
    &lt;xsl:apply-templates select="xqx:prolog"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:mainModule"&gt;
    &lt;xsl:apply-templates select="xqx:prolog"/&gt;
    &lt;xsl:apply-templates select="xqx:queryBody"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="xqx:module" priority="2"&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/xsl:template&gt;


  &lt;xsl:template match="/xqx:*"&gt;
   &lt;xsl:message terminate="yes"&gt;Incorrect XQueryX:
      The only top-level element permitted is xqx:module&lt;/xsl:message&gt;
  &lt;/xsl:template&gt;


&lt;/xsl:stylesheet&gt;
</pre></div>
</div>
<div class="xqueryx">
<div class="div1">
<h2><a id="xqueryx-id-mime-type" name="xqueryx-id-mime-type"></a>C
The <code>application/xquery+xml</code> Media Type</h2>
<p>This Appendix specifies the media type for XQueryX Version 1.0.
XQueryX is the XML syntax of a language, XQuery, for querying over
data from XML data sources, as specified in <a href=
"#xquery">[XQuery 1.0: An XML Query Language (Second
Edition)]</a>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Specification of media types is described in <a href=
"#RFC3023">[RFC 3023]</a>.</p>
</div>
<div class="div2">
<h3><a id="xqueryx-mime-introduction" name=
"xqueryx-mime-introduction"></a>C.1 Introduction</h3>
<p>This document, together with its normative references, defines
the XML syntax for the XML Query language XQuery Version 1.0. This
Appendix specifies the <code>application/xquery+xml</code> media
type, which is intended to be used for transmitting queries
expressed in the XQueryX syntax.</p>
<p>This media type is being submitted to the IESG for review,
approval, and registration with IANA.</p>
<p>This document was prepared by members of the W3C XML Query
Working Group. Please send comments to public-qt-comments@w3.org, a
public mailing list with archives at <a href=
"http://lists.w3.org/Archives/Public/public-qt-comments">http://lists.w3.org/Archives/Public/public-qt-comments</a>.</p>
</div>
<div class="div2">
<h3><a id="xqueryx-mime-registration" name=
"xqueryx-mime-registration"></a>C.2 Registration of MIME Media Type
<code>application/xquery+xml</code></h3>
<p>MIME media type name: <code>application</code></p>
<p>MIME subtype name: <code>xquery+xml</code></p>
<p>Required parameters: none</p>
<p>Optional parameters: <code>charset</code></p>
<p>This parameter has identical semantics to the
<code>charset</code> parameter of the <code>application/xml</code>
media type as specified in [RFC 3023].</p>
<div class="div3">
<h4><a id="xqueryx-mime-encoding" name=
"xqueryx-mime-encoding"></a>C.2.1 Encoding Considerations</h4>
<p>By virtue of XQueryX content being XML, it has the same
considerations when sent as "<code>application/xquery+xml</code>"
as does XML. See [RFC 3023], section 3.2.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-security" name=
"xqueryx-mime-security"></a>C.2.2 Security Considerations</h4>
<p>Queries written in XQuery may cause arbitrary URIs or IRIs to be
dereferenced. Therefore, the security issues of [RFC3987] Section 8
should be considered. In addition, the contents of resources
identified by <code>file:</code> URIs can in some cases be
accessed, processed and returned as results. XQuery expressions can
invoke any of the functions defined in XQuery 1.0 and XPath 2.0
Functions and Operators, including <code>file-exists()</code>; a
<code>doc()</code> function also allows local filesystem probes as
well as access to any URI-defined resource accessible from the
system evaluating the XQuery expression.</p>
<p>XQuery is a full declarative programming language, and supports
user-defined functions, external function libraries (modules)
referenced by URI, and system-specific "native" functions.</p>
<p>Arbitrary recursion is possible, as is arbitrarily large memory
usage, and implementations may place limits on CPU and memory
usage, as well as restricting access to system-defined
functions.</p>
<p>The XML Query Working group is working on a facility to allow
XQuery expressions to be used to create and update persistent data.
Untrusted queries should not be given write access to data.</p>
<p>Furthermore, because the XQuery language permits extensions, it
is possible that application/xquery may describe content that has
security implications beyond those described here.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-interoperability" name=
"xqueryx-mime-interoperability"></a>C.2.3 Interoperability
Considerations</h4>
<p>See <a href=
"http://www.w3.org/TR/xquery/#id-xquery-conformance">Section 5
Conformance</a><sup><small>XQ</small></sup>.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-pubspec" name=
"xqueryx-mime-pubspec"></a>C.2.4 Published specification</h4>
<p>This media type registration is for XQueryX documents as
described by the XQueryX 1.0 specification, which is located at
<a href=
"http://www.w3.org/TR/xqueryx/">http://www.w3.org/TR/xqueryx/</a>.
It is also appropriate to use this media type with later versions
of the XQueryX language.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-applications" name=
"xqueryx-mime-applications"></a>C.2.5 Applications That Use This
Media Type</h4>
<p>The public <a href="http://www.w3.org/XML/Query/">XQuery Web
page</a> lists more than two dozen implementations of the XQuery
language, both proprietary and open source. Some of these are known
to support XQueryX.</p>
<p>This new media type is being registered to allow for deployment
of XQueryX on the World Wide Web.</p>
<p>There is no experimental, vendor specific, or personal tree
predecessor to "application/xquery+xml", reflecting the fact that
no applications currently recognize it. This new type is being
registered in order to allow for the expected deployment of XQueryX
1.0 on the World Wide Web, as a first class XML application.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-additional" name=
"xqueryx-mime-additional"></a>C.2.6 Additional Information</h4>
<div class="div4">
<h5><a id="xqueryx-mime-recognizing" name=
"xqueryx-mime-recognizing"></a>C.2.6.1 Recognizing XQuery Files
("Magic Numbers")</h5>
<p>Although no byte sequences can be counted on to consistently
identify XQueryX, XQueryX documents will have the sequence
"http://www.w3.org/2005/XQueryX" to identify the XQueryX namespace.
This sequence will normally be found in a namespace attribute of
the first element in the document.</p>
</div>
<div class="div4">
<h5><a id="xqueryx-mime-extensions" name=
"xqueryx-mime-extensions"></a>C.2.6.2 File Extensions</h5>
<p>The most common file extension in use for XQueryX is
<code>.xqx</code>.</p>
</div>
<div class="div4">
<h5><a id="xqueryx-mime-macfiletype" name=
"xqueryx-mime-macfiletype"></a>C.2.6.3 Macintosh File Type
Code(s)</h5>
<p>The appropriate Macintosh file type code is
<code>TEXT</code>.</p>
</div>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-author" name=
"xqueryx-mime-author"></a>C.2.7 Person and Email Address to Contact
For Further Information</h4>
<p>Jim Melton, Oracle Corp., <a href=
"mailto:jim.melton@oracle.com">jim.melton@oracle.com</a></p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-intended-usage" name=
"xqueryx-mime-intended-usage"></a>C.2.8 Intended Usage</h4>
<p>COMMON</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-restrictions" name=
"xqueryx-mime-restrictions"></a>C.2.9 Restrictions on usage</h4>
<p>The intended usage of this media type is for interchange of
XQueryX expressions.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-owner" name="xqueryx-mime-owner"></a>C.2.10
Author/Change Controller</h4>
<p>XQuery was produced by, and is maintained by, the World Wide Web
Consortium's XML Query Working Group. The W3C has change control
over this specification.</p>
</div>
<div class="div3">
<h4><a id="xqueryx-mime-fragments" name=
"xqueryx-mime-fragments"></a>C.2.11 Fragment Identifiers</h4>
<p>For documents labeled as "<code>application/xquery+xml</code>",
the fragment identifier notation is exactly that for
"<code>application/xml</code>", as specified in [RFC 3023].</p>
</div>
</div>
</div>
</div>
<div class="div1">
<h2><a id="changelog" name="changelog"></a>D Changes since the
First Edition (Non-Normative)</h2>
<p>The changes made to this document, other than trivial editorial
changes, are described in detail in the <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html">Errata</a>
to the first edition. The rationale for each erratum is explained
in the corresponding Bugzilla database entry. The following table
summarizes the errata that have been applied.</p>
<table border="1" cellpadding="5" width="100%">
<thead>
<tr class="diff-add" title="Added for second edition">
<td>Erratum</td>
<td>Bugzilla</td>
<td>Category</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr class="diff-add" title="XQX.E1">
<td>Erratum <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E1">E1</a></td>
<td><a href=
"http://www.w3.org/Bugs/Public/show_bug.cgi?id=4924">Arguably
incorrect element definition in XQueryX's Schema.</a></td>
<td>Editorial.</td>
<td>The published XQueryX 1.0 schema defined many elements using
anonymous complex types. That made it infeasible to extend the
content model of those elements in other specifications that define
XQueryX extensions corresponding perhaps to XQuery extensions.
While conceptually simple, a number of changes were required to
ensure that all elements are defined using named complex
types.</td>
</tr>
<tr class="diff-add" title="XQX.E2 and XQX.E3">
<td>Errata <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E2">E2</a>
and <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E3">E3</a></td>
<td><a href=
"http://www.w3.org/Bugs/Public/show_bug.cgi?id=4963">Removed
element xqx:parenthesizedExpr used in example.</a></td>
<td>Editorial.</td>
<td>The XQueryX solution to Example 4 incorrectly contained an
&lt;xqx:parenthesizedExpr&gt; element. That element was changed to
an &lt;xqx:sequenceExpr&gt; element. The XSLT stylesheet in
Appendix B contained a template for the transformation of
&lt;xqx:parenthesizedExpr&gt; elements that was unnecessary and
confusing; that template was deleted.</td>
</tr>
<tr class="diff-add" title="XQX.E4">
<td>Erratum <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E4">E4</a></td>
<td><a href=
"http://www.w3.org/Bugs/Public/show_bug.cgi?id=5323">Bug in XQueryX
applet</a></td>
<td>Editorial.</td>
<td>The XQueryX 1.0 Recommendation linked to an obsolete version of
the XQuery 1.0 grammar applet. The proper link has now been
used.</td>
</tr>
<tr class="diff-add" title="XQX.E5">
<td>Erratum <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E5">E5</a></td>
<td><a href=
"http://www.w3.org/Bugs/Public/show_bug.cgi?id=5343">Problem with
{{ and }} in a Namespace Declaration Attribute</a></td>
<td>Editorial.</td>
<td>The XSLT stylsheet in Appendix B contained a template for the
transformation of &lt;xqx:namespaceDeclaration&gt; elements that
failed to correctly "escape" curly braces in the same manner as
does the template for the transformation of
&lt;xqx:attributeConstructor&gt; elements. That template has been
corrected.</td>
</tr>
<tr class="diff-add" title="XQX.E6">
<td>Erratum <a href=
"http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E6">E6</a></td>
<td><a href=
"http://www.w3.org/Bugs/Public/show_bug.cgi?id=6377">[XQX]
non-normative notes</a></td>
<td>Editorial.</td>
<td>Added text in <a href="#Introduction"><b>1 Introduction</b></a>
to clarify that Notes are non-normative.</td>
</tr>
<tr class="diff-add">
<td>(None)</td>
<td>(None)</td>
<td>Editorial</td>
<td>Corrected typographical error in MIME appendix ("XSLT" should
have been "XQueryX").</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>