CR-rdf-sparql-query-20070614 359 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345
<?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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta name="generator" content="Microsoft FrontPage 6.0" />
<meta name="generator" content="Emacs 22" />
<meta name="RCS-Id" content="$Id: Overview.html,v 1.5 2007/06/15 14:39:59 eric Exp $" />
<title>SPARQL Query Language for RDF</title>
<style type="text/css">
/*<![CDATA[*/
pre.data	{ border: thin solid #88AA88;
                  background-color: #E8F0E8;
                  margin: 1em 4em 1em 0em ; }

/*]]>*/
</style>
<link rel="stylesheet" type="text/css" href="local.css" />
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-CR" />
</head>

<body>

<div class="head">
  <p><a href="http://www.w3.org/">
  <img src="http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width="72" /></a></p>

  <h1 id="main">SPARQL Query Language for RDF</h1>
  <h2>W3C Candidate Recommendation 14 June 2007</h2>
  <dl>
	<dt>This version:</dt>
	<dd><a href="http://www.w3.org/TR/2007/CR-rdf-sparql-query-20070614/">http://www.w3.org/TR/2007/CR-rdf-sparql-query-20070614/</a></dd>
	<dt>Latest version:</dt>
	<dd><a href="http://www.w3.org/TR/rdf-sparql-query/">http://www.w3.org/TR/rdf-sparql-query/</a></dd>
	<dt>Previous version:</dt>
	<dd><a href="http://www.w3.org/TR/2007/WD-rdf-sparql-query-20070326/">http://www.w3.org/TR/2007/WD-rdf-sparql-query-20070326/</a></dd>
    <dt>Editors:</dt>
    <dd>Eric Prud&#39;hommeaux, W3C &lt;<a href="mailto:eric@w3.org">eric@w3.org</a>&gt;<br />
    Andy Seaborne, Hewlett-Packard Laboratories, Bristol &lt;<a href="mailto:andy.seaborne@hp.com">andy.seaborne@hp.com</a>&gt;</dd>
  </dl>
<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> &#169; 2006-2007 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>&#174;</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.org/"><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 title="Separator for header" />
<div>
  <h2 class="notoc"><a id="abstract" name="abstract">Abstract</a></h2>
  <p>
    RDF is a directed, labeled graph data format for representing information 
    in the Web. This specification defines the syntax and semantics of the 
    SPARQL query language for RDF. SPARQL can be used to express queries 
    across diverse data sources, whether the data is stored natively as RDF or 
    viewed as RDF via middleware. SPARQL contains capabilities for querying 
    required and optional graph patterns along with their conjunctions and 
    disjunctions. SPARQL also supports extensible value testing and 
    constraining queries by source RDF graph. The results of SPARQL queries 
    can be results sets or RDF graphs.
  </p>

</div>
<div>
    <h2><a id="status" name="status">Status of This Document</a></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 June 2007 publication is a <a
     href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsCR">Candidate
  Recommendation</a>; it has been widely reviewed and satisfies the
  requirements documented in <b><i><a href=
  "http://www.w3.org/TR/rdf-dawg-uc/">RDF Data Access Use Cases and
  Requirements</a></i></b>; W3C publishes a Candidate
  Recommendation to gather implementation experience.</p>
 
  <p>The first release of this document was 12 Oct 2004
  and the <a href=
  "http://www.w3.org/2001/sw/DataAccess/">RDF Data Access Working
  Group</a> has made its best effort to address <a href=
  "http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/">comments
  received</a> since then, releasing several drafts and resolving a <a
  href="http://www.w3.org/2001/sw/DataAccess/issues">list of
  issues</a> meanwhile. The <a href="#chlog">change log</a> enumerates changes since the
  <a href="http://www.w3.org/TR/2007/WD-rdf-sparql-query-20070326/"
  >26 March 2007 Working Draft</a>. The design has stabilized and the Working Group intends to advance this
  specification to Proposed Recommendation
once the exit
  criteria below are met:</p>

  <ul id="exitcri">
    <li>A test suite gives reasonable coverage of
    the features of the query language.
    <p>Note that the working group has developed a <a
    href="http://www.w3.org/2001/sw/DataAccess/tests/r2">collection of
    query tests</a> in the past, and the group is currently working
    on approving these tests and migrating them to 
    <a href="http://www.w3.org/2001/sw/DataAccess/tests/data-r2/">a new location</a> to form the 
    basis of an implementation report. This work is still in progress.</p>
    </li>

    <li>Each identified SPARQL feature has at least two implementations.</li>
    <li>Relevant media types are registered:
    <ul>
      <li>The SPARQL Query Language for RDF
    specification introduces one new Internet Media Type. Review
    has been requested, but the types are not yet registered:
        <ul>
          <li>application/sparql-query: <a href=
          "http://www.alvestrand.no/pipermail/ietf-types/2005-November/000895.html">
          review request</a> of 24 Nov 2005</li>
        </ul>
    </li>
    </ul>
    </li>

    <li>Normative dependencies have been advanced to Proposed
    Recommendation status:
    <ul>
      <li><cite><a href="http://www.w3.org/TR/xpath-functions/">XQuery
      1.0 and XPath 2.0 Functions and Operators</a></cite></li>
    </ul>
    </li>
  </ul>

  <p>This specification will
  remain a Candidate Recommendation until at least 31 August
  2007.
  An <a href="http://www.w3.org/2001/sw/DataAccess/imp39">implementation
  report</a> is in progress.</p>

  <p>This specification contains two <a
  href="http://www.w3.org/2005/10/Process-20051014/tr#cfi">features
  at-risk</a> listed both here and where the features appear in the
  specification:</p>
  <ul>
    <li>The <a href="#modReduced"><code>REDUCED</code></a> feature</li>
    <li>The allowance of <a
    href="#rPN_LOCAL">leading
    digits in prefixed names</a></li>
  </ul>

  <p>Comments on this document should be sent to
  public-rdf-dawg-comments@w3.org, a mailing list with a <a href=
  "http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/">public
  archive</a>.</p>

    <p><em>Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</em></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 rel="disclosure" href="http://www.w3.org/2004/01/pp-impl/35463/status">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>
<hr />

<div class="toc">
  <h2><a id="contents" name="contents">Table of Contents</a></h2>
  
  <ul class="toc">
  
    <li class="tocline1"><a href="#introduction">1 Introduction</a> </li>
      <li class="tocline2"><a href="#docOutline">1.1 Document Outline</a>
      <ul class="toc">
        <li class="tocline2"><a href="#docConventions">1.2 Document Conventions</a>
        <ul class="toc">
          <li class="tocline2"><a href="#docNamespaces">1.2.1 Namespaces</a></li>
          <li class="tocline2"><a href="#docDataDesc">1.2.2 Data Descriptions</a></li>
          <li class="tocline2"><a href="#docResultDesc">1.2.3 Result Descriptions</a></li>
          <li class="tocline2"><a href="#docTerminology">1.2.4 Terminology</a></li>
        </ul>
      </li>
      </ul>
    </li>

    <li class="tocline1"><a href="#basicpatterns">2 Making Simple Queries</a> (Informative)
    <ul class="toc">
      <li class="tocline2"><a href="#WritingSimpleQueries">2.1 Writing a Simple Query</a></li>
      <li class="tocline2"><a href="#MultipleMatches">2.2 Multiple Matches</a></li>
      <li class="tocline2"><a href="#matchingRDFLiterals">2.3 Matching RDF Literals</a>
      <ul class="toc">
	<li class="tocline2"><a href="#matchLangTags">2.3.1 Matching Literals with Language Tags</a></li>
	<li class="tocline2"><a href="#matchNumber">2.3.2 Matching Literals with Numeric Types</a></li>
	<li class="tocline2"><a href="#matchArbDT">2.3.3 Matching Literals with Arbitrary Datatypes</a></li>
      </ul>
      </li>
      <li class="tocline2"><a href="#BlankNodesInResults">2.4 Blank Node Labels in Query Results</a></li>
      <li class="tocline2"><a href="#constructGraph">2.5 Building RDF Graphs</a></li>
    </ul>
    </li>

    <li class="tocline1"><a href="#termConstraint">3 RDF Term Constraints</a> (Informative)
    <ul class="toc">
      <li class="tocline2"><a href="#restrictString">3.1 Restricting the Value of Strings</a></li>
      <li class="tocline2"><a href="#restrictNumber">3.2 Restricting Numeric Values</a></li>
      <li class="tocline2"><a href="#otherTermConstraints">3.3 Other Term Constraints</a></li>
    </ul>
    </li>

    <li class="tocline1"><a href="#sparqlSyntax">4 SPARQL Syntax</a>
    <ul class="toc">
      <li class="tocline2"><a href="#syntaxTerms">4.1 RDF Term Syntax</a>
      <ul class="toc">
	<li><a href="#QSynIRI">4.1.1 Syntax for IRI</a></li>
	<li><a href="#QSynLiterals">4.1.2 Syntax for Literals</a></li>
	<li><a href="#QSynVariables">4.1.3 Syntax for Variables</a></li>
	<li><a href="#QSynBlankNodes">4.1.4 Syntax for Blank Nodes</a></li>
      </ul>
      </li>
      <li class="tocline2"><a href="#QSynTriples">4.2 Syntax for Triple Patterns</a>
      <ul class="toc">
	<li class="tocline2"><a href="#predObjLists">4.2.1 Predicate-Object Lists</a></li>
	<li class="tocline2"><a href="#objLists">4.2.2 Object Lists</a></li>
	<li class="tocline2"><a href="#collections">4.2.3 RDF Collections</a></li>
	<li class="tocline2"><a href="#abbrevRdfType">4.2.4 rdf:type</a></li>
      </ul>
      </li>
      
    </ul>
    </li>

    <li class="tocline1"><a href="#GraphPattern">5 Graph Patterns</a><ul class="toc">
    <li class="tocline2"><a href="#BasicGraphPatterns">5.1 Basic Graph Patterns</a>
    <ul class="toc">
      <li class="tocline2"><a href="#bgpBNodeLabels">5.1.1 Blank Node Labels</a></li>
      <li class="tocline2"><a href="#bgpExtend">5.1.2 Extending Basic Graph Pattern Matching</a></li>
    </ul>
    </li>
    <li class="tocline2"><a href="#GroupPatterns">5.2 Group Graph Patterns</a>
    <ul class="toc">
      <li class="tocline2"><a href="#emptyGroupPattern">5.2.1 Empty Group Pattern</a></li>
      <li class="tocline2"><a href="#scopeFilters">5.2.2 Scope of Filters</a></li>
      <li class="tocline2"><a href="#groupExamples">5.2.3 Group Graph Pattern Examples</a></li>
    </ul>
    </li>
    </ul>
    </li>

    <li class="tocline1"><a href="#optionals">6 Including Optional Values</a>
    <ul class="toc">
      <li class="tocline2"><a href="#OptionalMatching">6.1 Optional Pattern Matching</a></li>
      <li class="tocline2"><a href="#OptionalAndConstraints">6.2 Constraints in Optional Pattern Matching</a></li>
      <li class="tocline2"><a href="#MultipleOptionals">6.3 Multiple Optional Graph Patterns</a></li>
    </ul>
    </li>
    
    <li class="tocline1"><a href="#alternatives">7 Matching Alternatives</a></li>
    
    <li class="tocline1"><a href="#rdfDataset">8 RDF Dataset</a>
    <ul class="toc">
      <li class="tocline2"><a href="#exampleDatasets">8.1 Examples of RDF Datasets</a></li>
      <li class="tocline2"><a href="#specifyingDataset">8.2 Specifying RDF Datasets</a>
      <ul class="toc">
        <li class="tocline2"><a href="#unnamedGraph">8.2.1 Specifying the default Graph</a></li>
        <li class="tocline2"><a href="#namedGraphs">8.2.2 Specifying Named Graphs</a></li>
        <li class="tocline2"><a href="#specDataset">8.2.3 Combining FROM and FROM NAMED</a></li>
      </ul></li>
      <li class="tocline2"><a href="#queryDataset">8.3 Querying the Dataset</a>
      <ul class="toc">
        <li class="tocline2"><a href="#accessByLabel">8.3.1 Accessing Graph Names</a></li>
        <li class="tocline2"><a href="#restrictByLabel">8.3.2 Restricting by Graph IRI</a></li>
        <li class="tocline2"><a href="#restrictInQuery">8.3.3 Restricting possible Graph IRIs</a></li>
        <li class="tocline2"><a href="#namedAndDefaultGraph">8.3.4 Named and Default Graphs</a></li>
      </ul></li>
    </ul>
    </li>
    
    <li class="tocline1"><a href="#solutionModifiers">9 Solution Sequences and Modifiers</a>
    <ul class="toc">
      <li class="tocline2"><a href="#modOrderBy">9.1 ORDER BY</a></li>
      <li class="tocline2"><a href="#modProjection">9.2 Projection</a></li>
      <li class="tocline2"><a href="#modDuplicates">9.3 Duplicate Solutions</a><ul class="toc">
	<li class="tocline2"><a href="#modDistinct">9.3.1 DISTINCT</a></li>
	<li class="tocline2"><a href="#modReduced">9.3.2 REDUCED</a></li>
      </ul></li>
      <li class="tocline2"><a href="#modOffset">9.4 OFFSET</a></li>
      <li class="tocline2"><a href="#modResultLimit">9.5 LIMIT</a></li>
    </ul>
    </li>

    <li class="tocline1"><a href="#QueryForms">10&nbsp; Query forms</a>
    <ul class="toc">
      <li class="tocline2"><a href="#select">10.1 SELECT</a></li>
      <li class="tocline2"><a href="#construct">10.2 CONSTRUCT</a><ul class="toc">
	  <li class="tocline2"><a href="#tempatesWithBNodes">10.2.1 Templates with Blank Nodes</a></li>
      <li class="tocline2"><a href="#accessingRdfGraphs">10.2.2 Accessing Graphs in the RDF Dataset</a></li>
      <li class="tocline2"><a href="#SolModandCONSTRUCT">10.2.3 Solution Modifiers and CONSTRUCT</a></li>
    </ul>
	</li>
    <li class="tocline2"><a href="#ask">10.3 ASK</a></li>
    <li class="tocline2"><a href="#describe">10.4 DESCRIBE</a> (Informative)
    <ul class="toc">
	  <li class="tocline2"><a href="#explititURIs">10.4.1 Explicit IRIs</a></li>
	  <li class="tocline2"><a href="#identifyingResources">10.4.2 Identifying Resources</a></li>
	  <li class="tocline2"><a href="#descriptionsOfResources">10.4.3 Descriptions of Resources</a></li>
    </ul>
    </li>
  </ul>
  </li>
    
    <li class="tocline1"><a href="#tests">11 Testing Values</a>
    <ul class="toc">
      <li class="tocline2"><a href="#operandDataTypes">11.1 Operand 
      Data Types</a></li>
      <li class="tocline2"><a href="#evaluation">11.2 Filter Evaluation</a>
      <ul class="toc">
	<li class="tocline2"><a href="#invocation">11.2.1 Invocation</a></li>
	<li class="tocline2"><a href="#ebv">11.2.2 Effective Boolean Value</a></li>
      </ul>
      </li>
      <li class="tocline2"><a href="#OperatorMapping">11.3 Operator Mapping</a>
      <ul class="toc">
	<li class="tocline2"><a href="#operatorExtensibility">11.3.1 Operator 
	Extensibility</a></li>
      </ul>
      </li>
      <li class="tocline2"><a href="#SparqlOps">11.4 Operator Definitions</a>
      <ul class="toc">
	<li class="tocline2"><a href="#func-bound">11.4.1 <span class="sopTOC">
	bound</span></a></li>
	<li class="tocline2"><a href="#func-isIRI">11.4.2 <span class="sopTOC">
	isIRI</span></a></li>
	<li class="tocline2"><a href="#func-isBlank">11.4.3
	<span class="sopTOC">isBlank</span></a></li>
	<li class="tocline2"><a href="#func-isLiteral">11.4.4
	<span class="sopTOC">isLiteral</span></a></li>
	<li class="tocline2"><a href="#func-str">11.4.5 <span class="sopTOC">str</span></a></li>
	<li class="tocline2"><a href="#func-lang">11.4.6 <span class="sopTOC">
	lang</span></a></li>
	<li class="tocline2"><a href="#func-datatype">11.4.7
	<span class="sopTOC">datatype</span></a></li>
	<li class="tocline2"><a href="#func-logical-or">11.4.8
	<span class="sopTOC">logical-or</span></a></li>
	<li class="tocline2"><a href="#func-logical-and">11.4.9
	<span class="sopTOC">logical-and</span></a></li>
	<li class="tocline2"><a href="#func-RDFterm-equal">11.4.10
	<span class="sopTOC">RDFterm-equal</span></a></li>
	<li class="tocline2"><a href="#func-sameTerm">11.4.11
	<span class="sopTOC">sameTerm</span></a></li>
	<li class="tocline2"><a href="#func-langMatches">11.4.12
	<span class="sopTOC">langMatches</span></a></li>
	<li class="tocline2"><a href="#funcex-regex">11.4.13
	<span class="sopTOC">regex</span></a></li>
      </ul>
      </li>
      <li class="tocline2"><a href="#FunctionMapping">11.5 Constructor Functions</a></li>
      <li class="tocline2"><a href="#extensionFunctions">11.6 Extensible Value 
      Testing</a></li>
    </ul>
    </li>

    <li class="tocline1"><a href="#sparqlDefinition">12 Definition of SPARQL</a>
    <ul class="toc">
      <li class="tocline2"><a href="#initDefinitions">12.1 Initial Definitions</a>
      <ul class="toc">
        <li class="tocline2"><a href="#sparqlBasicTerms">12.1.1 RDF Terms</a></li>
        <li class="tocline2"><a href="#sparqlDataset">12.1.2 RDF Dataset</a></li>
        <li class="tocline2"><a href="#sparqlQueryVariables">12.1.3 Query Variables</a></li>
        <li class="tocline2"><a href="#sparqlTriplePatterns">12.1.4 Triple Patterns</a></li>
        <li class="tocline2"><a href="#sparqlBasicGraphPatterns">12.1.5 Basic Graph Patterns</a></li>
        <li class="tocline2"><a href="#sparqlSolutions">12.1.6 Solution Mappings</a></li>
        <li class="tocline2"><a href="#sparqlSolMod">12.1.7 Solution Sequence Modifiers</a></li>
      </ul>
      </li>

      <li class="tocline2"><a href="#sparqlQuery">12.2 SPARQL Query</a>
        <ul class="toc">
          <li class="tocline2"><a href="#convertGraphPattern">12.2.1 Converting Graph Patterns</a></li>
          <li class="tocline2"><a href="#sparqlAbsExamples">12.2.2 Examples of Mapped Graph Patterns</a></li>
          <li class="tocline2"><a href="#convertSolMod">12.2.3 Converting Solution Modifiers</a></li>
        </ul>
      </li>

      <li class="tocline2"><a href="#BasicGraphPattern">12.3 Basic Graph Patterns</a>
      <ul class="toc">
        <li class="tocline2"><a href="#BGPsparql">12.3.1 SPARQL Basic Graph Pattern Matching</a></li>
        <li class="tocline2"><a href="#BGPsparqlBNodes">12.3.2 Treatment of Blank Nodes</a></li>
      </ul>
      </li>
      <li class="tocline2"><a href="#sparqlAlgebra">12.4 SPARQL Algebra</a></li>
      <li class="tocline2"><a href="#sparqlAlgebraEval">12.5 SPARQL Evaluation Semantics</a></li>
      <li class="tocline2"><a href="#sparqlBGPExtend">12.6 Extending SPARQL Basic Graph Matching</a></li>
    </ul>
    </li>
  </ul>
</div>

<h3><a id="appendices" name="appendices">Appendices</a></h3>
<ul class="toc">
  <li class="tocline2"><a href="#grammar">A SPARQL Grammar</a><ul class="toc">
  <li class="tocline2"><a href="#queryString">A.1 SPARQL Query String References</a></li>
  <li class="tocline2"><a href="#codepointEscape">A.2 Codepoint Escape Sequences</a></li>
  <li class="tocline2"><a href="#whitespace">A.3 White Space</a></li>
  <li class="tocline2"><a href="#grammarComments">A.4 Comments</a></li>
  <li class="tocline2"><a href="#iriRefs">A.5 IRI References</a></li>
  <li class="tocline2"><a href="#grammarBNodeLabels">A.6 Blank Node Labels</a></li>
  <li class="tocline2"><a href="#grammarEscapes">A.7 Escape sequences in strings</a></li>
  <li class="tocline2"><a href="#sparqlGrammar">A.8 Grammar</a></li>
  </ul>
  </li>
  <li class="tocline2"><a href="#conformance">B Conformance</a></li>
  <li class="tocline2"><a href="#security">C Security Considerations</a> (Informative)</li>
  <li class="tocline2"><a href="#mediaType">D Internet Media Type, File Extension 
  and Macintosh File Type</a></li>
  <li class="tocline2"><a href="#references">E References</a></li>
  <li class="tocline2"><a href="#acknowledgements">F Acknowledgements</a> (Informative)</li>
  <li class="tocline2"><a href="#chlog">G Change Log</a></li>
</ul>
<hr />

<h2>1 <a id="introduction" name="introduction">Introduction</a></h2>

<p>
 RDF is a directed, labeled graph data format for representing information 
 in the Web. RDF is often used to represent, among other things, personal 
 information, social networks, metadata about digital artifacts, as well as 
 to provide a means of integration over disparate sources of information. 
 This specification defines the syntax and semantics of the SPARQL query 
 language for RDF.
</p>

<p>
  The SPARQL query language for RDF is designed to meet the use cases and requirements
  identified by the RDF Data Access Working Group in 
  <cite>
  <a href="http://www.w3.org/TR/rdf-dawg-uc/" class="inform">RDF Data Access Use 
  Cases and Requirements</a></cite> [<a href="#UCNR">UCNR</a>]. 
</p>

<p>
  The SPARQL query language is closely related to the following specifications:
</p>

<ul>
<li>The <a class="inform" href="http://www.w3.org/TR/rdf-sparql-protocol/">SPARQL Protocol 
  for RDF</a> [<a href="#SPROT">SPROT</a>] specification defines the remote protocol for issuing SPARQL queries and receiving the results.</li> 
<li>The <a class="inform" href="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL Query 
  Results XML Format</a> [<a href="#RESULTS">RESULTS</a>] specification defines an XML document format for representing the results of SPARQL SELECT and ASK queries.</li>
</ul>


<h3>1.1 <a id="docOutline" name="docOutline">Document Outline</a></h3>
<p>Unless otherwise noted in the section heading, all sections and appendices in this document are normative.</p>

<p>
This section of the document, <a href="#introduction">section 1</a>, introduces the SPARQL query 
language specification. It presents the organization of this specification 
document and the conventions used throughout the specification.
</p>

<p><a href="#basicpatterns">Section 2</a> of the specification introduces the SPARQL query language itself 
via a series of example queries and query results. <a href="#termConstraint">Section 3</a> continues 
the introduction of the SPARQL query language with more examples that 
demonstrate SPARQL's ability to express constraints on the RDF terms that 
appear in a query's results.</p>

<p><a href="#sparqlSyntax">Section 4</a> presents details of the SPARQL query language's syntax. It is a 
companion to the full grammar of the language and defines how grammatical 
constructs represent IRIs, blank nodes, literals, and variables. Section 4 
also defines the meaning of several grammatical constructs that serve as 
syntactic sugar for more verbose expressions.</p>

<p><a href="#GraphPattern">Section 5</a> introduces basic graph patterns and group graph patterns, the 
building blocks from which more complex SPARQL query patterns are 
constructed. Sections 6, 7, and 8 present constructs that combine SPARQL 
graph patterns into larger graph patterns. In particular, <a href="#optionals">Section 6</a> 
introduces the ability to make portions of a query optional; <a href="#alternatives">Section 7</a> 
introduces the ability to express the disjunction of alternative graph 
patterns; and <a href="#rdfDataset">Section 8</a> introduces the ability to constrain portions of a 
query to particular source graphs. Section 8 also presents SPARQL's 
mechanism for defining the source graphs for a query.</p>
 
<p><a href="#solutionModifiers">Section 9</a> defines the constructs that affect the solutions of a query by 
ordering, slicing, projecting, limiting, and removing duplicates from a 
sequence of solutions.</p>

<p><a href="#QueryForms">Section 10</a> defines the four types of SPARQL queries that produce results 
in different forms.</p>

<p><a href="#tests">Section 11</a> defines SPARQL's extensible value testing framework. It also 
presents the functions and operators that can be used to constrain the 
values that appear in a query's results.</p>

<p><a href="#sparqlDefinition">Section 12</a> is a formal definition of the evaluation of SPARQL graph 
patterns and solution modifiers.</p>

<p><a href="#grammar">Appendix A</a> contains the normative definition of the SPARQL query 
language's syntax, as given by a grammar expressed in EBNF notation.</p>




<h3>1.2 <a id="docConventions" name="docConventions">Document Conventions</a></h3>
<h4>1.2.1 <a id="docNamespaces" name="docNamespaces">Namespaces</a></h4>
<p>In this document, examples assume the following namespace prefix bindings unless 
otherwise stated:</p>
<div style="text-align: center;">
  <table style="border-collapse: collapse; border-color: #000000" border="1" cellpadding="5">
    <tr>
      <th>Prefix</th>
      <th>IRI</th>
    </tr>
    <tr>
      <td><code>rdf:</code></td>
      <td><code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code></td>
    </tr>
    <tr>
      <td><code>rdfs:</code></td>
      <td><code>http://www.w3.org/2000/01/rdf-schema#</code></td>
    </tr>
    <tr>
      <td><code>xsd:</code></td>
      <td><code>http://www.w3.org/2001/XMLSchema#</code></td>
    </tr>
    <tr>
      <td><code>fn:</code></td>
      <td><code>http://www.w3.org/2005/xpath-functions#</code></td>
    </tr>
  </table>
</div>
<h4>1.2.2 <a id="docDataDesc" name="docDataDesc">Data Descriptions</a></h4>
<p>This document uses the 
<a class="inform" href="http://www.dajobe.org/2004/01/turtle/">Turtle</a> [<a href="#TURTLE">TURTLE</a>]
data format to show each triple explicitly. Turtle allows IRIs to be abbreviated with prefixes:</p>
<pre class="data">
@prefix dc:   &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix :     &lt;http://example.org/book/&gt; .
:book1  dc:title  &quot;SPARQL Tutorial&quot; .
</pre>
<h4>1.2.3 <a id="docResultDesc" name="docResultDesc">Result Descriptions</a></h4>
<p>Result sets are illustrated in tabular form.
</p>
<div class="result">
  <table class="resultTable" id="table39">
    <tr>
      <th>x</th>
      <th>y</th>
      <th>z</th>
    </tr>
    <tr>
      <td>&quot;Alice&quot;</td>
      <td><code>&lt;http://example/a&gt;</code></td>
      <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
    </tr>
  </table>
</div>
<p>A 'binding' is a pair (<a href="#defn_QueryVariable">variable</a>,
<a href="#defn_RDFTerm">RDF term</a>). In this result set, there are three
variables:
<code>x</code>, <code>y</code> and <code>z</code> (shown as column headers). Each 
solution is shown as one row in the body of the table.&nbsp; Here, there is a single 
solution, in which variable <code>x</code> is bound to <code>&quot;Alice&quot;</code>, variable
<code>y</code> is bound to <code>&lt;http://example/a&gt;</code>, and variable <code>z</code> 
is not bound to an RDF term. Variables are not required to be bound in a 
solution.</p>

<h4>1.2.4 <a id="docTerminology" name="docTerminology">Terminology</a></h4>

  <p>The SPARQL language includes IRIs, a subset of RDF URI References that omits spaces. Note that all IRIs 
  in SPARQL queries are absolute; they may or may not include a fragment identifier [<a href=
  "#rfc3987">RFC3987</a>, section 3.1]. IRIs include URIs [<a href="#rfc3986">RFC3986</a>] and URLs. The abbreviated
  forms (<a href="#QSynIRI">relative IRIs and prefixed names</a>) in the SPARQL syntax are resolved to produce absolute
  IRIs.</p>
<p>The following terms are defined in
<a class="norm" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">RDF
  Concepts and Abstract Syntax</a> <a href="#CONCEPTS">[CONCEPTS]</a> and used 
in SPARQL:</p>

  <ul>
    <li><a class="type IRI" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-URI-reference">IRI</a> (corresponds to the Concepts and Abstract Syntax term "<code>RDF URI reference</code>")</li>
    <li><a class="type literal" href=    "http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">literal</a></li>
    <li><a class="type lexicalForm" href="http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">lexical form</a></li>
    <li><a class="type plainLiteral" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-plain-literal">plain literal</a></li>
    <li><a class="type langTag" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-language-identifier">language tag</a></li>
    <li><a class="type typedLiteral" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-typed-literal">typed literal</a></li>
    <li><a class="type datatypeIRI" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-datatype-URI">datatype IRI</a> (corresponds to the Concepts and Abstract Syntax term "<code>datatype URI</code>")</li>
    <li><a class="type bNode" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">blank node</a></li>
  </ul>

<h2>2 <a id="basicpatterns" name="basicpatterns">Making Simple Queries</a> (Informative)</h2>
<p>The SPARQL query language is based on matching graph patterns. Graph 
patterns contain triple patterns. Triple patterns are like RDF triples, but with the option 
of a query variables in place of <a href="#defn_RDFTerm">RDF terms</a> in the subject, 
predicate or object positions. Combining triple patterns gives a basic graph pattern, 
where an exact match to a graph is needed.</p>
<h3>2.1 <a id="WritingSimpleQueries" name="WritingSimpleQueries">Writing a Simple 
Query</a></h3>
<p>The example below shows a SPARQL query to find the title of a book from the 
given data graph. The query consists of two parts:
the <code>SELECT</code> clause identifies 
the variables to appear in the query results, and the <code>WHERE</code> clause 
provides the basic graph pattern to match against the data graph. The basic graph pattern in this example 
consists of a single triple pattern with a single variable (<code>?title</code>) in the object position.</p>
<div class="exampleGroup" id="foo">
  <p>Data:</p>
  <pre class="data">
&lt;http://example.org/book/book1&gt; &lt;http://purl.org/dc/elements/1.1/title&gt; &quot;SPARQL Tutorial&quot; .
</pre>
  <div class="queryGroup">
    <p>Query:</p>
    <pre class="query">
SELECT ?title
WHERE
{
  &lt;http://example.org/book/book1&gt; &lt;http://purl.org/dc/elements/1.1/title&gt; ?title .
}    
</pre>
    <p>This query, on the data above, has one solution:</p>
    <p>Query Result:</p>
    <div class="result">
      <table class="resultTable" id="table1">
        <tr>
          <th>title</th>
        </tr>
        <tr>
          <td>&quot;SPARQL Tutorial&quot;</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<h3>2.2 <a id="MultipleMatches" name="MultipleMatches">Multiple Matches</a></h3>
<p>The result of a query is a <a href="#defn_sparqlSolutionSequence">solution sequence</a>, corresponding to the ways in which 
the query's graph pattern matches the data. There may be 
zero, one or multiple solutions to a query.</p>
<p>Data:</p>
<div class="exampleGroup">
  <pre class="data">
@prefix foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name   &quot;Johnny Lee Outlaw&quot; .
_:a  foaf:mbox   &lt;mailto:jlow@example.com&gt; .
_:b  foaf:name   &quot;Peter Goodguy&quot; .
_:b  foaf:mbox   &lt;mailto:peter@example.org&gt; .
_:c  foaf:mbox   &lt;mailto:carol@example.org&gt; .
</pre>
  <p>Query:</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
WHERE
  { ?x foaf:name ?name .
    ?x foaf:mbox ?mbox }
</pre>
    <p>Query Result:</p>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>name</th>
          <th>mbox</th>
        </tr>
        <tr>
          <td>&quot;Johnny Lee Outlaw&quot;</td>
          <td>&lt;mailto:jlow@example.com&gt;</td>
        </tr>
        <tr>
          <td>&quot;Peter Goodguy&quot;</td>
          <td>&lt;mailto:peter@example.org&gt;</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>Each solution gives one way in which the selected variables can be bound 
to RDF terms so that the query pattern matches the data. The result set gives 
all the possible solutions. In the above example, 
the following two subsets of the data provided the two matches.</p>
<pre class="dataExcerpt untested">
 _:a foaf:name  &quot;Johnny Lee Outlaw&quot; .
 _:a foaf:box   &lt;mailto:jlow@example.com&gt; .
</pre>
<pre class="dataExcerpt untested">
 _:b foaf:name  &quot;Peter Goodguy&quot; .
 _:b foaf:box   &lt;mailto:peter@example.org&gt; .
</pre>
<p>This is a <a href="#BGPsparql">basic graph pattern match</a>; all the 
variables used in the query pattern must be bound in every solution.</p>

<h3>2.3 <a id="matchingRDFLiterals" name="matchingRDFLiterals">Matching RDF Literals</a></h3>
<p>The data below contains three RDF literals:</p>
<div class="exampleGroup">
  <pre class="data">
@prefix dt:   &lt;http://example.org/datatype#&gt; .
@prefix ns:   &lt;http://example.org/ns#&gt; .
@prefix :     &lt;http://example.org/ns#&gt; .
@prefix xsd:  &lt;<code>http://www.w3.org/2001/XMLSchema#&gt; .</code>

:x   ns:p     "cat"@en .
:y   ns:p     "42"^^xsd:integer .
:z   ns:p     "abc"^^dt:specialDatatype .
</pre>

      <p>Note that, in Turtle, <code>"cat"@en</code> is an RDF literal with a lexical form "cat" and a language <code>en</code>; <code>"42"^^xsd:integer</code> is a typed literal with the datatype <code>http://www.w3.org/2001/XMLSchema#integer</code>; and <code>"abc"^^dt:specialDatatype</code> is a typed literal with the datatype <code>http://example.org/datatype#specialDatatype</code>.</p>

  <p>This RDF data is the data graph for the query examples in sections 2.3.1&ndash;2.3.3.</p>
  <h4>2.3.1 <a id="matchLangTags" name="matchLangTags">Matching Literals with Language Tags</a></h4>
      <p>Language tags in SPARQL are expressed using <code>@</code> and the 
      language tag, as defined in <a class="norm" href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">Best Common Practice 47</a> [<a href="#BCP47">BCP47</a>].</p>

  <p>This following query has no solution because <code>&quot;cat&quot;</code> is not the 
  same RDF literal as <code>&quot;cat&quot;@en</code>:</p>
  <div class="queryGroup">
    <pre class="query">
SELECT ?v WHERE { ?v ?p &quot;cat&quot; }
</pre>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>&nbsp;&nbsp; v&nbsp;&nbsp;&nbsp;&nbsp; </th>
        </tr>
      </table>
    </div>
    <p>but the query below will find a solution where variable <code>v</code> is bound to
    <code>:x</code> because the language tag is specified and matches the given data:</p>
    <pre class="query">
SELECT ?v WHERE { ?v ?p &quot;cat&quot;@en }
</pre>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>v</th>
        </tr>
        <tr>
          <td>&lt;http://example.org/ns#x&gt;</td>
        </tr>
      </table>
    </div>
  </div>
</div>

  <h4>2.3.2 <a id="matchNumber" name="matchNumber">Matching Literals with Numeric Types</a></h4>
    <p>Integers in a SPARQL query indicate an RDF typed literal with the datatype
    <code>xsd:integer</code>. For example: <code>42</code> is a shortened form 
    of&nbsp; <code>"42"^^&lt;http://www.w3.org/2001/XMLSchema#integer&gt;</code>.</p>
  <p>The pattern in the following query has a solution with variable <code>v</code> 
  bound to <code>:y</code>.</p>
  <div class="queryGroup">
    <pre class="query">
SELECT ?v WHERE { ?v ?p 42 }
</pre>
    <div class="result">
      <table class="resultTable" id="table60">
        <tr>
          <th>v</th>
        </tr>
        <tr>
          <td>&lt;http://example.org/ns#y&gt;</td>
        </tr>
      </table>
    </div>
  </div>
    <p><a href="#QSynLiterals">Section 4.1.2</a> defines SPARQL shortened forms for <code>xsd:float</code> and <code>xsd:double</code>.</p>
  <h4>2.3.3 <a id="matchArbDT" name="matchArbDT">Matching Literals with Arbitrary Datatypes</a></h4>
  <p>The following query has a solution with variable <code>v</code> bound to
  <code>:z</code>. The query processor does not have to have any understanding 
  of the values in the space of the datatype. Because the lexical form and 
  datatype IRI both match, the literal matches.</p>
  <div class="queryGroup">
    <pre class="query">
SELECT ?v WHERE { ?v ?p &quot;abc&quot;^^&lt;http://example.org/datatype#specialDatatype&gt; }
</pre>
    <div class="result">
      <table class="resultTable" id="table61">
        <tr>
          <th>v</th>
        </tr>
        <tr>
          <td>&lt;http://example.org/ns#z&gt;</td>
        </tr>
      </table>
    </div>
  </div>

<h3>2.4 <a id="BlankNodesInResults" name="BlankNodesInResults">Blank Node Labels in Query Results</a></h3>
<p>Query results can contain labeled blank nodes.</p>
<p>Blank node labels are scoped to a result set (as defined in &quot;<a class="inform" href="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL 
Query Results XML Format</a>&quot;) or, for the <code>CONSTRUCT</code> query 
form, the result graph. 
Use of the same label within a 
result set indicates the same blank node.</p>
<div class="exampleGroup">
  Data:
  <pre class="data">
@prefix foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name   &quot;Alice&quot; .
_:b  foaf:name   &quot;Bob&quot; .
</pre>
  <div class="queryGroup">
    Query:
    <pre class="query">
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?x ?name
WHERE  { ?x foaf:name ?name }
</pre>
    <div class="result">
      <table class="resultTable" id="table56">
        <tr>
          <th>x</th>
          <th>name</th>
        </tr>
        <tr>
          <td>_:c</td>
          <td>&quot;Alice&quot;</td>
        </tr>
        <tr>
          <td>_:d</td>
          <td>&quot;Bob&quot;</td>
        </tr>
      </table>
    </div>
  </div>
  <p>The results above could equally be given with different blank node labels because 
  the labels in the results only indicate whether RDF terms in the solutions are 
  the same or different.</p>
  <div class="result untested">
    <table class="resultTable" id="table57">
      <tr>
        <th>x</th>
        <th>name</th>
      </tr>
      <tr>
        <td>_:r</td>
        <td>&quot;Alice&quot;</td>
      </tr>
      <tr>
        <td>_:s</td>
        <td>&quot;Bob&quot;</td>
      </tr>
    </table>
  </div>
</div>
<p>These two results have the same information: the blank nodes used to match the 
query are different in the two solutions. There need not be any relation between a 
label
<code>_:a</code> in the result set and a blank node in the data graph 
with the same label.</p>

<p>An application writer should not expect blank node labels in a query to refer to a particular blank node in the data.</p>


<h3>2.5 <a id="constructGraph" name="constructGraph">Building RDF Graphs</a></h3>
<p>SPARQL has several <a href="#QueryForms">query forms</a>.
The <code>SELECT</code> query form 
returns variable bindings. The <code>CONSTRUCT</code> query form
returns an RDF graph. The graph is built based on a template
which is used to generate RDF triples based on the results of matching
the graph pattern of the query.</p>

<div class="exampleGroup">
<p>Data:</p>
  <pre class="data">
@prefix org:    &lt;http://example.com/ns#&gt; .

_:a  org:employeeName   &quot;Alice&quot; .
_:a  org:employeeId     12345 .

_:b  org:employeeName   &quot;Bob&quot; .
_:b  org:employeeId     67890 .</pre>
  <div class="queryGroup">
<p>Query:</p>
    <pre class="query">
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX org:    &lt;http://example.com/ns#&gt;

CONSTRUCT { ?x foaf:name ?name }
WHERE  { ?x org:employeeName ?name }</pre>
<p>Results:</p>
    <div class="result">
      <pre class="resultGraph">@prefix org: &lt;http://example.com/ns#&gt; .
      
_:x foaf:name &quot;Alice&quot; .
_:y foaf:name &quot;Bob&quot; .</pre>
      </div>
  </div>

  <p>which can be serialized in
  <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a> as:</p>
  
  <div class="result">
      <pre class="resultGraph" style="text-align: left;">
&lt;rdf:RDF
    xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;
    xmlns:foaf=&quot;http://xmlns.com/foaf/0.1/&quot;
    &gt;
  &lt;rdf:Description&gt;
    &lt;foaf:name&gt;Alice&lt;/foaf:name&gt;
  &lt;/rdf:Description&gt;
  &lt;rdf:Description&gt;
    &lt;foaf:name&gt;Bob&lt;/foaf:name&gt;
  &lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;</pre>
  </div>
  </div>



<h2>3 <a id="termConstraint" name="termConstraint">RDF Term Constraints</a> (Informative)</h2>
  <p>Graph pattern matching produces a solution sequence, where each solution has a set of bindings of variables to RDF terms. SPARQL <code>FILTER</code>s
  restrict solutions to those for which the filter expression evaluates to <code>TRUE</code>.</p>

    <p>This section provides an informal introduction to SPARQL <code>FILTER</code>s; their semantics are defined in <a href="#tests">Section 11. Testing Values</a>. The examples in this section share one input graph:</p>

<div class="exampleGroup">
  Data:
  <pre class="data">
@prefix dc:   &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix :     &lt;http://example.org/book/&gt; .
@prefix ns:   &lt;http://example.org/ns#&gt; .

:book1  dc:title  &quot;SPARQL Tutorial&quot; .
:book1  ns:price  42 .
:book2  dc:title  &quot;The Semantic Web&quot; .
:book2  ns:price  23 .
</pre>
  <h3>3.1 <a name="restrictString" id="restrictString">Restricting the Values of Strings</a></h3>
  <p>SPARQL <code>FILTER</code> functions like <code><a href="#funcex-regex">regex</a></code> can test RDF literals. <code>regex</code> matches only plain 
  literals with no language tag.
  <code>regex</code> can be used to match the lexical forms of other literals by 
  using the <a href="#func-str">str</a> 
  function.</p>
  <p>Query:</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX  dc:  &lt;http://purl.org/dc/elements/1.1/&gt;
SELECT  ?title
WHERE   { ?x dc:title ?title
          FILTER regex(?title, &quot;^SPARQL&quot;) 
        }
</pre>
    <p>Query Result:</p>
    <div class="result">
      <table class="resultTable" id="table63">
        <tr>
          <th>title</th>
        </tr>
        <tr>
          <td>&quot;SPARQL Tutorial&quot;</td>
        </tr>
      </table>
    </div>
  </div>
  <p>Regular expression matches may be made case-insensitive with the &quot;<code>i</code>&quot; 
  flag.</p>
  <p>Query:</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX  dc:  &lt;http://purl.org/dc/elements/1.1/&gt;
SELECT  ?title
WHERE   { ?x dc:title ?title
          FILTER regex(?title, &quot;web&quot;, &quot;i&quot; ) 
        }
</pre>
    <p>Query Result:</p>
    <div class="result">
      <table class="resultTable" id="table64">
        <tr>
          <th>title</th>
        </tr>
        <tr>
          <td>&quot;The Semantic Web&quot;</td>
        </tr>
      </table>
    </div>
  </div>
      <p>The regular expression language is <a href="http://www.w3.org/TR/xpath-functions/#regex-syntax">defined by XQuery 1.0 and XPath 2.0 Functions and Operators</a> and is based on <a href="http://www.w3.org/TR/xmlschema-2/#regexs">XML Schema Regular Expressions</a>.</p>
  <h3>3.2 <a name="restrictNumber" id="restrictNumber">Restricting Numeric Values</a></h3>
  <p>SPARQL <code>FILTER</code>s can restrict on arithmetic expressions.</p>
  <p>Query:</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX  dc:  &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX  ns:  &lt;http://example.org/ns#&gt;
SELECT  ?title ?price
WHERE   { ?x ns:price ?price .
          FILTER (?price &lt; 30.5)
          ?x dc:title ?title . }
</pre>
    <p>Query Result:</p>
    <div class="result">
      <table class="resultTable" id="table58">
        <tr>
          <th>title</th>
          <th>price</th>
        </tr>
        <tr>
          <td>&quot;The Semantic Web&quot;</td>
          <td>23</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>By constraining the <code>price</code> variable, only <code>:book2</code> matches 
the query because only <code>:book2</code> has a price less than <code>30.5</code>, 
as the filter condition requires. </p>

<h3>3.3 <a id="otherTermConstraints" name="otherTermConstraints">Other Term Constraints</a></h3>

    <p>In addition to <span class="type numeric">numeric</span> types, SPARQL supports 
	types <code>xsd:string</code>, <code>xsd:boolean</code> and <code>xsd:dateTime</code> (see <a href="#operandDataTypes">11.1 Operand Data Types</a>). <a href="#OperatorMapping">11.3 Operator Mapping</a> lists a set of test functions, including <code>BOUND</code>, <code>isLITERAL</code> and <code>langMATCHES</code> and accessors, including <code>STR</code>, <code>LANG</code> and <code>DATATYPE</code>. <a href="#FunctionMapping">11.5 Constructor Functions</a> lists a set of XML Schema constructor functions that are in the SPARQL language to cast values from one type to another.</p>

<h2>4 <a id="sparqlSyntax" name="sparqlSyntax">SPARQL Syntax</a></h2>
<p>This section covers the syntax used by SPARQL for <a href="#sparqlBasicTerms">
RDF terms</a> and <a href="#sparqlTriplePatterns">triple patterns</a>. The full grammar 
is given in <a href="#grammar">appendix A</a>.</p>
<h3>4.1 <a id="syntaxTerms" name="syntaxTerms">RDF Term Syntax</a></h3>
<h4>4.1.1 <a id="QSynIRI" name="QSynIRI">Syntax for IRIs</a></h4>
<p>The terms delimited by &quot;<code>&lt;&gt;</code>&quot; are IRI references [<a href="#rfc3987">RFC3987</a>]; 
the delimiters do not form part of the reference. IRI references stand for IRIs, either directly 
or relative to a base IRI. IRIs are a generalization of URIs [<a href="#rfc3986">RFC3986</a>] 
and are fully compatible with URIs and URLs.</p>
<p>The SPARQL syntax provides two abbreviation mechanisms for IRIs: prefixed names 
and relative IRIs.</p>
<p class="todo">@@Check this against the final grammar.</p>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table109">
<tr>
  <td><code class="gRuleLabel">[67]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rIRIref">IRIref</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRI_REF">IRI_REF</a> |	<a href="#rPrefixedName">PrefixedName</a></code></td>
</tr>

<tr>
  <td><code class="gRuleLabel">[68]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rPrefixedName">PrefixedName</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPNAME_LN">PNAME_LN</a> | <a href="#rPNAME_NS">PNAME_NS</a></code></td>
</tr>

<tr>
  <td><code class="gRuleLabel">[69]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rBlankNode">BlankNode</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rBLANK_NODE_LABEL">BLANK_NODE_LABEL</a> |	<a href="#rANON">ANON</a></code></td>
</tr>

<tr>
  <td><code class="gRuleLabel">[70]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rIRI_REF">IRI_REF</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'&lt;' ([^&lt;&gt;&quot;{}|^`\]-[#x00-#x20])* '&gt;'</span></code></td>
</tr>

<tr>
  <td><code class="gRuleLabel">[71]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rPNAME_NS">PNAME_NS</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPN_PREFIX">PN_PREFIX</a>? ':'</code></td>
</tr>

<tr>
  <td><code class="gRuleLabel">[72]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rPNAME_LN">PNAME_LN</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPNAME_NS">PNAME_NS</a> <a href="#rPN_LOCAL">PN_LOCAL</a></code></td>
</tr>
    </table>
  </div>
</div>

<p>The set of RDF terms defined in RDF Concepts and Abstract Syntax
   includes RDF URI references while SPARQL terms include IRIs. RDF URI
   references containing "<code>&lt;</code>", "<code>&gt;</code>", '<code>&quot;</code>' (double 
quote), space, &quot;<code>{</code>&quot;, &quot;<code>}</code>&quot;, &quot;<code>|</code>&quot;,
&quot;<code>\</code>&quot;, &quot;<code>^</code>&quot;, and 
&quot;<code>`</code>&quot; are not IRIs. The behavior of a SPARQL query against RDF
   statements composed of such RDF URI references is not defined.</p>
<h5>Prefixed names</h5>
<p>The <code>PREFIX</code> keyword associates a prefix label with an IRI. A prefixed 
name is a prefix label and a local part, separated by a colon &quot;<code>:</code>&quot;. 
A prefixed name is mapped to an IRI by concatenating the IRI associated with the prefix and the local part. 
The prefix label or the local part may be empty.</p>

<div class="issue issueBlock">
<h5 id="notXmlQNames">At-Risk Feature: Not all Prefixed Names are XML QNames</h5>

<p>The Prefixed Name representation for IRIs is derived from the syntax
for XML QNames.  This practice first appeared in the <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a>
specification, in which it is used to express statement predicates.
However, the constraints XML stipulates for QNames rule out certain
otherwise convenient character strings, such as <code>isbn:0752820907</code>
or <code>rfc:0822.txt</code>.  The issue in these particular cases is
that the local name (the part following the colon) must be an XML
NCName, which may not have leading digits.</p>

<p>Earlier drafts of the SPARQL Query Language restricted the grammar of
Prefixed Names to always be valid QNames.  The Working Group decided
in May 2007 to relax this restriction, so that the examples posed
above are now allowed.  This extension is being marked as a feature
<em>at-risk</em> because of its late addition to the specification, and
because existing software (e.g. RDF-XML serializers) may rely on
Prefixed Names being transparently expressible as QNames.</p>
    </div>

<h5>Relative IRIs</h5>
<p>Relative IRIs are combined with base IRIs as per
<a class="norm" href="http://www.ietf.org/rfc/rfc3986.txt">Uniform Resource Identifier 
(URI): Generic Syntax</a> [<a href="#rfc3986">RFC3986</a>] using only the basic 
algorithm in Section 5.2 . Neither Syntax-Based Normalization nor Scheme-Based Normalization 
(described in sections 6.2.2 and 6.2.3 of RFC3986) are performed. Characters additionally 
allowed in IRI references are treated in the same way that unreserved characters 
are treated in URI references, per section 6.5 of
<a class="norm" href="http://www.ietf.org/rfc/rfc3987.txt">Internationalized Resource 
Identifiers (IRIs)</a> [<a href="#rfc3987">RFC3987</a>].</p>
<p>The <code>BASE</code> keyword defines the Base IRI used to resolve relative IRIs 
per RFC3986 section 5.1.1, &quot;Base URI Embedded in Content&quot;. Section 5.1.2, &quot;Base 
URI from the Encapsulating Entity&quot; defines how the Base IRI may come from an encapsulating 
document, such as a SOAP envelope with an xml:base directive or a mime multipart 
document with a Content-Location header. The &quot;Retrieval URI&quot; identified in 5.1.3, 
Base &quot;URI from the Retrieval URI&quot;, is the URL from which a particular SPARQL query 
was retrieved. If none of the above specifies the Base URI, the default Base URI 
(section 5.1.4, &quot;Default Base URI&quot;) is used.</p>
<p>The following fragments are some of the different ways to write the same IRI:</p>
<pre class="data">
&lt;http://example.org/book/book1&gt;
</pre>
<pre class="data">
BASE &lt;http://example.org/book/&gt;
&lt;book1&gt;
</pre>
<pre class="data">
PREFIX book: &lt;http://example.org/book/&gt;
book:book1</pre>
<h4>4.1.2 <a id="QSynLiterals" name="QSynLiterals">Syntax for Literals</a></h4>
<p>The general syntax for literals is a string (enclosed in either double 
quotes, <code>&quot;...&quot;</code>, or single quotes, <code>&#39;...&#39;</code>), with either an optional 
language tag (introduced by <code>@</code>) or an optional datatype IRI or prefixed 
name (introduced by <code>^^</code>).</p>
<p>As a convenience, integers can be written directly (without quotation marks and an explicit datatype IRI) and are interpreted as typed 
literals of datatype <code>xsd:integer</code>; decimal numbers for which there is &#39;.&#39; 
in the number but no exponent are interpreted as <code>xsd:decimal</code>; and 
numbers with exponents are interpreted as <code>xsd:double</code>. Values of 
type <code>xsd:boolean</code> can also be written as <code>true</code> or <code>
false</code>.</p>
<p>To facilitate writing literal values which themselves contain quotation marks 
or which are long and contain newline characters, SPARQL provides an additional 
quoting construct in which literals are enclosed in three single- or double-quotation 
marks.</p>
<p>Examples of literal syntax in SPARQL include:</p>
<ul>
  <li><code>&quot;chat&quot;</code></li>
  <li><code>&#39;chat&#39;@fr</code> with language tag &quot;fr&quot;</li>
  <li><code>&quot;xyz&quot;^^&lt;http://example.org/ns/userDatatype&gt;</code></li>
  <li><code>&quot;abc&quot;^^appNS:appDataType</code></li>
  <li><code>&quot;&quot;&quot;The librarian said, &quot;Perhaps you would enjoy &#39;War and Peace&#39;.&quot;&quot;&quot;&quot;</code></li>
  <li><code>1</code>, which is the same as <code>&quot;1&quot;^^xsd:integer</code></li>
  <li><code>1.3</code>, which is the same as <code>&quot;1.3&quot;^^xsd:decimal</code></li>
  <li><code>1.0e6</code>, which is the same as <code>&quot;1.0e6&quot;^^xsd:double</code></li>
  <li><code>true</code>, which is the same as <code>&quot;true&quot;^^xsd:boolean</code></li>
  <li><code>false</code>, which is the same as <code>&quot;false&quot;^^xsd:boolean</code></li>
</ul>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table110">
      <tr>
  <td><code class="gRuleLabel">[60]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rRDFLiteral">RDFLiteral</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rString">String</a> ( <a href="#rLANGTAG">LANGTAG</a> | ( <span class="token">'^^'</span> <a href="#rIRIref">IRIref</a> ) )?</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[61]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rNumericLiteral">NumericLiteral</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rNumericLiteralUnsigned">NumericLiteralUnsigned</a> | 
  <br/>
  <a href="#rNumericLiteralPositive">NumericLiteralPositive</a> | <br/>
  <a href="#rNumericLiteralNegative">NumericLiteralNegative</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[62]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rNumericLiteralUnsigned">NumericLiteralUnsigned</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rINTEGER">INTEGER</a> |	<a href="#rDECIMAL">DECIMAL</a> |	<a href="#rDOUBLE">DOUBLE</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[63]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rNumericLiteralPositive">NumericLiteralPositive</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rINTEGER_POSITIVE">INTEGER_POSITIVE</a> |	
  <br/>
  <a href="#rDECIMAL_POSITIVE">DECIMAL_POSITIVE</a> |	<br/>
  <a href="#rDOUBLE_POSITIVE">DOUBLE_POSITIVE</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[64]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rNumericLiteralNegative">NumericLiteralNegative</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rINTEGER_NEGATIVE">INTEGER_NEGATIVE</a> |	
  <br/>
  <a href="#rDECIMAL_NEGATIVE">DECIMAL_NEGATIVE</a> |	<br/>
  <a href="#rDOUBLE_NEGATIVE">DOUBLE_NEGATIVE</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[65]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rBooleanLiteral">BooleanLiteral</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'true'</span> |	<span class="token">'false'</span></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[66]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rString">String</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rSTRING_LITERAL1">STRING_LITERAL1</a> | <a href="#rSTRING_LITERAL2">STRING_LITERAL2</a> | 
  <br/>
  <a href="#rSTRING_LITERAL_LONG1">STRING_LITERAL_LONG1</a> | <a href="#rSTRING_LITERAL_LONG2">STRING_LITERAL_LONG2</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[76]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rLANGTAG">LANGTAG</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[77]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rINTEGER">INTEGER</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[0-9]+</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[78]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDECIMAL">DECIMAL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[0-9]+ '.' [0-9]* | '.' [0-9]+</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[79]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDOUBLE">DOUBLE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[0-9]+ '.' [0-9]* <a href="#rEXPONENT">EXPONENT</a> |<br/>
  '.' ([0-9])+ <a href="#rEXPONENT">EXPONENT</a> |<br/>
  ([0-9])+ <a href="#rEXPONENT">EXPONENT</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[80]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rINTEGER_POSITIVE">INTEGER_POSITIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'+'</span> <a href="#rINTEGER">INTEGER</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[81]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDECIMAL_POSITIVE">DECIMAL_POSITIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'+'</span> <a href="#rDECIMAL">DECIMAL</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[82]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDOUBLE_POSITIVE">DOUBLE_POSITIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'+'</span> <a href="#rDOUBLE">DOUBLE</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[83]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rINTEGER_NEGATIVE">INTEGER_NEGATIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'-'</span> <a href="#rINTEGER">INTEGER</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[84]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDECIMAL_NEGATIVE">DECIMAL_NEGATIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'-'</span> <a href="#rDECIMAL">DECIMAL</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[85]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDOUBLE_NEGATIVE">DOUBLE_NEGATIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'-'</span> <a href="#rDOUBLE">DOUBLE</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[86]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rEXPONENT">EXPONENT</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[eE] [+-]? [0-9]+</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[87]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rSTRING_LITERAL1">STRING_LITERAL1</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">"'" ( ([^#x27#x5C#xA#xD]) | <a href="#rECHAR">ECHAR</a> )* "'"</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[88]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rSTRING_LITERAL2">STRING_LITERAL2</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'"' ( ([^#x22#x5C#xA#xD]) | <a href="#rECHAR">ECHAR</a> )* '"'</code></td>
      </tr>
    </table>
  </div>
</div>
<h4>4.1.3 <a id="QSynVariables" name="QSynVariables">Syntax for Query Variables</a></h4>
<p>Query variables in SPARQL queries have global scope; use of a given variable 
name anywhere in a query identifies the same variable. Variables are prefixed by 
either "?" or "$"; the "?" or "$" is not part of the variable name. 
In a query, <code>$abc</code> and <code>?abc</code> identify the same variable. The
<a href="#rVARNAME">possible names</a> for variables are given in the
<a href="#grammar">SPARQL grammar</a>.</p>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table111">
      <tr>
        <td><code class="gRuleLabel">[44]</code></td>
  <td><code class="gRuleHead"><a href="#rVar">Var</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVAR1">VAR1</a> | <a href="#rVAR2">VAR2</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[74]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rVAR1">VAR1</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'?' <a href="#rVARNAME">VARNAME</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[75]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rVAR2">VAR2</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'$' <a href="#rVARNAME">VARNAME</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[97]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rVARNAME">VARNAME</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">( <a href="#rPN_CHARS_U">PN_CHARS_U</a>  | [0-9] ) ( <a href="#rPN_CHARS_U">PN_CHARS_U</a> | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*</code></td>
      </tr>
    </table>
  </div>
</div>
<h4>4.1.4 <a id="QSynBlankNodes" name="QSynBlankNodes">Syntax for Blank Nodes</a></h4>
<p><a class="norm" href="http://www.w3.org/TR/rdf-concepts/#section-blank-nodes">Blank 
nodes</a> in graph patterns act as non-distinguished variables, not as references to specific blank nodes in the 
data being queried.</p>
    <p>Blank nodes are indicated by either the label form, such as "<code>_:abc</code>", or the abbreviated form "<code>[]</code>". A blank 
node that is used in only one place in the query syntax can be indicated with
<code>[]</code>. A unique blank node will be used to form the triple 
pattern. Blank node labels are written as &quot;<code>_:abc</code>&quot; for a blank node with 
label &quot;<code>abc</code>&quot;. The same blank node label cannot be used 
    in two different basic graph patterns in the same query.</p>
<p>The <code>[:p :v]</code> construct can be used in triple patterns. It creates 
a blank node label which is used as the subject of all contained predicate-object 
pairs. The created blank node can also be used in further triple patterns in the 
subject and object positions.</p>
<p>The following two forms</p>
<pre class="query untested">
[ :p &quot;v&quot; ] .
</pre>
<pre class="query untested">
[] :p &quot;v&quot; .
</pre>
<p>allocate a unique blank node label (here &quot;<code>b57</code>&quot;) and are equivalent 
to writing:</p>
<pre class="query untested">
_:b57 :p &quot;v&quot; .
</pre>
<p>This allocated blank node label can be used as the subject or object of further 
triple patterns. For example, as a subject:</p>
<pre class="query untested">
[ :p &quot;v&quot; ] :q &quot;w&quot; .
</pre>
<p>which is equivalent to the two triples:</p>
<pre class="query untested">
_:b57 :p &quot;v&quot; .
_:b57 :q &quot;w&quot; .
</pre>
<p>and as an object:</p>
<pre class="query untested">
:x :q [ :p &quot;v&quot; ] .
</pre>
<p>which is equivalent to the two triples:</p>
<pre class="query untested">
:x  :q _:b57 .
_:b57 :p &quot;v&quot; .
</pre>
<p>Abbreviated blank node syntax can be combined with other abbreviations for 
<a href="#predObjLists">common 
subjects</a> and <a href="#objLists">common predicates</a>.</p>
<pre class="query untested">
  [ foaf:name  ?name ;
    foaf:mbox  &lt;mailto:alice@example.org&gt; ]
</pre>
<p>This is the same as writing the following basic graph pattern for some uniquely 
allocated blank node label, &quot;<code>b18</code>&quot;:</p>
<pre class="query untested">
  _:b18  foaf:name  ?name .
  _:b18  foaf:mbox  &lt;mailto:alice@example.org&gt; .
</pre>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table112">
      <tr>
  <td><code class="gRuleLabel">[39]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rBlankNodePropertyList">BlankNodePropertyList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'['</span><a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a><span class="token">']'</span></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[69]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rBlankNode">BlankNode</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rBLANK_NODE_LABEL">BLANK_NODE_LABEL</a> |	<a href="#rANON">ANON</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[73]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rBLANK_NODE_LABEL">BLANK_NODE_LABEL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'_:' <a href="#rPN_LOCAL">PN_LOCAL</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[94]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rANON">ANON</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'['  <a href="#rWS">WS</a>* ']'</code></td>
      </tr>
    </table>
  </div>
</div>
<h3>4.2 <a id="QSynTriples" name="QSynTriples">Syntax for Triple Patterns</a></h3>
<p><a href="#defn_TriplePattern">Triple Patterns</a> are written as a list of subject, 
predicate, object; there are abbreviated ways of writing some common triple pattern 
constructs.</p>
<p>The following examples express the same query:</p>
<pre class="query">
PREFIX  dc: &lt;http://purl.org/dc/elements/1.1/&gt;
SELECT  ?title
WHERE   { &lt;http://example.org/book/book1&gt; dc:title ?title }  
</pre>
<pre class="query">
PREFIX  dc: &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX  : &lt;http://example.org/book/&gt;

SELECT  $title
WHERE   { :book1  dc:title  $title }
</pre>
<pre class="query">
BASE    &lt;http://example.org/book/&gt;
PREFIX  dc: &lt;http://purl.org/dc/elements/1.1/&gt;

SELECT  $title
WHERE   { &lt;book1&gt;  dc:title  ?title }
</pre>
<div class="grammarExtract">Grammar rules:<div class="grammarTable">
  <table id="table113">
    <tr>
  <td><code class="gRuleLabel">[32]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rTriplesSameSubject">TriplesSameSubject</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVarOrTerm">VarOrTerm</a> <a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a> |<br/>
  <a href="#rTriplesNode">TriplesNode</a> <a href="#rPropertyList">PropertyList</a></code></td>
    </tr>
    <tr>
  <td><code class="gRuleLabel">[33]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVerb">Verb</a> <a href="#rObjectList">ObjectList</a> ( <span class="token">';'</span> ( <a href="#rVerb">Verb</a> <a href="#rObjectList">ObjectList</a> )? )*</code></td>
    </tr>
    <tr>
  <td><code class="gRuleLabel">[34]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rPropertyList">PropertyList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a>?</code></td>
    </tr>
    <tr>
  <td><code class="gRuleLabel">[35]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rObjectList">ObjectList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rObject">Object</a> ( <span class="token">','</span> <a href="#rObject">Object</a> )*</code></td>
    </tr>
    <tr>
  <td><code class="gRuleLabel">[37]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rVerb">Verb</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVarOrIRIref">VarOrIRIref</a> | <span class="token">'a'</span></code></td>
    </tr>
  </table>
  </div>
</div>
<h4>4.2.1 <a id="predObjLists" name="predObjLists">Predicate-Object Lists</a></h4>
<p>Triple patterns with a common subject can be written so that the subject is only 
written once and is used for more than one triple pattern by employing the &quot;<code>;</code>&quot; 
notation.</p>
<pre class="query untested">
    ?x  foaf:name  ?name ;
        foaf:mbox  ?mbox .
</pre>
<p>This is the same as writing the triple patterns:</p>
<pre class="query untested">
    ?x  foaf:name  ?name .
    ?x  foaf:mbox  ?mbox .
</pre>
<h4>4.2.2 <a id="objLists" name="objLists">Object Lists</a></h4>
<p>If triple patterns share both subject and predicate, the objects may be separated
by "<code>,</code>".</p>
<pre class="query untested">
    ?x foaf:nick  &quot;Alice&quot; , &quot;Alice_&quot; .
</pre>
<p>is the same as writing the triple patterns:</p>
<pre class="query untested">
   ?x  foaf:nick  &quot;Alice&quot; .
   ?x  foaf:nick  &quot;Alice_&quot; .
</pre>
<p>Object lists can be combined with predicate-object lists:</p>
<pre class="query untested">
   ?x  foaf:name ?name ; foaf:nick  &quot;Alice&quot; , &quot;Alice_&quot; .
</pre>
<p>is equivalent to:</p>
<pre class="query untested">
   ?x  foaf:name  ?name .
   ?x  foaf:nick  &quot;Alice&quot; .
   ?x  foaf:nick  &quot;Alice_&quot; .
</pre>
<h4>4.2.3 <a id="collections" name="collections">RDF Collections</a></h4>
<p>
<a class="norm" href="http://www.w3.org/TR/2004/REC-rdf-mt-20040210/#collections">
RDF collections</a> can be written in triple patterns using the syntax &quot;(element1 element2 ...)&quot;. The 
form "<code>()</code>" is an alternative for the IRI <code>
<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil">http://www.w3.org/1999/02/22-rdf-syntax-ns#nil</a></code>. 
When used with collection elements, such as <code>(1 ?x 3 4)</code>, triple patterns 
with blank nodes are allocated for the collection. The blank node at the head 
of the collection can be used as a subject or object in other triple patterns. The blank nodes allocated by the collection syntax do not occur elsewhere in the query.</p>
<pre class="query untested">
(1 ?x 3 4) :p &quot;w&quot; .
</pre>
<p>is syntactic sugar for (noting that <code>b0</code>, <code>b1</code>, <code>b2</code> and <code>b3</code> do not occur anywhere else in the 
query):</p>
<pre class="query untested">
    _:b0  rdf:first  1 ;
          rdf:rest   _:b1 .
    _:b1  rdf:first  ?x ;
          rdf:rest   _:b2 .
    _:b2  rdf:first  3 ;
          rdf:rest   _:b3 .
    _:b3  rdf:first  4 ;
          rdf:rest   rdf:nil .
    _:b0  :p         &quot;w&quot; . 
</pre>
<p>RDF collections can be nested and can involve other syntactic forms:</p>
<pre class="query untested">
(1 [:p :q] ( 2 ) ) .
</pre>
<p>is syntactic sugar for:</p>
<pre class="query untested">
    _:b0  rdf:first  1 ;
          rdf:rest   _:b1 .
    _:b1  rdf:first  _:b2 .
    _:b2  :p         :q .
    _:b1  rdf:rest   _:b3 .
    _:b3  rdf:first  _:b4 .
    _:b4  rdf:first  2 ;
          rdf:rest   rdf:nil .
    _:b3  rdf:rest   rdf:nil .
</pre>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table124">
      <tr>
  <td><code class="gRuleLabel">[40]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rCollection">Collection</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'('</span> <a href="#rGraphNode">GraphNode</a>+ <span class="token">')'</span></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[92]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rNIL">NIL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'(' <a href="#rWS">WS</a>* ')'</code></td>
      </tr>
    </table>
  </div>
</div>
<h4>4.2.4 <a name="abbrevRdfType" id="abbrevRdfType">rdf:type</a></h4>
<p>The keyword &quot;<code>a</code>&quot; can be used as a predicate in a triple pattern and 
is an alternative for the IRI&nbsp; <code>
<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#type">http://www.w3.org/1999/02/22-rdf-syntax-ns#type</a></code>. 
This keyword is case-sensitive.</p>
<pre class="query untested">
  ?x  a  :Class1 .
  [ a :appClass ] :p &quot;v&quot; .
</pre>
<p>is syntactic sugar for:</p>
<pre class="query untested">
  ?x    rdf:type  :Class1 .
  _:b0  rdf:type  :appClass .
  _:b0  :p        &quot;v&quot; .
</pre>

<h2>5 <a id="GraphPattern" name="GraphPattern">Graph Patterns</a></h2>

<p>SPARQL is based around graph pattern matching. More complex graph patterns
can be formed by combining smaller patterns in various ways:</p>

<ul>
  <li><a href="#BasicGraphPatterns">Basic Graph Patterns</a>,
  where a set of triple 
  patterns must match</li>
  <li><a href="#GroupPatterns">Group Graph Pattern</a>, where a set of graph 
  patterns must all match</li>
  <li><a href="#optionals">Optional Graph patterns</a>, where additional patterns 
  may extend the solution</li>
  <li><a href="#alternatives">Alternative Graph Pattern</a>, where two or more possible 
  patterns are tried</li>
  <li><a href="#queryDataset">Patterns on Named Graphs</a>, where patterns are matched 
  against named graphs</li>
</ul>

<p>In this section we describe the two forms that combine patterns by 
conjunction: basic graph patterns, which combine triples patterns, and group 
graph patterns, which combine all other graph patterns.</p>

<h3>5.1 <a id="BasicGraphPatterns" name="BasicGraphPatterns">Basic Graph Patterns</a></h3>

<p>Basic graph patterns are sets of triple patterns. SPARQL graph pattern 
matching is defined in terms of combining the results from matching basic graph patterns.</p>

<p>A sequence of triple patterns interrupted by a filter comprises a single
basic graph pattern. Any graph pattern terminates a basic graph pattern.</p>

<h4>5.1.1 <a id="bgpBNodeLabels" name="bgpBNodeLabels">Blank Node Labels</a></h4>

<p>When using blank nodes of the form <code>_:abc</code>,&nbsp; labels for blank 
nodes are scoped to the basic graph pattern.&nbsp; A label can be used in only a 
single basic graph pattern in any query.
</p>

<h4>5.1.2 <a id="bgpExtend" name="bgpExtend">Extending Basic Graph Pattern Matching</a></h4>

<p>SPARQL is defined for matching RDF graphs with simple entailment. SPARQL can 
be extended to other forms of entailment given certain conditions as
<a href="#sparqlBGPExtend">described below</a>.
</p>


<h3>5.2 <a id="GroupPatterns" name="GroupPatterns">Group Graph Patterns</a></h3>

<p>In a SPARQL query string, a group graph pattern is delimited with braces:
<code>{}</code>. For example, this query's query pattern is a group graph pattern of one basic 
graph pattern.</p><div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:&nbsp;&nbsp;&nbsp; &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
WHERE&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?x foaf:name ?name .
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?x foaf:mbox ?mbox .
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
</pre></div></div><div class="exampleGroup">
  <div class="queryGroup">
    The same solutions would be obtained from a query that grouped the triple patterns
    into two basic graph patterns. For example, the query below has a different
    structure but would yield the same solutions as the previous query:
    <pre class="query">
PREFIX foaf:&nbsp;&nbsp;&nbsp; &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
WHERE&nbsp; { { ?x foaf:name ?name . }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ?x foaf:mbox ?mbox . }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</pre></div></div><div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
  <table id="table118">
    <tbody>
      <tr>
	<td>
	  <code class="gRuleLabel">[20]&nbsp;&nbsp;</code>
	</td>
	<td>
	  <code class="gRuleHead"><a href="#rGroupGraphPattern">GroupGraphPattern</a></code>
	</td>
	<td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
	<td>
	  <code class="gRuleBody"><span class="token">'{'</span> <a href="#rTriplesBlock">TriplesBlock</a>? ( ( <a href="#rGraphPatternNotTriples">GraphPatternNotTriples</a> | <a href="#rFilter">Filter</a> ) <span class="token">'.'</span>? <a href="#rTriplesBlock">TriplesBlock</a>? )* <span class="token">'}'</span></code>
	</td>
      </tr>
      <tr>
	<td>
	  <code class="gRuleLabel">[21]&nbsp;&nbsp;</code>
	</td>
	<td>
	  <code class="gRuleHead"><a href="#rTriplesBlock">TriplesBlock</a></code>
	</td>
	<td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
	<td><code class="gRuleBody"><a href="#rTriplesSameSubject">TriplesSameSubject</a> ( <span class="token">'.'</span> <a href="#rTriplesBlock">TriplesBlock</a>? )?</code>
	</td>
      </tr>
      <tr>
	<td><code class="gRuleLabel">[22]&nbsp;&nbsp;</code></td>
	<td><code class="gRuleHead"><a href="#rGraphPatternNotTriples">GraphPatternNotTriples</a></code></td>
	<td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
	<td>
	  <code class="gRuleBody"><a href="#rOptionalGraphPattern">OptionalGraphPattern</a> | <a href="#rGroupOrUnionGraphPattern">GroupOrUnionGraphPattern</a> | <a href="#rGraphGraphPattern">GraphGraphPattern</a></code>
	</td>
      </tr>
    </tbody>
  </table>
  </div>
</div>
  
<h4>5.2.1 <a name="emptyGroupPattern" id="emptyGroupPattern">Empty Group Pattern</a></h4>

<p>The group pattern:</p>
<pre class="query untested">{ }</pre>

<p>matches any graph (including the empty graph) with one solution that does not bind any 
variables. For example:</p>

<pre class="query untested">
SELECT ?x
WHERE {}
</pre>

<p>matches with one solution in which variable <code>x</code> is not bound.</p>

<h4>5.2.2 <a name="scopeFilters" id="scopeFilters">Scope of Filters</a></h4>

<p>A constraint, expressed by the keyword <code>FILTER</code>, is a 
restriction on solutions over the whole group in which the filter appears. The 
following patterns all have the same solutions:</p>

<div class="exampleGroup">
<div class="queryGroup">
  <pre class="query">
&nbsp;{&nbsp; ?x foaf:name ?name .
    ?x foaf:mbox ?mbox .
&nbsp;&nbsp;&nbsp; FILTER regex(?name, &quot;Smith&quot;)
 }
  </pre>
</div>
</div>

<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
&nbsp;{&nbsp; FILTER regex(?name, &quot;Smith&quot;)
    ?x foaf:name ?name .
    ?x foaf:mbox ?mbox .
&nbsp;}
</pre>
</div>
</div>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
&nbsp;{&nbsp; ?x foaf:name ?name .
&nbsp;&nbsp;&nbsp; FILTER regex(?name, &quot;Smith&quot;)
    ?x foaf:mbox ?mbox .
 }
</pre>
</div>
</div>

<h4>5.2.3 <a id="groupExamples" name="groupExamples">Group Graph Pattern Examples</a></h4>

<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
&nbsp; {
&nbsp;&nbsp;&nbsp; ?x foaf:name ?name .
&nbsp;&nbsp;&nbsp; ?x foaf:mbox ?mbox .
&nbsp; }</pre>
  </div>
</div>

<p>is a group of one basic graph pattern and that basic graph pattern consists 
    of two triple patterns.</p>

<div class="exampleGroup">
    <div class="queryGroup">
      <pre class="query">
&nbsp; {
&nbsp;&nbsp;&nbsp; ?x foaf:name ?name . FILTER regex(?name, &quot;Smith&quot;)
&nbsp;&nbsp;&nbsp; ?x foaf:mbox ?mbox .
&nbsp; }</pre>

</div>
</div>

<p>is a group of one basic graph pattern and a filter, and that basic graph 
pattern consists of two triple patterns; the filter does not break the 
basic graph pattern into two basic graph patterns.</p>

<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
&nbsp; {
&nbsp;&nbsp;&nbsp; ?x foaf:name ?name .
&nbsp;&nbsp;&nbsp; {}
&nbsp;&nbsp;&nbsp; ?x foaf:mbox ?mbox .
&nbsp; }</pre>
</div>
</div>

<p>is a group of three elements, a basic graph pattern of one triple pattern, 
an empty group, and another basic graph pattern of one triple pattern.
</p>

<h2>6 <a id="optionals" name="optionals">Including Optional Values</a></h2>
<p>Basic graph patterns allow applications to make queries where the entire query 
pattern must match for there to be a solution. For every solution of a query containing only group graph patterns with at least one basic graph pattern, 
every variable is bound to an RDF Term in a solution. However, regular, 
complete structures cannot be assumed in all RDF graphs. It is useful to be able 
to have queries that allow information to be added to the solution where the information 
is available, but do not reject the solution because some part of the query 
pattern does not match. Optional matching provides this facility: if the optional 
part does not match, it creates no bindings but does not eliminate
the solution.</p>
<h3>6.1 <a id="OptionalMatching" name="OptionalMatching">Optional Pattern Matching</a></h3>
<p>Optional parts of the graph pattern may be specified syntactically with the OPTIONAL 
keyword applied to a graph pattern:</p>
<pre class="query untested">
<i>pattern</i> OPTIONAL { <i>pattern</i> }
</pre>
<div class="exampleGroup">
  <p>The syntactic form:</p>
<pre class="query untested">
{ OPTIONAL { <i>pattern</i> } }
</pre>
<p>is equivalent to:</p>
<pre class="query untested">
{ { } OPTIONAL { <i>pattern</i> } }
</pre>
<div class="grammarExtract">
  Grammar rule:<div class="grammarTable">
    <table id="table116">
      <tr>
  <td><code class="gRuleLabel">[23]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOptionalGraphPattern">OptionalGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'OPTIONAL'</span> <a href="#rGroupGraphPattern">GroupGraphPattern</a></code></td>
      </tr>
    </table>
  </div>
</div>
<p>The <code>OPTIONAL</code> keyword is left-associative :</p>
<pre class="query untested">
<i>pattern</i> OPTIONAL { <i>pattern</i> } OPTIONAL { pattern }
</pre>
<p>is the same as:</p>
<pre class="query untested">
{ <i>pattern</i> OPTIONAL { <i>pattern</i> } } OPTIONAL { pattern }
</pre>

  <p>In an optional match, either the optional graph pattern matches a graph, thereby 
defining and adding bindings to one or more solutions, or it leaves a solution unchanged without adding 
any additional bindings.</p>
  <p>Data:</p>
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix rdf:        &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .

_:a  rdf:type        foaf:Person .
_:a  foaf:name       &quot;Alice&quot; .
_:a  foaf:mbox       &lt;mailto:alice@example.com&gt; .
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  rdf:type        foaf:Person .
_:b  foaf:name       &quot;Bob&quot; .
</pre>
  <div class="queryGroup">
    Query:<pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
WHERE  { ?x foaf:name  ?name .
         OPTIONAL { ?x  foaf:mbox  ?mbox }
       }
</pre>
    <p>With the data above, the query result is:</p>
    <div class="result">
      <table class="resultTable" id="table92">
        <tr>
          <th>name</th>
          <th>mbox</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
          <td>&lt;mailto:alice@example.com&gt;</td>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
          <td>&lt;mailto:alice@work.example&gt;</td>
        </tr>
        <tr>
          <td>&quot;Bob&quot;</td>
          <td></td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>There is no value of <code>mbox</code> in the solution where the name is
<code>&quot;Bob&quot;</code>.</p>
<p>This query finds the names of people in the data. If there is a triple with predicate
<code>mbox</code> and the same subject, a solution will contain the object of that triple 
as well. In this example, only a single triple pattern is given in the optional match 
part of the query but, in general, the optional part may be any graph pattern. The entire
optional graph pattern must match for the optional graph pattern to affect 
the query solution.</p>
<h3>6.2 <a id="OptionalAndConstraints" name="OptionalAndConstraints">Constraints 
in Optional Pattern Matching</a></h3>
<p>Constraints can be given in an optional graph pattern. For example:</p>
<div class="exampleGroup">
  <pre class="data">
@prefix dc:   &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix :     &lt;http://example.org/book/&gt; .
@prefix ns:   &lt;http://example.org/ns#&gt; .

:book1  dc:title  &quot;SPARQL Tutorial&quot; .
:book1  ns:price  42 .
:book2  dc:title  &quot;The Semantic Web&quot; .
:book2  ns:price  23 .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX  dc:  &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX  ns:  &lt;http://example.org/ns#&gt;
SELECT  ?title ?price
WHERE   { ?x dc:title ?title .
          OPTIONAL { ?x ns:price ?price . FILTER (?price &lt; 30) }
        }
</pre>
    <div class="result">
      <table class="resultTable" id="table93">
        <tr>
          <th>title</th>
          <th>price</th>
        </tr>
        <tr>
          <td>&quot;SPARQL Tutorial&quot;</td>
          <td></td>
        </tr>
        <tr>
          <td>&quot;The Semantic Web&quot;</td>
          <td>23</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>No price appears for the book with title &quot;SPARQL Tutorial&quot; because the optional 
graph pattern did not lead to a solution involving the variable &quot;<code>price</code>&quot;.</p>
<h3>6.3 <a id="MultipleOptionals" name="MultipleOptionals">Multiple Optional Graph 
Patterns</a></h3>
<p>Graph patterns are defined recursively. A graph pattern may have zero or more 
optional graph patterns, and any part of a query pattern may have an optional part. 
In this example, there are two optional graph patterns.</p>
<div class="exampleGroup">
  Data:<pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       &quot;Alice&quot; .
_:a  foaf:homepage   &lt;http://work.example.org/alice/&gt; .

_:b  foaf:name       &quot;Bob&quot; .
_:b  foaf:mbox       &lt;mailto:bob@work.example&gt; .
</pre>
  <div class="queryGroup">
    Query:<pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox ?hpage
WHERE  { ?x foaf:name  ?name .
         OPTIONAL { ?x foaf:mbox ?mbox } .
         OPTIONAL { ?x foaf:homepage ?hpage }
       }
</pre>
    <p>Query result:</p>
    <div class="result">
      <table class="resultTable" id="table94">
        <tr>
          <th>name</th>
          <th>mbox</th>
          <th>hpage</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
          <td></td>
          <td>&lt;http://work.example.org/alice/&gt;</td>
        </tr>
        <tr>
          <td>&quot;Bob&quot;</td>
          <td>&lt;mailto:bob@work.example&gt;</td>
          <td></td>
        </tr>
      </table>
    </div>
  </div>
</div>

<h2>7 <a id="alternatives" name="alternatives">Matching Alternatives</a></h2>
<p>SPARQL provides a means of combining graph patterns so that one of several alternative 
graph patterns may match. If more than one of the alternatives matches, all the 
possible pattern solutions are found.</p>
<p>Pattern alternatives are syntactically specified with the <code>UNION</code> keyword.</p>
<div class="exampleGroup">
  Data:<pre class="data">
@prefix dc10:  &lt;http://purl.org/dc/elements/1.0/&gt; .
@prefix dc11:  &lt;http://purl.org/dc/elements/1.1/&gt; .

_:a  dc10:title     &quot;SPARQL Query Language Tutorial&quot; .
_:a  dc10:creator   &quot;Alice&quot; .

_:b  dc11:title     &quot;SPARQL Protocol Tutorial&quot; .
_:b  dc11:creator   &quot;Bob&quot; .

_:c  dc10:title     &quot;SPARQL&quot; .
_:c  dc11:title     &quot;SPARQL (updated)&quot; .
</pre>
  <div class="queryGroup">
    Query:<pre class="query">
PREFIX dc10:  &lt;http://purl.org/dc/elements/1.0/&gt;
PREFIX dc11:  &lt;http://purl.org/dc/elements/1.1/&gt;

SELECT ?title
WHERE  { { ?book dc10:title  ?title } UNION { ?book dc11:title  ?title } }
</pre>
    <p>Query result:</p>
    <div class="result">
      <table class="resultTable" id="table97">
        <tr>
          <th>title</th>
        </tr>
        <tr>
          <td>&quot;SPARQL Protocol Tutorial&quot;</td>
        </tr>
        <tr>
          <td>&quot;SPARQL&quot;</td>
        </tr>
        <tr>
          <td>&quot;SPARQL (updated)&quot;</td>
        </tr>
        <tr>
          <td>&quot;SPARQL Query Language Tutorial&quot;</td>
        </tr>
      </table>
    </div>
  </div>
  <p>This query finds titles of the books in the data, whether the title is recorded 
  using <a class="inform" href="http://dublincore.org/">Dublin Core</a> properties 
  from version 1.0 or version 1.1. To determine exactly how the information was 
  recorded, a query could use different variables for the two alternatives:</p> 
  <div class="queryGroup">
    <pre class="query">
PREFIX dc10:  &lt;http://purl.org/dc/elements/1.0/&gt;
PREFIX dc11:  &lt;http://purl.org/dc/elements/1.1/&gt;

SELECT ?x ?y
WHERE  { { ?book dc10:title ?x } UNION { ?book dc11:title  ?y } }
</pre>
    <div class="result">
      <table class="resultTable" id="table98">
        <tr>
          <th>x</th>
          <th>y</th>
        </tr>
        <tr>
          <td></td>
          <td>&quot;SPARQL (updated)&quot;</td>
        </tr>
        <tr>
          <td></td>
          <td>&quot;SPARQL Protocol Tutorial&quot;</td>
        </tr>
        <tr>
          <td>&quot;SPARQL&quot;</td>
          <td></td>
        </tr>
        <tr>
          <td>&quot;SPARQL Query Language Tutorial&quot;</td>
          <td></td>
        </tr>
      </table>
    </div>
  </div>
  <p>This will return results with the variable <code>x</code> bound for solutions from the left branch of the <code>UNION</code>, and <code>y</code> bound 
  for the solutions from the right branch. If neither part of the <code>UNION</code> 
  pattern matched, then the graph pattern would not match.</p>
  <p>The <code>UNION</code> pattern combines graph patterns; each alternative possibility can contain more 
	than one triple 
  pattern:</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX dc10:  &lt;http://purl.org/dc/elements/1.0/&gt;
PREFIX dc11:  &lt;http://purl.org/dc/elements/1.1/&gt;

SELECT ?title ?author
WHERE  { { ?book dc10:title ?title .  ?book dc10:creator ?author }
         UNION
         { ?book dc11:title ?title .  ?book dc11:creator ?author }
       }
</pre>
    <div class="result">
      <table class="resultTable" id="table99">
        <tr>
          <th>author</th>
          <th>title</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
          <td>&quot;SPARQL Protocol Tutorial&quot;</td>
        </tr>
        <tr>
          <td>&quot;Bob&quot;</td>
          <td>&quot;SPARQL Query Language Tutorial&quot;</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>This query will only match a book if it has both a title and creator predicate 
from the same version of Dublin Core.</p>
<div class="grammarExtract">
  Grammar rule:<div class="grammarTable">
    <table id="table117">
      <tr>
  <td><code class="gRuleLabel">[25]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rGroupOrUnionGraphPattern">GroupOrUnionGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rGroupGraphPattern">GroupGraphPattern</a> 
  <br/>
  ( <span class="token">'UNION'</span> <a href="#rGroupGraphPattern">GroupGraphPattern</a> )*</code></td>
      </tr>
    </table>
  </div>
</div>

<h2>8 <a id="rdfDataset" name="rdfDataset">RDF Dataset</a></h2>
<p>The RDF data model expresses information as graphs consisting of triples with 
subject, predicate and object. Many RDF data stores hold multiple RDF graphs and 
record information about each graph, allowing an application to make queries that 
involve information from more than one graph.</p>
<p>A SPARQL query is executed against an <em>RDF Dataset</em> which represents a 
collection of graphs. An RDF Dataset comprises one graph, the default graph, which 
does not have a name, and zero or more named graphs, where each named graph is identified by 
an IRI. A SPARQL 
query can match different parts of the query pattern against different graphs as 
described in section <a href="#queryDataset">8.3 Querying the Dataset</a>. </p>
<p>An RDF Dataset may contain zero named graphs; an RDF Dataset always contains one default graph. 
A query does not need to involve 
matching the default graph; the query can just involve matching named graphs.</p>
<p>The graph that is used for matching a basic graph pattern is the <i>active 
graph</i>. In the previous sections, all queries have been shown executed 
against a single graph, the default graph of an RDF dataset as the active graph. 
The <code>GRAPH</code> keyword is used to make the active graph one of all of 
the named graphs in the dataset for part of the query.</p>
<h3>8.1 <a name="exampleDatasets" id="exampleDatasets">Examples of RDF Datasets</a></h3>
<p>The definition of RDF Dataset does not restrict the relationships of named and 
default graphs. Information can be repeated in different graphs; relationships between 
graphs can be exposed. Two useful arrangements are:</p>
<ul>
  <li>to have information in the default graph that includes provenance information 
  about the named graphs</li>
  <li>to include the information in the named graphs in the default graph as well.</li>
</ul>
<div class="exampleGroup">
  <b>Example 1:</b><pre class="data">
# <b>Default graph</b>
@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt; .

&lt;http://example.org/bob&gt;    dc:publisher  &quot;Bob&quot; .
&lt;http://example.org/alice&gt;  dc:publisher  &quot;Alice&quot; .
</pre>
  <pre class="data">
# <b>Named graph: http://example.org/bob</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Bob&quot; .
_:a foaf:mbox &lt;mailto:bob@oldcorp.example.org&gt; .
</pre>
  <pre class="data">
# <b>Named graph: http://example.org/alice</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a foaf:mbox &lt;mailto:alice@work.example.org&gt; .
</pre>
</div>
<p>In this example, the default graph contains the names of the publishers of two 
named graphs. The triples in the named graphs are not visible in the default graph 
in this example.</p>
<p id="ex_2"><b>Example 2:</b></p>
<p>RDF data can be combined by the
<a class="norm" href="http://www.w3.org/TR/rdf-mt/#graphdefs">RDF merge</a>
[<a href="#RDF-MT">RDF-MT</a>] of graphs. One possible arrangement of graphs in 
an RDF Dataset is to have the default graph be the RDF merge of some or all of 
the information in the named graphs.</p>
<p>In this next example, the named graphs contain the same triples as before. The 
RDF dataset includes an RDF merge of the named graphs in the default graph, re-labeling 
blank nodes to keep them distinct.</p>
<div class="exampleGroup">
  <pre class="data">
# <b>Default graph</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:x foaf:name &quot;Bob&quot; .
_:x foaf:mbox &lt;mailto:bob@oldcorp.example.org&gt; .

_:y foaf:name &quot;Alice&quot; .
_:y foaf:mbox &lt;mailto:alice@work.example.org&gt; .
</pre>
  <pre class="data">
# <b>Named graph: http://example.org/bob</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Bob&quot; .
_:a foaf:mbox &lt;mailto:bob@oldcorp.example.org&gt; .
</pre>
  <pre class="data">
# <b>Named graph: http://example.org/alice</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a foaf:mbox &lt;<a href="mailto:alice@work.example">mailto:alice@work.example</a>&gt; .</pre>
  <p>In an RDF merge, blank nodes in the merged graph are not shared with blank 
  nodes from the graphs being merged.</p>
</div>
<h3>8.2 <a id="specifyingDataset" name="specifyingDataset">Specifying RDF Datasets</a></h3>
<p>A SPARQL query may specify the dataset to be used for matching by using the
<code>FROM</code> clause and the <code>FROM NAMED</code> clause to describe the 
RDF dataset. If a query provides such a dataset description, then it is used in 
place of any dataset that the query service would use if no dataset description 
is provided in a query. The RDF dataset may also be
<a class="inform" href="http://www.w3.org/TR/rdf-sparql-protocol/#specify-dataset">
specified in a SPARQL protocol request</a>, in which case the protocol description 
overrides any description in the query itself. A query service may refuse a query 
request if the dataset description is not acceptable to the service.</p>
<p>The <code>FROM</code> and <code>FROM NAMED</code> keywords allow a query to specify 
an RDF dataset by reference; they indicate that the dataset should include graphs 
that are obtained from representations of the resources identified by the given 
IRIs (i.e. the absolute form of the given IRI references). The dataset resulting 
from a number of <code>FROM</code> and <code>FROM NAMED</code> clauses is:</p>
<ul>
  <li>a default graph consisting of the RDF merge of the graphs referred to in the
  <code>FROM</code> clauses, and</li>
  <li>a set of (IRI, graph) pairs, one from each <code>FROM NAMED</code> clause.</li>
</ul>
<p>If there is no <code>FROM</code> clause, but there is one or more <code>FROM NAMED</code> 
clauses, then the dataset includes an empty graph for the default graph.</p>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table101">
      <tr>
  <td><code class="gRuleLabel">[9]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDatasetClause">DatasetClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'FROM'</span> ( <a href="#rDefaultGraphClause">DefaultGraphClause</a> | <a href="#rNamedGraphClause">NamedGraphClause</a> )</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[10]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDefaultGraphClause">DefaultGraphClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rSourceSelector">SourceSelector</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[11]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rNamedGraphClause">NamedGraphClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'NAMED'</span> <a href="#rSourceSelector">SourceSelector</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[12]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rSourceSelector">SourceSelector</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRIref">IRIref</a></code></td>
      </tr>
    </table>
  </div>
</div>
<h4>8.2.1 <a id="unnamedGraph" name="unnamedGraph">Specifying the Default Graph</a></h4>
<p>Each <code>FROM</code> clause contains an IRI that indicates a graph to be 
used to form the default graph. This does not put the graph in as a named graph.</p>
<p>In this example, the RDF Dataset contains a single default graph and no named graphs:</p>
<div class="exampleGroup">
  <pre class="data">
<b># Default graph (stored at http://example.org/foaf/aliceFoaf)
</b>@prefix  foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name     &quot;Alice&quot; .
_:a  foaf:mbox     &lt;mailto:alice@work.example&gt; .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT  ?name
FROM    &lt;http://example.org/foaf/aliceFoaf&gt;
WHERE   { ?x foaf:name ?name }
</pre>
    <div class="result">
      <table class="resultTable" id="table102">
        <tr>
          <th>name</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>If a query provides more than one <code>FROM</code> clause, providing more than 
one IRI to indicate the default graph, then the default graph is based on the
<a class="norm" href="http://www.w3.org/TR/rdf-mt/#graphdefs">RDF merge</a> of the 
graphs obtained from representations of the resources identified by the given IRIs.</p>
<h4>8.2.2 <a id="namedGraphs" name="namedGraphs">Specifying Named Graphs</a></h4>
<p>A query can supply IRIs for the named graphs in the RDF Dataset using the
<code>FROM NAMED</code> clause. Each IRI is used to provide one named graph in the 
RDF Dataset. Using the same IRI in two or more <code>FROM NAMED</code> clauses results 
in one named graph with that IRI appearing in the dataset.</p>
<pre class="data"><b># Graph: http://example.org/bob</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Bob&quot; .
_:a foaf:mbox &lt;mailto:bob@oldcorp.example.org&gt; .
</pre>
<pre class="data"># <b>Graph: http://example.org/alice</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a foaf:mbox &lt;mailto:alice@work.example&gt; .
</pre>
<div class="queryGroup">
  <pre class="query">...
FROM NAMED &lt;http://example.org/alice&gt;
FROM NAMED &lt;http://example.org/bob&gt;
...</pre>
</div>
<p>The <code>FROM NAMED</code> syntax suggests that the IRI identifies the corresponding 
graph, but the relationship between an IRI and a graph in an RDF dataset 
is indirect. The IRI identifies a resource, and the resource is represented by a 
graph (or, more precisely: by a document that serializes a graph). For
<a class="inform" href="http://www.w3.org/TR/webarch/#intro">further details</a> 
see [<a href="#WEBARCH">WEBARCH</a>].</p>
<h4>8.2.3 <a id="specDataset" name="specDataset">Combining FROM and FROM NAMED</a></h4>
<p>The <code>FROM</code> clause and <code>FROM NAMED</code> clause can be used in 
the same query.</p>
<div class="exampleGroup">
  <pre class="data">
# <b>Default graph (stored at http://example.org/dft.ttl)
</b>@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt; .

&lt;http://example.org/bob&gt;    dc:publisher  &quot;Bob Hacker&quot; .
&lt;http://example.org/alice&gt;  dc:publisher  &quot;Alice Hacker&quot; .
</pre>
  <pre class="data">
# <b>Named graph: http://example.org/bob</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Bob&quot; .
_:a foaf:mbox &lt;mailto:bob@oldcorp.example.org&gt; .
</pre>
  <pre class="data">
# <b>Named graph: http://example.org/alice</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a foaf:mbox &lt;mailto:alice@work.example.org&gt; .
</pre>
    <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;

SELECT ?who ?g ?mbox
FROM &lt;http://example.org/dft.ttl&gt;
FROM NAMED &lt;http://example.org/alice&gt;
FROM NAMED &lt;http://example.org/bob&gt;
WHERE
{
   ?g dc:publisher ?who .
   GRAPH ?g { ?x foaf:mbox ?mbox }
}
</pre>
</div>
<p>The RDF Dataset for this query contains a default graph and two named graphs. 
The <code>GRAPH</code> keyword is described below.</p>
<h3>8.3 <a id="queryDataset" name="queryDataset">Querying the Dataset</a></h3>
<p>When querying a collection of graphs, the <code>GRAPH</code> keyword is used 
to match patterns against named graphs. <code>GRAPH</code> can provide an IRI to select 
one graph or use a variable which will range over the IRI of all the named graphs in the query's RDF dataset.</p>
<p>The use of <code>GRAPH</code> changes the active graph for matching basic 
graph patterns within part of the query. Outside the use of <code>GRAPH</code>, 
the default graph is matched by basic graph patterns.</p>
<p>The following two graphs will be used in examples:</p>
<div class="exampleGroup">
  <pre class="data">
<b># Named graph: http://example.org/foaf/aliceFoaf
</b>@prefix  foaf:     &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix  rdf:      &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix  rdfs:     &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .

_:a  foaf:name     &quot;Alice&quot; .
_:a  foaf:mbox     &lt;mailto:alice@work.example&gt; .
_:a  foaf:knows    _:b .

_:b  foaf:name     &quot;Bob&quot; .
_:b  foaf:mbox     &lt;mailto:bob@work.example&gt; .
_:b  foaf:nick     &quot;Bobby&quot; .
_:b  rdfs:seeAlso  &lt;http://example.org/foaf/bobFoaf&gt; .

&lt;http://example.org/foaf/bobFoaf&gt;
     rdf:type      foaf:PersonalProfileDocument .
</pre>
  <pre class="data">
<b># Named graph: http://example.org/foaf/bobFoaf
</b>@prefix  foaf:     &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix  rdf:      &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix  rdfs:     &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .

_:z  foaf:mbox     &lt;mailto:bob@work.example&gt; .
_:z  rdfs:seeAlso  &lt;http://example.org/foaf/bobFoaf&gt; .
_:z  foaf:nick     &quot;Robert&quot; .

&lt;http://example.org/foaf/bobFoaf&gt;
     rdf:type      foaf:PersonalProfileDocument .
</pre>
  <div class="grammarExtract">
    Grammar rule:<div class="grammarTable">
      <table id="table104">
        <tr>
  <td><code class="gRuleLabel">[24]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rGraphGraphPattern">GraphGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'GRAPH'</span> <a href="#rVarOrIRIref">VarOrIRIref</a> <a href="#rGroupGraphPattern">GroupGraphPattern</a></code></td>
        </tr>
      </table>
    </div>
  </div>
  <h4>8.3.1 <a id="accessByLabel" name="accessByLabel">Accessing Graph Names</a></h4>
  <p>The query below matches the graph pattern against each of the named graphs in the 
  dataset and forms solutions which have the <code>src</code> variable bound to 
  IRIs of the graph being matched. The graph pattern is matched with the active 
  graph being each of the named graphs in the dataset. </p>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;

SELECT ?src ?bobNick
FROM NAMED &lt;http://example.org/foaf/aliceFoaf&gt;
FROM NAMED &lt;http://example.org/foaf/bobFoaf&gt;
WHERE
  {
    GRAPH ?src
    { ?x foaf:mbox &lt;mailto:bob@work.example&gt; .
      ?x foaf:nick ?bobNick
    }
  }
</pre>
    <p>The query result gives the name of the graphs where the information was found 
    and the value for Bob&#39;s nick:</p>
    <div class="result">
      <table class="resultTable" id="table105">
        <tr>
          <th>src</th>
          <th>bobNick</th>
        </tr>
        <tr>
          <td>&lt;http://example.org/foaf/aliceFoaf&gt;</td>
          <td>&quot;Bobby&quot;</td>
        </tr>
        <tr>
          <td>&lt;http://example.org/foaf/bobFoaf&gt;</td>
          <td>&quot;Robert&quot;</td>
        </tr>
      </table>
    </div>
  </div>
  <h4>8.3.2 <a id="restrictByLabel" name="restrictByLabel">Restricting by Graph 
  IRI</a></h4>
  <p>The query can restrict the matching applied to a specific graph by supplying 
  the graph IRI. This sets the active graph to the graph named by the IRI. This query looks for Bob&#39;s nick as given in the graph <code>http://example.org/foaf/bobFoaf</code>.</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX data: &lt;http://example.org/foaf/&gt;

SELECT ?nick
FROM NAMED &lt;http://example.org/foaf/aliceFoaf&gt;
FROM NAMED &lt;http://example.org/foaf/bobFoaf&gt;
WHERE
  {
     GRAPH data:bobFoaf {
         ?x foaf:mbox &lt;mailto:bob@work.example&gt; .
         ?x foaf:nick ?nick }
  }
</pre>
    <p>which yields a single solution:</p>
    <div class="result">
      <table class="resultTable" id="table106">
        <tr>
          <th>nick</th>
        </tr>
        <tr>
          <td>&quot;Robert&quot;</td>
        </tr>
      </table>
    </div>
  </div>
  <h4>8.3.3 <a id="restrictInQuery" name="restrictInQuery">Restricting Possible Graph IRIs</a></h4>
  <p>A variable used in the <code>GRAPH</code> clause may also be used in another
  <code>GRAPH</code> clause or in a graph pattern matched against the default graph 
  in the dataset.</p>
  <p>The query below uses the graph 
  with IRI <code>http://example.org/foaf/aliceFoaf</code> to find the profile document 
  for Bob; it then matches another pattern against that graph. The pattern in the 
  second <code>GRAPH</code> clause finds the blank node (variable <code>w</code>) 
  for the person with the same mail box (given by variable <code>mbox</code>) as 
  found in the first <code>GRAPH</code> clause (variable <code>whom</code>), because 
  the blank node used to match for variable <code>whom</code> from Alice&#39;s FOAF 
  file is not the same as the blank node in the profile document (they are in different 
  graphs).</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX  data:  &lt;http://example.org/foaf/&gt;
PREFIX  foaf:  &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX  rdfs:  &lt;http://www.w3.org/2000/01/rdf-schema#&gt;

SELECT ?mbox ?nick ?ppd
FROM NAMED &lt;http://example.org/foaf/aliceFoaf&gt;
FROM NAMED &lt;http://example.org/foaf/bobFoaf&gt;
WHERE
{
  GRAPH data:aliceFoaf
  {
    ?alice foaf:mbox &lt;mailto:alice@work.example&gt; ;
           foaf:knows ?whom .
    ?whom  foaf:mbox ?mbox ;
           rdfs:seeAlso ?ppd .
    ?ppd  a foaf:PersonalProfileDocument .
  } .
  GRAPH ?ppd
  {
      ?w foaf:mbox ?mbox ;
         foaf:nick ?nick
  }
}
</pre>
    <div class="result">
      <table class="resultTable" id="table107">
        <tr>
          <th>mbox</th>
          <th>nick</th>
          <th>ppd</th>
        </tr>
        <tr>
          <td>&lt;mailto:bob@work.example&gt;</td>
          <td>&quot;Robert&quot;</td>
          <td>&lt;http://example.org/foaf/bobFoaf&gt;</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>Any triple in Alice&#39;s FOAF file giving Bob&#39;s <code>nick</code> is not used to 
provide a nick for Bob because the pattern involving variable <code>nick</code> 
is restricted by <code>ppd</code> to a particular Personal Profile Document.</p>
<h4>8.3.4 <a id="namedAndDefaultGraph" name="namedAndDefaultGraph">Named and Default 
Graphs</a></h4>
<p>Query patterns can involve both the default graph and the named graphs. In this 
example, an aggregator has read in a Web resource on two different occasions. Each 
time a graph is read into the aggregator, it is given an IRI by the local system. 
The graphs are nearly the same but the email address for &quot;Bob&quot; has changed.</p>
<p>In this example, the default graph is being used to record the provenance information and the 
RDF data actually read is kept in two separate graphs, each of which is given a 
different IRI by the system. The RDF dataset consists of two named graphs and the 
information about them.</p>
<p>RDF Dataset:</p>
<div class="exampleGroup">
  <pre class="data">
# <b>Default graph</b>
@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix g:  &lt;tag:example.org,2005-06-06:&gt; .
@prefix xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt; .

g:graph1 dc:publisher &quot;Bob&quot; .
g:graph1 dc:date &quot;2004-12-06&quot;^^xsd:date .

g:graph2 dc:publisher &quot;Bob&quot; .
g:graph2 dc:date &quot;2005-01-10&quot;^^xsd:date .
</pre>
  <pre class="data">
# <b>Graph: locally allocated IRI: tag:example.org,2005-06-06:graph1</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a foaf:mbox &lt;mailto:alice@work.example&gt; .

_:b foaf:name &quot;Bob&quot; .
_:b foaf:mbox &lt;mailto:bob@oldcorp.example.org&gt; .
</pre>
  <pre class="data">
# <b>Graph: locally allocated IRI: tag:example.org,2005-06-06:graph2</b>
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a foaf:mbox &lt;mailto:alice@work.example&gt; .

_:b foaf:name &quot;Bob&quot; .
_:b foaf:mbox &lt;mailto:bob@newcorp.example.org&gt; .
</pre>
  <p>This query finds email addresses, detailing the name of the person and the 
  date the information was discovered.</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX dc:   &lt;http://purl.org/dc/elements/1.1/&gt;

SELECT ?name ?mbox ?date
WHERE
  {  ?g dc:publisher ?name ;
        dc:date ?date .
    GRAPH ?g
      { ?person foaf:name ?name ; foaf:mbox ?mbox }
  }
</pre>
    <p>The results show that the email address for &quot;Bob&quot; has changed.</p>
    <div class="result">
      <table class="resultTable" id="table108">
        <tr>
          <th>name</th>
          <th>mbox</th>
          <th>date</th>
        </tr>
        <tr>
          <td>&quot;Bob&quot;</td>
          <td>&lt;mailto:bob@oldcorp.example.org&gt;</td>
          <td>&quot;2004-12-06&quot;^^xsd:date</td>
        </tr>
        <tr>
          <td>&quot;Bob&quot;</td>
          <td>&lt;mailto:bob@newcorp.example.org&gt;</td>
          <td>&quot;2005-01-10&quot;^^xsd:date</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<p>The IRI for the date datatype has been abbreviated in the results for clarity.</p>

<h2>9 <a name="solutionModifiers" id="solutionModifiers">Solution Sequences and Modifiers</a></h2>
<p>Query patterns generate an unordered collection of solutions, each
<a href="#defn_sparqlSolutionMapping">solution</a> being a partial function from variables to RDF terms. 
These solutions are then treated as a sequence (a solution sequence), initially in no specific order; 
any sequence modifiers are then applied to create another sequence. Finally, this 
latter sequence is used to generate one of the results of a
<a href="#QueryForms">SPARQL query form</a>.</p>
<p>A <span class="definedTerm">solution sequence modifier</span> is one of:</p>
<ul>
  <li><a href="#modOrderBy">Order</a> modifier: put the solutions in order</li>
  <li><a href="#modProjection">Projection</a> modifier: choose certain 
  variables</li>
  <li><a href="#modDistinct">Distinct</a> modifier: ensure solutions in the 
  sequence are unique</li>
  <li><a href="#modReduced">Reduced</a> modifier: permit elimination of some non-unique solutions</li>
  <li><a href="#modOffset">Offset</a> modifier: control where the solutions 
  start from in the overall sequence of solutions</li>
  <li><a href="#modResultLimit">Limit</a> modifier: restrict the number of solutions</li>
</ul>
<p>Modifiers are applied in the order given by the list above.</p>
<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table id="table125">
      <tr>
  <td><code class="gRuleLabel">[5]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rSelectQuery">SelectQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'SELECT'</span> ( <span class="token">
  'DISTINCT'</span> | <span class="token"> 'REDUCED'</span> )? ( <a href="#rVar">Var</a>+ | <span class="token">'*'</span> 
  ) <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">
  WhereClause</a> <a href="#rSolutionModifier">SolutionModifier</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[14]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rSolutionModifier">SolutionModifier</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rOrderClause">OrderClause</a>? <a href="#rLimitOffsetClauses">
  LimitOffsetClauses</a>?</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[15]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rLimitOffsetClauses">LimitOffsetClauses</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">( <a href="#rLimitClause">LimitClause</a> <a href="#rOffsetClause">
  OffsetClause</a>? | <a href="#rOffsetClause">OffsetClause</a> <a href="#rLimitClause">
  LimitClause</a>? )</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[16]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOrderClause">OrderClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'ORDER'</span> <span class="token">
  'BY'</span> <a href="#rOrderCondition">OrderCondition</a>+</code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[17]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOrderCondition">OrderCondition</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">   ( ( <span class="token">'ASC'</span> | <span class="token">
  'DESC'</span> ) <a href="#rBrackettedExpression">BrackettedExpression</a> )<br/>
  | ( <a href="#rConstraint">Constraint</a> | <a href="#rVar">Var</a> ) </code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[18]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rLimitClause">LimitClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'LIMIT'</span> <a href="#rINTEGER">
  INTEGER</a></code></td>
      </tr>
      <tr>
  <td><code class="gRuleLabel">[19]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOffsetClause">OffsetClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'OFFSET'</span> <a href="#rINTEGER">
  INTEGER</a></code></td>
      </tr>
    </table>
  </div>
</div>

<h3>9.1 <a id="modOrderBy" name="modOrderBy">ORDER BY</a></h3>

<p>The <code>ORDER BY</code> clause establishes the order of a solution sequence.</p>

<p>Following the <code>ORDER BY</code> clause is a sequence of order comparators, composed of an expression and an optional order modifier (either <code>ASC()</code> or <code>DESC()</code>). Each ordering comparator is either ascending (indicated by the <code>ASC()</code> modifier or by no modifier) or descending (indicated by the <code>DESC()</code> modifier).</p>

<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;

SELECT ?name
WHERE { ?x foaf:name ?name }
ORDER BY ?name
</pre>
  </div>
</div>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX     :    &lt;http://example.org/ns#&gt;
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX xsd:     &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?name
WHERE { ?x foaf:name ?name ; :empId ?emp }
ORDER BY DESC(?emp)
</pre>
  </div>
</div>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;

SELECT ?name
WHERE { ?x foaf:name ?name ; :empId ?emp }
ORDER BY ?name DESC(?emp)
</pre>
  </div>
</div>

<p>The <a href="#op_lt">&quot;&lt;&quot; operator</a> (see the <a href="#OperatorMapping">Operator Mapping</a> and <a href="#operatorExtensibility">11.3.1 Operator Extensibility</a>) defines 
the relative order of pairs of <code>numerics</code>, <code>simple literals</code>, <code>xsd:strings</code>, <code>xsd:booleans</code> 
and <code>xsd:dateTimes</code>. Pairs of IRIs are ordered by comparing them as <code>simple literals</code>.</p>

<p>SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be ordered:</p>
<ol>
  <li>(Lowest) no value assigned to the variable or expression in this solution.</li>
  <li>Blank nodes</li>
  <li>IRIs</li>
  <li>RDF literals</li>
  <li>A plain literal is lower than an RDF literal with type <code>xsd:string</code> 
  of the same lexical form.</li>
</ol>

    <p>The relative order of literals with language tags or typed literals with different types is undefined.</p>

    <p>This list of variable bindings is in ascending order:</p>

    <div class="result">
    <table class="resultTable">
      <thead>
	<tr><th>RDF Term</th><th>Reason</th></tr>
      </thead>
      <tbody>
	<tr><td></td><td>Unbound results sort earliest.</td></tr>
	<tr><td><code>_:z</code></td><td>Blank nodes follow unbound.</td></tr>
	<tr><td><code>_:a</code></td><td>There is no relative ordering of blank nodes.</td></tr>
	<tr><td><code>&lt;http://script.example/Latin&gt;</code></td><td>IRIs follow blank nodes.</td></tr>
	<tr><td><code>&lt;http://script.example/&#1050;&#1080;&#1088;&#1080;&#1083;&#1083;&#1080;&#1094;&#1072;&gt;</code></td><td>The character in the 23rd position, "&#1050;", has a unicode codepoint 0x41A, which is higher than 0x4C ("L").</td></tr>
	<tr><td><code>&lt;http://script.example/&#26085;&#26412;&#35486;&gt;</code></td><td>The character in the 23rd position, "&#26085;", has a unicode codepoint 0x65E5, which is higher than 0x41A ("&#1050;").</td></tr>
	<tr><td><code>"http://script.example/Latin"</code></td><td>Simple literals follow IRIs.</td></tr>
	<tr><td><code>"http://script.example/Latin"^^xsd:string</code></td><td>xsd:strings follow simple literals.</td></tr>
      </tbody>
    </table>
    </div>

<p>The ascending order of two solutions with respect to an ordering comparator is established by substituting the solution bindings into the expressions and comparing them with the <a href="#op_lt">"&lt;" operator</a>. The descending order is the reverse of the ascending order.</p>

<p>The relative order of two solutions is the relative order of the two solutions with respect to the first ordering comparator in the sequence. For solutions where the substitutions of the solution bindings produce the same RDF term, the order is the relative order of the two solutions with respect to the next ordering comparator. The relative order of two solutions is undefined if no order expression evaluated for the two solutions produces distinct RDF terms.</p>

<p>Ordering a sequence of solutions always results in a sequence with the same number 
of solutions in it.</p>

<p>Using <code>ORDER BY</code> on a solution sequence for a <code>CONSTRUCT</code> or
<code>DESCRIBE</code> query has no direct effect because only <code>SELECT</code> returns 
a sequence of results. Used in combination with <code>LIMIT</code> and <code>OFFSET</code>, 
<code>ORDER BY</code> can be used to return results generated from a different slice of the solution sequence.
An <code>ASK</code> query does not include <code>ORDER BY</code>, <code>LIMIT</code> or <code>OFFSET</code>.
</p>

<div class="grammarExtract">
  Grammar rules:<div class="grammarTable">
    <table>
<tr>
  <td><code class="gRuleLabel">[16]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOrderClause">OrderClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'ORDER'</span> <span class="token">'BY'</span> <a href="#rOrderCondition">OrderCondition</a>+</code></td>
</tr>
<tr>
  <td><code class="gRuleLabel">[17]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOrderCondition">OrderCondition</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">   ( ( <span class="token">'ASC'</span> | <span class="token">'DESC'</span> ) <a href="#rBrackettedExpression">BrackettedExpression</a> )<br/>| ( <a href="#rConstraint">Constraint</a> | <a href="#rVar">Var</a> ) </code></td>
</tr>
<tr>
  <td><code class="gRuleLabel">[18]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rLimitClause">LimitClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'LIMIT'</span> <a href="#rINTEGER">INTEGER</a></code></td>
</tr>
<tr>
  <td><code class="gRuleLabel">[19]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rOffsetClause">OffsetClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'OFFSET'</span> <a href="#rINTEGER">INTEGER</a></code></td>
</tr>

    </table>
  </div>
</div>


<h3>9.2 <a id="modProjection" name="modProjection">Projection</a></h3>
<p>The solution sequence can be transformed into one involving only a subset of 
the variables. For each solution in the sequence, a new solution is formed using 
a specified selection of the variables using the SELECT query form.</p>
<p>The following example shows a query to extract just the names of people described 
in an RDF graph using FOAF properties.</p>
<div class="exampleGroup">
  <pre class="data">
@prefix foaf:        &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       &quot;Alice&quot; .
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  foaf:name       &quot;Bob&quot; .
_:b  foaf:mbox       &lt;mailto:bob@work.example&gt; .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:       &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name
WHERE
 { ?x foaf:name ?name }
</pre>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>name</th>
        </tr>
        <tr>
          <td>&quot;Bob&quot;</td>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
      </table>
    </div>
  </div>
</div>

<h3>9.3 <a id="modDuplicates" name="modDuplicates">Duplicate Solutions</a></h3>

<p>A solution sequence with no <code>DISTINCT</code> or <code>REDUCED</code> query modifier 
will preserve duplicate solutions.</p>

<div class="exampleGroup">
  <pre class="data">
@prefix  foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:x    foaf:name   &quot;Alice&quot; .
_:x    foaf:mbox   &lt;mailto:alice@example.com&gt; .

_:y    foaf:name   &quot;Alice&quot; .
_:y    foaf:mbox   &lt;mailto:asmith@example.com&gt; .

_:z    foaf:name   &quot;Alice&quot; .
_:z    foaf:mbox   &lt;mailto:alice.smith@example.com&gt; .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name WHERE { ?x foaf:name ?name }
</pre>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>name</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
      </table>
    </div>
  </div>

      <p>The modifiers <code>DISTINCT</code> and <code>REDUCED</code> affect whether duplicates are included in the query results.</p>

<h4>9.3.1 <a id="modDistinct" name="modDistinct">DISTINCT</a></h4>

<p>The <code>DISTINCT</code> solution modifier eliminates duplicate solutions. Specifically, each solution that binds the same variables to the same RDF terms as another solution is eliminated from the solution set.</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT DISTINCT ?name WHERE { ?x foaf:name ?name }
</pre>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>name</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
      </table>
    </div>
  </div>
<p id="defunSELECT">Note that, per the <a href="#solutionModifiers">order of solution sequence modifiers</a>, duplicates are eliminated before either limit or offset is applied.</p>

<h4>9.3.2 <a id="modReduced" name="modReduced">REDUCED</a></h4>
    <p>While the <code>DISTINCT</code> modifier ensures that duplicate solutions are eliminated from the solution set, <code>REDUCED</code> simply permits them to be eliminated. The cardinality of any set of variable bindings in an <code>REDUCED</code> solution set is at least one and not more than the cardinality of the solution set with no <code>DISTINCT</code> or <code>REDUCED</code> modifier. For example, using the data above, the query</p>

  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT REDUCED ?name WHERE { ?x foaf:name ?name }
</pre>
<p>may have one, two (shown here) or three solutions:</p>
    <div class="result">
      <table class="resultTable">
        <tr>
          <th>name</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
        </tr>
      </table>
    </div>
  </div>

      <p class="issue issueBlock">The <code>REDUCED</code> feature is <em>at
      risk</em>. Queries using the <code>REDUCED</code> keywords will not have
      any counting semantics and will therefore not be useful with aggregate functions added to SPARQL or performed on SPARQL result sets.</p>
</div>

<h3>9.4 <a id="modOffset" name="modOffset">OFFSET</a></h3>
<p><code>OFFSET</code> causes the solutions generated to start after the specified 
number of solutions. An <code>OFFSET</code> of zero has no effect.</p>
<p>Using <code>
LIMIT</code> and <code>OFFSET</code> to select different subsets of the query solutions 
will not be useful unless the order is made predictable by using <code>ORDER BY</code>.</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;

SELECT  ?name
WHERE   { ?x foaf:name ?name }
ORDER BY ?name
LIMIT   5
OFFSET  10</pre>
  </div>
</div>

<h3>9.5 <a id="modResultLimit" name="modResultLimit">LIMIT</a></h3>
<p>The <code>LIMIT</code> clause puts an upper bound on the number of solutions returned. If the 
number of actual solutions is greater than the limit, then at most the limit number 
of solutions will be returned.</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;

SELECT ?name
WHERE { ?x foaf:name ?name }
LIMIT 20
</pre>
  </div>
</div>
<p>A <code>LIMIT</code> of 0 would cause no results to be returned. A limit may not be negative.</p>


<h2>10 <a id="QueryForms" name="QueryForms">Query Forms</a></h2>
<p>SPARQL has four query forms. These query forms use the solutions from 
pattern matching to form result sets or RDF graphs. The query forms are:</p>
<blockquote>
  <dl>
    <dt><a href="#select">SELECT</a></dt>
    <dd>Returns all, or a subset of, the variables bound in a query pattern match.</dd>
    <dt><a href="#construct">CONSTRUCT</a></dt>
    <dd>Returns an RDF graph constructed by substituting variables in a set of triple 
    templates.</dd>
    <dt><a href="#ask">ASK</a></dt>
    <dd>Returns a boolean indicating whether a query pattern matches or not.</dd>
    <dt><a href="#describe">DESCRIBE</a></dt>
    <dd>Returns an RDF graph that describes the resources found.</dd>
  </dl>
</blockquote>
<p>The <a class="inform" href="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL Variable 
Binding Results XML Format</a> can be used to serialize the result set from a <code>
SELECT</code> query or the boolean result of an <code>ASK</code> query.</p>


<h3>10.1 <a name="select">SELECT</a></h3>
<p>The SELECT form of results returns variables and their bindings directly. The syntax <code>SELECT 
*</code> is an abbreviation that selects all of the variables in a query.</p>
<div class="exampleGroup">
  <pre class="data">
@prefix  foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a    foaf:name   &quot;Alice&quot; .
_:a    foaf:knows  _:b .
_:a    foaf:knows  _:c .

_:b    foaf:name   &quot;Bob&quot; .

_:c    foaf:name   &quot;Clare&quot; .
_:c    foaf:nick   &quot;CT&quot; .

</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?nameX ?nameY ?nickY
WHERE
  { ?x foaf:knows ?y ;
       foaf:name ?nameX .
    ?y foaf:name ?nameY .
    OPTIONAL { ?y foaf:nick ?nickY }
  }
</pre>
    <div class="result">
      <table class="resultTable" id="table33">
        <tr>
          <th>nameX</th>
          <th>nameY</th>
          <th>nickY</th>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
          <td>&quot;Bob&quot;</td>
          <td></td>
        </tr>
        <tr>
          <td>&quot;Alice&quot;</td>
          <td>&quot;Clare&quot;</td>
          <td>&quot;CT&quot;</td>
        </tr>
      </table>
    </div>
    <p>Result sets can be accessed by a local API but also can be serialized into 
    either XML or an RDF graph. An XML format is described in
    <a class="inform" href="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL Query 
    Results XML Format</a>, and gives for this example:</p>
    <div class="result">
      <pre class="resultSet">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;sparql xmlns=&quot;http://www.w3.org/2005/sparql-results#&quot;&gt;
  &lt;head&gt;
    &lt;variable name=&quot;nameX&quot;/&gt;
    &lt;variable name=&quot;nameY&quot;/&gt;
    &lt;variable name=&quot;nickY&quot;/&gt;
  &lt;/head&gt;
  &lt;results&gt;
    &lt;result&gt;
      &lt;binding name=&quot;nameX&quot;&gt;
        &lt;literal&gt;Alice&lt;/literal&gt;
      &lt;/binding&gt;
      &lt;binding name=&quot;nameY&quot;&gt;
        &lt;literal&gt;Bob&lt;/literal&gt;
      &lt;/binding&gt;
   &lt;/result&gt;
    &lt;result&gt;
      &lt;binding name=&quot;nameX&quot;&gt;
        &lt;literal&gt;Alice&lt;/literal&gt;
      &lt;/binding&gt;
      &lt;binding name=&quot;nameY&quot;&gt;
        &lt;literal&gt;Clare&lt;/literal&gt;
      &lt;/binding&gt;
      &lt;binding name=&quot;nickY&quot;&gt;
        &lt;literal&gt;CT&lt;/literal&gt;
      &lt;/binding&gt;
    &lt;/result&gt;
  &lt;/results&gt;
&lt;/sparql&gt;
</pre>
    </div>
  </div>
</div>
<div class="grammarExtract">
  Grammar rule:<div class="grammarTable">
  <table>

<tr valign="baseline">
  <td><code class="gRuleLabel">[5]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rSelectQuery">SelectQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'SELECT'</span> ( <span class="token">'DISTINCT'</span> | <span class="token"> 'REDUCED'</span> )? ( <a href="#rVar">Var</a>+ | <span class="token">'*'</span> )<br/>
  <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a> <a href="#rSolutionModifier">SolutionModifier</a></code></td>
</tr>

    </table>
  </div>
</div>

<h3>10.2 <a id="construct" name="construct">CONSTRUCT</a></h3>
<p>The <code>CONSTRUCT</code> query form returns a single RDF graph specified by 
a graph template. The result is an RDF graph formed by taking each query solution 
in the solution sequence, substituting for the variables in the graph template, 
and combining the triples into a single RDF graph by set union.</p>
<p>If any such instantiation produces a triple containing an unbound variable or 
an illegal RDF construct, such as a literal in subject or predicate position, then 
that triple is not included in the output RDF graph. The graph template can contain 
triples with no variables (known as ground or explicit triples), and these also appear 
in the output RDF graph returned by the CONSTRUCT query form.</p>
<div class="exampleGroup">
  <pre class="data">
@prefix  foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a    foaf:name   &quot;Alice&quot; .
_:a    foaf:mbox   &lt;mailto:alice@example.org&gt; .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX vcard:   &lt;http://www.w3.org/2001/vcard-rdf/3.0#&gt;
CONSTRUCT   { &lt;http://example.org/person#Alice&gt; vcard:FN ?name }
WHERE       { ?x foaf:name ?name }
</pre>
    <p>creates vcard properties from the FOAF information:</p>
    <div class="result">
      <pre class="resultGraph" style="text-align:left;">
@prefix vcard: &lt;http://www.w3.org/2001/vcard-rdf/3.0#&gt; .

&lt;http://example.org/person#Alice&gt; vcard:FN &quot;Alice&quot; .
</pre>
    </div>
  </div>
</div>

<h3>10.2.1 <a id="tempatesWithBNodes" name="tempatesWithBNodes">Templates with Blank Nodes</a></h3>
<p>A template can create an RDF graph containing blank nodes. The blank node labels 
are scoped to the template for each solution. If the same label occurs twice in 
a template, then there will be one blank node created for each query solution, but 
there will be different blank nodes for triples generated by different query 
solutions.</p>
<div class="exampleGroup">
  <pre class="data">
@prefix  foaf:  &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a    foaf:givenname   &quot;Alice&quot; .
_:a    foaf:family_name &quot;Hacker&quot; .

_:b    foaf:firstname   &quot;Bob&quot; .
_:b    foaf:surname     &quot;Hacker&quot; .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX vcard:   &lt;http://www.w3.org/2001/vcard-rdf/3.0#&gt;

CONSTRUCT { ?x  vcard:N _:v .
            _:v vcard:givenName ?gname .
            _:v vcard:familyName ?fname }
WHERE
 {
    { ?x foaf:firstname ?gname } UNION  { ?x foaf:givenname   ?gname } .
    { ?x foaf:surname   ?fname } UNION  { ?x foaf:family_name ?fname } .
 }
</pre>
    <p>creates vcard properties corresponding to the FOAF information:</p>
    <div class="result">
      <pre class="resultGraph" style="text-align:left;">
@prefix vcard: &lt;http://www.w3.org/2001/vcard-rdf/3.0#&gt; .

_:v1 vcard:N         _:x .
_:x vcard:givenName  &quot;Alice&quot; .
_:x vcard:familyName &quot;Hacker&quot; .

_:v2 vcard:N         _:z .
_:z vcard:givenName  &quot;Bob&quot; .
_:z vcard:familyName &quot;Hacker&quot; .
</pre>
    </div>
  </div>
</div>
<p>The use of variable <code>x</code> in the template, which in this example will be bound to 
blank nodes with labels <code>_:a</code> and <code>_:b</code> in the data, 
causes different blank node labels (<code>_:v1</code> and <code>_:v2</code>) in the resulting RDF graph.</p> 

<h3>10.2.2 <a id="accessingRdfGraphs" name="accessingRdfGraphs">Accessing Graphs in the RDF Dataset</a></h3>
<p>Using <code>CONSTRUCT</code>, it is possible to extract parts or the whole of 
graphs from the target RDF dataset. This first example returns the graph (if it 
is in the dataset) with IRI label <code>http://example.org/aGraph</code>; otherwise, 
it returns an empty graph.</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
CONSTRUCT { ?s ?p ?o } WHERE { GRAPH &lt;http://example.org/aGraph&gt; { ?s ?p ?o } . }
</pre>
  </div>
</div>
<p>The access to the graph can be conditional on other information. For example, if the 
default graph contains metadata about the named graphs in the dataset, then a query 
like the following one can extract one graph based on information about the named 
graph:</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX  dc: &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX app: &lt;http://example.org/ns#&gt;
CONSTRUCT { ?s ?p ?o } WHERE
 {
   GRAPH ?g { ?s ?p ?o } .
   { ?g dc:publisher &lt;http://www.w3.org/&gt; } .
   { ?g dc:date ?date } .
   FILTER ( app:customDate(?date) &gt; &quot;2005-02-28T00:00:00Z&quot;^^xsd:dateTime ) .
 }
</pre>
  </div>
</div>
<p>where <code>app:customDate</code> identified an <a href="#extensionFunctions">
extension function</a> to turn the data format into an <code>xsd:dateTime</code> 
RDF term.</p>
<div class="grammarExtract">
  Grammar rule:<div class="grammarTable">
  <table>

<tr valign="baseline">
  <td><code class="gRuleLabel">[6]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rConstructQuery">ConstructQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'CONSTRUCT'</span> <a href="#rConstructTemplate">ConstructTemplate</a><br/>
  <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a> <a href="#rSolutionModifier">SolutionModifier</a></code></td>
</tr>

    </table>
  </div>
</div>

<h3>10.2.3 <a id="SolModandCONSTRUCT" name="SolModandCONSTRUCT">Solution Modifiers and CONSTRUCT</a></h3>
<p>The solution modifiers of a query affect the results of a <code>CONSTRUCT</code> 
query. In this example, the output graph from the <code>CONSTRUCT</code> template 
is formed from just two of the solutions from graph pattern matching. The query outputs 
a graph with the names of the people with the top two sites, rated by hits. The triples 
in the RDF graph are not ordered.</p>
<div class="exampleGroup">
  <pre class="data">
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix site: &lt;http://example.org/stats#&gt; .

_:a foaf:name &quot;Alice&quot; .
_:a site:hits 2349 .

_:b foaf:name &quot;Bob&quot; .
_:b site:hits 105 .

_:c foaf:name &quot;Eve&quot; .
_:c site:hits 181 .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX site: &lt;http://example.org/stats#&gt;

CONSTRUCT { [] foaf:name ?name }
WHERE
{ [] foaf:name ?name ;
     site:hits ?hits .
}
ORDER BY desc(?hits)
LIMIT 2
</pre>
    <div class="result">
      <pre class="resultGraph">
@prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .
_:x foaf:name &quot;Alice&quot; .
_:y foaf:name &quot;Eve&quot; .
</pre>
    </div>
  </div>
</div>

<h3>10.3 <a id="ask" name="ask">ASK</a></h3>
<p>Applications can use the <code>ASK</code> form to test whether or not a query 
pattern has a solution. No information is returned about the possible query solutions, 
just whether or not a solution exists.</p>
<div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       &quot;Alice&quot; .
_:a  foaf:homepage   &lt;http://work.example.org/alice/&gt; .

_:b  foaf:name       &quot;Bob&quot; .
_:b  foaf:mbox       &lt;mailto:bob@work.example&gt; .
</pre>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
ASK  { ?x foaf:name  &quot;Alice&quot; }
</pre>
    <div class="result">
      <pre class="resultAsk">
yes
</pre>
    </div>
    <p>The <a class="inform" href="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL 
    Query Results XML Format</a> form of this result set gives:</p>
    <div class="result">
      <pre class="resultSet">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;sparql xmlns=&quot;http://www.w3.org/2005/sparql-results#&quot;&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;results&gt;
    &lt;boolean&gt;true&lt;/boolean&gt;
  &lt;/results&gt;
&lt;/sparql&gt;
</pre>
    </div>
  </div>
  <p>On the same data, the following returns no match because Alice&#39;s <code>mbox</code> 
  is not mentioned.</p>
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:    &lt;http://xmlns.com/foaf/0.1/&gt;
ASK  { ?x foaf:name  &quot;Alice&quot; ;
          foaf:mbox  &lt;mailto:alice@work.example&gt; }
</pre>
    <div class="result">
      <pre class="resultAsk">
no
</pre>
    </div>
  </div>
</div>
<div class="grammarExtract">
  Grammar rule:<div class="grammarTable">
    <table id="table126">
      <tr>
  <td><code class="gRuleLabel">[8]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rAskQuery">AskQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'ASK'</span> <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a></code></td>
      </tr>
    </table>
  </div>
</div>

<h3>10.4 <a id="describe" name="describe">DESCRIBE</a> (Informative)</h3>
<p>The <code>DESCRIBE</code> form returns a single result RDF graph containing RDF 
data about resources. This data is not prescribed by a SPARQL query, where the query 
client would need to know the structure of the RDF in the data source, but, instead, 
is determined by the SPARQL query processor. The query pattern is used to create 
a result set. The <code>DESCRIBE</code> form takes each of the resources identified 
in a solution, together with any resources directly named by IRI, and assembles 
a single RDF graph by taking a &quot;description&quot; from the target RDF Dataset. The 
description is determined by the query service. The syntax <code>DESCRIBE *</code> 
is an abbreviation that describes all of the variables in a query.</p>

<h4>10.4.1 <a id="explititURIs" name="explititURIs">Explicit IRIs</a></h4>
<p>The <code>DESCRIBE</code> clause itself can take IRIs to identify the resources. 
The simplest <code>DESCRIBE</code> query is just an IRI in the <code>DESCRIBE</code> 
clause:</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
DESCRIBE &lt;http://example.org/&gt;
</pre>
  </div>
</div>

<h4>10.4.2 <a id="identifyingResources" name="identifyingResources">Identifying Resources</a></h4>
<p>The resources to be described can also be taken from the bindings to a query variable in a result set. This enables description 
of resources whether they are identified by IRI or by blank node in the dataset:</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;
DESCRIBE ?x
WHERE    { ?x foaf:mbox &lt;mailto:alice@org&gt; }
</pre>
  </div>
</div>
<p>The property <code>foaf:mbox</code> is defined as being an inverse function property 
in the FOAF vocabulary. If treated as such, this query will return information about 
at most one person. If, however, the query pattern has multiple solutions, the RDF 
data for each is the union of all RDF graph descriptions.</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;
DESCRIBE ?x
WHERE    { ?x foaf:name &quot;Alice&quot; }
</pre>
  </div>
</div>
<p>More than one IRI or variable can be given:</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;
DESCRIBE ?x ?y &lt;http://example.org/&gt;
WHERE    {?x foaf:knows ?y}
</pre>
  </div>
</div>

<h4>10.4.3 <a id="descriptionsOfResources" name="descriptionsOfResources">Descriptions of Resources</a></h4>
<p>The RDF returned is determined by the information publisher. It is the useful 
information the service has about a resource. It may include information about other 
resources: for example, the RDF data for a book may also include details about the author.</p>
<p>A simple query such as</p>
<div class="exampleGroup">
  <div class="queryGroup">
    <pre class="query">
PREFIX ent:  &lt;http://org.example.com/employees#&gt;
DESCRIBE ?x WHERE { ?x ent:employeeId &quot;1234&quot; }
</pre>
    <p>might return a description of the employee and some other potentially useful 
    details:</p>
    <div class="result">
      <pre class="resultGraph">
@prefix foaf:   &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix vcard:  &lt;http://www.w3.org/2001/vcard-rdf/3.0&gt; .
@prefix exOrg:  &lt;http://org.example.com/employees#&gt; .
@prefix <code>rdf:    &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix owl:    &lt;http://www.w3.org/2002/07/owl#&gt;</code>

_:a     exOrg:employeeId    &quot;1234&quot; ;
       
        <code>foaf:mbox_sha1sum   &quot;ABCD1234&quot; ;</code>
        vcard:N
         [ vcard:Family       &quot;Smith&quot; ;
           vcard:Given        &quot;John&quot;  ] .

<code>foaf:mbox_sha1sum  rdf:type  owl:InverseFunctionalProperty .</code>
</pre>
    </div>
  </div>
</div>
<p>which includes the blank node closure for the
<a href="http://www.w3.org/TR/vcard-rdf" class="inform">vcard</a> vocabulary vcard:N. 
Other possible mechanisms for deciding what information to return include Concise 
Bounded Descriptions [<a href="#CBD">CBD</a>].</p>
<p>For a vocabulary such as FOAF, where the resources are typically blank nodes, 
returning sufficient information to identify a node such as the InverseFunctionalProperty
<code>foaf:mbox_sha1sum</code> as well as information like name and other details recorded 
would be appropriate. In the example, the match to the WHERE clause was returned, 
but this is not required.</p>
<div class="grammarExtract">
  Grammar rule:<div class="grammarTable">
    <table id="table87">
      <tr>
  <td><code class="gRuleLabel">[7]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a href="#rDescribeQuery">DescribeQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'DESCRIBE'</span> ( <a href="#rVarOrIRIref">VarOrIRIref</a>+ | <span class="token">'*'</span> )<br/>
  <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a>? <a href="#rSolutionModifier">SolutionModifier</a></code></td>
      </tr>
    </table>
  </div>
</div>

<h2>11 <a id="tests" name="tests">Testing Values</a></h2>

    <p>SPARQL <code>FILTERs</code> restrict the solutions of a graph pattern match according to a given <a href="#rExpression">expression</a>. Specifically,
    <code>FILTERs</code> eliminate any solutions that, when substituted into the expression, either result in an effective boolean value of <code>false</code> or produce an error. Effective boolean values are defined in section <a href="#ebv">11.2.2 <em>Effective Boolean Value</em></a> and errors are defined in XQuery 1.0: An XML Query Language [<a href="#XQUERY">XQUERY</a>] section <a class="norm" href="http://www.w3.org/TR/2005/WD-xquery-20050404/#dt-type-error">2.3.1, <em>Kinds of Errors</em></a>. These errors have no affect outside of <code>FILTER</code> evaluation.</p>

  <div class="exampleGroup">
    <p>RDF literals may have a <a>datatype IRI</a>:</p>

  <pre class="data">@prefix a:          &lt;http://www.w3.org/2000/10/annotation-ns#&gt; .
@prefix dc:         &lt;http://purl.org/dc/elements/1.1/&gt; .

_:a   a:annotates   &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
_:a   dc:date       &quot;2004-12-31T19:00:00-05:00&quot; .

_:b   a:annotates   &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
_:b   dc:date       &quot;2004-12-31T19:01:00-05:00&quot;^^&lt;http://www.w3.org/2001/XMLSchema#dateTime&gt; .</pre>
    <p>The object of the first <code>dc:date</code> triple has no type information. The second has the datatype <code>xsd:dateTime</code>.</p>

    <p>SPARQL expressions are constructed according to the grammar and provide access to functions (named by IRI) and operator functions (invoked by keywords and symbols in the SPARQL grammar). SPARQL operators can be used to compare the values of typed literals:</p>

  <div class="queryGroup">
  <pre class="query">
PREFIX a:      &lt;http://www.w3.org/2000/10/annotation-ns#&gt;
PREFIX dc:     &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX xsd:    &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?annot
WHERE { ?annot  a:annotates  &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
        ?annot  dc:date      ?date .
        FILTER ( ?date &gt; &quot;2005-01-01T00:00:00Z&quot;^^xsd:dateTime ) }</pre></div></div>

    <p>The SPARQL operators are listed in <a href="#OperatorMapping">section 11.3</a> and are associated with their productions in the grammar.</p>

    <p>In addition, SPARQL provides the ability to invoke arbitrary functions, including a subset of the XPath casting functions, listed in <a href="#FunctionMapping">section 11.5</a>. These functions are invoked by name (an IRI) within a SPARQL query. For example:</p>

  <pre class="query untested">... FILTER ( xsd:dateTime(?date) &lt; xsd:dateTime(&quot;2005-01-01T00:00:00Z&quot;) ) ...</pre>

    <p>The following typographical conventions are used in this section:</p>

    <ul>
      <li>XPath operators are labeled with the prefix <code>op:</code>. XPath operators have no namespace; <code>op:</code> is a labeling convention.</li>
      <li>Operators introduced by this specification are indicated with the <span class="SPARQLoperator">SPARQLoperator class</span>.</li>
    </ul>

    <h3>11.1 <a id="operandDataTypes" name="operandDataTypes">Operand Data Types</a></h3>

    <p>SPARQL functions and operators operate on RDF terms and SPARQL variables. A subset of these functions and operators are taken from the <a class="norm" href=
  "http://www.w3.org/TR/xpath-functions/">XQuery 1.0 and XPath 2.0 Functions and Operators</a> [<a href="#FUNCOP">FUNCOP</a>] and have XML Schema <a href="http://www.w3.org/TR/xpath20/#dt-typed-value">typed value</a> arguments and return types.

RDF <code class="type typedLiteral">typed literals</code> passed as arguments to these functions and operators are mapped to XML Schema typed values with a <a href="http://www.w3.org/TR/xpath20/#dt-string-value">string value</a> of the <code class="type lexicalForm">lexical form</code> and an <a href="http://www.w3.org/TR/xmlschema-2/#dt-atomic">atomic datatype</a> corresponding to the <span class="type datatypeIRI">datatype IRI</span>. The returned typed values are mapped back to RDF <code class="type typedLiteral">typed literals</code> the same way.</p>

    <p>SPARQL has additional operators which operate on specific subsets of RDF terms. When referring to a type, the following terms denote a <code class="type typedLiteral">typed literal</code> with the corresponding <a class="norm" href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">XML Schema</a> [<a class="norm" href="#XSDT">XSDT</a>] <span class="type datatypeIRI">datatype IRI</span>:</p>

    <ul>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-integer">xsd:integer</a></code></li>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-decimal">xsd:decimal</a></code><!-- and derived types:<ul>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-nonPositiveInteger">xsd:nonPositiveInteger</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-negativeInteger">xsd:negativeInteger</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-long">xsd:long</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-int">xsd:int</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-short">xsd:short</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-byte">xsd:byte</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-nonNegativeInteger">xsd:nonNegativeInteger</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedLong">xsd:unsignedLong</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedInt">xsd:unsignedInt</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedShort">xsd:unsignedShort</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedByte">xsd:unsignedByte</a></code></li>
	  <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-positiveInteger">xsd:positiveInteger</a></code></li>
	</ul> --></li>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-float">xsd:float</a></code></li>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-double">xsd:double</a></code></li>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-string">xsd:string</a></code></li>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-boolean">xsd:boolean</a></code></li>
      <li><code><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-dateTime">xsd:dateTime</a></code></li>
    </ul>

    <p>The following terms identify additional types used in SPARQL value tests:</p>

    <ul>
      <li><span class="type numeric">numeric</span> denotes <code class="type typedLiteral">typed literals</code> with datatypes <code>xsd:integer</code>, <code>xsd:decimal</code>, <code>xsd:float</code>, and <code>xsd:double</code>.</li>
      <li><span class="type simpleLiteral">simple literal</span> denotes a <code class="type plainLiteral">plain literal</code> with no <code class="type langTag">language tag</code>.</li>
      <li><span class="type RDFterm">RDF term</span> denotes the types <code class="type IRI">IRI</code>, <code class="type literal">literal</code>, and <code class="type bNode">blank node</code>.</li>
      <li><span class="type variable">variable</span> denotes a SPARQL variable.</li>
    </ul>

  <!-- blockquote>
    <dl>
      <dt class="type numeric">numeric</dt> <dd><code class="type typedLiteral">typed literals</code> with datatypes <code>xsd:integer</code>, <code>xsd:decimal</code>, <code>xsd:float</code>, and <code>xsd:double</code></dd>
      <dt></dt>
      <dt class="type simpleLiteral">simple literal</dt> <dd>a <code class="type plainLiteral">plain literal</code> with no <code class="type langTag">language tag</code>.</dd>
      <dt class="type RDFterm">RDF term</dt> <dd>the types <code class="type IRI">IRI</code>, <code class="type literal">literal</code>, and <code class="type bNode">blank node</code></dd>
      <dt class="type variable">variable</dt> <dd>a SPARQL variable</dd>

    </dl>
  </blockquote -->

    <p>The following types are derived from <span class="type numeric">numeric</span> types and are valid arguments to functions and operators taking <span class="type numeric">numeric</span> arguments:</p>

    <ul>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-nonPositiveInteger"><code>xsd:nonPositiveInteger</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-negativeInteger"><code>xsd:negativeInteger</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-long"><code>xsd:long</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-int"><code>xsd:int</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-short"><code>xsd:short</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-byte"><code>xsd:byte</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-nonNegativeInteger"><code>xsd:nonNegativeInteger</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedLong"><code>xsd:unsignedLong</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedInt"><code>xsd:unsignedInt</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedShort"><code>xsd:unsignedShort</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-unsignedByte"><code>xsd:unsignedByte</code></a></li>
      <li><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-positiveInteger"><code>xsd:positiveInteger</code></a></li>
    </ul>

    <p>SPARQL language extensions may treat additional types as being derived from XML schema data types.</p>

    <h3>11.2 <a id="evaluation" name="evaluation">Filter Evaluation</a></h3>

    <p>SPARQL provides a subset of the functions and operators defined by XQuery <a href="http://www.w3.org/TR/xquery/#mapping" class="norm">Operator Mapping</a>. XQuery 1.0 section <a href="http://www.w3.org/TR/xquery/#id-expression-processing" class="norm">2.2.3 Expression Processing</a> describes the invocation of XPath functions. The following rules accommodate the differences in the data and execution models between XQuery and SPARQL:</p>

    <ul>
      <li>Unlike XPath/XQuery, SPARQL functions do not process node sequences. When interpreting the semantics of XPath functions, assume that each argument is a sequence of a single node.</li>

      <li>Functions invoked with an argument of the wrong type will produce a <a href="http://www.w3.org/TR/xquery/#dt-type-error" class="norm">type error</a>. Effective boolean value arguments (labeled "xsd:boolean (EBV)" in the operator mapping table below), are coerced to <code>xsd:boolean</code> using the <a href="#ebv">EBV rules</a> in section 11.2.2 .</li>

      <li>Apart from <a href="#func-bound">BOUND</a>, all functions and operators operate on RDF Terms and will produce a type error if any arguments are unbound.</li>

      <li>Any expression other than <a href="#func-logical-or">logical-or</a> (<code>||</code>) or <a href="#func-logical-and">logical-and</a> (<code>&amp;&amp;</code>) that encounters an error will produce that error.</li>

      <li>A <a href="#func-logical-or">logical-or</a> that encounters an error on only one branch will return TRUE if the other branch is TRUE and an error if the other branch is FALSE.</li>

      <li>A <a href="#func-logical-and">logical-and</a> that encounters an error on only one branch will return an error if the other branch is TRUE and FALSE if the other branch is FALSE.</li>

      <li>A <a href="#func-logical-or">logical-or</a> or <a href="#func-logical-and">logical-and</a> that encounters errors on both branches will produce <em>either</em> of the errors.</li>

    </ul>

    <p>The logical-and and logical-or truth table for true (<span class="truth">T</span>), false (<span class="truth">F</span>), and error (<span class="truth error">E</span>) is as follows:</p>

    <table id="truthTable" class="truthTable">
      <thead>
	<tr><th>A</th><th>B</th><th>A || B</th><th>A &amp;&amp; B</th></tr>
      </thead>
      <tbody>
	<tr><th>T</th><th>T</th><td>T</td><td>T</td></tr>
	<tr><th>T</th><th>F</th><td>T</td><td>F</td></tr>
	<tr><th>F</th><th>T</th><td>T</td><td>F</td></tr>
	<tr><th>F</th><th>F</th><td>F</td><td>F</td></tr>
      </tbody>
      <tbody>
	<tr><th>T</th><th><span class="error">E</span></th><td>T</td><td><span class="error">E</span></td></tr>
	<tr><th><span class="error">E</span></th><th>T</th><td>T</td><td><span class="error">E</span></td></tr>
	<tr><th>F</th><th><span class="error">E</span></th><td><span class="error">E</span></td><td>F</td></tr>
	<tr><th><span class="error">E</span></th><th>F</th><td><span class="error">E</span></td><td>F</td></tr>
	<tr><th><span class="error">E</span></th><th><span class="error">E</span></th><td><span class="error">E</span></td><td><span class="error">E</span></td></tr>
      </tbody>
    </table>

    <h4>11.2.1 <a id="invocation" name="invocation">Invocation</a></h4>
    <p>SPARQL defines a syntax for invoking <a>functions</a> and <a>operators</a> on a list of arguments. These are invoked as follows:</p>
    <ul>
      <li>Argument expressions are evaluated, producing argument values. The order of argument evaluation is not defined.</li>
      <li>Numeric arguments are promoted as necessary to fit the expected types for that function or operator.</li>
      <li>The function or operator is invoked on the argument values.</li>
    </ul>

    <p>If any of these steps fails, the invocation generates an error. The effects of errors are defined in <a href="#evaluation">Filter Evaluation</a>.</p>

    <h4>11.2.2 <a id="ebv" name="ebv">Effective Boolean Value</a> (EBV)</h4>

    <p>Effective boolean value is used to calculate the arguments to the logical functions <a href="#func-logical-and">logical-and</a>, <a href="#func-logical-or">logical-or</a>, and <a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>, as well as evaluate the result of a <code>FILTER</code> expression.</p>

    <p>The XQuery <a href="http://www.w3.org/TR/xquery/#id-ebv"> Effective Boolean Value</a> rules rely on the definition of XPath's <a href="http://www.w3.org/TR/xpath-functions/#func-boolean">fn:boolean</a>. The following rules reflect the rules for <code>fn:boolean</code> applied to the argument types present in SPARQL Queries:</p>

    <ul>
      <li>If the argument is a <span class="type typedLiteral">typed literal</span> with a <span class="type datatype">datatype</span> of <code>xsd:boolean</code>, the EBV is the value of that argument.</li>
      <li>If the argument is a <span class="type plainLiteral">plain literal</span> or a <span class="type typedLiteral">typed literal</span> with a <span class="type datatype">datatype</span> of <code>xsd:string</code>, the EBV is false if the operand value has zero length; otherwise the EBV is true.</li>
      <li>If the argument is a <span class="type numeric">numeric</span> type or a <span class="type typedLiteral">typed literal</span> with a datatype derived from a <span class="type numeric">numeric</span> type, the EBV is false if the operand value is NaN or is numerically equal to zero; otherwise the EBV is true.</li>
      <li>All other arguments, including unbound arguments, produce a type error.</li>
    </ul>

    <p>An EBV of <code>true</code> is represented as a <span class="type typedLiteral">typed literal</span> with a datatype of <code>xsd:boolean</code> and a lexical value of "true"; an EBV of false is represented as a <span class="type typedLiteral">typed literal</span> with a datatype of <code>xsd:boolean</code> and a lexical value of "false".</p>

    <h3>11.3 <a id="OperatorMapping" name="OperatorMapping">Operator Mapping</a></h3>

    <p>The SPARQL grammar identifies a set of operators (for instance, <span class="token">&amp;&amp;</span>, <span class="token">*</span>, <span class="token">isIRI</span>) used to construct constraints. The following table associates each of these grammatical productions with the appropriate operands and an operator function defined by either <a class="norm" href="http://www.w3.org/TR/xpath-functions/">XQuery 1.0 and XPath 2.0 Functions and Operators</a> [<a href="#FUNCOP">FUNCOP</a>] or the SPARQL operators specified in <a href="#SparqlOps">section 11.4</a>. When selecting the operator definition for a given set of parameters, the definition  with the most specific parameters applies. For instance, when evaluating <code>xsd:integer = xsd:signedInt</code>, the definition for <code>=</code> with two <code>numeric</code> parameters applies, rather than the one with two <span class="type RDFterm">RDF terms</span>. The table is arranged so that the upper-most viable candiate is the most specific. Operators invoked without appropriate operands result in a type error.</p>

    <p>SPARQL follows XPath's scheme for numeric type promotions and subtype substitution for arguments to numeric operators. The <a href="http://www.w3.org/TR/xpath20/#mapping">XPath Operator Mapping</a> rules for <span class="type numeric">numeric</span> operands (<code>xsd:integer</code>, <code>xsd:decimal</code>, <code>xsd:float</code>, <code>xsd:double</code>, and types derived from a <span class="type numeric">numeric</span> type) apply to SPARQL operators as well (see <a class="norm" href="http://www.w3.org/TR/xpath20/">XML Path Language (XPath) 2.0</a> [<a href="#XPATH20">XPATH20</a>] for defintions of <a class="norm" href="http://www.w3.org/TR/xpath20/#promotion">numeric type promotions</a> and <a class="norm" href="http://www.w3.org/TR/xpath20/#dt-subtype-substitution">subtype substitution</a>). Some of the operators are associated with nested function expressions, e.g. <code>fn:not(op:numeric-equal(A, B))</code>. Note that per the XPath definitions, <code>fn:not</code> and <code>op:numeric-equal</code> produce an error if their argument is an error.</p>

    <p>The collation for <code>fn:compare</code> is <a href="http://www.w3.org/TR/xpath-functions/#collations">defined by XPath</a> and identified by <code>http://www.w3.org/2005/xpath-functions/collation/codepoint</code>. This collation allows for string comparison based on code point values. Codepoint string equivalence can be tested with <span class="type RDFterm">RDF term</span> equivalence.</p>

    <table summary="SPARQL Unary Operators" class="FAndOTable">
      <caption>SPARQL Unary Operators</caption>
      <tbody>
	<tr><th class="major" scope="col">Operator</th>
	  <th class="major" scope="col">Type(A)</th><th class="major" scope="col">Function</th><th class="major" scope="col">Result type</th></tr>
	<tr><th colspan="4" class="subHeading" scope="col">XQuery Unary Operators</th></tr>
	<tr><th scope="row"><a href="#rUnaryExpression" title="UnaryExpression"><span class="FAOTtoken">!</span> A</a>
	  </th>
	  <td>xsd:boolean <a href="#ebv-arg">(EBV)</a></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(A)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rUnaryExpression" title="UnaryExpression"><span class="FAOTtoken">+</span> A</a>
	  </th>
	  <td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-unary-plus">op:numeric-unary-plus</a>(A)</td><td><span class="type numeric">numeric</span></td></tr>
	<tr><th scope="row"><a href="#rUnaryExpression" title="UnaryExpression"><span class="FAOTtoken">-</span> A</a>
	  </th>
	  <td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus">op:numeric-unary-minus</a>(A)</td><td><span class="type numeric">numeric</span></td></tr>


	<tr><th colspan="5" class="subHeading" scope="col">SPARQL Tests, defined in <a href="#SparqlOps">section 11.4</a></th></tr>

	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">BOUND</span></a>(A)
	  </th>
	  <td><span class="type variable">variable</span></td><td class="xpathOp"><a href="#func-bound" class="SPARQLoperator">bound</a>(A)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">isIRI</span></a>(A)<br/><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">isURI</span></a>(A)
	  </th>
	  <td><span class="type RDFterm">RDF term</span></td><td class="xpathOp"><a href="#func-isIRI" class="SPARQLoperator">isIRI</a>(A)</td><td>xsd:boolean</td></tr>

	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">isBLANK</span></a>(A)
	  </th>
	  <td><span class="type RDFterm">RDF term</span></td><td class="xpathOp"><a href="#func-isBlank" class="SPARQLoperator">isBlank</a>(A)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">isLITERAL</span></a>(A)
	  </th>
	  <td><span class="type RDFterm">RDF term</span></td><td class="xpathOp"><a href="#func-isLiteral" class="SPARQLoperator">isLiteral</a>(A)</td><td>xsd:boolean</td></tr>

	<tr><th colspan="5" class="subHeading" scope="col">SPARQL Accessors, defined in <a href="#SparqlOps">section 11.4</a></th></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">STR</span></a>(A)
	  </th>
	  <td><span class="type literal">literal</span></td><td class="xpathOp"><a href="#func-str" class="SPARQLoperator">str</a>(A)</td><td><span class="type simpleLiteral">simple literal</span></td></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">STR</span></a>(A)
	  </th>
	  <td><span class="type IRI">IRI</span></td><td class="xpathOp"><a href="#func-str" class="SPARQLoperator">str</a>(A)</td><td><span class="type simpleLiteral">simple literal</span></td></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">LANG</span></a>(A)
	  </th>
	  <td><span class="type literal">literal</span></td><td class="xpathOp"><a href="#func-lang" class="SPARQLoperator">lang</a>(A)</td><td><span class="type simpleLiteral">simple literal</span></td></tr>

	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">DATATYPE</span></a>(A)
	  </th>
	  <td><span class="type typedLiteral">typed literal</span></td><td class="xpathOp"><a href="#func-datatype" class="SPARQLoperator">datatype</a>(A)</td><td><span class="type IRI">IRI</span></td></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">DATATYPE</span></a>(A)
	  </th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a href="#func-datatype" class="SPARQLoperator">datatype</a>(A)</td><td><span class="type IRI">IRI</span></td></tr>
      </tbody>
    </table>

    <table summary="SPARQL Binary Operators" class="FAndOTable">
      <caption>SPARQL Binary Operators</caption>
      <tbody>
	<tr><th class="major" scope="col">Operator</th>
	  <th class="major" scope="col">Type(A)</th><th class="major" scope="col">Type(B)</th><th class="major" scope="col">Function</th><th class="major" scope="col">Result type</th></tr>
	<tr><th colspan="5" class="subHeading" scope="col">Logical Connectives, defined in <a href="#SparqlOps">section 11.4</a></th></tr>

	<tr><th><a href="#rConditionalOrExpression" title="ConditionalOrExpression">A <span class="FAOTtoken">||</span> B</a></th>
	  <td>xsd:boolean <a href="#ebv-arg">(EBV)</a></td><td>xsd:boolean <a href="#ebv-arg">(EBV)</a></td><td class="sparqlOp"><a href="#func-logical-or" class="SPARQLoperator">logical-or</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th><a href="#rConditionalAndExpression" title="ConditionalAndExpression">A <span class="FAOTtoken">&amp;&amp;</span> B</a></th>
	  <td>xsd:boolean <a href="#ebv-arg">(EBV)</a></td><td>xsd:boolean <a href="#ebv-arg">(EBV)</a></td><td class="sparqlOp"><a href="#func-logical-and" class="SPARQLoperator">logical-and</a>(A, B)</td><td>xsd:boolean</td></tr>

	<tr><th colspan="5" class="subHeading" scope="col">XPath Tests</th></tr>

	<!-- eq -->
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), 0)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
	  <td>xsd:string</td><td>xsd:string</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(<a href="#func-str" class="FAOTtoken">STR</a>(A), <a href="#func-str" class="FAOTtoken">STR</a>(B)), 0)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
	  <td>xsd:boolean</td><td>xsd:boolean</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-boolean-equal">op:boolean-equal</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
	  <td>xsd:dateTime</td><td>xsd:dateTime</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-dateTime-equal">op:dateTime-equal</a>(A, B)</td><td>xsd:boolean</td></tr>


	<!-- ne -->
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), 0))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td>xsd:string</td><td>xsd:string</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(<a href="#func-str" class="FAOTtoken">STR</a>(A), <a href="#func-str" class="FAOTtoken">STR</a>(B)), 0))</td><td>xsd:boolean</td></tr>
	<!-- tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="sparqlOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), 0))</td><td>xsd:boolean</td></tr -->
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td>xsd:boolean</td><td>xsd:boolean</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-boolean-equal">op:boolean-equal</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td>xsd:dateTime</td><td>xsd:dateTime</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-dateTime-equal">op:dateTime-equal</a>(A, B))</td><td>xsd:boolean</td></tr>

	<!-- lt -->
	<tr id="op_lt"><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-less-than">op:numeric-less-than</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), -1)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;</span> B</a></th>
	  <td>xsd:string</td><td>xsd:string</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(<a href="#func-str" class="FAOTtoken">STR</a>(A), <a href="#func-str" class="FAOTtoken">STR</a>(B)), -1)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;</span> B</a></th>
	  <td>xsd:boolean</td><td>xsd:boolean</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-boolean-less-than">op:boolean-less-than</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;</span> B</a></th>
	  <td>xsd:dateTime</td><td>xsd:dateTime</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-dateTime-less-than">op:dateTime-less-than</a>(A, B)</td><td>xsd:boolean</td></tr>

	<!-- gt -->
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-greater-than">op:numeric-greater-than</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), 1)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;</span> B</a></th>
	  <td>xsd:string</td><td>xsd:string</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(<a href="#func-str" class="FAOTtoken">STR</a>(A), <a href="#func-str" class="FAOTtoken">STR</a>(B)), 1)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;</span> B</a></th>
	  <td>xsd:boolean</td><td>xsd:boolean</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-boolean-greater-than">op:boolean-greater-than</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;</span> B</a></th>
	  <td>xsd:dateTime</td><td>xsd:dateTime</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-dateTime-greater-than">op:dateTime-greater-than</a>(A, B)</td><td>xsd:boolean</td></tr>

	<!-- le -->
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;=</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a href="#func-logical-or" class="SPARQLoperator">logical-or</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-less-than">op:numeric-less-than</a>(A, B), <a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;=</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), 1))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;=</span> B</a></th>
	  <td>xsd:string</td><td>xsd:string</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(<a href="#func-str" class="FAOTtoken">STR</a>(A), <a href="#func-str" class="FAOTtoken">STR</a>(B)), 1))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;=</span> B</a></th>
	  <td>xsd:boolean</td><td>xsd:boolean</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-boolean-greater-than">op:boolean-greater-than</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;=</span> B</a></th>
	  <td>xsd:dateTime</td><td>xsd:dateTime</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-dateTime-greater-than">op:dateTime-greater-than</a>(A, B))</td><td>xsd:boolean</td></tr>

	<!-- ge -->
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;=</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a href="#func-logical-or" class="SPARQLoperator">logical-or</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-greater-than">op:numeric-greater-than</a>(A, B), <a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;=</span> B</a></th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(A, B), -1))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;=</span> B</a></th>
	  <td>xsd:string</td><td>xsd:string</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-equal">op:numeric-equal</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-compare">fn:compare</a>(<a href="#func-str" class="FAOTtoken">STR</a>(A), <a href="#func-str" class="FAOTtoken">STR</a>(B)), -1))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;=</span> B</a></th>
	  <td>xsd:boolean</td><td>xsd:boolean</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-boolean-less-than">op:boolean-less-than</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;=</span> B</a></th>
	  <td>xsd:dateTime</td><td>xsd:dateTime</td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-dateTime-less-than">op:dateTime-less-than</a>(A, B))</td><td>xsd:boolean</td></tr>

	<tr><th colspan="5" class="subHeading" scope="col">XPath Arithmetic</th></tr>

	<tr><th scope="row"><a href="#rMultiplicativeExpression" title="MultiplicativeExpression">A <span class="FAOTtoken">*</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-multiply">op:numeric-multiply</a>(A, B)</td><td><span class="type numeric">numeric</span></td></tr>
	<tr><th scope="row"><a href="#rMultiplicativeExpression" title="MultiplicativeExpression">A <span class="FAOTtoken">/</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-divide">op:numeric-divide</a>(A, B)</td><td><span class="type numeric">numeric</span>; but xsd:decimal if both operands are xsd:integer</td></tr>

	<tr><th scope="row"><a href="#rAdditiveExpression" title="AdditiveExpression">A <span class="FAOTtoken">+</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-add">op:numeric-add</a>(A, B)</td><td><span class="type numeric">numeric</span></td></tr>
	<tr><th scope="row"><a href="#rAdditiveExpression" title="AdditiveExpression">A <span class="FAOTtoken">-</span> B</a></th>
	  <td><span class="type numeric">numeric</span></td><td><span class="type numeric">numeric</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-numeric-subtract">op:numeric-subtract</a>(A, B)</td><td><span class="type numeric">numeric</span></td></tr>


	<tr><th colspan="5" class="subHeading" scope="col">SPARQL Tests, defined in <a href="#SparqlOps">section 11.4</a></th></tr>

	<tr><th ><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
	  <td><span class="type RDFterm">RDF term</span></td><td><span class="type RDFterm">RDF term</span></td><td class="xpathOp"><a href="#func-RDFterm-equal" class="SPARQLoperator">RDFterm-equal</a>(A, B)</td><td>xsd:boolean</td></tr>
	<tr><th ><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
	  <td><span class="type RDFterm">RDF term</span></td><td><span class="type RDFterm">RDF term</span></td><td class="xpathOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-not">fn:not</a>(<a href="#func-RDFterm-equal" class="SPARQLoperator">RDFterm-equal</a>(A, B))</td><td>xsd:boolean</td></tr>
	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">sameTERM</span></a>(A)
	  </th>
	  <td><span class="type RDFterm">RDF term</span></td><td><span class="type RDFterm">RDF term</span></td><td class="xpathOp"><a href="#func-sameTerm" class="SPARQLoperator">sameTerm</a>(A, B)</td><td>xsd:boolean</td></tr>

	<tr><th scope="row"><a href="#rBuiltInCall" title="CallExpression"><span class="FAOTtoken">langMATCHES</span></a>(A, B)
	  </th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="xpathOp"><a href="#func-langMatches" class="SPARQLoperator">langMatches</a>(A, B)</td><td>xsd:boolean</td></tr>

	<tr><th><a href="#rRegexExpression" title="Regular Expression"><span class="FAOTtoken">REGEX</span></a>(STRING, PATTERN)</th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="sparqlOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-matches">fn:matches</a>(STRING, PATTERN)</td><td>xsd:boolean</td></tr>

      </tbody>
  </table>

    <table summary="SPARQL Trinary Operators" class="FAndOTable">
      <caption>SPARQL Trinary Operators</caption>
      <tbody>
	<tr><th class="major" scope="col">Operator</th>
	  <th class="major" scope="col">Type(A)</th><th class="major" scope="col">Type(B)</th><th class="major" scope="col">Type(C)</th><th class="major" scope="col">Function</th><th class="major" scope="col">Result type</th></tr>
	<tr><th colspan="6" class="subHeading" scope="col">SPARQL Tests, defined in <a href="#SparqlOps">section 11.4</a></th></tr>
	<tr><th><a href="#rRegexExpression" title="Regular Expression"><span class="FAOTtoken">REGEX</span></a>(STRING, PATTERN, FLAGS)</th>
	  <td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td><span class="type simpleLiteral">simple literal</span></td><td class="sparqlOp"><a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-matches">fn:matches</a>(STRING, PATTERN, FLAGS)</td><td>xsd:boolean</td></tr>
	<!-- tr><td colspan="5">The <code>fn:matches</code> function is defined in XPath. Its use in SPARQL and an example invocation are described in <a href="#funcex-regex">section 11.4.12</a>.</td></tr -->
      </tbody>
    </table>

    <p><a id="ebv-arg" name="ebv-arg" />xsd:boolean function arguments marked with "(EBV)" are coerced to xsd:boolean by evaluating the <a href="#ebv">effective boolean value of that argument.</a></p>

    <h4>11.3.1 <a id="operatorExtensibility" name="operatorExtensibility">Operator Extensibility</a></h4>

    <p>SPARQL language extensions may provide additional associations between operators and operator functions; this amounts to adding rows to the table above. No additional operator may yield a result that replaces any result other than a type error in the semantics defined above. The consequence of this rule is that SPARQL extensions will produce <em>at least</em> the same solutions as an unextended implementation, and may, for some queries, produce more solutions.</p>

    <p>Additional mappings of the '&lt;' operator are expected to control the relative ordering of the operands, specifically, when used in an <a href="#modOrderBy"><code>ORDER BY</code></a> clause.</p>

    <h3>11.4 <a id="SparqlOps" name="SparqlOps">Operators Definitions</a></h3>

    <p>This section defines the operators introduced by the SPARQL Query language. The examples show the behavior of the operators as invoked by the appropriate grammatical constructs.</p>

    <h4>11.4.1 <a id="func-bound" name="func-bound" class="SPARQLoperator">bound</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">bound</code> (<code class="parm type" title="paramter type">variable</code> <code class="parm name" title="parameter name">var</code>)
</pre>

    <p>Returns <code>true</code> if <code>var</code> is bound to a value. Returns false otherwise. Variables with the value NaN or INF are considered bound.</p>

  <div class="exampleGroup">
  <p>Data:</p>

  <pre class="data">
@prefix foaf:        &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix dc:          &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix xsd:          &lt;http://www.w3.org/2001/XMLSchema#&gt; .

_:a  foaf:givenName  "Alice".

_:b  foaf:givenName  "Bob" .
_:b  dc:date         "2005-04-04T04:04:04Z"^^xsd:dateTime .</pre>

  <div class="queryGroup">
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX dc:   &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX xsd:   &lt;http://www.w3.org/2001/XMLSchema#&gt;
SELECT ?name
 WHERE { ?x foaf:givenName  ?givenName .
         OPTIONAL { ?x dc:date ?date } .
         FILTER ( bound(?date) ) }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>givenName</th>
          </tr>

          <tr>
            <td>"Bob&quot;</td>
          </tr>
        </tbody>
      </table>
  </div></div>

    <p>One may test that a  graph pattern is <em>not</em> expressed by specifying an <a><code class="term">OPTIONAL</code></a> <a>graph pattern</a> that introduces a variable and testing to see that the variable is <a><code class="term">not</code></a> <a><code class="term">bound</code></a>. This is called <em>Negation as Failure</em> in logic programming.</p>

  <div class="queryGroup">
  <p>This query matches the people with a <code>name</code> but <em>no</em> expressed <code>date</code>:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX dc:   &lt;http://purl.org/dc/elements/1.1/&gt;
SELECT ?name
 WHERE { ?x foaf:givenName  ?name .
         OPTIONAL { ?x dc:date ?date } .
         FILTER (!bound(?date)) }</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
          </tr>

          <tr>
            <td>"Alice&quot;</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

  <p>Because Bob's <code>dc:date</code> was known, <code>"Bob&quot;</code> was not a solution to the query.</p>


    <h4>11.4.2 <a id="func-isIRI" name="func-isIRI" class="SPARQLoperator">isIRI</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">isIRI</code> (<code class="parm type" title="paramter type">RDF term</code> <code class="parm name" title="parameter name">term</code>)
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">isURI</code> (<code class="parm type" title="paramter type">RDF term</code> <code class="parm name" title="parameter name">term</code>)
</pre>

    <p>Returns <code>true</code> if <code>term</code> is an <span class="type IRI">IRI</span>. Returns <code>false</code> otherwise. <code class="operator" title="operator">isURI</code> is an alternate spelling for the <code class="operator" title="operator">isIRI</code> operator.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Alice".
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  foaf:name       "Bob" .
_:b  foaf:mbox       "bob@work.example" .
</pre>

  <div class="queryGroup">
  <p>This query matches the people with a <code>name</code> and an <code>mbox</code> which is an IRI:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
 WHERE { ?x foaf:name  ?name ;
            foaf:mbox  ?mbox .
         FILTER isIRI(?mbox) }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
            <th>mbox</th>
          </tr>

          <tr>
            <td>"Alice"</td>
            <td>&lt;mailto:alice@work.example&gt;</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <h4>11.4.3 <a id="func-isBlank" name="func-isBlank" class="SPARQLoperator">isBlank</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">isBlank</code> (<code class="parm type" title="paramter type">RDF term</code> <code class="parm name" title="parameter name">term</code>)
</pre>

    <p>Returns <code>true</code> if <code>term</code> is a <span class="type bNode">blank node</span>. Returns <code>false</code> otherwise.</p>

  <div class="exampleGroup">
  <pre class="data">@prefix a:          &lt;http://www.w3.org/2000/10/annotation-ns#&gt; .
@prefix dc:         &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a   a:annotates   &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
_:a   dc:creator    &quot;Alice B. Toeclips&quot; .

_:b   a:annotates   &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
_:b   dc:creator    _:c .
_:c   foaf:given    &quot;Bob&quot;.
_:c   foaf:family   &quot;Smith&quot;.</pre>

  <div class="queryGroup">
  <p>This query matches the people with a <code>dc:creator</code> which uses
  predicates from the FOAF vocabulary to express the name. </p>
  <pre class="query">PREFIX a:      &lt;http://www.w3.org/2000/10/annotation-ns#&gt;
PREFIX dc:     &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX foaf:   &lt;http://xmlns.com/foaf/0.1/&gt;

SELECT ?given ?family
 WHERE { ?annot  a:annotates  &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
         ?annot  dc:creator   ?c .
         OPTIONAL { ?c  foaf:given   ?given ; foaf:family  ?family } .
         FILTER isBlank(?c)
       }</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>given</th>
            <th>family</th>
          </tr>

          <tr>
            <td>"Bob"</td>
            <td>"Smith"</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <p>In this example, there were two objects of <code>foaf:knows</code> predicates, but only one (<code>_:c</code>) was a blank node.</p>

    <h4>11.4.4 <a id="func-isLiteral" name="func-isLiteral" class="SPARQLoperator">isLiteral</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">isLiteral</code> (<code class="parm type" title="paramter type">RDF term</code> <code class="parm name" title="parameter name">term</code>)
</pre>

    <p>Returns <code>true</code> if <code>term</code> is a <span class="type literal">literal</span>. Returns <code>false</code> otherwise.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Alice".
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  foaf:name       "Bob" .
_:b  foaf:mbox       "bob@work.example" .
</pre>

  <div class="queryGroup">
  <p>This query is similar to the one in <a href="#func-isIRI">11.4.2</a> except that is matches the people with a <code>name</code> and an <code>mbox</code> which is a literal. This could be used to look for erroneous data (<code>foaf:mbox</code> should only have an 
  IRI as its object).</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
 WHERE { ?x foaf:name  ?name ;
           foaf:mbox  ?mbox .
         FILTER isLiteral(?mbox) }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
            <th>mbox</th>
          </tr>

          <tr>
            <td>"Bob"</td>
            <td>"bob@work.example"</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <h4>11.4.5 <a id="func-str" name="func-str" class="SPARQLoperator">str</a></h4>

  <pre class="prototype">
 <code class="return" title="return"><span class="type simpleLiteral">simple literal</span></code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">str</code> (<code class="parm type" title="paramter type"><span class="type literal">literal</span></code> <code class="parm name" title="parameter name">ltrl</code>)
 <code class="return" title="return"><span class="type simpleLiteral">simple literal</span></code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">str</code> (<code class="parm type" title="paramter type"><span class="type IRI">IRI</span></code> <code class="parm name" title="parameter name">rsrc</code>)
</pre>

    <p>Returns the <code class="type lexicalForm">lexical form</code> of <code>ltrl</code> (a <span class="type literal">literal</span>); returns the codepoint representation of <code>rsrc</code> (an <span class="type IRI">IRI</span>). This is useful for examining parts of an IRI, for instance, the host-name.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Alice".
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  foaf:name       "Bob" .
_:b  foaf:mbox       &lt;mailto:bob@home.example&gt; .
</pre>

  <div class="queryGroup">
  <p>This query selects the set of people who use their <code>work.example</code> address in their foaf profile:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
 WHERE { ?x foaf:name  ?name ;
            foaf:mbox  ?mbox .
         FILTER regex(str(?mbox), &quot;@work.example&quot;) }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
            <th>mbox</th>
          </tr>

          <tr>
            <td>"Alice"</td>
            <td>&lt;mailto:alice@work.example&gt;</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <h4>11.4.6 <a id="func-lang" name="func-lang" class="SPARQLoperator">lang</a></h4>

  <pre class="prototype">
 <code class="return" title="return"><span class="type simpleLiteral">simple literal</span></code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">lang</code> (<code class="parm type" title="paramter type"><span class="type literal">literal</span></code> <code class="parm name" title="parameter name">ltrl</code>)
</pre>

    <p>Returns the <code class="type langTag">language tag</code> of <code>ltrl</code>, if it has one. It returns <code>""</code> if <code>ltrl</code> has no <code class="type langTag">language tag</code>. Note that the RDF data model does not include literals with an empty <code class="type langTag">language tag</code>.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Robert"@EN.
_:a  foaf:name       "Roberto"@ES.
_:a  foaf:mbox       &lt;mailto:bob@work.example&gt; .
</pre>

  <div class="queryGroup">
  <p>This query finds the Spanish <code>foaf:name</code> and <code>foaf:mbox</code>:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?mbox
 WHERE { ?x foaf:name  ?name ;
            foaf:mbox  ?mbox .
         FILTER ( lang(?name) = "ES" ) }</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
            <th>mbox</th>
          </tr>

          <tr>
            <td>"Roberto"@ES</td>
            <td>&lt;mailto:bob@work.example&gt;</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <h4>11.4.7 <a id="func-datatype" name="func-datatype" class="SPARQLoperator">datatype</a></h4>

  <pre class="prototype">
 <code class="return" title="return"><span class="type IRI">IRI</span></code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">datatype</code> (<code class="parm type" title="paramter type"><span class="type typedLiteral">typed literal</span></code> <code class="parm name" title="parameter name">typedLit</code>)
 <code class="return" title="return"><span class="type IRI">IRI</span></code>&nbsp;&nbsp;&nbsp;<code class="operator" title="operator">datatype</code> (<code class="parm type" title="paramter type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name" title="parameter name">simpleLit</code>)
</pre>

    <p>Returns the <code class="type datatypeIRI">datatype IRI</code> of <code>typedLit</code>; returns <code>xsd:string</code> if the parameter is a <span class="type simpleLiteral">simple literal</span>.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .
@prefix eg:         &lt;http://biometrics.example/ns#&gt; .
@prefix xsd:        &lt;http://www.w3.org/2001/XMLSchema#&gt; .

_:a  foaf:name       "Alice".
_:a  eg:shoeSize     "9.5"^^xsd:float .

_:b  foaf:name       "Bob".
_:b  eg:shoeSize     "42"^^xsd:integer .
</pre>

  <div class="queryGroup">
  <p>This query finds the <code>foaf:name</code> and <code>foaf:shoeSize</code> of everyone with a shoeSize that is an integer:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX xsd:  &lt;http://www.w3.org/2001/XMLSchema#&gt;
PREFIX eg:   &lt;http://biometrics.example/ns#&gt;
SELECT ?name ?shoeSize
 WHERE { ?x foaf:name  ?name ; eg:shoeSize  ?shoeSize .
         FILTER ( datatype(?shoeSize) = xsd:integer ) }</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
            <th>shoeSize</th>
          </tr>

          <tr>
            <td>"Bob"</td>
            <td>42</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <h4>11.4.8 <a id="func-logical-or" name="func-logical-or" class="SPARQLoperator">logical-or</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="parm type" title="paramter type">xsd:boolean</code> <code class="parm name" title="parameter name">left</code> <code class="operator" title="operator">||</code> <code class="parm type" title="parameter type">xsd:boolean</code> <code class="parm name" title="parameter name">right</code>
</pre>

    <p>Returns a logical <code>OR</code> of <code>left</code> and <code>right</code>. Note that <code class="SPARQLoperator">logical-or</code> operates on the <a href="#ebv">effective boolean value</a> of its arguments.</p>

    <p>Note: see section 11.2, <a href="#evaluation">Filter Evaluation</a>, for 
    the <code>||</code> operator's treatment of errors.</p>

    <h4>11.4.9 <a id="func-logical-and" name="func-logical-and" class="SPARQLoperator">logical-and</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="parm type" title="paramter type">xsd:boolean</code> <code class="parm name" title="parameter name">left</code> <code class="operator" title="operator">&amp;&amp;</code> <code class="parm type" title="parameter type">xsd:boolean</code> <code class="parm name" title="parameter name">right</code>
</pre>

    <p>Returns a logical <code>AND</code> of <code>left</code> and <code>right</code>. Note that <code class="SPARQLoperator">logical-and</code> operates on the <a href="#ebv">effective boolean value</a> of its arguments.</p>

    <p>Note: see section 11.2, <a href="#evaluation">Filter Evaluation</a>, for 
    the <code>&amp;&amp;</code> operator's treatment of errors.</p>

    <h4>11.4.10 <a id="func-RDFterm-equal" name="func-RDFterm-equal" class="SPARQLoperator">RDFterm-equal</a></h4>

  <pre class="prototype">
 <code class="return" title="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="parm type" title="paramter type">RDF term</code> <code class="parm name" title="parameter name">term1</code> <code class="operator" title="operator">=</code> <code class="parm type" title="parameter type">RDF term</code> <code class="parm name" title="parameter name">term2</code>
</pre>

    <p>Returns TRUE if <code>term1</code> and <code>term2</code> are the same RDF term as defined in <a class="norm" href="http://www.w3.org/TR/rdf-concepts/">Resource Description Framework (RDF): Concepts and Abstract Syntax</a> [<a href="#CONCEPTS">CONCEPTS</a>]; produces a type error if the arguments are both literal but are not the same RDF term <sup><a href="#func-RDFterm-equal-foot1" class="footnote">*</a></sup>; returns FALSE otherwise. <code>term1</code> and <code>term2</code> are the same if any of the following is true:</p>

    <ul>
      <li><code class="parm name" title="parameter name">term1</code> and <code class="parm name" title="parameter name">term2</code> are equivalent <span class="IRI type">IRIs</span> as defined in <a href="http://www.w3.org/TR/rdf-concepts/#section-Graph-URIref">6.4 RDF URI References</a> 
		of [<a href="#CONCEPTS">CONCEPTS</a>].</li>
      <li><code class="parm name" title="parameter name">term1</code> and <code class="parm name" title="parameter name">term2</code> are equivalent <span class="literal type">literals</span> as defined in <a class="norm" href="http://www.w3.org/TR/rdf-concepts/#section-Literal-Equality">6.5.1 Literal Equality</a> 
		of [<a href="#CONCEPTS">CONCEPTS</a>].</li>
      <li><code class="parm name" title="parameter name">term1</code> and <code class="parm name" title="parameter name">term2</code> are the same <span class="bnode type">blank node</span> as described in <a class="norm" href="http://www.w3.org/TR/rdf-concepts/#section-blank-nodes">6.6 Blank Nodes</a> 
		of [<a href="#CONCEPTS">CONCEPTS</a>].</li>
    </ul>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Alice".
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  foaf:name       "Ms A.".
_:b  foaf:mbox       &lt;mailto:alice@work.example&gt; .
</pre>

  <div class="queryGroup">
  <p>This query finds the people who have multiple <code>foaf:name</code> triples:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name1 ?name2
 WHERE { ?x foaf:name  ?name1 ;
            foaf:mbox  ?mbox1 .
         ?y foaf:name  ?name2 ;
            foaf:mbox  ?mbox2 .
         FILTER (?mbox1 = ?mbox2 &amp;&amp; ?name1 != ?name2)
       }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name1</th>
            <th>name2</th>
          </tr>

          <tr>
            <td>"Alice"</td>
            <td>"Ms A."</td>
          </tr>

          <tr>
            <td>"Ms A."</td>
            <td>"Alice"</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <p>In this query for documents that were annotated on New Year's Day (2004 or 2005), the RDF terms are not the same, but have equivalent values:</p>

  <div class="exampleGroup">
  <pre class="data">@prefix a:          &lt;http://www.w3.org/2000/10/annotation-ns#&gt; .
@prefix dc:         &lt;http://purl.org/dc/elements/1.1/&gt; .

_:b   a:annotates   &lt;http://www.w3.org/TR/rdf-sparql-query/&gt; .
_:b   dc:date       &quot;2004-12-31T19:00:00-05:00&quot;^^&lt;http://www.w3.org/2001/XMLSchema#dateTime&gt; .</pre>

  <div class="queryGroup">
  <pre class="query">
PREFIX a:      &lt;http://www.w3.org/2000/10/annotation-ns#&gt;
PREFIX dc:     &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX xsd:    &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?annotates
WHERE { ?annot  a:annotates  ?annotates .
        ?annot  dc:date      ?date .
        FILTER ( ?date = xsd:dateTime(&quot;2005-01-01T00:00:00Z&quot;) ) }</pre>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>annotates</th>
          </tr>

          <tr>
            <td>&lt;http://www.w3.org/TR/rdf-sparql-query/&gt;</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <p><sup id="func-RDFterm-equal-foot1" class="footnote">*</sup> Invoking RDFterm-equal on two typed literals tests for 
    equivalent values. An extended implementation may have support for additional datatypes. An implementation processing a query that tests for equivalence on unsupported datatypes (and non-identical lexical form and datatype IRI) returns an error, indicating that it was unable to determine whether or not the values are equivalent. For example, an unextended implementation will produce an error when testing either

    <span class="queryExcerpt untested"><code>"iiii"^^my:romanNumeral = "iv"^^my:romanNumeral</code></span> or
    <span class="queryExcerpt untested"><code>"iiii"^^my:romanNumeral != "iv"^^my:romanNumeral</code></span>.</p>

    <h4>11.4.11 <a id="func-sameTerm" name="func-sameTerm" class="SPARQLoperator">sameTerm</a></h4>

  <pre class="prototype">
 <code class="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator">sameTerm</code> (<code class="parm type"><span class="type RDFterm">RDF term</span></code> <code class="parm name">term1</code>, <code class="parm type"><span class="type RDFterm">RDF term</span></code> <code class="parm name">term2</code>)
</pre>

    <p>Returns TRUE if <code>term1</code> and <code>term2</code> are the same RDF term as defined in <a class="norm" href="http://www.w3.org/TR/rdf-concepts/">Resource Description Framework (RDF): Concepts and Abstract Syntax</a> [<a href="#CONCEPTS">CONCEPTS</a>]; returns FALSE otherwise.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Alice".
_:a  foaf:mbox       &lt;mailto:alice@work.example&gt; .

_:b  foaf:name       "Ms A.".
_:b  foaf:mbox       &lt;mailto:alice@work.example&gt; .
</pre>

  <div class="queryGroup">
  <p>This query finds the people who have multiple <code>foaf:name</code> triples:</p>
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name1 ?name2
 WHERE { ?x foaf:name  ?name1 ;
            foaf:mbox  ?mbox1 .
         ?y foaf:name  ?name2 ;
            foaf:mbox  ?mbox2 .
         FILTER (sameTerm(?mbox1, ?mbox2) &amp;&amp; !sameTerm(?name1, ?name2))
       }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name1</th>
            <th>name2</th>
          </tr>

          <tr>
            <td>"Alice"</td>
            <td>"Ms A."</td>
          </tr>

          <tr>
            <td>"Ms A."</td>
            <td>"Alice"</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <p>Unlike <code class="operatro">RDFterm-equal</code>, <code class="operatro">sameTerm</code> can be used to test for non-equivalent <span class="type typedLiteral">typed literals</span> with unsupported data types:</p>

  <div class="exampleGroup">
  <pre class="data">@prefix :          &lt;http://example.org/WMterms#&gt; .
@prefix t:         &lt;http://example.org/types#&gt; .

_:c1  :label        "Container 1" .
_:c1  :weight       "100"^^t:kilos .
_:c1  :displacement  "100"^^t:liters .

_:c2  :label        "Container 2" .
_:c2  :weight       "100"^^t:kilos .
_:c2  :displacement  "85"^^t:liters .

_:c3  :label        "Container 3" .
_:c3  :weight       "85"^^t:kilos .
_:c3  :displacement  "85"^^t:liters .</pre>

  <div class="queryGroup">
  <pre class="query">
PREFIX  :      &lt;http://example.org/WMterms#&gt;
PREFIX  t:     &lt;http://example.org/types#&gt;

SELECT ?aLabel1 ?bLabel
WHERE { ?a  :label        ?aLabel .
        ?a  :weight       ?aWeight .
        ?a  :displacement ?aDisp .

        ?b  :label        ?bLabel .
        ?b  :weight       ?bWeight .
        ?b  :displacement ?bDisp .

        FILTER ( sameTerm(?aWeight, ?bWeight) &amp;&amp; !sameTerm(?aDisp, ?bDisp) }</pre>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>aLabel</th>
            <th>bLabel</th>
          </tr>

          <tr>
            <td>"Container 1"</td>
            <td>"Container 2"</td>
          </tr>
          <tr>
            <td>"Container 2"</td>
            <td>"Container 1"</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <p>The test for boxes with the same weight may also be done with the '=' operator (<a href="#func-RDFterm-equal" class="SPARQLoperator">RDFterm-equal</a>) as the test for <code>"100"^^t:kilos = "85"^^t:kilos</code> will result in an error, eliminating that potential solution.</p>

   <h4>11.4.12 <a id="func-langMatches" name="func-langMatches" class="SPARQLoperator">langMatches</a></h4>

  <pre class="prototype">
 <code class="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator">langMatches</code> (<code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">language-tag</code>, <code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">language-range</code>)
</pre>

    <p>Returns <code>true</code> if <code>language-tag</code> (first argument) matches <code>language-range</code> (second argument) per the basic filtering scheme defined in  [<a href="#rfc4647">RFC4647</a>] section 3.3.1. <code>language-range</code> is a basic language range  per <a class="norm" href="http://www.ietf.org/rfc/rfc4647.txt">Matching of Language Tags</a> [<a href="#rfc4647">RFC4647</a>] section 2.1. A <code>language-range</code> of "*" matches any non-empty <code>language-tag</code> string.</p>

  <div class="exampleGroup">
  <pre class="data">
@prefix dc:       &lt;http://purl.org/dc/elements/1.1/&gt; .

_:a  dc:title         "That Seventies Show"@en .
_:a  dc:title         "Cette S&eacute;rie des Ann&eacute;es Soixante-dix"@fr .
_:a  dc:title         "Cette S&eacute;rie des Ann&eacute;es Septante"@fr-BE .
_:b  dc:title         "Il Buono, il Bruto, il Cattivo" .
</pre>

  <div class="queryGroup">
  <p>This query uses <code>langMatches</code> and <code>lang</code> (described in <a href="#func-lang">section 11.2.3.8</a>) to find the French titles for the show known in English as "That Seventies Show":</p>
  <pre class="query">
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
SELECT ?title
 WHERE { ?x dc:title  "That Seventies Show"@en ;
            dc:title  ?title .
         FILTER langMatches( lang(?title), "FR" ) }</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>title</th>
          </tr>
          <tr> <td>"Cette S&eacute;rie des Ann&eacute;es Soixante-dix"@fr</td> </tr>
          <tr> <td>"Cette S&eacute;rie des Ann&eacute;es Septante"@fr-BE</td> </tr>
        </tbody>
      </table>
  </div></div>

  <div class="queryGroup">
  <p>The idiom <code>langMatches( lang( ?v ), "*" )</code> will not match literals without a language tag as <code>lang( ?v )</code> will return an empty string, so</p>

  <pre class="query add">
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
SELECT ?title
 WHERE { ?x dc:title  ?title .
         FILTER langMatches( lang(?title), "*" ) }</pre>

  <p>will report all of the titles with a language tag:</p>

  <div class="result add">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>title</th>
          </tr>
          <tr> <td>"That Seventies Show"@en</td> </tr>
          <tr> <td>"Cette S&eacute;rie des Ann&eacute;es Soixante-dix"@fr</td> </tr>
          <tr> <td>"Cette S&eacute;rie des Ann&eacute;es Septante"@fr-BE</td> </tr>
        </tbody>
      </table>
  </div></div></div>

    <h4>11.4.13 <a id="funcex-regex" name="funcex-regex" class="SPARQLoperator">regex</a></h4>

  <pre class="prototype">
 <code class="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator">regex</code> (<code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">text</code>, <code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">pattern</code>)
 <code class="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="operator">regex</code> (<code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">text</code>, <code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">pattern</code>, <code class="parm type"><span class="type simpleLiteral">simple literal</span></code> <code class="parm name">flags</code>)
</pre>

    <p>Invokes the XPath <a class="norm" href="http://www.w3.org/TR/xpath-functions/#func-matches">fn:matches</a> function to match <code>text</code> against a regular expression <code>pattern</code>. The regular expression language is defined in XQuery 1.0 and XPath 2.0 Functions and Operators section <a class="norm" href="http://www.w3.org/TR/xpath-functions/#regex-syntax">7.6.1 Regular Expression Syntax</a> [<a href="#FUNCOP">FUNCOP</a>].</p>


  <div class="exampleGroup">
  <pre class="data">
@prefix foaf:       &lt;http://xmlns.com/foaf/0.1/&gt; .

_:a  foaf:name       "Alice".
_:b  foaf:name       "Bob" .
</pre>

  <div class="queryGroup">
  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name
 WHERE { ?x foaf:name  ?name
         FILTER regex(?name, "^ali", "i") }
</pre>

  <p>Query result:</p>

  <div class="result">
      <table class="resultTable">
        <tbody>
          <tr>
            <th>name</th>
          </tr>

          <tr>
            <td>"Alice"</td>
          </tr>
        </tbody>
      </table>
  </div></div></div>

    <h3>11.5 <a id="FunctionMapping" name="FunctionMapping" class="FAndOTable">Constructor Functions</a></h3>
    <p>SPARQL imports a subset of the XPath constructor functions defined in <a class="norm" href="http://www.w3.org/TR/xpath-functions/">XQuery 1.0 and XPath 2.0 Functions and Operators</a> [<a href="#FUNCOP">FUNCOP</a>] in section <a class="norm" href="http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive">17.1 Casting from primitive types to primitive types</a>. SPARQL constructors include all of the XPath constructors for the <a href="#operandDataTypes">SPARQL operand data types</a> plus the <a href="#operandDataTypes">additional datatypes</a> imposed by the RDF data model. Casting in SPARQL is performed by calling a constructor function for the target type on an operand of the source type.</p>

    <p>XPath defines only the casts from one XML Schema datatype to another. The remaining casts are defined as follows:</p>
    <ul>
      <li>Casting an <span class="IRI type">IRI</span> to an <code>xsd:string</code> produces a <span class="IRI typedLiteral">typed literal</span> with a lexical value of the codepoints comprising the IRI, and a datatype of <code>xsd:string</code>.</li>
      <li>Casting a <span class="simpleLiteral type">simple literal</span> to any XML Schema datatype is defined as the product of casting an <code>xsd:string</code> with the <a href="http://www.w3.org/TR/xpath20/#dt-string-value">string value</a> equal to the lexical value of the literal to the target datatype.</li>
    </ul>

    <p>The table below summarizes the casting operations that are always allowed (<span class="castY">Y</span>), never allowed (<span class="castN">N</span>) and dependent on the lexical value (<span class="castM">M</span>). For example, a casting operation from an <code>xsd:string</code> (the first row) to an <code>xsd:float</code> (the second column) is dependent on the lexical value (<span class="castM">M</span>).</p>

<blockquote>
<p>bool = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#boolean">xsd:boolean</a><br />
dbl = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#double">xsd:double</a><br />
flt = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#float">xsd:float</a><br />
dec = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#decimal">xsd:decimal</a><br />
int = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#integer">xsd:integer</a><br />
dT = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#dateTime">xsd:dateTime</a><br />
str = <a class="norm" href="http://www.w3.org/TR/xmlschema-2/#string">xsd:string</a><br />
<span class="rdfDM">IRI</span> = <span class="type IRI">IRI</span><br />
<span class="rdfDM">ltrl</span> = <code class="type simpleLiteral">simple literal</code></p>
</blockquote>

<table class="casting" summary="Casting table" border="1" cellpadding="1">
<col width="13%" span="1" />
<col width="11%" span="1" />
<col width="11%" span="1" />
<col width="11%" span="1" />
<col width="11%" span="1" />
<col width="11%" span="1" />
<col width="11%" span="1" />
<col width="11%" span="1" />
<!-- col width="3%" span="1" / -->
<!-- col width="3%" span="1" / -->
<!-- col width="3%" span="1" / -->
<thead>
<tr>
<th><span class="cancast" title="From\To">From \ To</span></th>
<th><span class="cancast" title="string">str</span></th>
<th><span class="cancast" title="float">flt</span></th>
<th><span class="cancast" title="double">dbl</span></th>
<th><span class="cancast" title="decimal">dec</span></th>
<th><span class="cancast" title="integer">int</span></th>
<th><span class="cancast" title="dateTime">dT</span></th>
<th><span class="cancast" title="boolean">bool</span></th>
<!-- th><span class="cancast rdfDM" title="IRI">IRI</span></th -->
<!-- th><span class="cancast rdfDM" title="Literal">ltrl</span></th -->
<!-- th><span class="cancast rdfDM" title="bNode">BN</span></th -->
</tr>
</thead>
<tbody>
<tr>
<th><span class="cancast" title="string">str</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast string to string? Yes">Y</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast string to float? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast string to double? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast string to decimal? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast string to integer? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast string to dateTime? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast string to boolean? Maybe">M</span></td>
<!-- td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast string to IRI? Yes">Y</span></td -->
<!-- td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast string to Literal? Yes">Y</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast string to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast" title="float">flt</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast float to string? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast float to float? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast float to double? Yes">Y</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast float to decimal? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast float to integer? Maybe">M</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast float to dateTime? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast float to boolean? Yes">Y</span></td>
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast float to IRI? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast float to Literal? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast float to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast" title="double">dbl</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast double to string? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast double to float? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast double to double? Yes">Y</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast double to decimal? Maybe">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast" title="Cast double to integer? Maybe">M</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast double to dateTime? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast double to boolean? Yes">Y</span></td>
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast double to IRI? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast double to Literal? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast double to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast" title="decimal">dec</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast decimal to string? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast decimal to float? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast decimal to double? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast decimal to decimal? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast decimal to integer? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast decimal to dateTime? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast decimal to boolean? Yes">Y</span></td>
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast decimal to IRI? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast decimal to Literal? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast decimal to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast" title="integer">int</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast integer to string? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast integer to float? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast integer to double? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast integer to decimal? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast integer to integer? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast integer to dateTime? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast integer to boolean? Yes">Y</span></td>
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast integer to IRI? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast integer to Literal? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast integer to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast" title="dateTime">dT</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast dateTime to string? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast dateTime to float? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast dateTime to double? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast dateTime to decimal? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast dateTime to integer? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast dateTime to dateTime? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast dateTime to boolean? No">N</span></td>
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast dateTime to IRI? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast dateTime to Literal? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast dateTime to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast" title="boolean">bool</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast boolean to string? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast boolean to float? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast boolean to double? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast boolean to decimal? Yes">Y</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast boolean to integer? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast" title="Cast boolean to dateTime? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast" title="Cast boolean to boolean? Yes">Y</span></td>
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast boolean to IRI? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast boolean to Literal? No">N</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast boolean to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast rdfDM" title="IRI">IRI</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to string? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to float? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to double? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to decimal? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to integer? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to dateTime? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to boolean? No">N</span></td>
<!-- td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to IRI? Yes">Y</span></td -->
<!-- td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to Literal? Yes">Y</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast IRI to bNode? No">N</span></td -->
</tr>
<tr>
<th><span class="cancast rdfDM" title="Literal">ltrl</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to string? Yes">Y</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to float? No">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to double? No">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to decimal? No">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to integer? No">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to dateTime? No">M</span></td>
<td class="castM" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to boolean? No">M</span></td>
<!-- td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to IRI? Yes">Y</span></td -->
<!-- td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to Literal? Yes">Y</span></td -->
<!-- td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast Literal to bNode? No">N</span></td -->
</tr>
<!-- tr>
<th><span class="cancast rdfDM" title="bNode">BN</span></th>
<td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to string? Yes">Y</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to float? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to double? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to decimal? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to integer? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to dateTime? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to boolean? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to IRI? No">N</span></td>
<td class="castN" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to Literal? No">N</span></td>
<td class="castY" align="center" valign="middle"><span class="cancast rdfDM" title="Cast bNode to bNode? Yes">Y</span></td>
</tr -->
</tbody>
</table>

  <h3>11.6 <a id="extensionFunctions" name=
  "extensionFunctions">Extensible Value Testing</a></h3>

    <p>A <a href="#rPrimaryExpression">PrimaryExpression</a> grammar rule can be a call to an extension function named by an IRI. An extension function takes some number of RDF terms as arguments and returns an RDF term. The semantics of these functions are identified by the IRI that identifies the function.</p>

    <p>SPARQL queries using extension functions are likely to have limited interoperability.</p>

  <p>As an example, consider a function called <code class="function">func:even</code>:</p>

  <pre class="prototype">
 <code class="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="function">func:even</code> (<code class="parm type"><span class="type numeric">numeric</span></code> <code class="parm name">value</code>)
</pre>

  <div class="exampleGroup">
  <div class="queryGroup">
  <p>This function would be invoked in a FILTER as such:</p>

  <pre class="query">
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX func: &lt;http://example.org/functions#&gt;
SELECT ?name ?id
WHERE { ?x foaf:name  ?name ;
           func:empId   ?id .
        FILTER (func:even(?id)) }</pre></div></div>

    <p>For a second example, consider a function <code>aGeo:distance</code> that calculates the distance between two points, which is used here to find the places near Grenoble:</p>

  <pre class="prototype">
 <code class="return">xsd:boolean</code>&nbsp;&nbsp;&nbsp;<code class="function">aGeo:distance</code> (<code class="parm type"><span class="type numeric">numeric</span></code> <code class="parm name">x1</code>, <code class="parm type"><span class="type numeric">numeric</span></code> <code class="parm name">y1</code>, <code class="parm type"><span class="type numeric">numeric</span></code> <code class="parm name">x2</code>, <code class="parm type"><span class="type numeric">numeric</span></code> <code class="parm name">y2</code>)
</pre>

  <div class="exampleGroup">
  <div class="queryGroup">
  <pre class="query">
PREFIX aGeo: &lt;http://example.org/geo#&gt;

SELECT ?neighbor
WHERE { ?a aGeo:placeName &quot;Grenoble&quot; .
        ?a aGeo:location ?axLoc .
        ?a aGeo:location ?ayLoc .

        ?b aGeo:placeName ?neighbor .
        ?b aGeo:location ?bxLoc .
        ?b aGeo:location ?byLoc .

        FILTER ( aGeo:distance(?axLoc, ?ayLoc, ?bxLoc, ?byLoc) &lt; 10 ) .
      }
</pre></div></div>

  <p>An extension function might be used to test some
  application datatype not supported by the core SPARQL specification, it might
  be a transformation between datatype formats, for example into an XSD dateTime
  RDF term from another date format. </p>

  <h2>12 <a name="sparqlDefinition" id="sparqlDefinition">Definition of SPARQL</a></h2>

<p>This section defines the correct behavior for evaluation of graph patterns 
and solution modifiers, given a query string and an RDF 
dataset. It does not imply a SPARQL implementation must use the process defined 
here. </p>

  <p>The outcome of executing a SPARQL is defined by a series of steps, starting 
  from the SPARQL query as a string, turning that string into an abstract syntax 
  form, then turning the abstract syntax into a SPARQL abstract query comprising operators from the SPARQL algebra. This abstract query 
  is then evaluated on an RDF 
  dataset.</p>
<h3>12.1 <a id="initDefinitions" name="initDefinitions">Initial Definitions</a></h3>


  <h4>12.1.1 <a id="sparqlBasicTerms" name="sparqlBasicTerms">RDF Terms</a></h4>

  <p>SPARQL is defined in terms of IRIs [<a href=
  "#rfc3987">RFC3987</a>]. IRIs are a subset of RDF URI References that omits spaces.</p>

  <div class="defn">
    <b>Definition:</b> <a id="defn_RDFTerm" name="defn_RDFTerm">RDF Term</a>

    <p>Let I be the set of all IRIs.<br />
    Let RDF-L be the set of all <a class="norm" href=
    "http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">RDF Literals</a><br />
    Let RDF-B be the set of all <a class="norm" href=
    "http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">blank nodes</a> in RDF graphs</p>

    <p>The set of <span class="definedTerm">RDF Terms</span>, RDF-T, is I union RDF-L union RDF-B.</p>
  </div>

  <p>This definition of <span class="definedTerm">RDF Term</span> collects together several basic notions from the
  <a class="norm" href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-data-model">RDF data model</a>,
  but <a href="http://www.w3.org/TR/rdf-concepts/#section-Graph-URIref">updated</a> to refer to IRIs rather than RDF
  URI references.</p>

  <h4>12.1.2 <a id="sparqlDataset" name="sparqlDataset">RDF Dataset</a></h4>
<div class="defn">
  <b>Definition:</b> <a id="defn_RDFDataset" name="defn_RDFDataset">RDF Dataset</a><p>
  An RDF dataset is a set:<br />
  { G, (&lt;u<sub>1</sub>&gt;, G<sub>1</sub>), (&lt;u<sub>2</sub>&gt;, G<sub>2</sub>), . . .
  (&lt;u<sub>n</sub>&gt;, G<sub>n</sub>) }<br />
  where G and each G<sub>i</sub> are graphs, and each &lt;u<sub>i</sub>&gt; is
  an IRI.
  Each &lt;u<sub>i</sub>&gt; is distinct.</p>
  <p>G is called the default graph. (&lt;u<sub>i</sub>&gt;, G<sub>i</sub>) are called
  named graphs.</p>
</div>

  <div class="defn">
    <b>Definition:</b> <a id="defn_ActiveGraph" name="defn_ActiveGraph">Active Graph</a>
    <p>The <b>active graph</b> is the graph from the dataset used for basic 
    graph pattern matching.</p>
  </div>

  <h4>12.1.3 <a id="sparqlQueryVariables" name="sparqlQueryVariables">Query Variables</a></h4>

  <div class="defn">
    <b>Definition:</b> <a id="defn_QueryVariable" name="defn_QueryVariable">Query Variable</a>

    <p>A <span class="definedTerm">query variable</span> is a member of the set V where V is infinite and disjoint from
    RDF-T.</p>
  </div>

  <h4>12.1.4 <a id="sparqlTriplePatterns" name="sparqlTriplePatterns">Triple Patterns</a></h4>

  <div class="defn">
    <b>Definition:</b> <a id="defn_TriplePattern" name="defn_TriplePattern">Triple Pattern</a>

    <p>A <span class="definedTerm">triple pattern</span> is member of the set:<br />
    (RDF-T union V) x (I union V) x (RDF-T union V)</p>
  </div>

  <p>This definition of Triple Pattern includes literal subjects. <a href=
  "http://www.w3.org/2000/03/rdf-tracking/#rdfms-literalsubjects">This has been noted by RDF-core</a>.</p>
  <pre id="body">
"[The RDF core Working Group] noted that it is aware of no reason why literals should not
  be subjects and a future WG with a less restrictive charter may
  extend the syntaxes to allow literals as the subjects of statements."
</pre>

  <p>Because RDF graphs may not contain literal subjects, any SPARQL triple pattern with a literal as subject will fail
  to match on any RDF graph.</p>
  
  <h4>12.1.5 <a id="sparqlBasicGraphPatterns" name="sparqlBasicGraphPatterns">Basic Graph Patterns</a></h4>

  
<div class="defn">
    <b>Definition:</b> <a id="defn_BasicGraphPattern" name="defn_BasicGraphPattern">Basic Graph Pattern</a>

    <p>A <span class="definedTerm">Basic Graph Pattern</span> is a
    set of <a href="#defn_TriplePattern">Triple Patterns</a>.</p>
  </div>

  <p>The empty graph pattern is a basic graph pattern which is the empty set.</p>
<h4>12.1.6 <a name="sparqlSolutions" id="sparqlSolutions">Solution Mapping</a></h4>

  <p>A solution mapping is a mapping from a set of variables to a set of RDF terms. 
  We use the term 'solution' where it is clear.</p>

  <div class="defn">
    <b>Definition: <a id="defn_sparqlSolutionMapping" name="defn_sparqlSolutionMapping">Solution 
    Mapping</a></b><p>A <b>solution mapping</b>, &mu;, is a partial function &mu; : V -&gt; T.</p>

    <p>The domain of &mu;, dom(&mu;), is the subset of V where &mu; is defined.</p>
  </div>
  <div class="defn">
    <b>Definition: 
    <a id="defn_sparqlSolutionSequence" name="defn_sparqlSolutionSequence">Solution Sequence</a></b>
    
    <p>A <b>solution sequence</b> is a list of solutions, possibly unordered.</p>
  </div>

<h4>12.1.7 <a name="sparqlSolMod" id="sparqlSolMod">Solution Sequence Modifiers</a></h4>

<div class="defn">
    <b>Definition:</b> 
    <a id="defn_SolutionModifier" name="defn_SolutionModifier">Solution Sequence Modifier</a>

    <p>A <span class="definedTerm">solution sequence modifier</span> is one of:</p>
    <ul>
      <li>
      <a href="#defn_algOrdered">
      Order By</a> modifier: put the solutions in order</li>
      <li>
      <a href="#defn_algProjection">
      Projection</a> modifier: choose certain variables</li>
      <li>
      <a href="#defn_algDistinct">
      Distinct</a> modifier: ensure solutions in the sequence are unique</li>
      <li>
      <a href="#defn_algReduced">
      Reduced</a> modifier: permit any non-unique solutions to be eliminated</li>
      <li>
      <a href="#defn_algSlice">
      Offset</a> modifier: control where the solutions start from in 
      the overall sequence of solutions</li>
      <li>
      <a href="#defn_algSlice">
      Limit</a> modifier: restrict the number of solutions</li>
    </ul>
  </div>
<h3>12.2 <a id="sparqlQuery" name="sparqlQuery">SPARQL Query</a></h3>
<p>This section defines the process of converting graph patterns and solution 
modifiers in a SPARQL query string into a SPARQL algebra expression.</p>
<p>After parsing a SPARQL query string, and applying the abbreviations for IRIs 
and triple patterns given in 
  <a href="#sparqlSyntax">section 4</a>, there is an abstract syntax tree 
composed of:</p>

<table class="plain">
  <tbody>
  <tr>
    <th>Patterns</th>
    <th>Modifiers</th>
    <th>Query Forms</th>
  </tr>
  <tr>
    <td>RDF terms</td>
    <td>DISTINCT</td>
    <td>SELECT</td>
  </tr>
  <tr>
    <td>triple patterns</td>
    <td>REDUCED</td>
    <td>CONSTRUCT</td>
  </tr>
  <tr>
    <td>Basic graph patterns</td>
    <td>PROJECT</td>
    <td>DESCRIBE</td>
  </tr>
  <tr>
    <td>Groups</td>
    <td>ORDER BY</td>
    <td>ASK</td>
  </tr>
  <tr>
    <td>OPTIONAL</td>
    <td>LIMIT</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>UNION</td>
    <td>OFFSET</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>GRAPH</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>FILTER</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  </tbody>
</table>
<p>The result of converting such an abstract syntax tree is a SPARQL query that 
uses the following symbols in the SPARQL algebra:</p>

<table class="plain">
  <tbody>
  <tr>
    <th>Graph Pattern</th>
    <th>Solution Modifiers</th>
  </tr>
  <tr>
    <td>BGP </td>
    <td>ToList</td>
  </tr>
  <tr>
    <td>Join</td>
    <td>OrderBy</td>
  </tr>
  <tr>
    <td>LeftJoin</td>
    <td>Project</td>
  </tr>
  <tr>
    <td>Filter</td>
    <td>Distinct</td>
  </tr>
  <tr>
    <td>Union</td>
    <td>Reduced</td>
  </tr>
  <tr>
    <td>Graph</td>
    <td>Slice</td>
  </tr>
  </tbody>
</table>

  <p><i>Slice</i> is the combination of OFFSET and LIMIT. <i>mod</i> is any one of the 
  solution modifiers.</p>
<p><i>ToList</i> is used where conversion from the results of graph pattern 
matching to sequences occurs.</p>

	<div class="defn">
    <b>Definition:</b> <a id="defn_SPARQLQuery" name="defn_SPARQLQuery">
    SPARQL Query</a>

    <p>A <span class="definedTerm">SPARQL Abstract Query</span> is a tuple (E, DS, R) where:</p>

    <ul>
      <li>E is a <a href="#sparqlAlgebra">SPARQL algebra</a> expression</li>
      <li>DS is an <a href="#defn_RDFDataset">RDF Dataset</a></li>
      <li>R is a <a href="#QueryForms"><span style="background-position: 0% 0%">
      q</span>uery form</a></li>
    </ul>
	</div>
    <h4>12.2.1 <a id="convertGraphPattern" name="convertGraphPattern">Converting Graph Patterns</a></h4>
    
<p>Step 0 : Expand abbreviations for IRIs and triple patterns given in 
  <a href="#sparqlSyntax">section 4</a>.</p>
<p>Step 1 : BasicGraphPatterns</p>

  <p>Replace all basic graph patterns by
  <code>BGP(list of triple patterns)</code></p>

  <p>Step 2 : <code class="gRuleBody"><a href="#rGroupOrUnionGraphPattern">GroupOrUnionGraphPattern</a></code></p>

  <p>Replace any <a href="#rGroupOrUnionGraphPattern"><code class="gRuleBody">GroupOrUnionGraphPattern</code></a>
  elements:</p>

  <ul>
    <li>If the element consists of a single <code class="gRuleBody"><a href=
    "#rGroupGraphPattern">GroupGraphPattern</a></code> then replace with the <code class="gRuleBody"><a href=
    "#rGroupGraphPattern">GroupGraphPattern</a></code>.</li>
    <li>If the element consists of multiple <code class="gRuleBody"><a href=
    "#rGroupGraphPattern">GroupGraphPattern</a>s</code> connected with <span class="token"><code class=
    "gRuleBody">'UNION'</code></span> terminals,  then replace with a sequence of nested union operators:<br />
    e.g. Union(Union(GroupGraphPattern, GroupGraphPattern), GroupGraphPattern).</li>
  </ul>

  <p>Step 3 : <code class="gRuleBody"><a href="#rGraphGraphPattern">GraphGraphPattern</a></code></p>
  <p>Replace any <code><a href="#rGraphGraphPattern">GraphGraphPattern</a></code> elements:</p>

  <ul>
  <li>Replace <code class="gRuleBody">GRAPH IRI <a href=
"#rGroupGraphPattern">GroupGraphPattern</a></code> with Graph(IRI, <a href=
"#rGroupGraphPattern"> <code>GroupGraphPattern</code></a>)</li>
<li>
Replace <code class="gRuleBody">GRAPH Var <a href=
"#rGroupGraphPattern">GroupGraphPattern</a></code> with Graph(var, <a href=
"#rGroupGraphPattern"> <code>GroupGraphPattern</code></a>)</li>
</ul>

  <p>Step 4 : <code class="gRuleBody"><a href="#rGroupGraphPattern">GroupGraphPattern</a></code></p>

  <p>We introduce the following symbols:</p>

  <ul>
    <li>Join(Pattern, Pattern)</li>
    <li>LeftJoin(Pattern, Pattern, expression)</li>
    <li>Filter(expression, Pattern)</li>
  </ul>

  <p>After parsing, a group pattern consists of a sequence of graph patterns and filters (<code class=
  "gRuleBody"><a href="#rConstraint">Constraint</a></code>).</p>

  <p>A group pattern is mapped into the SPARQL algebra as follows: first, 
  convert all elements making up the group into algebra expressions using this 
  transformation process recursively, then apply 
  the following transformation:</p>

  <pre class="codeBlock">
Let SP := list of algebra expressions for sub-patterns of the group
Let F := all filters in the group (not in sub-patterns)
Let G := the empty pattern, Z, a basic graph pattern which is the empty set.

for each algebra sub-expression SA:
   If SA is an OPTIONAL,
      If SA is of the form OPTIONAL(Filter(F, A))
           G := LeftJoin(G, A, F)
      else
           G := LeftJoin(G, A, true)
   Otherwise for expression SA, G := Join(G, SA)

If F is not empty:
  If G = empty pattern then G := Filter(F, Z)
  If G = LeftJoin(A1, A2, true) then G := LeftJoin(A1, A2, F)
  If G = Join(A1, A2) then G := Filter(F, Join(A1, A2))
  If G = Union(A1, A2) then G := Filter(F, Union(A1, A2))
  If G = Graph(x, A) then G := Filter(F, Graph(x, A)) 
         where x is a variable or IRI.

The result is G
</pre>

  <p>Step 5 : Simplification</p>

  <p>Groups of one graph pattern (not a filter) become join(Z, A) and can be replaced by A. 
  The empty graph pattern Z is the identity for join.</p>
  <pre class="codeBlock">
Replace join(Z, A) by A
Replace join(A, Z) by A
</pre>

  <h4>12.2.2 <a id="sparqlAbsExamples" name="sparqlAbsExamples">Examples of Mapped Graph Patterns</a></h4>

  <p>The second form of a rewrite example is the first with empty group joins removed by step 5.</p>
<p>Example: group with a basic graph pattern consisting of a single triple 
pattern:</p>

  <div class="algExample">
    <div class="algExample1">
      { ?s ?p ?o }
    </div>

    <div class="algExample2">
      Join(Z,
      BGP(?s ?p ?o) )</div>
    <div class="algExample2">
      BGP(?s ?p ?o)</div>
  </div>

<p>Example: group with a basic graph pattern consisting of two triple patterns:</p>

  <div class="algExample">
    <div class="algExample1">
      { ?s :p1 ?v1 ; :p2 ?v2 }
    </div>

    <div class="algExample2">
      BGP( ?s :p1 ?v1 .?s :p2 ?v2 )
    </div>
  </div>

<p>Example: group consisting of a union of two basic graph patterns:</p>

  <div class="algExample">
    <div class="algExample1">
      { { ?s :p1 ?v1 } UNION {?s :p2 ?v2 } }
    </div>

    <div class="algExample2">
      Union(Join(Z, BGP(?s :p1 ?v1)),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p2 ?v2)) )
    </div>

    <div class="algExample2">
      Union( BGP(?s :p1 ?v1) , BGP(?s :p2 ?v2) )
    </div>
  </div>

<p>Example: group consisting a union of a union and a basic graph pattern:</p>

  <div class="algExample">
    <div class="algExample1">
      { { ?s :p1 ?v1 } UNION {?s :p2 ?v2 } UNION {?s :p3 ?v3 } }
    </div>

    <div class="algExample2">
      Union(<br/>
&nbsp;&nbsp;&nbsp; Union( Join(Z, BGP(?s :p1 ?v1)),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p2 ?v2))) 
      ,<br/>
&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p3 ?v3)) )</div>

    <div class="algExample2">
      Union( <br/>
&nbsp;&nbsp;&nbsp; Union( BGP(?s :p1 ?v1) ,<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BGP(?s :p2 ?v2),<br/>
&nbsp;&nbsp;&nbsp; BGP(?s :p3 ?v3))</div>
  </div>

<p>Example: group consisting of a basic graph pattern and an optional graph 
pattern:</p>

  <div class="algExample">
    <div class="algExample1">
      { ?s :p1 ?v1 OPTIONAL {?s :p2 ?v2 } }
    </div>

    <div class="algExample2">
      LeftJoin(<br/>
&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p1 ?v1)),<br/>
&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p1 ?v1)) ),<br/>
&nbsp;&nbsp;&nbsp; true)
    </div>

    <div class="algExample2">
      LeftJoin(BGP(?s :p1 ?v1), BGP(?s :p2 ?v2), true)
    </div>
  </div>

<p>Example: group consisting of a basic graph pattern and two optional graph 
patterns:</p>

  <div class="algExample">
    <div class="algExample1">
      { ?s :p1 ?v1 OPTIONAL {?s :p2 ?v2 } OPTIONAL { ?s :p3 ?v3 } }
    </div>

    <div class="algExample2">
      LeftJoin(<br />
           &nbsp;&nbsp;&nbsp; LeftJoin(<br />
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BGP(?s :p1 ?v1),<br />
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BGP(?s :p2 ?v2),<br />
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              true) ,<br />
           &nbsp;&nbsp;&nbsp; BGP(?s :p3 ?v3),<br />
           &nbsp;&nbsp;&nbsp; true)
    </div>
  </div>

<p>Example: group consisting of a basic graph pattern and an optional graph 
pattern with a filter:</p>

  <div class="algExample">
    <div class="algExample1">
      { ?s :p1 ?v1 OPTIONAL {?s :p2 ?v2 FILTER(?v1&lt;3) } }
    </div>

    <div class="algExample2">
      LeftJoin(<br/>
&nbsp;&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p1 ?v1)),<br/>
&nbsp;&nbsp;&nbsp;&nbsp; Join(Z, BGP(?s :p1 ?v1)),<br/>
&nbsp;&nbsp;&nbsp;&nbsp; (?v1&lt;3) )
    </div>

    <div class="algExample2">
      LeftJoin(<br/>
&nbsp;&nbsp;&nbsp; BGP(?s :p1 ?v1) ,<br/>
&nbsp;&nbsp;&nbsp; BGP(?s :p2 ?v2) ,<br/>
&nbsp;&nbsp; (?v1&lt;3) )
    </div>
  </div>

<p>Example: group consisting of a union graph pattern and an optional graph 
pattern:</p>

  <div class="algExample">
    <div class="algExample1">
      { {?s :p1 ?v1} UNION {?s :p2 ?v2} OPTIONAL {?s :p3 ?v3} }
    </div>

    <div class="algExample2">
      LeftJoin(<br />
        &nbsp;
        Union(BGP(?s :p1 ?v1),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BGP(?s :p2 ?v2)) ,<br />
        &nbsp;
        BGP(?s :p3 ?v3) ,<br />
        &nbsp;
        true )
    </div>
  </div>

<p>Example: group consisting of a basic graph pattern, a filter and an optional 
graph pattern:</p>

  <div class="algExample">
    <div class="algExample1">
      { ?s :p1 ?v1} FILTER (?v1 &lt; 3 ) OPTIONAL {?s :p2 ?v2} }
    </div>

    <div class="algExample2">
      Filter( ?v1 &lt; 3 ,<br />
              &nbsp;
              LeftJoin( BGP(?s :p1 ?v1), BGP(?s :p2 ?v2), true) ,<br />
             &nbsp;
             )
    </div>
  </div>

  <h4>12.2.3 <a id="convertSolMod" name="convertSolMod">Converting Solution Modifiers</a></h4>

  <p>Step 1 : ToList</p>

  <p>ToList turns a multiset into a sequence with the same elements and cardinality. There is no implied ordering to
  the sequence; duplicates need not be adjacent.</p>

  <blockquote>
    <p>Let M := ToList(Pattern)</p>
  </blockquote>

  <p>Step 2 : ORDER BY</p>

  <p>If the query string has an ORDER BY clause</p>

  <blockquote>
    <p>M := OrderBy(M, list of order comparators)</p>
  </blockquote>

  <p>Step 3 : Projection</p>

  <blockquote>
    <p>M := Project(M, vars)</p>
  </blockquote>

  <p>where vars is the set of variables mentioned in the SELECT clause or all named variables in the query if SELECT *
  used.</p>

  <p>Step 4 : DISTINCT</p>

  <p>If the query contains DISTINCT,</p>

  <blockquote>
    <p>M := Distinct(M)</p>
  </blockquote>

  <p>Step 5 : REDUCED</p>

  <p>If the query contains REDUCED,</p>

  <blockquote>
    <p>M := Reduced(M)</p>
  </blockquote>

  <p>Step 6 : OFFSET and LIMIT</p>

  <p>If the query contains "OFFSET start" or "LIMIT length"</p>

  <blockquote>
    <p>M := Slice(M, start, length)</p>
    <blockquote>
      <p>start defaults to 0</p>
      <p>length defaults to (size(M)-start).</p>
    </blockquote>

  </blockquote>

  <p>The overall abstract query is M.</p>


  <h3>12.3 <a id="BasicGraphPattern" name="BasicGraphPattern">Basic Graph Patterns</a></h3>
<p>When matching graph patterns, the possible solutions form a <i>
<a href="http://en.wikipedia.org/wiki/Multiset">multiset</a></i>, also known as 
a <i>bag</i>. A multiset is an unordered collection of elements in which each 
element may appear more than once. It is described by a set of elements and a
cardinality function giving the number of occurrences of each element from the 
set in the multiset.</p>

  <p>Write &mu;<sub>0</sub> for the mapping such that dom(&mu;<sub>0</sub>) is the empty set.</p>

  <p>Write &Omega;<sub>0</sub> for the multiset consisting of exactly the empty mapping &mu;<sub>0,</sub> with
  cardinality 1.</p>

  <p>Write &mu;(?x-&gt;t) for the solution mapping variable x to RDF term t : { (x, t) }</p>

  <p>Write &Omega;(?x-&gt;t) for the multiset consisting of exactly &mu;(?x-&gt;t), that is, { { (x, t) } } with
  cardinality 1.</p>

  <div class="defn">
    <b>Definition: <a id="defn_algCompatibleMapping" name="defn_algCompatibleMapping">Compatible Mappings</a></b>

    <p>Two solution mappings &mu;<sub>1</sub> and &mu;<sub>2</sub> are compatible if, for every variable v in
    dom(&mu;<sub>1</sub>) and in dom(&mu;<sub>2</sub>), &mu;<sub>1</sub>(v) = &mu;<sub>2</sub>(v).</p>

  </div>

    <p>If &mu;<sub>1</sub> and &mu;<sub>2</sub> are compatible then &mu;<sub>1</sub> <i>set-union</i> &mu;<sub>2</sub>
    is also a mapping. Write merge(&mu;<sub>1</sub>, &mu;<sub>2</sub>) for &mu;<sub>1</sub> <i>set-union</i> &mu;<sub>2</sub></p>

  <p>Write card[&Omega;](&mu;) for the cardinality of &mu; in a multiset of mappings &Omega;. 
  If &#956; is not a member of &#937;, cardinality is not defined.</p>

  <h4>12.3.1 <a id="BGPsparql" name="BGPsparql">SPARQL Basic Graph Pattern Matching</a></h4>

  <p>Basic graph patterns form the basis of SPARQL pattern matching. A basic 
  graph pattern is matched against the active graph for that part of the query. 
  Basic graph patterns can be instantiated by 
replacing both variables and blank nodes by terms, giving two notions 
of instance. Blank nodes are replaced using an
  <a href="http://www.w3.org/TR/rdf-mt#definst">RDF 
instance mapping</a>, &nbsp;&#963;, from blank nodes to RDF terms; variables are 
  replaced by a solution mapping from query variables to RDF terms.</p>

<div class="defn">
    <b>Definition: <a id="defn_PatternInstanceMapping" name="defn_PatternInstanceMapping">Pattern Instance Mapping</a></b>
    
    <p>A <b>Pattern Instance Mapping</b>, P, is the combination of an RDF 
    instance mapping, &#963;, and solution mapping, &#956;. P(x) = &#956;(&#963;(x))</p>
</div>    


    <p>Any pattern instance mapping defines a unique solution mapping
    and a unique RDF instance mapping obtained by restricting it to query 
	variables and blank nodes respectively.</p>

<div class="defn">
    <b>Definition: Basic Graph Pattern Matching</b>
    <p>Let BGP be a basic graph pattern and let G be an RDF graph.</p>
    <p>&#956; is a <b>solution</b> for BGP from G when there is a pattern instance 
    mapping P such that P(BGP) is a subgraph of G and &#956; is a restriction of P to 
    the query variables in BGP.</p>
    <p>card[&Omega;](&mu;) = card[&Omega;](number of distinct RDF instance mappings, &#963;, 
    such that P = &#956;(&#963;) is a pattern instance mapping and P(BGP) is a subgraph of G).</p>
</div>    
<p>If a basic graph pattern is the empty set, then the solution is &#937;<sub>0</sub>.</p>
<h4>12.3.2 <a id="BGPsparqlBNodes" name="BGPsparqlBNodes">Treatment of Blank Nodes</a></h4>

		<p>This definition allows the solution mapping to bind a variable in a 
        basic graph pattern, BGP, to a blank node in G. Since SPARQL treats 
        blank node identifiers in a <a href="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL Query Results XML Format</a> document as scoped to the document, they 
cannot be understood as identifying nodes in the active graph of the dataset. If DS is 
the dataset of a query, pattern solutions are therefore understood to 
be not from the active graph of DS itself, but from an RDF graph, called the <i>scoping 
graph,</i> which is graph-equivalent to the active graph of DS but shares no blank nodes 
with DS or with BGP. The same scoping graph is used for all solutions 
to a single query. The scoping graph is purely a theoretical 
construct; in practice, the effect is obtained simply by the document 
scope conventions for blank node identifiers. </p>

<!--
 <div class="defn">
    <b>Definition:</b> <a id="defn_ScopingGraph" name="defn_GraphSet">Scoping Graph</a>

    <p>The <span class="definedTerm">Scoping Graph</span> G' for
    RDF graph G, is an RDF Graph that is <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-graph-equality">

    graph-equivalent</a> to G</p>
  </div>
-->
		<p>Since RDF blank nodes allow infinitely many redundant solutions for 
        many patterns, there can be infinitely many pattern solutions (obtained 
        by replacing blank nodes by different blank nodes). It is necessary, 
        therefore, to somehow delimit the solutions for a basic graph pattern. SPARQL uses the 
        subgraph match criterion to determine the solutions of a basic graph 
        pattern. There is 
        one solution for each distinct pattern instance mapping from the basic 
        graph pattern to a subset of the active graph.</p>
<p>This is optimized for ease of computation rather 
than redundancy elimination. It allows query results to contain 
redundancies even when the active graph of the dataset is 
<a href="http://www.w3.org/TR/rdf-mt/#deflean">lean</a>, and it allows logically 
equivalent datasets to yield query results. </p>

  <h3>12.4 <a id="sparqlAlgebra" name="sparqlAlgebra">SPARQL Algebra</a></h3>

  <p>For each symbol in a SPARQL abstract query, we define an operator for 
  evaluation. The SPARQL algebra operators of the same name are
  used to evaluate SPARQL abstract query nodes as described in the section "<a href="#sparqlAlgebraEval">Evaluation
  Semantics</a>".</p>

  <div class="defn">
    <p><b>Definition: <a id="defn_algFilter" name="defn_algFilter">Filter</a></b></p>

    <p>Let &Omega; be a multiset of solution mappings and expr be an expression. We define:</p>

    <p>Filter(expr, &Omega;) = { &mu; | &mu; in &Omega; and expr(&mu;) is an expression that has an 
    effective boolean value of true }</p>

    <p>card[Filter(expr, &Omega;)](&mu;) = card[&Omega;](&mu;)</p>
  </div>

  <div class="defn">
    <p><b>Definition: <a id="defn_algJoin" name="defn_algJoin">Join</a></b></p>

    <p>Let &Omega;<sub>1</sub> and &Omega;<sub>2</sub> be multisets of solution mappings. We define:</p>

    <p>Join(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>) = { merge(&mu;<sub>1</sub>, &mu;<sub>2</sub>) | &mu;<sub>1</sub>
    in &Omega;<sub>1</sub>and &mu;<sub>2</sub> in &Omega;<sub>2</sub>, and &mu;<sub>1</sub> and &mu;<sub>2</sub> are
    compatible }</p>

    <p>card[Join(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>)](&mu;) = <br/>
&nbsp;&nbsp;&nbsp; for each merge(&#956;<sub>1</sub>, &mu;<sub>2</sub>), &#956;<sub>1</sub>
    in &Omega;<sub>1</sub>and &mu;<sub>2</sub> in &Omega;<sub>2</sub> such that &#956; = merge(&#956;<sub>1</sub>, &mu;<sub>2</sub>),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum over (&#956;<sub>1</sub>, &mu;<sub>2</sub>), card[&Omega;<sub>1</sub>](&mu;<sub>1</sub>)*card[&Omega;<sub>2</sub>](&mu;<sub>2</sub>)</p>
  </div>

<p>It is possible that a solution mapping &#956; in a Join can arise in different 
solution mappings, &#956;<sub>1</sub>and &mu;<sub>2</sub> in the multisets being 
joined. The cardinality of&nbsp; &#956; is the sum of the cardinalities from all 
possibilities.</p>

  <div class="defn">
    <p><b>Definition: <a id="defn_algDiff" name="defn_algDiff">Diff</a></b></p>

    <p>Let &Omega;<sub>1</sub> and &Omega;<sub>2</sub> be multisets of solution mappings. We define:</p>

    <p>Diff(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>, expr) =
            { &mu; | &mu; in &Omega;<sub>1</sub> such that for all &mu;&prime; in &Omega;<sub>2</sub>, 
    either &#956; and &#956;&#8242; are not compatible or &mu; and &mu;'
    are compatible and expr(merge(&mu;, &mu;')) has an effective boolean value 
	of false }</p>

    <p>card[Diff(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>, expr)](&mu;) = card[&Omega;<sub>1</sub>](&mu;)</p>
  </div>

  <p>Diff is used internally for the definition of LeftJoin.</p>

  <div class="defn">
    <p><b>Definition: <a id="defn_algLeftJoin" name="defn_algLeftJoin">LeftJoin</a></b></p>

    <p>Let &Omega;<sub>1</sub> and &Omega;<sub>2</sub> be multisets of solution mappings and F a filter. We define:</p>

    <p>LeftJoin(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>, expr) = Filter(expr, Join(&Omega;<sub>1</sub>,
    &Omega;<sub>2</sub>)) <i>set-union</i> Diff(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>, expr)</p>

    <p>card[LeftJoin(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>, expr)](&mu;) = card[Filter(expr,
    Join(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>))](&mu;) + card[Diff(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>,
    expr)](&mu;)</p>
  </div>

  <p>Written in full that is:</p>

  <p>LeftJoin(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>, expr) =<br />
          &nbsp;&nbsp;&nbsp;
          { merge(&mu;<sub>1,</sub> &mu;<sub>2</sub>) | &mu;<sub>1</sub> in &Omega;<sub>1</sub>and &mu;<sub>2</sub> in
  &Omega;<sub>2</sub>, and &mu;<sub>1</sub> and &mu;<sub>2</sub> are compatible and expr(merge(&mu;<sub>1</sub>,
  &mu;<sub>2</sub>)) is true }<br />
              <i>set-union</i><br />
          &nbsp;&nbsp;&nbsp;
          { &mu;<sub>1</sub> | &mu;<sub>1</sub> in &Omega;<sub>1</sub>and &mu;<sub>2</sub> in &Omega;<sub>2</sub>, and
  &mu;<sub>1</sub> and &mu;<sub>2</sub> are not compatible }<br />
              <i>set-union</i><br />
          &nbsp;&nbsp;&nbsp;
          { &mu;<sub>1</sub> | &mu;<sub>1</sub> in &Omega;<sub>1</sub>and &mu;<sub>2</sub> in &Omega;<sub>2</sub>, and
  &mu;<sub>1</sub> and &mu;<sub>2</sub> are compatible and expr(merge(&mu;<sub>1</sub>, &mu;<sub>2</sub>)) is false
  }</p>

  <p>As these are distinct, the cardinality of LeftJoin is cardinality of these individual components of the
  definition.</p>

  <div class="defn">
    <p><b>Definition: <a id="defn_algUnion" name="defn_algUnion">Union</a></b></p>

    <p>Let &Omega;<sub>1</sub> and &Omega;<sub>2</sub> be multisets of solution mappings. We define:</p>

    <p>Union(&Omega;<sub>1</sub>, &Omega;<sub>2</sub>) = { &mu; | &mu; in &Omega;<sub>1</sub> or &mu; in
    &Omega;<sub>2</sub> }</p>

    <p>card[Union(&Omega;1, &Omega;2)](&mu;) = card[&Omega;1](&mu;) + card[&Omega;2](&mu;)</p>
  </div>

  <p>Write [x | C] for a sequence of elements where C(x) is true.</p>

  <p>Write card[L](x) to be the cardinality of x in L.</p>

  <div class="defn">
    <b>Definition: <a id="defn_algToList" name="defn_algToList">ToList</a></b>

    <p>Let &Omega; be a multiset of solution mappings.  We define:</p>

    <p>ToList(&Omega;) = a sequence of mappings &mu; in &Omega; in any order, with card[&Omega;](&mu;) occurrences of
    &mu;</p>

    <p>card[ToList(&Omega;)](&mu;) = card[&Omega;](&mu;)</p>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_algOrdered" name="defn_algOrdered">OrderBy</a></b>

    <p>Let &Psi; be a sequence of solution mappings.  We define:</p>

    <p><a id="defn_algOrderBy0" name="defn_algOrderBy0">OrderBy</a>(&Psi;, condition) = [ &mu; | &mu; in &Psi; and the
    sequence satisfies the ordering condition]</p>

    <p>card[<a id="defn_algOrderBy1" name="defn_algOrderBy1">OrderBy</a>(&Psi;, condition)](&mu;) =
    card[&Psi;](&mu;)</p>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_algProjection" name="defn_algProjection">Project</a></b>

    <p>Let &Psi; be a sequence of solution mappings and PV a set of variables.</p>

    <p>For mapping &mu;, write Proj(&mu;, PV) to be the restriction of &mu; to variables in 
    PV.</p>

    <p>Project(&Psi;, PV)  = [ Proj(&Psi;[&#956;], PV) | &#956; in &#936; ]</p>
    <p>card[Project(&Psi;, PV)](&#956;) = card[&#936;](&#956;)</p>
    <p>The order of Project(&Psi;, PV) must preserve any ordering given by OrderBy.</p>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_algDistinct" name="defn_algDistinct">Distinct</a></b>

    <p>Let &Psi; be a sequence of solution mappings.  We define:</p>

    <p>Distinct(&Psi;) = [ &#956; | &#956; in &#936; ]</p>
    <p>card[Distinct(&Psi;)](&mu;) = 1</p>

    <p>The order of Distinct(&Psi;) must preserve any ordering given by OrderBy.</p>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_algReduced" name="defn_algReduced">Reduced</a></b>

    <p>Let &Psi; be a sequence of solution mappings.  We define:</p>

    <p>Reduced(&Psi;) = [ &#956; | &#956; in &#936; ]</p>
    <p>card[Reduced(&Psi;)](&mu;) is between 1 and card[&#936;](&#956;)</p>

    <p>The order of Reduced(&Psi;) must preserve any ordering given by OrderBy.</p>
  </div>

  <p>The Reduced solution sequence modifier does not guarantee a defined cardinality.</p>
  <p class="issue issueBlock">Reduced is an <em>at-risk</em> feature of SPARQL. See section <a href="#modReduced">9.3.2 Reduced</a> for more information.</p>

  <div class="defn">
    <b>Definition: <a id="defn_algSlice" name="defn_algSlice">Slice</a></b>

    <p>Let &Psi; be a sequence of solution mappings.  We define:</p>

    <p><a name="defn_algOrderBy2" id="defn_algOrderBy2">Slice</a>(&Psi;, start, length)[i] = &Psi;[start+i] for i = 0
    to (length-1)</p>
  </div>

  <h3>12.5 <a id="sparqlAlgebraEval" name="sparqlAlgebraEval">Evaluation Semantics</a></h3>

  <p>We define eval(D(G), graph pattern) as the evaluation of a graph pattern with respect to a dataset D having active
  graph G. The active graph is initially the default graph.</p>

  <pre class="box">
D : a dataset
D(G) : D a dataset with active graph G (the one patterns match against)
D[i] : The graph with IRI i in dataset D
D[DFT] : the default graph of D
P, P1, P2 : graph patterns
L : a solution sequence
</pre>

  <div class="defn">
    <b>Definition: <a id="defn_evalFilter" name="defn_evalFilter">Evaluation of Filter(P, F)</a></b>
    <pre class="code">
eval(D(G), Filter(P, F)) = Filter(eval(D(G), F))</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalJoin" name="defn_evalJoin">Evaluation of Join(P1, P2, F)</a></b>
    <pre class="code">
eval(D(G), Join(P1, P2)) = Join(eval(D(G), P1), eval(D(G), P2))</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalLeftJoin" name="defn_evalLeftJoin">Evaluation of LeftJoin(P1, P2, F)</a></b>
    <pre class="code">eval(D(G), LeftJoin(P1, P2, F)) = LeftJoin(eval(D(G), P1), eval(D(G), P2), F)
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalBasicGraphPattern" name="defn_evalBasicGraphPattern">Evaluation of a Basic Graph
    Pattern</a></b>
	<pre class="code">eval(D(G), BGP) = multiset of solution mappings</pre>
    <p>See section <a href="#BasicGraphPattern">12.3 Basic Graph Patterns</a></p>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalUnion" name="defn_evalUnion">Evaluation of a Union Pattern</a></b>
    <pre class="code">
eval(D(G), Union(P1,P2)) = Union(eval(D(G), P1), eval(D(G), P2))
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalGraph" name="defn_evalGraph">Evaluation of a Graph Pattern</a></b>
    <pre class="code">
eval(D(G), Graph(IRI,P)) = eval(D(D[IRI]), P)
eval(D(G), Graph(var,P)) =
     Let R be the empty multiset
     foreach IRI i in D
        R := Union(R, Join( eval(D(D[i]), P) , &Omega;(?var-&gt;i) )
     the result is R
</pre>
  </div>
<p>The evaluation of graph uses the SPARQL algebra union operator. The 
cardinality of a solution mapping is the sum of the cardinalities of that 
solution mapping in each join operation.</p>
  <div class="defn">
    <b>Definition: <a id="defn_evalList" name="defn_evalList">Evaluation of ToList</a></b><pre class="code">
eval(D, ToList(P)) = ToList(eval(D(D[DFT]), P))
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalDistinct" name="defn_evalDistinct">Evaluation of Distinct</a></b><pre class="code">
eval(D, Distict(L)) = Distinct(eval(D, L))
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalReduced" name="defn_evalReduced">Evaluation of Reduced</a></b><pre class="code">
eval(D, Reduced(L)) = Reduced(eval(D, L))
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalProject" name="defn_evalProject">Evaluation of Project</a></b><pre class="code">
eval(D, Project(L, vars)) = Project(eval(D, L), vars)
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalOrderBy" name="defn_evalOrderBy">Evaluation of OrderBy</a></b><pre class="code">
eval(D, OrderBy(L, condition)) = OrderBy(eval(D, L), condition)
</pre>
  </div>

  <div class="defn">
    <b>Definition: <a id="defn_evalSlice" name="defn_evalSlice">Evaluation of Slice</a></b><pre class="code">
eval(D, Slice(L, start, length)) = Slice(eval(D, L), start, length)
</pre>
  </div>
  
<h3>12.6 <a id="sparqlBGPExtend" name="sparqlBGPExtend">Extending SPARQL Basic Graph Matching</a></h3>

<p>The overall SPARQL design can be used for queries 
which assume a more elaborate form of entailment than simple 
entailment, by re-writing the matching conditions for basic graph 
patterns. Since it is an open research problem to state such 
conditions in a single general form which applies to all forms of 
entailment and optimally eliminates needless or inappropriate 
redundancy, this document only gives necessary conditions which any 
such solution should satisfy. These will need to be extended to full 
definitions for each particular case. </p>

 <p>Basic graph patterns stand in the same relation to triple patterns 
that RDF graphs do to RDF triples, and much of the same terminology 
can be applied to them. In particular, two basic graph patterns are 
said to be <i>equivalent</i> if there is a bijection M between the 
terms of the triple patterns that maps blank nodes to blank nodes and 
maps variables, literals and IRIs to themselves, such that a triple ( 
s, p, o ) is in the first pattern if and only if the triple ( M(s), 
M(p) M(o) ) is in the second. This definition extends that for RDF 
graph equivalence to basic graph patterns by preserving variable 
names across equivalent patterns. </p>

<p>An <i>entailment regime</i> specifies </p>
<ol>
	<li>a subset of RDF graphs called <i>well-formed</i> for the regime</li>
	<li>an <i>entailment</i> relation between subsets of well-formed graphs
	 and well-formed graphs.</li>
</ol>

<p>Examples of entailment regimes include simple 
entailment [<a href="#RDF-MT">RDF-MT</a>], RDF entailment
[<a href="#RDF-MT">RDF-MT</a>], RDFS entailment 
[<a href="#RDF-MT">RDF-MT</a>], D-entailment [<a href="#RDF-MT">RDF-MT</a>] and
OWL-DL entailment [<a href="#OWL_Semantics">OWL-Semantics</a>]. 
Of these, only OWL-DL entailment restricts the set of well-formed graphs.
If E is an entailment
regime then we will refer to E-entailment, 
E-consistency, etc, following this naming convention.</p>

<p>Some entailment regimes can categorize some RDF 
graphs as inconsistent. For example, the RDF graph:</p>
<pre class="data">
_:x rdf:type xsd:string .
_:x rdf:type xsd:decimal .
</pre>
<p>is D-inconsistent when D contains the XSD datatypes. The effect of a query
on an inconsistent graph is not 
covered by this specification, but must be specified by the particular 
SPARQL extension.</p>
        
        
<p>A SPARQL extension to E-entailment must satisfy the following 
conditions. </p>
<p>1 -- The 
<a href="#BGPsparqlBNodes">scoping graph</a>, SG, corresponding to any consistent 
active graph AG is uniquely specified and is E-equivalent to AG.</p>
<p>2 -- For any basic graph pattern BGP and pattern solution mapping P, P(BGP) is 
well-formed for E</p>
<p>3 -- For any scoping graph SG and answer set {P<sub>1</sub> ... P<sub>n</sub>} 
for a basic graph pattern BGP, and where {BGP<sub>1 .... </sub>BGP<sub>n</sub>} is a set of basic graph patterns 
all equivalent to BGP, none of which share any blank nodes with any other or with 
SG</p>
<blockquote>
	<p>SG E-entails (SG union P<sub>1</sub>(BGP<sub>1</sub>) union ... union P<sub>n</sub>(BGP<sub>n</sub>))</p>
</blockquote>
<p>These conditions do not fully determine the set of possible answers, since 
RDF allows unlimited amounts of redundancy. In addition, therefore, the 
following must hold.</p>
<p>4 -- Each SPARQL extension must provide conditions on answer sets which 
guarantee that every BGP and AG has a finite set of answers which is unique up 
to RDF graph equivalence.</p>
<h4 id="sparqlBGPExtend-notes">Notes</h4>
<p>(a) SG will often be graph equivalent to AG, but restricting this to 
E-equivalence allows some forms of normalization, for example elimination of 
semantic redundancies, to be applied to the source documents before querying.
</p>
<p>(b) The construction in condition 3 ensures that any blank nodes introduced 
by the solution mapping are used in a way which is internally consistent with the 
way that blank nodes occur in SG. This ensures that blank node identifiers occur 
in more than one answer in an answer set only when the blank nodes so identified 
are indeed identical in SG. If the extension does not allow answer bindings to 
blank nodes, then this condition can be simplified to the condition:</p>
<blockquote>
	<p>SG E-entails P(BGP) for each pattern solution P.</p>
</blockquote>
<p>(c) These conditions do not impose the SPARQL requirement that SG share no 
blank nodes with AG or BGP. In particular, it allows SG to actually be AG. This 
allows query protocols in which blank node identifiers retain their meaning 
between the query and the source document, or across multiple queries. Such 
protocols are not supported by the current SPARQL protocol specification, 
however. </p>
<p>(d) Since conditions 1 to 3 are only necessary conditions on answers, 
condition 4 allows cases where the set of legal answers can be restricted in 
various ways. For example, the current state of the art in OWL-DL querying 
focusses on the case where answer bindings to blank nodes are prohibited. We 
note that these conditions even allow the pathological 'mute' case where every 
query has an empty answer set. </p>
<p>(e) None of these conditions refer explicitly to instance mappings on blank 
nodes in BGP. For some entailment regimes, the existential interpretation of 
blank nodes cannot be fully captured by the existence of a single instance 
mapping. These conditions allow such regimes to give blank nodes in query 
patterns a 'fully existential' reading. </p>
<p>It is straightforward to show that SPARQL satisfies these conditions for the 
case where E is simple entailment, given that the SPARQL condition on SG is that 
it is graph-equivalent to AG but shares no blank nodes with AG or BGP (which 
satisfies the first condition). The only condition which is nontrivial is (3).
</p>
<p>Every answer P<sub>i</sub> is the solution mapping restriction of a SPARQL 
instance M<sub>i</sub> such that M<sub>i</sub>(BGP<sub>i</sub>) is a subgraph of 
SG. Since BGP<sub>i</sub> and SG have no blank nodes in common, the range of M<sub>i</sub> 
contains no blank nodes from BGP<sub>i</sub>; therefore, the solution mapping P<sub>i</sub> 
and RDF instance mapping I<sub>i</sub> components of M<sub>i</sub> commute, so M<sub>i</sub>(BGP<sub>i</sub>) 
= I<sub>i</sub>(P<sub>i</sub>(BGP<sub>i</sub>)). So</p>
<p>M<sub>1</sub>(BGP<sub>1</sub>) union ... union M<sub>n</sub>(BGP<sub>n</sub>)
<br/>= I<sub>1</sub>(P<sub>1</sub>(BGP<sub>1</sub>)) union ... union I<sub>n</sub>(P<sub>n</sub>(BGP<sub>n</sub>))<br/>= [ I<sub>1</sub> + ... + I<sub>n</sub>]( P<sub>1</sub>(BGP<sub>1</sub>) union 
... union P<sub>n</sub>(BGP<sub>n</sub>) )</p>
<p>since the domains of the I<sub>i</sub> instance mappings are all mutually 
exclusive. Since they are also exclusive from SG, </p>
<p>SG union [ I<sub>1</sub> + ... + I<sub>n</sub>]( P<sub>1</sub>(BGP<sub>1</sub>) 
union ... union P<sub>n</sub>(BGP<sub>n</sub>) )<br/>= [ I<sub>1</sub> + ... + I<sub>n</sub>](SG union P<sub>1</sub>(BGP<sub>1</sub>) 
union ... union P<sub>n</sub>(BGP<sub>n</sub>) )</p>
<p>i.e. </p>
<p>SG union P<sub>1</sub>(BGP<sub>1</sub>) union ... union P<sub>n</sub>(BGP<sub>n</sub>)</p>
<p>has an instance which is a subgraph of SG, so is simply entailed by SG by the 
<a href="http://www.w3.org/TR/rdf-mt/#interplemmaprf">RDF interpolation lemma</a> 
[<a href="#RDF-MT">RDF-MT</a>].</p>
<h2>A. <a id="grammar" name="grammar">SPARQL Grammar</a></h2>
<h4>A.1 <a id="queryString" name="queryString">SPARQL Query String</a></h4>
<p>A <a name="defn_SPARQLQueryString" id="defn_SPARQLQueryString">SPARQL query string</a> 
is a Unicode character string (c.f. section 6.1 String concepts of [<a href="#CHARMOD">CHARMOD</a>]) 
in the language defined by the following grammar, starting with the
<a href="#rQuery">Query</a> production. For compatibility with future versions of 
Unicode, the characters in this string may include Unicode codepoints that are unassigned 
as of the date of this publication (see
<a class="inform" href="http://www.unicode.org/reports/tr31/tr31-5.html">Identifier 
and Pattern Syntax</a> [<a href="#UNIID">UNIID</a>] section 4 Pattern Syntax). For 
productions with excluded character classes (for example <code>[^&lt;&gt;&#39;{}|^`]</code>), 
the characters are excluded from the range <code>#x0 - #x10FFFF</code>.</p>
<h4>A.2 <a id="codepointEscape" name="codepointEscape">Codepoint Escape Sequences</a></h4>
<p>A SPARQL Query String is processed for codepoint escape sequences before parsing 
by the grammar defined in EBNF below. The codepoint escape sequences for a SPARQL 
query string are:</p>
<table summary="Codepoint escapes" id="table68">
	<colgroup><col width="40%" />
	</colgroup>
	<tr>
		<th class="major">Escape</th>
		<th class="major">Unicode code point</th>
	</tr>
	<tr>
		<td><span class="token">&#39;\u&#39;</span> <a href="#rHEX">HEX</a>
		<a href="#rHEX">HEX</a> <a href="#rHEX">HEX</a> <a href="#rHEX">HEX</a></td>
		<td>A Unicode code point in the range U+0 to U+FFFF inclusive corresponding 
    to the encoded hexadecimal value.</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\U&#39;</span> <a href="#rHEX">HEX</a>
		<a href="#rHEX">HEX</a> <a href="#rHEX">HEX</a> <a href="#rHEX">HEX</a>
		<a href="#rHEX">HEX</a> <a href="#rHEX">HEX</a> <a href="#rHEX">HEX</a>
		<a href="#rHEX">HEX</a></td>
		<td>A Unicode code point in the range U+0 to U+10FFFF inclusive corresponding 
    to the encoded hexadecimal value.</td>
	</tr>
</table>
<p>where <a href="#rHEX">HEX</a> is a hexadecimal character</p>
<blockquote>
	<p><span style="font-family: monospace; font-size: 85%"><a name="rHEX" id="rHEX">HEX</a> 
  ::= [0-9] | [A-F] | [a-f]</span></p>
</blockquote>
<p>Examples:</p>
<pre class="query untested">&lt;ab\u00E9xy&gt;        # Codepoint 00E9 is Latin small e with acute - &eacute;
\u03B1:a            # Codepoint x03B1 is Greek small alpha - &#945;
a\u003Ab            # a:b -- codepoint x3A is colon</pre>
<p>Codepoint escape sequences can appear anywhere in the query string. They are 
processed before parsing based on the grammar rules and so may be replaced by codepoints 
with significance in the grammar, such as &quot;<code>:</code>&quot; marking a prefixed name.
</p>
<p>These escape sequences are not included in the grammar below. Only escape sequences 
for characters that would be legal at that point in the grammar may be given. For 
example, the variable &quot;<code>?x\u0020y</code>&quot; is not legal (<code>\u0020</code> 
is a space and is not permitted in a variable name).</p>
<h4>A.3 <a id="whitespace" name="whitespace">White Space</a></h4>
<p>White space (production <code class="gRuleBody"><a href="#rWS">WS</a></code>) 
is used to separate two terminals which would otherwise be (mis-)recognized as one 
terminal. Rule names below in capitals indicate where white space is significant; 
these form a possible choice of terminals for constructing a SPARQL parser. White 
space is significant in strings.</p>
<p>For example:</p>
<blockquote>
	<p><code>?a&lt;?b&amp;&amp;?c&gt;?d</code></p>
</blockquote>
<p>is the token sequence variable '<code>?a</code>', an IRI '<code>&lt;?b&amp;&amp;?c&gt;</code>', 
and variable '<code>?d</code>', not a expression involving the operator '<code>&amp;&amp;</code>' 
connextting two expression using '<code>&lt;</code>' (less than) and '<code>&gt;</code>' (greater than).</p>
<h4>A.4 <a id="grammarComments" name="grammarComments">Comments</a></h4>
<p>Comments in SPARQL queries take the form of &#39;<code>#</code>&#39;, outside an IRI 
or string, and continue to the end of line (marked by characters <code>0x0D</code> 
or <code>0x0A</code>) or end of file if there is no end of line after the comment 
marker. Comments are treated as white space.</p>
<h4>A.5 <a id="iriRefs" name="iriRefs">IRI References</a></h4>
<p>Text matched by the <code class="gRuleBody"><a href="#rIRI_REF">IRI_REF</a></code> 
production and <code class="gRuleHead"><a href="#rPrefixedName">PrefixedName</a></code> (after 
prefix expansion) production, after escape processing, must be conform to the generic 
syntax of IRI references in section 2.2 of RFC 3987 &quot;ABNF for IRI References and 
IRIs&quot; [<a href="#rfc3987">RFC3987</a>]. For example, the 
<code class="gRuleBody"><a href="#rIRI_REF">IRI_REF</a></code> <code>&lt;abc#def&gt;</code> may occur in a 
SPARQL query string, but the <code class="gRuleBody"><a href="#rIRI_REF">IRI_REF</a></code>
<code>&lt;abc##def&gt;</code> must not.</p>
<p>Base IRIs declared with the <span class="token">BASE</span> keyword must be absolute 
IRIs. A prefix declared with the <span class="token">PREFIX</span> keyword may not 
be re-declared in the same query. See section 2.1.1, <a href="#QSynIRI">Syntax 
of IRI Terms</a>, for a description of <span class="token">BASE</span> and
<span class="token">PREFIX</span>.</p>
<h4>A.6 <a id="grammarBNodeLabels" name="grammarBNodeLabels">Blank Node Labels</a></h4>
<p>The same blank node label may not be used in two separate basic graph patterns 
with a single query.</p>
<h4>A.7 <a id="grammarEscapes" name="grammarEscapes">Escape sequences in strings</a></h4>
<p>In addition to the <a href="#codepointEscape">codepoint escape sequences</a>, the following escape sequences 
any <code><a href="#rString">string</a></code> production (e.g. <code>
<a href="#rSTRING_LITERAL1">STRING_LITERAL1</a></code>, <code>
<a href="#rSTRING_LITERAL2">STRING_LITERAL2</a></code>, <code>
<a href="#rSTRING_LITERAL_LONG1">STRING_LITERAL_LONG1</a></code>, <code>
<a href="#rSTRING_LITERAL_LONG2">STRING_LITERAL_LONG2</a></code>):</p>
<table summary="String escapes">
	<colgroup><col width="40%" />
	</colgroup>
	<tr>
		<th class="major">Escape</th>
		<th class="major">Unicode code point</th>
	</tr>
	<tr>
		<td><span class="token">&#39;\t&#39;</span></td>
		<td>U+0009 (tab)</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\n&#39;</span></td>
		<td>U+000A (line feed)</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\r&#39;</span></td>
		<td>U+000D (carriage return)</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\b&#39;</span></td>
		<td>U+0008 (backspace)</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\f&#39;</span></td>
		<td>U+000C (form feed)</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\&quot;&#39;</span></td>
		<td>U+0022 (quotation mark, double quote mark)</td>
	</tr>
	<tr>
		<td><span class="token">&quot;\&#39;&quot;</span></td>
		<td>U+0027 (apostrophe-quote, single quote mark)</td>
	</tr>
	<tr>
		<td><span class="token">&#39;\\&#39;</span></td>
		<td>U+005C (backslash)</td>
	</tr>
</table>
<p>Examples:</p>
<pre class="query untested">&quot;abc\n&quot;
&quot;xy\rz&quot;
&#39;xy\tz&#39;</pre>
<h4>A.8 <a name="sparqlGrammar" id="sparqlGrammar">Grammar</a></h4>
<p>The EBNF notation used in the grammar is defined in Extensible Markup Language 
(XML) 1.1 [<a href="#XML11">XML11</a>] section 6
<a class="norm" href="http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-notation">Notation</a>.</p>
<p>Keywords are matched in a case-insensitive manner with the exception of the keyword 
&#39;<code>a</code>&#39; which, in line with Turtle and N3, is used in place of the IRI
<code>rdf:type</code> (in full, <code>
<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#type">http://www.w3.org/1999/02/22-rdf-syntax-ns#type</a></code>).</p>
<p>Keywords:</p>

<!-- <table cellpadding="0" cellspacing="1" style="border-collapse: collapse"> -->
<table class="plain">
	<tbody>
		<tr>
			<td>BASE</td>
			<td>SELECT</td>
			<td>ORDER BY</td>
			<td>FROM</td>
			<td>GRAPH</td>
			<td>STR</td>
			<td>isURI</td>
		</tr>
		<tr>
			<td>PREFIX</td>
			<td>CONSTRUCT</td>
			<td>LIMIT</td>
			<td>FROM NAMED</td>
			<td>OPTIONAL</td>
			<td>LANG</td>
			<td>isIRI</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>DESCRIBE</td>
			<td>OFFSET</td>
			<td>WHERE</td>
			<td>UNION</td>
			<td>LANGMATCHES</td>
			<td>isLITERAL</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>ASK</td>
			<td>DISTINCT</td>
			<td>&nbsp;</td>
			<td>FILTER</td>
			<td>DATATYPE</td>
			<td>REGEX</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>REDUCED</td>
			<td>&nbsp;</td>
			<td>a</td>
			<td>BOUND</td>
			<td>true</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>sameTERM</td>
			<td>false</td>
		</tr>
	</tbody>
</table>
<p>Escape sequences are case sensitive.</p>
<p>When choosing a rule to match, the longest match is chosen.</p>

<!-- MARKER html GRAMMAR -->

<div class="grammarTable">
  <table><tbody>

<tr valign="baseline">
  <td><code class="gRuleLabel">[1]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rQuery" name="rQuery">Query</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPrologue">Prologue</a><br/>( <a href="#rSelectQuery">SelectQuery</a> | <a href="#rConstructQuery">ConstructQuery</a> | <a href="#rDescribeQuery">DescribeQuery</a> | <a href="#rAskQuery">AskQuery</a> )</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[2]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPrologue" name="rPrologue">Prologue</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rBaseDecl">BaseDecl</a>? <a href="#rPrefixDecl">PrefixDecl</a>*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[3]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBaseDecl" name="rBaseDecl">BaseDecl</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'BASE'</span> <a href="#rIRI_REF">IRI_REF</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[4]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPrefixDecl" name="rPrefixDecl">PrefixDecl</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'PREFIX'</span> <a href="#rPNAME_NS">PNAME_NS</a> <a href="#rIRI_REF">IRI_REF</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[5]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSelectQuery" name="rSelectQuery">SelectQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'SELECT'</span> ( <span class="token">'DISTINCT'</span> | <span class="token">'REDUCED'</span> )? ( <a href="#rVar">Var</a>+ | <span class="token">'*'</span> ) <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a> <a href="#rSolutionModifier">SolutionModifier</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[6]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rConstructQuery" name="rConstructQuery">ConstructQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'CONSTRUCT'</span> <a href="#rConstructTemplate">ConstructTemplate</a> <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a> <a href="#rSolutionModifier">SolutionModifier</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[7]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDescribeQuery" name="rDescribeQuery">DescribeQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'DESCRIBE'</span> ( <a href="#rVarOrIRIref">VarOrIRIref</a>+ | <span class="token">'*'</span> ) <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a>? <a href="#rSolutionModifier">SolutionModifier</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[8]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rAskQuery" name="rAskQuery">AskQuery</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'ASK'</span> <a href="#rDatasetClause">DatasetClause</a>* <a href="#rWhereClause">WhereClause</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[9]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDatasetClause" name="rDatasetClause">DatasetClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'FROM'</span> ( <a href="#rDefaultGraphClause">DefaultGraphClause</a> | <a href="#rNamedGraphClause">NamedGraphClause</a> )</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[10]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDefaultGraphClause" name="rDefaultGraphClause">DefaultGraphClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rSourceSelector">SourceSelector</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[11]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNamedGraphClause" name="rNamedGraphClause">NamedGraphClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'NAMED'</span> <a href="#rSourceSelector">SourceSelector</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[12]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSourceSelector" name="rSourceSelector">SourceSelector</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRIref">IRIref</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[13]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rWhereClause" name="rWhereClause">WhereClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'WHERE'</span>? <a href="#rGroupGraphPattern">GroupGraphPattern</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[14]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSolutionModifier" name="rSolutionModifier">SolutionModifier</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rOrderClause">OrderClause</a>? <a href="#rLimitOffsetClauses">LimitOffsetClauses</a>?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[15]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rLimitOffsetClauses" name="rLimitOffsetClauses">LimitOffsetClauses</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">( <a href="#rLimitClause">LimitClause</a> <a href="#rOffsetClause">OffsetClause</a>? | <a href="#rOffsetClause">OffsetClause</a> <a href="#rLimitClause">LimitClause</a>? )</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[16]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rOrderClause" name="rOrderClause">OrderClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'ORDER'</span> <span class="token">'BY'</span> <a href="#rOrderCondition">OrderCondition</a>+</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[17]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rOrderCondition" name="rOrderCondition">OrderCondition</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">   ( ( <span class="token">'ASC'</span> | <span class="token">'DESC'</span> ) <a href="#rBrackettedExpression">BrackettedExpression</a> )<br/>| ( <a href="#rConstraint">Constraint</a> | <a href="#rVar">Var</a> ) </code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[18]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rLimitClause" name="rLimitClause">LimitClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'LIMIT'</span> <a href="#rINTEGER">INTEGER</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[19]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rOffsetClause" name="rOffsetClause">OffsetClause</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'OFFSET'</span> <a href="#rINTEGER">INTEGER</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[20]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rGroupGraphPattern" name="rGroupGraphPattern">GroupGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'{'</span> <a href="#rTriplesBlock">TriplesBlock</a>? ( ( <a href="#rGraphPatternNotTriples">GraphPatternNotTriples</a> | <a href="#rFilter">Filter</a> ) <span class="token">'.'</span>? <a href="#rTriplesBlock">TriplesBlock</a>? )* <span class="token">'}'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[21]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rTriplesBlock" name="rTriplesBlock">TriplesBlock</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rTriplesSameSubject">TriplesSameSubject</a> ( <span class="token">'.'</span> <a href="#rTriplesBlock">TriplesBlock</a>? )?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[22]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rGraphPatternNotTriples" name="rGraphPatternNotTriples">GraphPatternNotTriples</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rOptionalGraphPattern">OptionalGraphPattern</a> | <a href="#rGroupOrUnionGraphPattern">GroupOrUnionGraphPattern</a> | <a href="#rGraphGraphPattern">GraphGraphPattern</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[23]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rOptionalGraphPattern" name="rOptionalGraphPattern">OptionalGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'OPTIONAL'</span> <a href="#rGroupGraphPattern">GroupGraphPattern</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[24]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rGraphGraphPattern" name="rGraphGraphPattern">GraphGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'GRAPH'</span> <a href="#rVarOrIRIref">VarOrIRIref</a> <a href="#rGroupGraphPattern">GroupGraphPattern</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[25]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rGroupOrUnionGraphPattern" name="rGroupOrUnionGraphPattern">GroupOrUnionGraphPattern</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rGroupGraphPattern">GroupGraphPattern</a> ( <span class="token">'UNION'</span> <a href="#rGroupGraphPattern">GroupGraphPattern</a> )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[26]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rFilter" name="rFilter">Filter</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'FILTER'</span> <a href="#rConstraint">Constraint</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[27]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rConstraint" name="rConstraint">Constraint</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rBrackettedExpression">BrackettedExpression</a> | <a href="#rBuiltInCall">BuiltInCall</a> | <a href="#rFunctionCall">FunctionCall</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[28]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rFunctionCall" name="rFunctionCall">FunctionCall</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRIref">IRIref</a> <a href="#rArgList">ArgList</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[29]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rArgList" name="rArgList">ArgList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">( <a href="#rNIL">NIL</a> | <span class="token">'('</span> <a href="#rExpression">Expression</a> ( <span class="token">','</span> <a href="#rExpression">Expression</a> )* <span class="token">')'</span> )</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[30]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rConstructTemplate" name="rConstructTemplate">ConstructTemplate</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'{'</span> <a href="#rConstructTriples">ConstructTriples</a>? <span class="token">'}'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[31]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rConstructTriples" name="rConstructTriples">ConstructTriples</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rTriplesSameSubject">TriplesSameSubject</a> ( <span class="token">'.'</span> <a href="#rConstructTriples">ConstructTriples</a>? )?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[32]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rTriplesSameSubject" name="rTriplesSameSubject">TriplesSameSubject</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVarOrTerm">VarOrTerm</a> <a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a> |	<a href="#rTriplesNode">TriplesNode</a> <a href="#rPropertyList">PropertyList</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[33]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPropertyListNotEmpty" name="rPropertyListNotEmpty">PropertyListNotEmpty</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVerb">Verb</a> <a href="#rObjectList">ObjectList</a> ( <span class="token">';'</span> ( <a href="#rVerb">Verb</a> <a href="#rObjectList">ObjectList</a> )? )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[34]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPropertyList" name="rPropertyList">PropertyList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a>?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[35]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rObjectList" name="rObjectList">ObjectList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rObject">Object</a> ( <span class="token">','</span> <a href="#rObject">Object</a> )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[36]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rObject" name="rObject">Object</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rGraphNode">GraphNode</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[37]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVerb" name="rVerb">Verb</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVarOrIRIref">VarOrIRIref</a> | <span class="token">'a'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[38]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rTriplesNode" name="rTriplesNode">TriplesNode</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rCollection">Collection</a> |	<a href="#rBlankNodePropertyList">BlankNodePropertyList</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[39]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBlankNodePropertyList" name="rBlankNodePropertyList">BlankNodePropertyList</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'['</span> <a href="#rPropertyListNotEmpty">PropertyListNotEmpty</a> <span class="token">']'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[40]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rCollection" name="rCollection">Collection</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'('</span> <a href="#rGraphNode">GraphNode</a>+ <span class="token">')'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[41]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rGraphNode" name="rGraphNode">GraphNode</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVarOrTerm">VarOrTerm</a> |	<a href="#rTriplesNode">TriplesNode</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[42]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVarOrTerm" name="rVarOrTerm">VarOrTerm</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVar">Var</a> | <a href="#rGraphTerm">GraphTerm</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[43]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVarOrIRIref" name="rVarOrIRIref">VarOrIRIref</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVar">Var</a> | <a href="#rIRIref">IRIref</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[44]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVar" name="rVar">Var</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rVAR1">VAR1</a> | <a href="#rVAR2">VAR2</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[45]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rGraphTerm" name="rGraphTerm">GraphTerm</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRIref">IRIref</a> |	<a href="#rRDFLiteral">RDFLiteral</a> |	<a href="#rNumericLiteral">NumericLiteral</a> |	<a href="#rBooleanLiteral">BooleanLiteral</a> |	<a href="#rBlankNode">BlankNode</a> |	<a href="#rNIL">NIL</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[46]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rExpression" name="rExpression">Expression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rConditionalOrExpression">ConditionalOrExpression</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[47]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rConditionalOrExpression" name="rConditionalOrExpression">ConditionalOrExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rConditionalAndExpression">ConditionalAndExpression</a> ( <span class="token">'||'</span> <a href="#rConditionalAndExpression">ConditionalAndExpression</a> )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[48]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rConditionalAndExpression" name="rConditionalAndExpression">ConditionalAndExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rValueLogical">ValueLogical</a> ( <span class="token">'&amp;&amp;'</span> <a href="#rValueLogical">ValueLogical</a> )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[49]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rValueLogical" name="rValueLogical">ValueLogical</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rRelationalExpression">RelationalExpression</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[50]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rRelationalExpression" name="rRelationalExpression">RelationalExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rNumericExpression">NumericExpression</a> ( <span class="token">'='</span> <a href="#rNumericExpression">NumericExpression</a> | <span class="token">'!='</span> <a href="#rNumericExpression">NumericExpression</a> | <span class="token">'&lt;'</span> <a href="#rNumericExpression">NumericExpression</a> | <span class="token">'&gt;'</span> <a href="#rNumericExpression">NumericExpression</a> | <span class="token">'&lt;='</span> <a href="#rNumericExpression">NumericExpression</a> | <span class="token">'&gt;='</span> <a href="#rNumericExpression">NumericExpression</a> )?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[51]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNumericExpression" name="rNumericExpression">NumericExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rAdditiveExpression">AdditiveExpression</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[52]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rAdditiveExpression" name="rAdditiveExpression">AdditiveExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rMultiplicativeExpression">MultiplicativeExpression</a> ( <span class="token">'+'</span> <a href="#rMultiplicativeExpression">MultiplicativeExpression</a> | <span class="token">'-'</span> <a href="#rMultiplicativeExpression">MultiplicativeExpression</a> | <a href="#rNumericLiteralPositive">NumericLiteralPositive</a> | <a href="#rNumericLiteralNegative">NumericLiteralNegative</a> )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[53]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rMultiplicativeExpression" name="rMultiplicativeExpression">MultiplicativeExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rUnaryExpression">UnaryExpression</a> ( <span class="token">'*'</span> <a href="#rUnaryExpression">UnaryExpression</a> | <span class="token">'/'</span> <a href="#rUnaryExpression">UnaryExpression</a> )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[54]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rUnaryExpression" name="rUnaryExpression">UnaryExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">&nbsp;&nbsp;<span class="token">'!'</span> <a href="#rPrimaryExpression">PrimaryExpression</a> <br/>|	<span class="token">'+'</span> <a href="#rPrimaryExpression">PrimaryExpression</a> <br/>|	<span class="token">'-'</span> <a href="#rPrimaryExpression">PrimaryExpression</a> <br/>|	<a href="#rPrimaryExpression">PrimaryExpression</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[55]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPrimaryExpression" name="rPrimaryExpression">PrimaryExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rBrackettedExpression">BrackettedExpression</a> | <a href="#rBuiltInCall">BuiltInCall</a> | <a href="#rIRIrefOrFunction">IRIrefOrFunction</a> | <a href="#rRDFLiteral">RDFLiteral</a> | <a href="#rNumericLiteral">NumericLiteral</a> | <a href="#rBooleanLiteral">BooleanLiteral</a> | <a href="#rVar">Var</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[56]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBrackettedExpression" name="rBrackettedExpression">BrackettedExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[57]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBuiltInCall" name="rBuiltInCall">BuiltInCall</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">&nbsp;&nbsp;<span class="token">'STR'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'LANG'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'LANGMATCHES'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">','</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'DATATYPE'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'BOUND'</span> <span class="token">'('</span> <a href="#rVar">Var</a> <span class="token">')'</span> <br/>|	<span class="token">'sameTerm'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">','</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'isIRI'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'isURI'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'isBLANK'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<span class="token">'isLITERAL'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">')'</span> <br/>|	<a href="#rRegexExpression">RegexExpression</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[58]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rRegexExpression" name="rRegexExpression">RegexExpression</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'REGEX'</span> <span class="token">'('</span> <a href="#rExpression">Expression</a> <span class="token">','</span> <a href="#rExpression">Expression</a> ( <span class="token">','</span> <a href="#rExpression">Expression</a> )? <span class="token">')'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[59]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rIRIrefOrFunction" name="rIRIrefOrFunction">IRIrefOrFunction</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRIref">IRIref</a> <a href="#rArgList">ArgList</a>?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[60]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rRDFLiteral" name="rRDFLiteral">RDFLiteral</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rString">String</a> ( <a href="#rLANGTAG">LANGTAG</a> | ( <span class="token">'^^'</span> <a href="#rIRIref">IRIref</a> ) )?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[61]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNumericLiteral" name="rNumericLiteral">NumericLiteral</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rNumericLiteralUnsigned">NumericLiteralUnsigned</a> | <a href="#rNumericLiteralPositive">NumericLiteralPositive</a> | <a href="#rNumericLiteralNegative">NumericLiteralNegative</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[62]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNumericLiteralUnsigned" name="rNumericLiteralUnsigned">NumericLiteralUnsigned</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rINTEGER">INTEGER</a> |	<a href="#rDECIMAL">DECIMAL</a> |	<a href="#rDOUBLE">DOUBLE</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[63]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNumericLiteralPositive" name="rNumericLiteralPositive">NumericLiteralPositive</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rINTEGER_POSITIVE">INTEGER_POSITIVE</a> |	<a href="#rDECIMAL_POSITIVE">DECIMAL_POSITIVE</a> |	<a href="#rDOUBLE_POSITIVE">DOUBLE_POSITIVE</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[64]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNumericLiteralNegative" name="rNumericLiteralNegative">NumericLiteralNegative</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rINTEGER_NEGATIVE">INTEGER_NEGATIVE</a> |	<a href="#rDECIMAL_NEGATIVE">DECIMAL_NEGATIVE</a> |	<a href="#rDOUBLE_NEGATIVE">DOUBLE_NEGATIVE</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[65]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBooleanLiteral" name="rBooleanLiteral">BooleanLiteral</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'true'</span> |	<span class="token">'false'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[66]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rString" name="rString">String</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rSTRING_LITERAL1">STRING_LITERAL1</a> | <a href="#rSTRING_LITERAL2">STRING_LITERAL2</a> | <a href="#rSTRING_LITERAL_LONG1">STRING_LITERAL_LONG1</a> | <a href="#rSTRING_LITERAL_LONG2">STRING_LITERAL_LONG2</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[67]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rIRIref" name="rIRIref">IRIref</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rIRI_REF">IRI_REF</a> |	<a href="#rPrefixedName">PrefixedName</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[68]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPrefixedName" name="rPrefixedName">PrefixedName</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPNAME_LN">PNAME_LN</a> | <a href="#rPNAME_NS">PNAME_NS</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[69]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBlankNode" name="rBlankNode">BlankNode</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rBLANK_NODE_LABEL">BLANK_NODE_LABEL</a> |	<a href="#rANON">ANON</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[70]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rIRI_REF" name="rIRI_REF">IRI_REF</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'&lt;' ([^&lt;&gt;&quot;{}|^`\]-[#x00-#x20])* '&gt;'</span></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[71]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPNAME_NS" name="rPNAME_NS">PNAME_NS</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPN_PREFIX">PN_PREFIX</a>? ':'</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[72]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPNAME_LN" name="rPNAME_LN">PNAME_LN</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPNAME_NS">PNAME_NS</a> <a href="#rPN_LOCAL">PN_LOCAL</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[73]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rBLANK_NODE_LABEL" name="rBLANK_NODE_LABEL">BLANK_NODE_LABEL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'_:' <a href="#rPN_LOCAL">PN_LOCAL</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[74]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVAR1" name="rVAR1">VAR1</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'?' <a href="#rVARNAME">VARNAME</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[75]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVAR2" name="rVAR2">VAR2</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'$' <a href="#rVARNAME">VARNAME</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[76]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rLANGTAG" name="rLANGTAG">LANGTAG</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[77]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rINTEGER" name="rINTEGER">INTEGER</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[0-9]+</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[78]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDECIMAL" name="rDECIMAL">DECIMAL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[0-9]+ '.' [0-9]* | '.' [0-9]+</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[79]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDOUBLE" name="rDOUBLE">DOUBLE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[0-9]+ '.' [0-9]* <a href="#rEXPONENT">EXPONENT</a> | '.' ([0-9])+ <a href="#rEXPONENT">EXPONENT</a> | ([0-9])+ <a href="#rEXPONENT">EXPONENT</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[80]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rINTEGER_POSITIVE" name="rINTEGER_POSITIVE">INTEGER_POSITIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'+'</span> <a href="#rINTEGER">INTEGER</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[81]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDECIMAL_POSITIVE" name="rDECIMAL_POSITIVE">DECIMAL_POSITIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'+'</span> <a href="#rDECIMAL">DECIMAL</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[82]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDOUBLE_POSITIVE" name="rDOUBLE_POSITIVE">DOUBLE_POSITIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'+'</span> <a href="#rDOUBLE">DOUBLE</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[83]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rINTEGER_NEGATIVE" name="rINTEGER_NEGATIVE">INTEGER_NEGATIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'-'</span> <a href="#rINTEGER">INTEGER</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[84]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDECIMAL_NEGATIVE" name="rDECIMAL_NEGATIVE">DECIMAL_NEGATIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'-'</span> <a href="#rDECIMAL">DECIMAL</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[85]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rDOUBLE_NEGATIVE" name="rDOUBLE_NEGATIVE">DOUBLE_NEGATIVE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><span class="token">'-'</span> <a href="#rDOUBLE">DOUBLE</a></code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[86]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rEXPONENT" name="rEXPONENT">EXPONENT</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[eE] [+-]? [0-9]+</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[87]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSTRING_LITERAL1" name="rSTRING_LITERAL1">STRING_LITERAL1</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">"'" ( ([^#x27#x5C#xA#xD]) | <a href="#rECHAR">ECHAR</a> )* "'"</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[88]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSTRING_LITERAL2" name="rSTRING_LITERAL2">STRING_LITERAL2</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'"' ( ([^#x22#x5C#xA#xD]) | <a href="#rECHAR">ECHAR</a> )* '"'</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[89]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSTRING_LITERAL_LONG1" name="rSTRING_LITERAL_LONG1">STRING_LITERAL_LONG1</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">"'''" ( ( "'" | "''" )? ( [^'\] | <a href="#rECHAR">ECHAR</a> ) )* "'''"</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[90]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rSTRING_LITERAL_LONG2" name="rSTRING_LITERAL_LONG2">STRING_LITERAL_LONG2</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'"""' ( ( '"' | '""' )? ( [^"\] | <a href="#rECHAR">ECHAR</a> ) )* '"""'</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[91]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rECHAR" name="rECHAR">ECHAR</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'\' [tbnrf\"']</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[92]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rNIL" name="rNIL">NIL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'(' <a href="#rWS">WS</a>* ')'</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[93]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rWS" name="rWS">WS</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">#x20 | #x9 | #xD | #xA</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[94]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rANON" name="rANON">ANON</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">'['  <a href="#rWS">WS</a>* ']'</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[95]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPN_CHARS_BASE" name="rPN_CHARS_BASE">PN_CHARS_BASE</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">[A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[96]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPN_CHARS_U" name="rPN_CHARS_U">PN_CHARS_U</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPN_CHARS_BASE">PN_CHARS_BASE</a> | '_'</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[97]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rVARNAME" name="rVARNAME">VARNAME</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody">( <a href="#rPN_CHARS_U">PN_CHARS_U</a>  | [0-9] ) ( <a href="#rPN_CHARS_U">PN_CHARS_U</a> | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[98]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPN_CHARS" name="rPN_CHARS">PN_CHARS</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPN_CHARS_U">PN_CHARS_U</a> | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[99]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPN_PREFIX" name="rPN_PREFIX">PN_PREFIX</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
  <td><code class="gRuleBody"><a href="#rPN_CHARS_BASE">PN_CHARS_BASE</a> ((<a href="#rPN_CHARS">PN_CHARS</a>|'.')* <a href="#rPN_CHARS">PN_CHARS</a>)?</code></td>
</tr>

<tr valign="baseline">
  <td><code class="gRuleLabel">[100]&nbsp;&nbsp;</code></td>
  <td><code class="gRuleHead"><a id="rPN_LOCAL" name="rPN_LOCAL">PN_LOCAL</a></code></td>
  <td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td>
	    <td><code class="gRuleBody">( <a href="#rPN_CHARS_U">PN_CHARS_U</a> | [0-9] ) ((<a href="#rPN_CHARS">PN_CHARS</a>|'.')* <a href="#rPN_CHARS">PN_CHARS</a>)?</code><br/><span class="issue">Note that the inclusion of <code>[0-9]</code> in the leading character is <em>at-risk</em>. See <a href="#notXmlQNames">Not all Prefixed Names are XML QNames</a>.</span></td>
</tr>
  </tbody></table>
</div>


<!-- /MARKER html GRAMMAR -->
  <p>Notes:</p>
<ol>
	<li>The SPARQL grammar is LL(1) when the rules with uppercased names are used as 
  terminals.</li>
	<li>In signed numbers, no white space is allowed between the sign and the 
  number. The <code class="gRuleHead"><a href="#rAdditiveExpression">AdditiveExpression</a></code> grammar rule 
  allows for this by covering the the two cases of an expression followed by a 
  signed number. These produce an addition or substraction of the unsigned 
  number as appropriate.</li>
</ol>
<p>Some grammar files for some commonly used tools are <a href="/2001/sw/DataAccess/rq23/parsers/">available 
  here</a>.</p>
<h2>B. <a id="conformance" name="conformance">Conformance</a></h2>
<p>See appendix <a href="#grammar">A SPARQL Grammar</a> regarding conformance of
  <a href="#defn_SPARQLQueryString">SPARQL Query strings</a>, and section
<a href="#QueryForms">10 Query Forms</a> for conformance of query results. 
See appendix <a href="#mediaType">E. Internet Media Type</a> for conformance to 
the application/sparql-query media type.</p>
<p>This specification is intended for use in conjunction with the SPARQL Protocol 
[<a href="#SPROT">SPROT</a>] and the SPARQL Query Results XML Format [<a href="#RESULTS">RESULTS</a>]. 
See those specifications for their conformance criteria.</p>
<p>Note that the SPARQL protocol describes an abstract interface as well as a network 
protocol, and the abstract interface may apply to APIs as well as network interfaces.</p>
<h2>C. <a id="security" name="security">Security Considerations</a> (Informative)</h2>
<p>SPARQL queries using FROM, FROM NAMED, or GRAPH may cause the specified URI to 
be dereferenced. This may cause additional use of network, disk or CPU resources 
along with associated secondary issues such as denial of service. The security issues 
of <a class="norm" href="http://www.ietf.org/rfc/rfc3986.txt">Uniform Resource Identifier 
(URI): Generic Syntax</a> [<a href="#rfc3986">RFC3986</a>] Section 7 should be considered. 
In addition, the contents of <code>file:</code> URIs can in some cases be accessed, 
processed and returned as results, providing unintended access to local resources.</p>
<p>The SPARQL language permits extensions, which will have their own security implications.</p>
<p>Multiple IRIs may have the same appearance. Characters in different scripts may 
look similar (a Cyrillic &quot;&#1086;&quot; may appear similar to a Latin &quot;o&quot;). A character followed 
by combining characters may have the same visual representation as another character 
(LATIN SMALL LETTER E followed by COMBINING ACUTE ACCENT has the same visual representation 
as LATIN SMALL LETTER E WITH ACUTE).
<!-- (<code>foo:resum&#40751;code> and <code>f&#1086;&#1086;:resume&#769;</code>)-->
Users of SPARQL must take care to construct queries with IRIs that match the IRIs 
in the data. Further information about matching of similar characters can be found 
in <a class="inform" href="http://www.unicode.org/reports/tr36/">Unicode Security 
Considerations</a> [<a href="#UNISEC">UNISEC</a>] and
<a class="norm" href="http://www.ietf.org/rfc/rfc3987.txt">Internationalized Resource 
Identifiers (IRIs)</a> [<a href="#rfc3987">RFC3987</a>] Section 8.</p>
<h2>D. <a id="mediaType" name="mediaType">Internet Media Type, File Extension and 
Macintosh File Type</a></h2>
<dl>
	<dt>contact:</dt>
	<dd>Eric Prud&#39;hommeaux</dd>
	<dt>See also:</dt>
	<dd><a href="http://www.w3.org/2002/06/registering-mediatype">How to Register 
  a Media Type for a W3C Specification</a></dd>
	<dd><a href="http://www.w3.org/2001/tag/2002/0129-mime">Internet Media Type registration, 
  consistency of use</a><br />TAG Finding 3 June 2002 (Revised 4 September 2002)</dd>
</dl>
<p>The Internet Media Type / MIME Type for the SPARQL Query Language is &quot;application/sparql-query&quot;.</p>
<p>It is recommended that sparql query files have the extension &quot;.rq&quot; (all lowercase) 
on all platforms.</p>
<p>It is recommended that sparql query files stored on Macintosh HFS file systems 
be given a file type of &quot;TEXT&quot;.</p>
<p>This information that follows is intended to be submitted to the IESG for review, 
approval, and registration with IANA.</p>
<dl>
	<dt>Type name:</dt>
	<dd>application</dd>
	<dt>Subtype name:</dt>
	<dd>sparql-query</dd>
	<dt>Required parameters:</dt>
	<dd>None</dd>
	<dt>Optional parameters:</dt>
	<dd>None</dd>
	<dt>Encoding considerations:</dt>
	<dd>The syntax of the SPARQL Query Language is expressed over code points in Unicode 
  [<a href="#UNICODE">UNICODE</a>]. The encoding is always UTF-8 [<a href="#rfc3629">RFC3629</a>].</dd>
	<dd>Unicode code points may also be expressed using an \uXXXX (U+0 to U+FFFF) 
  or \UXXXXXXXX syntax (for U+10000 onwards) where X is a hexadecimal digit [0-9A-F]</dd>
	<dt>Security considerations:</dt>
	<dd>See SPARQL Query appendix C, <a href="#security">Security Considerations</a> 
  as well as <a class="norm" href="http://www.ietf.org/rfc/rfc3629.txt">RFC 3629</a> 
  [<a href="#rfc3629">RFC3629</a>] section 7, Security Considerations.</dd>
	<dt>Interoperability considerations:</dt>
	<dd>There are no known interoperability issues.</dd>
	<dt>Published specification:</dt>
	<dd>This specification.</dd>
	<dt>Applications which use this media type:</dt>
	<dd>No known applications currently use this media type.</dd>
	<dt>Additional information:</dt>
	<dt>Magic number(s):</dt>
	<dd>A SPARQL query may have the string &#39;PREFIX&#39; (case independent) near the beginning 
  of the document.</dd>
	<dt>File extension(s):</dt>
	<dd>&quot;.rq&quot;</dd>
	<dt>Base URI:</dt>
	<dd>The SPARQL &#39;BASE &lt;IRIref&gt;&#39; term can change the current base URI for relative 
  IRIrefs in the query language that are used sequentially later in the document.</dd>
	<dt>Macintosh file type code(s):</dt>
	<dd>&quot;TEXT&quot;</dd>
	<dt>Person &amp; email address to contact for further information:</dt>
	<dd>public-rdf-dawg-comments@w3.org</dd>
	<dt>Intended usage:</dt>
	<dd>COMMON</dd>
	<dt>Restrictions on usage:</dt>
	<dd>None</dd>
	<dt>Author/Change controller:</dt>
	<dd>The SPARQL specification is a work product of the World Wide Web Consortium&#39;s 
  RDF Data Access Working Group. The W3C has change control over these specifications.</dd>
</dl>
<div>
	<h2>E. <a id="references" name="references">References</a></h2>
	<h3 id="normativeRefs">Normative References</h3>
	<dl class="bib">
		<dt><a name="CHARMOD" id="CHARMOD">[CHARMOD]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/REC-charmod-20050215/">Character
      Model for the World Wide Web 1.0: Fundamentals</a></cite> ,
      R. Ishida, F. Yergeau, M. J. D&uuml;st, M. Wolf, T. Texin,
      Editors, W3C Recommendation, 15 February 2005,
      http://www.w3.org/TR/2005/REC-charmod-20050215/ . 
		<a href=
      "http://www.w3.org/TR/charmod/" title=
      "Latest version of Character Model for the World Wide Web 1.0: Fundamentals">Latest version</a> available at http://www.w3.org/TR/charmod/
      .</dd>
		<dt><a name="CONCEPTS" id="CONCEPTS">[CONCEPTS]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">Resource
      Description Framework (RDF): Concepts and Abstract
      Syntax</a></cite> , G. Klyne, J. J. Carroll, Editors, W3C
      Recommendation, 10 February 2004,
      http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/ .
      	<a href="http://www.w3.org/TR/rdf-concepts/" title=
      "Latest version of Resource Description Framework (RDF): Concepts and Abstract Syntax">Latest version</a> available at
      http://www.w3.org/TR/rdf-concepts/ .</dd>
		<dt><a name="FUNCOP" id="FUNCOP">[FUNCOP]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/WD-xpath-functions-20050404/">XQuery
      1.0 and XPath 2.0 Functions and Operators</a></cite> , J.
      Melton, A. Malhotra, N. Walsh, Editors, W3C Working Draft
      (work in progress), 4 April 2005,
      http://www.w3.org/TR/2005/WD-xpath-functions-20050404/ .
      	<a href="http://www.w3.org/TR/xpath-functions/" title=
      "Latest version of XQuery 1.0 and XPath 2.0 Functions and Operators">Latest version</a> available at
      http://www.w3.org/TR/xpath-functions/ .</dd>
		<dt><a id="RDF-MT" name="RDF-MT">[RDF-MT]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2004/REC-rdf-mt-20040210/">RDF
      Semantics</a></cite> , P. Hayes, Editor, W3C Recommendation,
      10 February 2004,
      http://www.w3.org/TR/2004/REC-rdf-mt-20040210/ . 
		<a title=
      "Latest version of RDF Semantics" href=
      "http://www.w3.org/TR/rdf-mt/">Latest version</a> available
      at http://www.w3.org/TR/rdf-mt/ .</dd>
		<dt><a name="rfc3629" id="rfc3629">[RFC3629]</a></dt>
		<dd>RFC 3629 <cite>
		<a href=
      "http://www.ietf.org/rfc/rfc3629.txt">UTF-8, a transformation
      format of ISO 10646</a></cite>, F. Yergeau November 2003</dd>

	<dt><a name="rfc4647" id="rfc4647">[RFC4647]</a></dt>
	<dd>RFC 4647 <cite><a href="http://www.ietf.org/rfc/rfc4647.txt">Matching of Language Tags</a></cite>, A. Phillips, M. Davis September 2006</dd>

		<dt><a name="rfc3986" id="rfc3986">[RFC3986]</a></dt>
		<dd>RFC 3986 <cite>
		<a href=
      "http://www.ietf.org/rfc/rfc3986.txt">Uniform Resource
      Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee,
      R. Fielding, L. Masinter January 2005</dd>
		<dt><a name="rfc3987" id="rfc3987">[RFC3987]</a></dt>
		<dd><a href="http://www.ietf.org/rfc/rfc3987.txt">RFC
      3987</a>, "Internationalized Resource Identifiers (IRIs)", M.
      D&uuml;rst , M. Suignard</dd>
		<dt><a name="UNICODE" id="UNICODE">[UNICODE]</a></dt>
		<dd><cite>The Unicode Standard, Version 4</cite>. ISBN
      0-321-18578-1, as updated from time to time by the
      publication of new versions. The latest version of Unicode
      and additional information on versions of the standard and of
      the Unicode Character Database is available at 
		<a href=
      "http://www.unicode.org/unicode/standard/versions/">http://www.unicode.org/unicode/standard/versions/</a>.</dd>
		<dt><a name="XML11" id="XML11">[XML11]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2004/REC-xml11-20040204/">Extensible
      Markup Language (XML) 1.1</a></cite> , J. Cowan, J. Paoli, E.
      Maler, C. M. Sperberg-McQueen, F. Yergeau, T. Bray, Editors,
      W3C Recommendation, 4 February 2004,
      http://www.w3.org/TR/2004/REC-xml11-20040204/ . 
		<a href=
      "http://www.w3.org/TR/xml11/" title=
      "Latest version of Extensible Markup Language (XML) 1.1">Latest
      version</a> available at http://www.w3.org/TR/xml11/ .</dd>
		<dt><a name="XPATH20" id="XPATH20">[XPATH20]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/WD-xpath20-20050404/">XML Path
      Language (XPath) 2.0</a></cite> , M. F. Fern?dez, D.
      Chamberlin, M. Kay, S. Boag, J. Robie, J. Sim?n, A. Berglund,
      Editors, W3C Working Draft (work in progress), 4 April 2005,
      http://www.w3.org/TR/2005/WD-xpath20-20050404/ . 
		<a href=
      "http://www.w3.org/TR/xpath20/" title=
      "Latest version of XML Path Language (XPath) 2.0">Latest
      version</a> available at http://www.w3.org/TR/xpath20/ .</dd>
		<dt><a name="XQUERY" id="XQUERY">[XQUERY]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/CR-xquery-20051103/">XQuery 1.0:
      An XML Query Language</a></cite> , S. Boag, M. F.
      Fern&aacute;ndez, D. Chamberlin, D. Florescu, J. Robie, J.
      Sim&eacute;on, Editors, W3C Candidate Recommendation 3
      November 2005, http://www.w3.org/TR/2005/CR-xquery-20051103/.
      	<a href="http://www.w3.org/TR/xquery/" title=
      "Latest version of XQuery 1.0: An XML Query Language">Latest
      version</a> available at http://www.w3.org/TR/xquery/ . 
      <!-- odd... bib generator knows it as http://www.w3.org/TR/xquery
      but the title page says http://www.w3.org/TR/xquery/ --></dd>
		<dt><a name="XSDT" id="XSDT">[XSDT]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">XML
      Schema Part 2: Datatypes Second Edition</a></cite>, P. V.
      Biron, A. Malhotra, Editors, W3C Recommendation, 28 October
      2004, http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/ .
      	<a href="http://www.w3.org/TR/xmlschema-2/" title=
      "Latest version of XML Schema Part 2: Datatypes Second Edition">Latest version</a> available at
      http://www.w3.org/TR/xmlschema-2/ .</dd>
	<dt><a name="BCP47" id="BCP47">[BCP47]</a></dt>
	<dd><cite><a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">Best Common Practice 47</a></cite>, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 28 October 2004, http://www.rfc-editor.org/rfc/bcp/bcp47.txt .</dd>
	</dl>
	<h3 id="informativeRefs">Informative References</h3>
	<dl class="bib">
		<dt><a name="CBD" id="CBD">[CBD]</a></dt>
		<dd><cite><a href="http://www.w3.org/Submission/CBD/">CBD - Concise 
        Bounded Description</a></cite>, Patrick Stickler, Nokia, W3C Member 
        Submission, 3 June 2005.</dd>
		<dt><a name="DC" id="DC">[DC]</a></dt>
		<dd><cite>
		<a href=
      "http://www.dublincore.org/documents/dcmes-xml/">Expressing
      Simple Dublin Core in RDF/XML</a></cite>
		<a href=
      "http://dublincore.org/">Dublin Core Dublin Core Metadata
      Initiative</a> Recommendation 2002-07-31.</dd><!--
    <dt><a name="namespace" id="namespace">[NAMESPACE]</a></dt>
    <dd>
      <cite><a
      href="http://www.w3.org/TR/2004/REC-xml-names11-20040204">Namespaces
      in XML 1.1</a> </cite>, T. Bray, A. Layman, D. Hollander,
      R. Tobin, Editors, W3C Recommendation, 4 February 2004,
      http://www.w3.org/TR/2004/REC-xml-names11-20040204 . <a
      href="http://www.w3.org/TR/xml-names11" title="Latest version
      of Namespaces in XML 1.1">Latest version</a> available at
      http://www.w3.org/TR/xml-names11/ .
    </dd>
-->

      	<dt><a id="OWL_Semantics" name=
      "OWL_Semantics">[OWL-Semantics]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2004/REC-owl-semantics-20040210/">OWL
      Web Ontology Language Semantics and Abstract
      Syntax</a></cite>, Peter F. Patel-Schneider, Patrick Hayes,
      Ian Horrocks, Editors, W3C Recommendation
      http://www.w3.org/TR/2004/REC-owl-semantics-20040210/.
      	<a href="http://www.w3.org/TR/owl-semantics/">Latest
      version</a> at <a href=
      "http://www.w3.org/TR/owl-semantics/">http://www.w3.org/TR/owl-semantics/</a>.</dd>
		<dt><a id="rdfschema" name="rdfschema">[RDFS]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2004/REC-rdf-schema-20040210/">RDF
      Vocabulary Description Language 1.0: RDF Schema</a></cite>,
      Dan Brickley, R.V. Guha, Editors. W3C Recommendation 
		<a href=
      "http://www.w3.org/TR/2004/REC-rdf-schema-20040210/">http://www.w3.org/TR/2004/REC-rdf-schema-20040210/</a>.
      	<a href="http://www.w3.org/TR/rdf-schema/">Latest version</a>
      at <a href=
      "http://www.w3.org/TR/rdf-schema/">http://www.w3.org/TR/rdf-schema/</a>.</dd>
		<dt><a name="RESULTS" id="RESULTS">[RESULTS]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/WD-rdf-sparql-XMLres-20050527/">SPARQL
      Query Results XML Format</a></cite> , D. Beckett, Editor, W3C
      Working Draft (work in progress), 27 May 2005,
      http://www.w3.org/TR/2005/WD-rdf-sparql-XMLres-20050527/ .
      	<a href="http://www.w3.org/TR/rdf-sparql-XMLres/" title=
      "Latest version of SPARQL Query Results XML Format">Latest
      version</a> available at 
		<a href=
      "http://www.w3.org/TR/rdf-sparql-XMLres/">http://www.w3.org/TR/rdf-sparql-XMLres/</a>
      .</dd>
		<dt><a id="SPROT" name="SPROT">[SPROT]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/WD-rdf-sparql-protocol-20050527/">SPARQL
      Protocol for RDF</a></cite>, K. Clark, Editor, W3C Working
      Draft (work in progress), 27 May 2005,
      http://www.w3.org/TR/2005/WD-rdf-sparql-protocol-20050527/ .
      	<a title="Latest version of SPARQL Protocol for RDF" href=
      "http://www.w3.org/TR/rdf-sparql-protocol/">Latest
      version</a> available at
      http://www.w3.org/TR/rdf-sparql-protocol/ .</dd>
		<dt><a name="TURTLE" id="TURTLE">[TURTLE]</a></dt>
		<dd><a href="http://www.dajobe.org/2004/01/turtle/">Turtle - Terse
      RDF Triple Language</a>, Dave Beckett.</dd>
		<dt><a name="UCNR" id="UCNR">[UCNR]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2005/WD-rdf-dawg-uc-20050325/">RDF Data
      Access Use Cases and Requirements</a></cite> , K. Clark,
      Editor, W3C Working Draft (work in progress), 25 March 2005,
      http://www.w3.org/TR/2005/WD-rdf-dawg-uc-20050325/ . 
		<a href=
      "http://www.w3.org/TR/rdf-dawg-uc/" title=
      "Latest version of RDF Data Access Use Cases and Requirements">Latest version</a> available at
      http://www.w3.org/TR/rdf-dawg-uc/ .</dd>
		<dt><a name="UNISEC" id="UNISEC">[UNISEC]</a></dt>
		<dd><cite><a href=
      "http://www.unicode.org/reports/tr36/">Unicode Security
      Considerations</a></cite>, Mark Davis, Michel Suignard</dd>
		<dt><a id="VCARD" name="VCARD">[VCARD]</a></dt>
		<dd><cite>
		<a href=
      "http://www.w3.org/TR/2001/NOTE-vcard-rdf-20010222/">Representing
      vCard Objects in RDF/XML</a></cite> W3C Note 22 February 2001
      Renato Iannella. <a href=
      "http://www.w3.org/TR/vcard-rdf">latest version</a> is
      available at <tt>http://www.w3.org/TR/vcard-rdf</tt></dd>
		<dt><a name="WEBARCH" id="WEBARCH">[WEBARCH]</a></dt>
		<dd><cite><a href=
      "http://www.w3.org/TR/webarch/">Architecture of the World
      Wide Web, Volume One</a></cite>, Editors: Ian Jacobs, Norman
      Walsh</dd>
		<dt><a name="UNIID" id="UNIID">[UNIID]</a></dt>
		<dd><cite>
		<a href=
      "http://www.unicode.org/reports/tr31/tr31-5.html">Identifier
      and Pattern Syntax 4.1.0</a></cite>, Mark Davis, Unicode
      Standard Annex #31, 25 March 2005,
      http://www.unicode.org/reports/tr31/tr31-5.html . 
		<a href=
      "http://www.unicode.org/reports/tr31/" title=
      "Latest version of Identifier and Pattern Syntax">Latest
      version</a> available at <a href="http://www.unicode.org/reports/tr31/">http://www.unicode.org/reports/tr31/</a>
      .</dd>
      <dt>[<a name="refSemantics1" id="refSemantics1">SPARQL-sem-05</a>]</dt>
      <dd><cite><a href="http://www.hpl.hp.com/techreports/2005/HPL-2005-170.html">A relational
      algebra for SPARQL</a></cite>, Richard Cyganiak, 2005</dd>
      <dt>[<a name="refSemantics3" id="refSemantics2">SPARQL-sem-06</a>]</dt>
      <dd><cite><a href="http://arxiv.org/abs/cs/0605124">Semantics of SPARQL</a></cite>, Jorge P&eacute;rez, Marcelo Arenas, and Claudio Gutierrez, 
      2006</dd>
</dl></div>

<h2>F. <a name="acknowledgements" id="acknowledgements">Acknowledgements</a> (Informative)</h2>
<p>The SPARQL RDF Query Language is a product of the whole of the
<a href="http://www.w3.org/2001/sw/DataAccess/">W3C RDF Data Access Working Group</a>, 
and our thanks for discussions, comments and reviews go to all
<a href="http://www.w3.org/2001/sw/DataAccess/#who">present and past members</a>.</p>
<p>In addition, we have had comments and discussions with many people through the 
working group comments list. All comments go to making a better document. Andy would 
also like to particularly thank Jorge Pe&eacute;rez, Geoff Chappell, Bob MacGregor, Yosi Scharf 
and Richard 
Newman for exploring specific issues related to SPARQL. Eric would like to acknowledge 
the invaluable help of Bj&ouml;rn H&ouml;hrmann.</p>


<div class="changes">
	<h2>G. <a name="chlog" id="chlog">Change Log</a></h2>

  <p>Changes since the <a
  href="http://www.w3.org/TR/2007/WD-rdf-sparql-query-20070326/">26
  March 2007 Working Draft</a> include design changes, for which the WG
  has or intends to have corresponding <a href=
  "http://www.w3.org/2001/sw/DataAccess/tests/r2">test cases</a>:</p>

      <ul>
	<li>Added leading digits in <a href="#rPN_LOCAL">local names</a> and labeled it <em>at-risk</em>.</li>
	<li>Various bug fixes to <a href="#sparqlDefinition">12 Definition of SPARQL</a>.</li>
	<li>Added definition of <code>REDUCED</code> to <a href="#sparqlDefinition">12 Definition of SPARQL</a>.</li>
	<li>Added syntax of <code>REDUCED</code> to <a href="#sparqlGrammar">A.8 Grammar</a>.</li>
	<li>Separated <a href="#modDistinct">9.3.1 DISTINCT</a> from <a href="#modReduced">9.3.2 REDUCED</a>.</li>
	<li>Compare/contrast BGPs and groups.</li>
	<li>Explain <code>ToList</code> symbol.</li>
	<li><code>langMatches</code> uses <a href="#rfc4647">RFC4647's basic filtering</a>.</li>
	<li>Added normative reference to <a href="#BCP47">BCP47</a>.</li>
      </ul>

	<p>Raw CVS log:</p>
	<pre>
Revision 1.101  2007/05/15 16:30:16  eric
~ well-formed XML

Revision 1.100  2007/05/10 17:18:15  eric
+ SimonR's at-risk text from 6D4A1AC1-5F11-4D3C-8B20-8B1A1EDA1EF2@itee.uq.edu.au
+ <a href="#modOrderBy">9.1 ORDER BY</a> explicity references <a href="#operatorExtensibility">11.3.1 Operator Extensibility</a>
- removed issue text: DESCRIBE may be further constrained in future versions...
~ updated issue stylings
+ <a href="#rPN_LOCAL">PN_LOCAL</a> references <a href="#notXmlQNames">Not all Prefixed Names are XML QNames</a>

Revision 1.99  2007/05/10 12:50:39  aseaborne
Added at-risk style to 'reduced' note in 12.4

Revision 1.98  2007/05/10 10:49:32  aseaborne
Use 'solution' for 'answer' in 12.2.3

Revision 1.97  2007/05/10 09:38:38  aseaborne
Empty pattern is Z, noted it is the empty BGP

Revision 1.96  2007/05/03 17:32:42  lfeigenb
added at-risk notice to reduced text in section 12

Revision 1.95  2007/05/03 14:06:17  aseaborne
Add REDUCED into the SPARQL algebra

Revision 1.94  2007/05/02 18:19:14  eric
+ <a href="#modDuplicates">9.3 Duplicate Solutions</a>
~ moved <code>DISTINT</code> and <code>REDUCED</code> into <a href="#modDistinct">9.3.1 DISTINCT</a> and <a href="#modReduced">9.3.2 REDUCED</a> respectively

Revision 1.93  2007/05/01 18:00:48  aseaborne
Formatting

Revision 1.92  2007/05/01 17:49:52  aseaborne
Prefixed name tidying

Revision 1.91  2007/05/01 16:52:44  aseaborne
Grammar update for decision on digits in localname (decision : telecon of 2007-05-01)

Some renaming to remove misleading qname terminology.

Revision 1.90  2007/05/01 09:13:41  aseaborne
Fix ref link

Revision 1.89  2007/04/30 13:49:06  aseaborne
Changes in response to: <a
href="http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2007Apr/0007.html"
>2007Apr/0007</a>

+ Added text to sec 5 intro to compare/contrast BGPs and groups.

+ Added a forward pointer in 8.2 for GRAPH used in example.

+ Removed "overall solution sequence" text from offset bullet item

+ Consistent use of "query form", not "result form"

+ Swappped ASK and DESCRIBE sections

+ Sec 12.2.1: explicitly note the recursive transformation.

+ Added explanation of ToList symbol

+ Added that project can't chnage the sequence order.

Revision 1.88  2007/04/29 23:48:53  eric
~ fixed prototype of example aGeo:distance function per <a href="http://www.w3.org/mid/44AE7B72.8060606@hp.com">[Fwd: [SPARQL] candidate Recommendation]</a>

Revision 1.87  2007/04/28 20:30:54  eric
+ REDUCED in <a href="#sparqlGrammar">A.8 Grammar</a> and <a href="#sparqlQuery">12.2 SPARQL Query</a> per <a href="http://www.w3.org/mid/6a8224ab0704240022p39c7dfe3ka11e968a55ec221@mail.gmail.com">Questions about REDUCED, LeftJoin, Join</a>

Revision 1.86  2007/04/26 14:36:54  eric
~ [EDITORIAL] change section headings for 2.3.1-3:s/Matching/Matching Literals with/ per <a href="http://www.w3.org/mid/20070419132536.9D4994C4B@toro.w3.mag.keio.ac.jp">[SPARQL] i18n comment: Renaming Section on \"Matching Language Tags\"</a>
+ Note that RDF has no empty language tags in ?<a href="#func-lang" class="SPARQLoperator">11.4.6 lang</a> per <a href="http://www.w3.org/mid/20070419132811.7B6D24C0F@toro.w3.mag.keio.ac.jp">[SPARQL] i18n comment: Modification in description of langMatches operator</a>
~ [EDITORIAL] change order of term descriptions in <a href="#func-langMatches" class="SPARQLoperator">11.4.12 langMatches</a>

Revision 1.85  2007/04/22 17:31:17  eric
~ changed stylesheet back to TR/base
~ s|<code>ASCENDING</code>}ascending} per <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>
~ s|<code>DECENDING</code>}decending} per <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>
~ changed wording of <a href="#modOrderBy">9.1 ORDER BY</a> per <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>

Revision 1.84  2007/04/22 00:08:18  eric
+ [CLARIFICATION] <a href="#func-langMatches" class="SPARQLoperator">langMatches</a> uses (or at least, always has)  [<a href="#rfc4647">RFC4647</a>] basic filtering.
  Responds to comment <a href="http://www.w3.org/mid/4614C2B4.9070407@hpl.hp.com">11.4.12 langMatches</a> and <a href="http://www.w3.org/mid/20070419132811.7B6D24C0F@toro.w3.mag.keio.ac.jp">[SPARQL] i18n comment: Modification in description of langMatches operator</a>.

Revision 1.83  2007/04/21 03:01:31  eric
+ ref to [<a href="#BCP47">BCP47</a>] in 2.3.1 <a href="#matchLangTags">Matching Language Tags</a> per comment <a href="http://www.w3.org/mid/20070419132419.9ACF74BAD@toro.w3.mag.keio.ac.jp">[SPARQL] i18n comment: Adding a reference to BCP47</a>
+ [EDITORIAL] ref to <code class="gRuleHead"><a href="#rBlankNodePropertyList">BlankNodePropertyList</a></code> in 4.1.4 <a href="#QSynBlankNodes">Syntax for Blank Nodes</a> per comment <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>
~ [EDITORIAL] wording change in 5.2.1 <a href="#emptyGroupPattern">Empty Group Pattern</a> per comment <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>
~ [EDITORIAL] wording change in 7 <a href="#alternatives">Matching Alternatives</a> per comment <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>
~ [EDITORIAL] wording change in 8 <a href="#rdfDataset">RDF Dataset</a> per comment <a href="http://www.w3.org/mid/4624FBA3.4060608@deri.org">Re: Last Call for comments on "SPARQL Query Language for RDF"</a>
~ [EDITORIAL] typos
+ normative ref to [<a href="#BCP47">BCP47</a>]per comment <a href="http://www.w3.org/mid/20070419132419.9ACF74BAD@toro.w3.mag.keio.ac.jp">[SPARQL] i18n comment: Adding a reference to BCP47</a>

Revision 1.82  2007/04/10 13:03:51  aseaborne
Fixed defn for diff (quatify over bothg clauses) and eval of graph

(cardinality).

Add informative refrences.

Revision 1.81  2007/04/09 16:43:40  aseaborne
Changes in response to <a
href="http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2007Mar/0000"
>2007Mar/0008</a> as noted in <a
href="http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2007Apr/0004"
>2007Apr/0003</a>

Revision 1.80  2007/04/07 17:35:56  aseaborne
Changes in response to <a
href="http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2007Mar/0008"
>2007Mar/0008</a> as noted in <a
href="http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2007Apr/0003"
>2007Apr/0003</a>

Revision 1.79  2007/04/04 09:30:37  aseaborne
Fix eval defn of ToList and other modifiers (editorial)

Revision 1.78  2007/04/04 09:23:14  aseaborne
Fix eval defn of ToList and other modifiers (editorial)

Revision 1.77  2007/03/27 02:58:40  eric
~ fix variable name typo

</pre></div>

<div class="nav"><a href="http://validator.w3.org/check/referer">
	<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a>
</div><hr />

</body>

</html>