File: index.html

package info (click to toggle)
w3-recs 20110107-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 195,972 kB
  • ctags: 48,964
  • sloc: xml: 67,284; makefile: 115; perl: 31
file content (37439 lines) | stat: -rw-r--r-- 1,681,135 bytes parent folder | download | duplicates (2)
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
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
34847
34848
34849
34850
34851
34852
34853
34854
34855
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
34871
34872
34873
34874
34875
34876
34877
34878
34879
34880
34881
34882
34883
34884
34885
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
34902
34903
34904
34905
34906
34907
34908
34909
34910
34911
34912
34913
34914
34915
34916
34917
34918
34919
34920
34921
34922
34923
34924
34925
34926
34927
34928
34929
34930
34931
34932
34933
34934
34935
34936
34937
34938
34939
34940
34941
34942
34943
34944
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
34960
34961
34962
34963
34964
34965
34966
34967
34968
34969
34970
34971
34972
34973
34974
34975
34976
34977
34978
34979
34980
34981
34982
34983
34984
34985
34986
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
35014
35015
35016
35017
35018
35019
35020
35021
35022
35023
35024
35025
35026
35027
35028
35029
35030
35031
35032
35033
35034
35035
35036
35037
35038
35039
35040
35041
35042
35043
35044
35045
35046
35047
35048
35049
35050
35051
35052
35053
35054
35055
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
35071
35072
35073
35074
35075
35076
35077
35078
35079
35080
35081
35082
35083
35084
35085
35086
35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
35102
35103
35104
35105
35106
35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191
35192
35193
35194
35195
35196
35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
35236
35237
35238
35239
35240
35241
35242
35243
35244
35245
35246
35247
35248
35249
35250
35251
35252
35253
35254
35255
35256
35257
35258
35259
35260
35261
35262
35263
35264
35265
35266
35267
35268
35269
35270
35271
35272
35273
35274
35275
35276
35277
35278
35279
35280
35281
35282
35283
35284
35285
35286
35287
35288
35289
35290
35291
35292
35293
35294
35295
35296
35297
35298
35299
35300
35301
35302
35303
35304
35305
35306
35307
35308
35309
35310
35311
35312
35313
35314
35315
35316
35317
35318
35319
35320
35321
35322
35323
35324
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
35359
35360
35361
35362
35363
35364
35365
35366
35367
35368
35369
35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
35412
35413
35414
35415
35416
35417
35418
35419
35420
35421
35422
35423
35424
35425
35426
35427
35428
35429
35430
35431
35432
35433
35434
35435
35436
35437
35438
35439
35440
35441
35442
35443
35444
35445
35446
35447
35448
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
35491
35492
35493
35494
35495
35496
35497
35498
35499
35500
35501
35502
35503
35504
35505
35506
35507
35508
35509
35510
35511
35512
35513
35514
35515
35516
35517
35518
35519
35520
35521
35522
35523
35524
35525
35526
35527
35528
35529
35530
35531
35532
35533
35534
35535
35536
35537
35538
35539
35540
35541
35542
35543
35544
35545
35546
35547
35548
35549
35550
35551
35552
35553
35554
35555
35556
35557
35558
35559
35560
35561
35562
35563
35564
35565
35566
35567
35568
35569
35570
35571
35572
35573
35574
35575
35576
35577
35578
35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
35592
35593
35594
35595
35596
35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
35609
35610
35611
35612
35613
35614
35615
35616
35617
35618
35619
35620
35621
35622
35623
35624
35625
35626
35627
35628
35629
35630
35631
35632
35633
35634
35635
35636
35637
35638
35639
35640
35641
35642
35643
35644
35645
35646
35647
35648
35649
35650
35651
35652
35653
35654
35655
35656
35657
35658
35659
35660
35661
35662
35663
35664
35665
35666
35667
35668
35669
35670
35671
35672
35673
35674
35675
35676
35677
35678
35679
35680
35681
35682
35683
35684
35685
35686
35687
35688
35689
35690
35691
35692
35693
35694
35695
35696
35697
35698
35699
35700
35701
35702
35703
35704
35705
35706
35707
35708
35709
35710
35711
35712
35713
35714
35715
35716
35717
35718
35719
35720
35721
35722
35723
35724
35725
35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
35737
35738
35739
35740
35741
35742
35743
35744
35745
35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
35757
35758
35759
35760
35761
35762
35763
35764
35765
35766
35767
35768
35769
35770
35771
35772
35773
35774
35775
35776
35777
35778
35779
35780
35781
35782
35783
35784
35785
35786
35787
35788
35789
35790
35791
35792
35793
35794
35795
35796
35797
35798
35799
35800
35801
35802
35803
35804
35805
35806
35807
35808
35809
35810
35811
35812
35813
35814
35815
35816
35817
35818
35819
35820
35821
35822
35823
35824
35825
35826
35827
35828
35829
35830
35831
35832
35833
35834
35835
35836
35837
35838
35839
35840
35841
35842
35843
35844
35845
35846
35847
35848
35849
35850
35851
35852
35853
35854
35855
35856
35857
35858
35859
35860
35861
35862
35863
35864
35865
35866
35867
35868
35869
35870
35871
35872
35873
35874
35875
35876
35877
35878
35879
35880
35881
35882
35883
35884
35885
35886
35887
35888
35889
35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
35937
35938
35939
35940
35941
35942
35943
35944
35945
35946
35947
35948
35949
35950
35951
35952
35953
35954
35955
35956
35957
35958
35959
35960
35961
35962
35963
35964
35965
35966
35967
35968
35969
35970
35971
35972
35973
35974
35975
35976
35977
35978
35979
35980
35981
35982
35983
35984
35985
35986
35987
35988
35989
35990
35991
35992
35993
35994
35995
35996
35997
35998
35999
36000
36001
36002
36003
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
36019
36020
36021
36022
36023
36024
36025
36026
36027
36028
36029
36030
36031
36032
36033
36034
36035
36036
36037
36038
36039
36040
36041
36042
36043
36044
36045
36046
36047
36048
36049
36050
36051
36052
36053
36054
36055
36056
36057
36058
36059
36060
36061
36062
36063
36064
36065
36066
36067
36068
36069
36070
36071
36072
36073
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
36089
36090
36091
36092
36093
36094
36095
36096
36097
36098
36099
36100
36101
36102
36103
36104
36105
36106
36107
36108
36109
36110
36111
36112
36113
36114
36115
36116
36117
36118
36119
36120
36121
36122
36123
36124
36125
36126
36127
36128
36129
36130
36131
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
36147
36148
36149
36150
36151
36152
36153
36154
36155
36156
36157
36158
36159
36160
36161
36162
36163
36164
36165
36166
36167
36168
36169
36170
36171
36172
36173
36174
36175
36176
36177
36178
36179
36180
36181
36182
36183
36184
36185
36186
36187
36188
36189
36190
36191
36192
36193
36194
36195
36196
36197
36198
36199
36200
36201
36202
36203
36204
36205
36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
36218
36219
36220
36221
36222
36223
36224
36225
36226
36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
36238
36239
36240
36241
36242
36243
36244
36245
36246
36247
36248
36249
36250
36251
36252
36253
36254
36255
36256
36257
36258
36259
36260
36261
36262
36263
36264
36265
36266
36267
36268
36269
36270
36271
36272
36273
36274
36275
36276
36277
36278
36279
36280
36281
36282
36283
36284
36285
36286
36287
36288
36289
36290
36291
36292
36293
36294
36295
36296
36297
36298
36299
36300
36301
36302
36303
36304
36305
36306
36307
36308
36309
36310
36311
36312
36313
36314
36315
36316
36317
36318
36319
36320
36321
36322
36323
36324
36325
36326
36327
36328
36329
36330
36331
36332
36333
36334
36335
36336
36337
36338
36339
36340
36341
36342
36343
36344
36345
36346
36347
36348
36349
36350
36351
36352
36353
36354
36355
36356
36357
36358
36359
36360
36361
36362
36363
36364
36365
36366
36367
36368
36369
36370
36371
36372
36373
36374
36375
36376
36377
36378
36379
36380
36381
36382
36383
36384
36385
36386
36387
36388
36389
36390
36391
36392
36393
36394
36395
36396
36397
36398
36399
36400
36401
36402
36403
36404
36405
36406
36407
36408
36409
36410
36411
36412
36413
36414
36415
36416
36417
36418
36419
36420
36421
36422
36423
36424
36425
36426
36427
36428
36429
36430
36431
36432
36433
36434
36435
36436
36437
36438
36439
36440
36441
36442
36443
36444
36445
36446
36447
36448
36449
36450
36451
36452
36453
36454
36455
36456
36457
36458
36459
36460
36461
36462
36463
36464
36465
36466
36467
36468
36469
36470
36471
36472
36473
36474
36475
36476
36477
36478
36479
36480
36481
36482
36483
36484
36485
36486
36487
36488
36489
36490
36491
36492
36493
36494
36495
36496
36497
36498
36499
36500
36501
36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
36512
36513
36514
36515
36516
36517
36518
36519
36520
36521
36522
36523
36524
36525
36526
36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
36542
36543
36544
36545
36546
36547
36548
36549
36550
36551
36552
36553
36554
36555
36556
36557
36558
36559
36560
36561
36562
36563
36564
36565
36566
36567
36568
36569
36570
36571
36572
36573
36574
36575
36576
36577
36578
36579
36580
36581
36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
36594
36595
36596
36597
36598
36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
36610
36611
36612
36613
36614
36615
36616
36617
36618
36619
36620
36621
36622
36623
36624
36625
36626
36627
36628
36629
36630
36631
36632
36633
36634
36635
36636
36637
36638
36639
36640
36641
36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
36655
36656
36657
36658
36659
36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
36672
36673
36674
36675
36676
36677
36678
36679
36680
36681
36682
36683
36684
36685
36686
36687
36688
36689
36690
36691
36692
36693
36694
36695
36696
36697
36698
36699
36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
36721
36722
36723
36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
36741
36742
36743
36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
36775
36776
36777
36778
36779
36780
36781
36782
36783
36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
36823
36824
36825
36826
36827
36828
36829
36830
36831
36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
36843
36844
36845
36846
36847
36848
36849
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
36865
36866
36867
36868
36869
36870
36871
36872
36873
36874
36875
36876
36877
36878
36879
36880
36881
36882
36883
36884
36885
36886
36887
36888
36889
36890
36891
36892
36893
36894
36895
36896
36897
36898
36899
36900
36901
36902
36903
36904
36905
36906
36907
36908
36909
36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
36935
36936
36937
36938
36939
36940
36941
36942
36943
36944
36945
36946
36947
36948
36949
36950
36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
36967
36968
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
36984
36985
36986
36987
36988
36989
36990
36991
36992
36993
36994
36995
36996
36997
36998
36999
37000
37001
37002
37003
37004
37005
37006
37007
37008
37009
37010
37011
37012
37013
37014
37015
37016
37017
37018
37019
37020
37021
37022
37023
37024
37025
37026
37027
37028
37029
37030
37031
37032
37033
37034
37035
37036
37037
37038
37039
37040
37041
37042
37043
37044
37045
37046
37047
37048
37049
37050
37051
37052
37053
37054
37055
37056
37057
37058
37059
37060
37061
37062
37063
37064
37065
37066
37067
37068
37069
37070
37071
37072
37073
37074
37075
37076
37077
37078
37079
37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
37091
37092
37093
37094
37095
37096
37097
37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
37111
37112
37113
37114
37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
37157
37158
37159
37160
37161
37162
37163
37164
37165
37166
37167
37168
37169
37170
37171
37172
37173
37174
37175
37176
37177
37178
37179
37180
37181
37182
37183
37184
37185
37186
37187
37188
37189
37190
37191
37192
37193
37194
37195
37196
37197
37198
37199
37200
37201
37202
37203
37204
37205
37206
37207
37208
37209
37210
37211
37212
37213
37214
37215
37216
37217
37218
37219
37220
37221
37222
37223
37224
37225
37226
37227
37228
37229
37230
37231
37232
37233
37234
37235
37236
37237
37238
37239
37240
37241
37242
37243
37244
37245
37246
37247
37248
37249
37250
37251
37252
37253
37254
37255
37256
37257
37258
37259
37260
37261
37262
37263
37264
37265
37266
37267
37268
37269
37270
37271
37272
37273
37274
37275
37276
37277
37278
37279
37280
37281
37282
37283
37284
37285
37286
37287
37288
37289
37290
37291
37292
37293
37294
37295
37296
37297
37298
37299
37300
37301
37302
37303
37304
37305
37306
37307
37308
37309
37310
37311
37312
37313
37314
37315
37316
37317
37318
37319
37320
37321
37322
37323
37324
37325
37326
37327
37328
37329
37330
37331
37332
37333
37334
37335
37336
37337
37338
37339
37340
37341
37342
37343
37344
37345
37346
37347
37348
37349
37350
37351
37352
37353
37354
37355
37356
37357
37358
37359
37360
37361
37362
37363
37364
37365
37366
37367
37368
37369
37370
37371
37372
37373
37374
37375
37376
37377
37378
37379
37380
37381
37382
37383
37384
37385
37386
37387
37388
37389
37390
37391
37392
37393
37394
37395
37396
37397
37398
37399
37400
37401
37402
37403
37404
37405
37406
37407
37408
37409
37410
37411
37412
37413
37414
37415
37416
37417
37418
37419
37420
37421
37422
37423
37424
37425
37426
37427
37428
37429
37430
37431
37432
37433
37434
37435
37436
37437
37438
37439
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="EN" xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN">
<head>
  <meta name="generator" content=
  "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org" />

  <title>XSL Transformations (XSLT) Version 2.0</title>
<style type="text/css">
/*<![CDATA[*/
code           { font-family: monospace; }

div.constraint,
div.issue,
div.note,
div.notice     { margin-left: 2em; }

div.issue
p.title        { margin-left: -2em; }

ol.enumar      { list-style-type: decimal; }
ol.enumla      { list-style-type: lower-alpha; }
ol.enumlr      { list-style-type: lower-roman; }
ol.enumua      { list-style-type: upper-alpha; }
ol.enumur      { list-style-type: upper-roman; }

li p           { margin-top: 0.3em;
                 margin-bottom: 0.3em; }

sup small      { font-style: italic;
                 color: #8F8F8F;
               }
    
div.exampleInner pre { margin-left: 1em;
                       margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
                  margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
                   border-top-width: 4px;
                   border-top-style: double;
                   border-top-color: #d3d3d3;
                   border-bottom-width: 4px;
                   border-bottom-style: double;
                   border-bottom-color: #d3d3d3;
                   padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
                    margin: 4px}

div.issue { border-bottom-color: black;
            border-bottom-style: solid;
            border-bottom-width: 1pt;
            margin-bottom: 20pt;
}

th.issue-toc-head { border-bottom-color: black;
                    border-bottom-style: solid;
                    border-bottom-width: 1pt;
}

      
dd.indent { margin-left: 2em; }
p.element-syntax { border: solid thin; background-color: #ffccff }
div.proto { border: solid thin; background-color: #ffccff }
div.example { border: solid thin; background-color: #40e0d0; padding: 1em }
span.verb { font: small-caps 100% sans-serif } 
span.error { font-size: small } 
span.definition { font: small-caps 100% sans-serif } 
span.grayed { color: gray }
/*]]>*/
</style>
  <link rel="stylesheet" type="text/css" href=
  "../../../StyleSheets/TR/W3C-REC.css" />
</head>

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

    <h1><a name="title" id="title"></a>XSL Transformations (XSLT)
    Version 2.0</h1>

    <h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C
    Recommendation 23 January 2007</h2>

    <dl>
      <dt>This version:</dt>

      <dd><a href=
      "index.html">http://www.w3.org/TR/2007/REC-xslt20-20070123/</a></dd>

      <dt>Latest version:</dt>

      <dd><a href=
      "http://www.w3.org/TR/xslt20/">http://www.w3.org/TR/xslt20/</a><br />
      </dd>

      <dt>Previous version:</dt>

      <dd><a href=
      "http://www.w3.org/TR/2006/PR-xslt20-20061121/">http://www.w3.org/TR/2006/PR-xslt20-20061121/</a><br />
      </dd>

      <dt>Editor:</dt>

      <dd>Michael Kay, Saxonica <a href=
      "http://www.saxonica.com/">&lt;http://www.saxonica.com/&gt;</a></dd>
    </dl>

    <p>Please refer to the <a href=
    "http://www.w3.org/XML/2007/qt-errata/xslt-errata.html"><strong>
    errata</strong></a> for this document, which may include some
    normative corrections.</p>

    <p>See also <a href=
    "http://www.w3.org/2003/03/Translations/byTechnology?technology=xslt20">
    <strong>translations</strong></a>.</p>

    <p class="copyright"><a href=
    "http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>&#160;©&#160;2007&#160;<a href="http://www.w3.org/">
    <acronym title=
    "World Wide Web Consortium">W3C</acronym></a><sup>®</sup>
    (<a href="http://www.csail.mit.edu/"><acronym title=
    "Massachusetts Institute of Technology">MIT</acronym></a>,
    <a href="http://www.ercim.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 />

  <div>
    <h2><a name="abstract" id="abstract"></a>Abstract</h2>

    <p>This specification defines the syntax and semantics of XSLT
    2.0, a language for transforming XML documents into other XML
    documents.</p>

    <p>XSLT 2.0 is a revised version of the XSLT 1.0 Recommendation
    <a href="index.html#xslt">[XSLT 1.0]</a> published on 16 November
    1999.</p>

    <p>XSLT 2.0 is designed to be used in conjunction with XPath
    2.0, which is defined in <a href="index.html#xpath20">[XPath 2.0]</a>.
    XSLT shares the same data model as XPath 2.0, which is defined
    in <a href="index.html#xpath-datamodel">[Data Model]</a>, and it uses the
    library of functions and operators defined in <a href=
    "index.html#xpath-functions">[Functions and Operators]</a>.</p>

    <p>XSLT 2.0 also includes optional facilities to serialize the
    results of a transformation, by means of an interface to the
    serialization component described in <a href=
    "index.html#xslt-xquery-serialization">[XSLT and XQuery
    Serialization]</a>.</p>

    <p><em>This document contains hyperlinks to specific sections
    or definitions within other documents in this family of
    specifications. These links are indicated visually by a
    superscript identifying the target specification: for example
    XP for XPath, DM for the XDM data model, FO for Functions and
    Operators.</em></p>
  </div>

  <div>
    <h2><a name="status" id="status"></a>Status of this
    Document</h2>

    <p><em>This section describes the status of this document at
    the time of its publication. Other documents may supersede this
    document. A list of current W3C publications and the latest
    revision of this technical report can be found in the <a href=
    "http://www.w3.org/TR/">W3C technical reports index</a> at
    http://www.w3.org/TR/.</em></p>

    <p>This <a href=
    "http://www.w3.org/2004/02/Process-20040205/tr.html#RecsW3C">Recommendation</a>
    builds on the success of <a href="index.html#xslt">[XSLT 1.0]</a>, which
    was published on 16 November 1999. Many new features have been
    added to the language (see <a href="index.html#changes-since-1.0"><i>J.2
    New Functionality</i></a>) while retaining a high level of
    backwards compatibility (see <a href=
    "index.html#incompatibilities"><i>J.1 Incompatible Changes</i></a>). The
    changes have been designed to meet the requirements for XSLT
    2.0 described in <a href="index.html#xslt20req">[XSLT 2.0
    Requirements]</a>. The way in which each requirement has been
    addressed is outlined in <a href="index.html#requirements-checklist"><i>I
    Checklist of Requirements</i></a>.</p>

    <p>XSLT 2.0 depends on a number of other specifications that
    have progressed to Recommendation status at the same time: see
    <a href="index.html#xpath20">[XPath 2.0]</a>, <a href=
    "index.html#xpath-datamodel">[Data Model]</a>, <a href=
    "index.html#xpath-functions">[Functions and Operators]</a>, and <a href=
    "index.html#xslt-xquery-serialization">[XSLT and XQuery
    Serialization]</a>. These subsidiary documents are also
    referenced in the specification of XQuery 1.0.</p>

    <p>This document has been produced by the <a href=
    "http://www.w3.org/Style/XSL/">XSL Working Group</a>, which is
    part of the <a href="http://www.w3.org/XML/Activity">XML
    Activity</a>. The document has been reviewed by W3C Members and
    other interested parties, and is endorsed by the Director. It
    is a stable document and may be used as reference material or
    cited as a normative reference from another document. W3C's
    role in making the Recommendation is to draw attention to the
    specification and to promote its widespread deployment. This
    enhances the functionality and interoperability of the Web.</p>

    <p>A small number of editorial corrections and clarifications
    have been made to the document since it <a href=
    "http://www.w3.org/TR/2006/PR-xslt20-20061121/">was
    published</a> as a <a href=
    "http://www.w3.org/2004/02/Process-20040205/tr.html#RecsPR">Proposed
    Recommendation</a> on 21 November 2006. These changes are
    listed at <a href="index.html#changes-2007-01"><i>J.2.4 Changes since
    Proposed Recommendation</i></a>.</p>

    <p>Please record any comments about this document in W3C's
    <a href="http://www.w3.org/Bugs/Public/">public Bugzilla
    system</a> (instructions can be found at <a href=
    "http://www.w3.org/XML/2005/04/qt-bugzilla">http://www.w3.org/XML/2005/04/qt-bugzilla</a>).
    If access to that system is not feasible, you may send your
    comments to the W3C XSLT/XPath/XQuery public comments mailing
    list, <a href=
    "mailto:public-qt-comments@w3.org">public-qt-comments@w3.org</a>.
    It is helpful to include the string [XSLT] in the subject line
    of your comment, whether made in Bugzilla or in email. Each
    Bugzilla entry and email message should contain only one
    comment. Archives of the comments and responses are available
    at <a href=
    "http://lists.w3.org/Archives/Public/public-qt-comments/">http://lists.w3.org/Archives/Public/public-qt-comments/</a>.</p>

    <p>General public discussion of XSLT takes place on the
    <a href="http://www.mulberrytech.com/xsl/xsl-list/index.html">XSL-List</a>
    forum.</p>

    <p>This document was produced by a group operating under the
    <a href=
    "http://www.w3.org/Consortium/Patent-Policy-20040205/">5
    February 2004 W3C Patent Policy</a>. W3C maintains a <a href=
    "http://www.w3.org/2004/01/pp-impl/19552/status#disclosures">public
    list of any patent disclosures</a> made in connection with the
    deliverables of the group; that page also includes instructions
    for disclosing a patent. An individual who has actual knowledge
    of a patent which the individual believes contains <a href=
    "http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">
    Essential Claim(s)</a> must disclose the information in
    accordance with <a href=
    "http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">
    section 6 of the W3C Patent Policy</a>.</p>
  </div>

  <div class="toc">
    <h2><a name="contents" id="contents"></a>Table of Contents</h2>

    <p class="toc">1 <a href="index.html#introduction">Introduction</a><br />
    &#160;&#160;&#160;&#160;1.1 <a href="index.html#what-is-xslt">What is
    XSLT?</a><br />
    &#160;&#160;&#160;&#160;1.2 <a href=
    "index.html#whats-new-in-xslt2">What's New in XSLT 2.0?</a><br />
    2 <a href="index.html#concepts">Concepts</a><br />
    &#160;&#160;&#160;&#160;2.1 <a href=
    "index.html#terminology">Terminology</a><br />
    &#160;&#160;&#160;&#160;2.2 <a href=
    "index.html#notation">Notation</a><br />
    &#160;&#160;&#160;&#160;2.3 <a href="index.html#initiating">Initiating a
    Transformation</a><br />
    &#160;&#160;&#160;&#160;2.4 <a href=
    "index.html#executing-a-transformation">Executing a
    Transformation</a><br />
    &#160;&#160;&#160;&#160;2.5 <a href="index.html#context">The Evaluation
    Context</a><br />
    &#160;&#160;&#160;&#160;2.6 <a href=
    "index.html#parsing-and-serialization">Parsing and
    Serialization</a><br />
    &#160;&#160;&#160;&#160;2.7 <a href=
    "index.html#extensibility">Extensibility</a><br />
    &#160;&#160;&#160;&#160;2.8 <a href=
    "index.html#stylesheets-and-schemas">Stylesheets and XML
    Schemas</a><br />
    &#160;&#160;&#160;&#160;2.9 <a href="index.html#errors">Error
    Handling</a><br />
    3 <a href="index.html#stylesheet-structure">Stylesheet
    Structure</a><br />
    &#160;&#160;&#160;&#160;3.1 <a href="index.html#xslt-namespace">XSLT
    Namespace</a><br />
    &#160;&#160;&#160;&#160;3.2 <a href=
    "index.html#reserved-namespaces">Reserved Namespaces</a><br />
    &#160;&#160;&#160;&#160;3.3 <a href=
    "index.html#extension-attributes">Extension Attributes</a><br />
    &#160;&#160;&#160;&#160;3.4 <a href="index.html#xslt-media-type">XSLT
    Media Type</a><br />
    &#160;&#160;&#160;&#160;3.5 <a href=
    "index.html#standard-attributes">Standard Attributes</a><br />
    &#160;&#160;&#160;&#160;3.6 <a href=
    "index.html#stylesheet-element">Stylesheet Element</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.6.1 <a href=
    "index.html#default-collation-attribute">The default-collation
    attribute</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.6.2 <a href=
    "index.html#user-defined-top-level">User-defined Data Elements</a><br />
    &#160;&#160;&#160;&#160;3.7 <a href=
    "index.html#simplified-stylesheet">Simplified Stylesheet
    Modules</a><br />
    &#160;&#160;&#160;&#160;3.8 <a href=
    "index.html#backwards">Backwards-Compatible Processing</a><br />
    &#160;&#160;&#160;&#160;3.9 <a href=
    "index.html#forwards">Forwards-Compatible Processing</a><br />
    &#160;&#160;&#160;&#160;3.10 <a href=
    "index.html#combining-modules">Combining Stylesheet Modules</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.10.1 <a href=
    "index.html#locating-modules">Locating Stylesheet Modules</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.10.2 <a href=
    "index.html#include">Stylesheet Inclusion</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3.10.3 <a href=
    "index.html#import">Stylesheet Import</a><br />
    &#160;&#160;&#160;&#160;3.11 <a href="index.html#embedded">Embedded
    Stylesheet Modules</a><br />
    &#160;&#160;&#160;&#160;3.12 <a href=
    "index.html#conditional-inclusion">Conditional Element
    Inclusion</a><br />
    &#160;&#160;&#160;&#160;3.13 <a href="index.html#built-in-types">Built-in
    Types</a><br />
    &#160;&#160;&#160;&#160;3.14 <a href="index.html#import-schema">Importing
    Schema Components</a><br />
    4 <a href="index.html#data-model">Data Model</a><br />
    &#160;&#160;&#160;&#160;4.1 <a href="index.html#xml-versions">XML
    Versions</a><br />
    &#160;&#160;&#160;&#160;4.2 <a href=
    "index.html#stylesheet-stripping">Stripping Whitespace from the
    Stylesheet</a><br />
    &#160;&#160;&#160;&#160;4.3 <a href=
    "index.html#stripping-annotations">Stripping Type Annotations from a
    Source Tree</a><br />
    &#160;&#160;&#160;&#160;4.4 <a href="index.html#strip">Stripping
    Whitespace from a Source Tree</a><br />
    &#160;&#160;&#160;&#160;4.5 <a href=
    "index.html#id-in-data-model">Attribute Types and DTD
    Validation</a><br />
    &#160;&#160;&#160;&#160;4.6 <a href="index.html#limits">Limits</a><br />
    &#160;&#160;&#160;&#160;4.7 <a href=
    "index.html#d-o-e-in-data-model">Disable Output Escaping</a><br />
    5 <a href="index.html#constructs">Features of the XSLT Language</a><br />
    &#160;&#160;&#160;&#160;5.1 <a href="index.html#qname">Qualified
    Names</a><br />
    &#160;&#160;&#160;&#160;5.2 <a href=
    "index.html#unprefixed-qnames">Unprefixed QNames in Expressions and
    Patterns</a><br />
    &#160;&#160;&#160;&#160;5.3 <a href=
    "index.html#expressions">Expressions</a><br />
    &#160;&#160;&#160;&#160;5.4 <a href=
    "index.html#static-and-dynamic-context">The Static and Dynamic
    Context</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.4.1 <a href=
    "index.html#static-context">Initializing the Static Context</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.4.2 <a href=
    "index.html#additional-static-context">Additional Static Context
    Components used by XSLT</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.4.3 <a href=
    "index.html#xpath-dynamic-context">Initializing the Dynamic
    Context</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.4.3.1
    <a href="index.html#focus">Maintaining Position: the Focus</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.4.3.2
    <a href="index.html#evaluation-context">Other components of the XPath
    Dynamic Context</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.4.4 <a href=
    "index.html#additional-dynamic-context">Additional Dynamic Context
    Components used by XSLT</a><br />
    &#160;&#160;&#160;&#160;5.5 <a href=
    "index.html#patterns">Patterns</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.5.1 <a href=
    "index.html#pattern-examples">Examples of Patterns</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.5.2 <a href=
    "index.html#pattern-syntax">Syntax of Patterns</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.5.3 <a href=
    "index.html#pattern-semantics">The Meaning of a Pattern</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.5.4 <a href=
    "index.html#pattern-errors">Errors in Patterns</a><br />
    &#160;&#160;&#160;&#160;5.6 <a href=
    "index.html#attribute-value-templates">Attribute Value
    Templates</a><br />
    &#160;&#160;&#160;&#160;5.7 <a href=
    "index.html#sequence-constructors">Sequence Constructors</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.7.1 <a href=
    "index.html#constructing-complex-content">Constructing Complex
    Content</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.7.2 <a href=
    "index.html#constructing-simple-content">Constructing Simple
    Content</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5.7.3 <a href=
    "index.html#namespace-fixup">Namespace Fixup</a><br />
    &#160;&#160;&#160;&#160;5.8 <a href="index.html#uri-references">URI
    References</a><br />
    6 <a href="index.html#rules">Template Rules</a><br />
    &#160;&#160;&#160;&#160;6.1 <a href=
    "index.html#defining-templates">Defining Templates</a><br />
    &#160;&#160;&#160;&#160;6.2 <a href=
    "index.html#defining-template-rules">Defining Template Rules</a><br />
    &#160;&#160;&#160;&#160;6.3 <a href=
    "index.html#applying-templates">Applying Template Rules</a><br />
    &#160;&#160;&#160;&#160;6.4 <a href="index.html#conflict">Conflict
    Resolution for Template Rules</a><br />
    &#160;&#160;&#160;&#160;6.5 <a href="index.html#modes">Modes</a><br />
    &#160;&#160;&#160;&#160;6.6 <a href="index.html#built-in-rule">Built-in
    Template Rules</a><br />
    &#160;&#160;&#160;&#160;6.7 <a href="index.html#apply-imports">Overriding
    Template Rules</a><br />
    7 <a href="index.html#for-each">Repetition</a><br />
    8 <a href="index.html#conditionals">Conditional Processing</a><br />
    &#160;&#160;&#160;&#160;8.1 <a href="index.html#xsl-if">Conditional
    Processing with xsl:if</a><br />
    &#160;&#160;&#160;&#160;8.2 <a href="index.html#xsl-choose">Conditional
    Processing with xsl:choose</a><br />
    9 <a href="index.html#variables-and-parameters">Variables and
    Parameters</a><br />
    &#160;&#160;&#160;&#160;9.1 <a href=
    "index.html#variables">Variables</a><br />
    &#160;&#160;&#160;&#160;9.2 <a href=
    "index.html#parameters">Parameters</a><br />
    &#160;&#160;&#160;&#160;9.3 <a href="index.html#variable-values">Values
    of Variables and Parameters</a><br />
    &#160;&#160;&#160;&#160;9.4 <a href="index.html#temporary-trees">Creating
    implicit document nodes</a><br />
    &#160;&#160;&#160;&#160;9.5 <a href="index.html#global-variables">Global
    Variables and Parameters</a><br />
    &#160;&#160;&#160;&#160;9.6 <a href="index.html#local-variables">Local
    Variables and Parameters</a><br />
    &#160;&#160;&#160;&#160;9.7 <a href="index.html#scope-of-variables">Scope
    of Variables</a><br />
    &#160;&#160;&#160;&#160;9.8 <a href="index.html#circularity">Circular
    Definitions</a><br />
    10 <a href="index.html#callable-components">Callable Components</a><br />
    &#160;&#160;&#160;&#160;10.1 <a href="index.html#named-templates">Named
    Templates</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;10.1.1 <a href=
    "index.html#with-param">Passing Parameters to Templates</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;10.1.2 <a href=
    "index.html#tunnel-params">Tunnel Parameters</a><br />
    &#160;&#160;&#160;&#160;10.2 <a href="index.html#attribute-sets">Named
    Attribute Sets</a><br />
    &#160;&#160;&#160;&#160;10.3 <a href=
    "index.html#stylesheet-functions">Stylesheet Functions</a><br />
    11 <a href="index.html#creating-new-nodes">Creating Nodes and
    Sequences</a><br />
    &#160;&#160;&#160;&#160;11.1 <a href=
    "index.html#literal-result-element">Literal Result Elements</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.1.1 <a href=
    "index.html#setting-annotation-for-lre">Setting the Type Annotation for
    Literal Result Elements</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.1.2 <a href=
    "index.html#attributes-for-lres">Attribute Nodes for Literal Result
    Elements</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.1.3 <a href=
    "index.html#lre-namespaces">Namespace Nodes for Literal Result
    Elements</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.1.4 <a href=
    "index.html#namespace-aliasing">Namespace Aliasing</a><br />
    &#160;&#160;&#160;&#160;11.2 <a href="index.html#xsl-element">Creating
    Element Nodes Using xsl:element</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.2.1 <a href=
    "index.html#annotation-for-constructed-element">Setting the Type
    Annotation for a Constructed Element Node</a><br />
    &#160;&#160;&#160;&#160;11.3 <a href=
    "index.html#creating-attributes">Creating Attribute Nodes Using
    xsl:attribute</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.3.1 <a href=
    "index.html#annotation-for-constructed-attribute">Setting the Type
    Annotation for a Constructed Attribute Node</a><br />
    &#160;&#160;&#160;&#160;11.4 <a href=
    "index.html#creating-text-nodes">Creating Text Nodes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.4.1 <a href=
    "index.html#literal-text-nodes">Literal Text Nodes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.4.2 <a href=
    "index.html#xsl-text">Creating Text Nodes Using xsl:text</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.4.3 <a href=
    "index.html#value-of">Generating Text with xsl:value-of</a><br />
    &#160;&#160;&#160;&#160;11.5 <a href=
    "index.html#creating-document-nodes">Creating Document Nodes</a><br />
    &#160;&#160;&#160;&#160;11.6 <a href=
    "index.html#creating-processing-instructions">Creating Processing
    Instructions</a><br />
    &#160;&#160;&#160;&#160;11.7 <a href=
    "index.html#creating-namespace-nodes">Creating Namespace Nodes</a><br />
    &#160;&#160;&#160;&#160;11.8 <a href=
    "index.html#creating-comments">Creating Comments</a><br />
    &#160;&#160;&#160;&#160;11.9 <a href="index.html#copying">Copying
    Nodes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.9.1 <a href=
    "index.html#shallow-copy">Shallow Copy</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11.9.2 <a href=
    "index.html#copy-of">Deep Copy</a><br />
    &#160;&#160;&#160;&#160;11.10 <a href=
    "index.html#constructing-sequences">Constructing Sequences</a><br />
    12 <a href="index.html#number">Numbering</a><br />
    &#160;&#160;&#160;&#160;12.1 <a href=
    "index.html#formatting-supplied-number">Formatting a Supplied
    Number</a><br />
    &#160;&#160;&#160;&#160;12.2 <a href=
    "index.html#numbering-based-on-position">Numbering based on Position in a
    Document</a><br />
    &#160;&#160;&#160;&#160;12.3 <a href="index.html#convert">Number to
    String Conversion Attributes</a><br />
    13 <a href="index.html#sorting">Sorting</a><br />
    &#160;&#160;&#160;&#160;13.1 <a href="index.html#xsl-sort">The xsl:sort
    Element</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;13.1.1 <a href=
    "index.html#sorting-process">The Sorting Process</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;13.1.2 <a href=
    "index.html#comparing-sort-keys">Comparing Sort Key Values</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;13.1.3 <a href=
    "index.html#collating-sequences">Sorting Using Collations</a><br />
    &#160;&#160;&#160;&#160;13.2 <a href=
    "index.html#creating-sorted-sequence">Creating a Sorted
    Sequence</a><br />
    &#160;&#160;&#160;&#160;13.3 <a href=
    "index.html#sorted-iteration">Processing a Sequence in Sorted
    Order</a><br />
    14 <a href="index.html#grouping">Grouping</a><br />
    &#160;&#160;&#160;&#160;14.1 <a href="index.html#current-group">The
    Current Group</a><br />
    &#160;&#160;&#160;&#160;14.2 <a href=
    "index.html#current-grouping-key">The Current Grouping Key</a><br />
    &#160;&#160;&#160;&#160;14.3 <a href="index.html#xsl-for-each-group">The
    xsl:for-each-group Element</a><br />
    &#160;&#160;&#160;&#160;14.4 <a href=
    "index.html#grouping-examples">Examples of Grouping</a><br />
    15 <a href="index.html#regular-expressions">Regular Expressions</a><br />
    &#160;&#160;&#160;&#160;15.1 <a href="index.html#analyze-string">The
    xsl:analyze-string instruction</a><br />
    &#160;&#160;&#160;&#160;15.2 <a href="index.html#regex-group">Captured
    Substrings</a><br />
    &#160;&#160;&#160;&#160;15.3 <a href="index.html#regex-examples">Examples
    of Regular Expression Matching</a><br />
    16 <a href="index.html#add-func">Additional Functions</a><br />
    &#160;&#160;&#160;&#160;16.1 <a href="index.html#document">Multiple
    Source Documents</a><br />
    &#160;&#160;&#160;&#160;16.2 <a href="index.html#unparsed-text">Reading
    Text Files</a><br />
    &#160;&#160;&#160;&#160;16.3 <a href="index.html#key">Keys</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.3.1 <a href=
    "index.html#xsl-key">The xsl:key Declaration</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.3.2 <a href=
    "index.html#keys">The key Function</a><br />
    &#160;&#160;&#160;&#160;16.4 <a href="index.html#format-number">Number
    Formatting</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.4.1 <a href=
    "index.html#defining-decimal-format">Defining a Decimal Format</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.4.2 <a href=
    "index.html#processing-picture-string">Processing the Picture
    String</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.4.3 <a href=
    "index.html#analysing-picture-string">Analysing the Picture
    String</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.4.4 <a href=
    "index.html#formatting-the-number">Formatting the Number</a><br />
    &#160;&#160;&#160;&#160;16.5 <a href="index.html#format-date">Formatting
    Dates and Times</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.5.1 <a href=
    "index.html#date-picture-string">The Picture String</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.5.2 <a href=
    "index.html#lang-cal-country">The Language, Calendar, and Country
    Arguments</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.5.3 <a href=
    "index.html#date-time-examples">Examples of Date and Time
    Formatting</a><br />
    &#160;&#160;&#160;&#160;16.6 <a href="index.html#misc-func">Miscellaneous
    Additional Functions</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.6.1 <a href=
    "index.html#current-function">current</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.6.2 <a href=
    "index.html#unparsed-entity-uri">unparsed-entity-uri</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.6.3 <a href=
    "index.html#unparsed-entity-public-id">unparsed-entity-public-id</a><br />

    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.6.4 <a href=
    "index.html#generate-id">generate-id</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;16.6.5 <a href=
    "index.html#system-property">system-property</a><br />
    17 <a href="index.html#message">Messages</a><br />
    18 <a href="index.html#extension">Extensibility and Fallback</a><br />
    &#160;&#160;&#160;&#160;18.1 <a href=
    "index.html#extension-functions">Extension Functions</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.1.1 <a href=
    "index.html#testing-function-availability">Testing Availability of
    Functions</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.1.2 <a href=
    "index.html#calling-extension-functions">Calling Extension
    Functions</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.1.3 <a href=
    "index.html#external-objects">External Objects</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.1.4 <a href=
    "index.html#testing-type-availability">Testing Availability of
    Types</a><br />
    &#160;&#160;&#160;&#160;18.2 <a href=
    "index.html#extension-instruction">Extension Instructions</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.2.1 <a href=
    "index.html#designating-extension-namespace">Designating an Extension
    Namespace</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.2.2 <a href=
    "index.html#testing-instruction-available">Testing Availability of
    Instructions</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;18.2.3 <a href=
    "index.html#fallback">Fallback</a><br />
    19 <a href="index.html#result-trees">Final Result Trees</a><br />
    &#160;&#160;&#160;&#160;19.1 <a href=
    "index.html#creating-result-trees">Creating Final Result Trees</a><br />
    &#160;&#160;&#160;&#160;19.2 <a href=
    "index.html#validation">Validation</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;19.2.1 <a href=
    "index.html#validating-constructed-nodes">Validating Constructed Elements
    and Attributes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;19.2.1.1
    <a href="index.html#validating-using-validation-attribute">Validation
    using the [xsl:]validation Attribute</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;19.2.1.2
    <a href="index.html#validation-xsl-type">Validation using the [xsl:]type
    Attribute</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;19.2.1.3
    <a href="index.html#validation-process">The Validation Process</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;19.2.2 <a href=
    "index.html#validating-document-nodes">Validating Document
    Nodes</a><br />
    20 <a href="index.html#serialization">Serialization</a><br />
    &#160;&#160;&#160;&#160;20.1 <a href=
    "index.html#character-maps">Character Maps</a><br />
    &#160;&#160;&#160;&#160;20.2 <a href=
    "index.html#disable-output-escaping">Disabling Output Escaping</a><br />
    21 <a href="index.html#conformance">Conformance</a><br />
    &#160;&#160;&#160;&#160;21.1 <a href="index.html#basic-conformance">Basic
    XSLT Processor</a><br />
    &#160;&#160;&#160;&#160;21.2 <a href=
    "index.html#schema-aware-conformance">Schema-Aware XSLT
    Processor</a><br />
    &#160;&#160;&#160;&#160;21.3 <a href=
    "index.html#serialization-feature">Serialization Feature</a><br />
    &#160;&#160;&#160;&#160;21.4 <a href=
    "index.html#backwards-compatibility-feature">Backwards Compatibility
    Feature</a><br /></p>

    <h3><a name="appendices" id="appendices"></a>Appendices</h3>

    <p class="toc">A <a href="index.html#references">References</a><br />
    &#160;&#160;&#160;&#160;A.1 <a href=
    "index.html#normative-references">Normative References</a><br />
    &#160;&#160;&#160;&#160;A.2 <a href="index.html#other-references">Other
    References</a><br />
    B <a href="index.html#xslt-mime-definition">The XSLT Media Type</a><br />
    &#160;&#160;&#160;&#160;B.1 <a href=
    "index.html#media-type-registration">Registration of MIME Media Type
    application/xslt+xml</a><br />
    &#160;&#160;&#160;&#160;B.2 <a href=
    "index.html#media-type-fragid">Fragment Identifiers</a><br />
    C <a href="index.html#glossary">Glossary</a> (Non-Normative)<br />
    D <a href="index.html#element-syntax-summary">Element Syntax Summary</a>
    (Non-Normative)<br />
    E <a href="index.html#error-summary">Summary of Error Conditions</a>
    (Non-Normative)<br />
    F <a href="index.html#implementation-defined-features">Checklist of
    Implementation-Defined Features</a> (Non-Normative)<br />
    G <a href="index.html#schema-for-xslt">Schema for XSLT Stylesheets</a>
    (Non-Normative)<br />
    H <a href="index.html#acknowledgements">Acknowledgements</a>
    (Non-Normative)<br />
    I <a href="index.html#requirements-checklist">Checklist of
    Requirements</a> (Non-Normative)<br />
    J <a href="index.html#changes">Changes from XSLT 1.0</a>
    (Non-Normative)<br />
    &#160;&#160;&#160;&#160;J.1 <a href=
    "index.html#incompatibilities">Incompatible Changes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.1.1 <a href=
    "index.html#incompatibility-stripping">Tree construction: whitespace
    stripping</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.1.2 <a href=
    "index.html#incompatibility-serialization">Changes in Serialization
    Behavior</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.1.3 <a href=
    "index.html#backwards-compatibility-behavior">Backwards Compatibility
    Behavior</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.1.4 <a href=
    "index.html#incompatibility-without-schema">Incompatibility in the
    Absence of a Schema</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.1.5 <a href=
    "index.html#compatibility-with-schema">Compatibility in the Presence of a
    Schema</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.1.6 <a href=
    "index.html#xpath-compatibility">XPath 2.0 Backwards
    Compatibility</a><br />
    &#160;&#160;&#160;&#160;J.2 <a href="index.html#changes-since-1.0">New
    Functionality</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.2.1 <a href=
    "index.html#pervasive-changes">Pervasive changes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.2.2 <a href=
    "index.html#major-features">Major Features</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.2.3 <a href=
    "index.html#minor-changes">Minor Changes</a><br />
    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;J.2.4 <a href=
    "index.html#changes-2007-01">Changes since Proposed
    Recommendation</a><br /></p>
  </div>
  <hr />

  <div class="body">
    <div class="div1">
      <h2><a name="introduction" id="introduction"></a>1
      Introduction</h2>

      <div class="div2">
        <h3><a name="what-is-xslt" id="what-is-xslt"></a>1.1 What
        is XSLT?</h3>

        <p>This specification defines the syntax and semantics of
        the XSLT 2.0 language.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-stylesheet" id="dt-stylesheet" title="stylesheet"></a>A
        transformation in the XSLT language is expressed in the
        form of a <b>stylesheet</b>, whose syntax is well-formed
        XML <a href="index.html#REC-xml">[XML 1.0]</a> conforming to the
        Namespaces in XML Recommendation <a href=
        "index.html#REC-xml-names">[Namespaces in XML 1.0]</a>.<span class=
        "definition">]</span></p>

        <p>A stylesheet generally includes elements that are
        defined by XSLT as well as elements that are not defined by
        XSLT. XSLT-defined elements are distinguished by use of the
        namespace <code>http://www.w3.org/1999/XSL/Transform</code>
        (see <a href="index.html#xslt-namespace"><i>3.1 XSLT
        Namespace</i></a>), which is referred to in this
        specification as the <a title="XSLT namespace" href=
        "index.html#dt-xslt-namespace">XSLT namespace</a>. Thus this
        specification is a definition of the syntax and semantics
        of the XSLT namespace.</p>

        <p>The term <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> reflects the fact that one
        of the important roles of XSLT is to add styling
        information to an XML source document, by transforming it
        into a document consisting of XSL formatting objects (see
        <a href="index.html#xsl">[Extensible Stylesheet Language (XSL)]</a>),
        or into another presentation-oriented format such as HTML,
        XHTML, or SVG. However, XSLT is used for a wide range of
        transformation tasks, not exclusively for formatting and
        presentation applications.</p>

        <p>A transformation expressed in XSLT describes rules for
        transforming zero or more source trees into one or more
        result trees. The structure of these trees is described in
        <a href="index.html#xpath-datamodel">[Data Model]</a>. The
        transformation is achieved by a set of <a title=
        "template rule" href="index.html#dt-template-rule">template
        rules</a>. A template rule associates a <a title="pattern"
        href="index.html#dt-pattern">pattern</a>, which matches nodes in the
        source document, with a <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a>.
        In many cases, evaluating the sequence constructor will
        cause new nodes to be constructed, which can be used to
        produce part of a result tree. The structure of the result
        trees can be completely different from the structure of the
        source trees. In constructing a result tree, nodes from the
        source trees can be filtered and reordered, and arbitrary
        structure can be added. This mechanism allows a <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> to be
        applicable to a wide class of documents that have similar
        source tree structures.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-principal-stylesheet-module" id=
        "dt-principal-stylesheet-module" title=
        "principal stylesheet module"></a>A <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> may consist of several
        <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet modules</a>, contained
        in different XML documents. For a given transformation, one
        of these functions as the <b>principal stylesheet
        module</b>. The complete <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> is assembled by finding the
        <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet modules</a> referenced
        directly or indirectly from the principal stylesheet module
        using <a href=
        "index.html#element-include"><code>xsl:include</code></a> and
        <a href="index.html#element-import"><code>xsl:import</code></a>
        elements: see <a href="index.html#include"><i>3.10.2 Stylesheet
        Inclusion</i></a> and <a href="index.html#import"><i>3.10.3
        Stylesheet Import</i></a>.<span class=
        "definition">]</span></p>
      </div>

      <div class="div2">
        <h3><a name="whats-new-in-xslt2" id=
        "whats-new-in-xslt2"></a>1.2 What's New in XSLT 2.0?</h3>

        <p>XSLT 1.0 was published in November 1999, and version 2.0
        represents a significant increase in the capability of the
        language. A detailed list of changes is included in
        <a href="index.html#changes"><i>J Changes from XSLT 1.0</i></a>. XSLT
        2.0 has been developed in parallel with XPath 2.0 (see
        <a href="index.html#xpath20">[XPath 2.0]</a>), so the changes to
        XPath must be considered alongside the changes to XSLT.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="concepts" id="concepts"></a>2 Concepts</h2>

      <div class="div2">
        <h3><a name="terminology" id="terminology"></a>2.1
        Terminology</h3>

        <p>For a full glossary of terms, see <a href=
        "index.html#glossary"><i>C Glossary</i></a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-processor" id="dt-processor" title="processor"></a>The
        software responsible for transforming source trees into
        result trees using an XSLT stylesheet is referred to as the
        <b>processor</b>. This is sometimes expanded to <em>XSLT
        processor</em> to avoid any confusion with other
        processors, for example an XML processor.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-implementation" id="dt-implementation" title=
        "implementation"></a>A specific product that performs the
        functions of an <a title="processor" href=
        "index.html#dt-processor">XSLT processor</a> is referred to as an
        <b>implementation</b> <span class=
        "definition">]</span>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-result-tree" id="dt-result-tree" title=
        "result tree"></a>The term <b>result tree</b> is used to
        refer to any tree constructed by <a title="instruction"
        href="index.html#dt-instruction">instructions</a> in the stylesheet.
        A result tree is either a <a title="final result tree"
        href="index.html#dt-final-result-tree">final result tree</a> or a
        <a title="temporary tree" href=
        "index.html#dt-temporary-tree">temporary tree</a>.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-final-result-tree" id="dt-final-result-tree" title=
        "final result tree"></a>A <b>final result tree</b> is a
        <a title="result tree" href="index.html#dt-result-tree">result
        tree</a> that forms part of the final output of a
        transformation. Once created, the contents of a final
        result tree are not accessible within the stylesheet
        itself.<span class="definition">]</span> The <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction always creates a final result tree, and a final
        result tree may also be created implicitly by the <a title=
        "initial template" href="index.html#dt-initial-template">initial
        template</a>. The conditions under which this happens are
        described in <a href="index.html#executing-a-transformation"><i>2.4
        Executing a Transformation</i></a>. A final result tree
        <span class="verb">may</span> be serialized as described in
        <a href="index.html#serialization"><i>20 Serialization</i></a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-source-tree" id="dt-source-tree" title=
        "source tree"></a>The term <b>source tree</b> means any
        tree provided as input to the transformation. This includes
        the document containing the <a title="initial context node"
        href="index.html#dt-initial-context-node">initial context node</a> if
        any, documents containing nodes supplied as the values of
        <a title="stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameters</a>,
        documents obtained from the results of functions such as
        <a href="index.html#function-document"><code>document</code></a>,
        <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
        <small>FO</small></sup>, and <a href=
        "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
        collection</code></a><sup><small>FO</small></sup>, and
        documents returned by extension functions or extension
        instructions. In the context of a particular XSLT
        instruction, the term <b>source tree</b> means any tree
        provided as input to that instruction; this may be a source
        tree of the transformation as a whole, or it may be a
        <a title="temporary tree" href=
        "index.html#dt-temporary-tree">temporary tree</a> produced during the
        course of the transformation.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-temporary-tree" id="dt-temporary-tree" title=
        "temporary tree"></a>The term <b>temporary tree</b> means
        any tree that is neither a <a title="source tree" href=
        "index.html#dt-source-tree">source tree</a> nor a <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a>.<span class="definition">]</span> Temporary
        trees are used to hold intermediate results during the
        execution of the transformation.</p>

        <p>In this specification the phrases <span class=
        "verb">must</span>, <span class="verb">must not</span>,
        <span class="verb">should</span>, <span class="verb">should
        not</span>, <span class="verb">may</span>, <span class=
        "verb">required</span>, and <span class=
        "verb">recommended</span> are to be interpreted as
        described in <a href="index.html#RFC2119">[RFC2119]</a>.</p>

        <p>Where the phrase <span class="verb">must</span>,
        <span class="verb">must not</span>, or <span class=
        "verb">required</span> relates to the behavior of the XSLT
        processor, then an implementation is not conformant unless
        it behaves as specified, subject to the more detailed rules
        in <a href="index.html#conformance"><i>21 Conformance</i></a>.</p>

        <p>Where the phrase <span class="verb">must</span>,
        <span class="verb">must not</span>, or <span class=
        "verb">required</span> relates to a stylesheet, then the
        processor <span class="verb">must</span> enforce this
        constraint on stylesheets by reporting an error if the
        constraint is not satisfied.</p>

        <p>Where the phrase <span class="verb">should</span>,
        <span class="verb">should not</span>, or <span class=
        "verb">recommended</span> relates to a stylesheet, then a
        processor <span class="verb">may</span> produce warning
        messages if the constraint is not satisfied, but
        <span class="verb">must not</span> treat this as an
        error.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-implementation-defined" id="dt-implementation-defined"
        title="implementation-defined"></a>In this specification,
        the term <b>implementation-defined</b> refers to a feature
        where the implementation is allowed some flexibility, and
        where the choices made by the implementation <span class=
        "verb">must</span> be described in documentation that
        accompanies any conformance claim.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-implementation-dependent" id=
        "dt-implementation-dependent" title=
        "implementation-dependent"></a>The term
        <b>implementation-dependent</b> refers to a feature where
        the behavior <span class="verb">may</span> vary from one
        implementation to another, and where the vendor is not
        expected to provide a full specification of the
        behavior.<span class="definition">]</span> (This might
        apply, for example, to limits on the size of source
        documents that can be transformed.)</p>

        <p>In all cases where this specification leaves the
        behavior implementation-defined or
        implementation-dependent, the implementation has the option
        of providing mechanisms that allow the user to influence
        the behavior.</p>

        <p>A paragraph labeled as a <b>Note</b> or described as an
        <b>example</b> is non-normative.</p>

        <p>Many terms used in this document are defined in the
        XPath specification <a href="index.html#xpath20">[XPath 2.0]</a> or
        the XDM specification <a href="index.html#xpath-datamodel">[Data
        Model]</a>. Particular attention is drawn to the
        following:</p>

        <ul>
          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-atomization" id="dt-atomization" title=
            "atomize"></a>The term <b>atomization</b> is defined in
            <a href=
            "http://www.w3.org/TR/xpath20/#id-atomization">Section
            2.4.2 Atomization</a><sup><small>XP</small></sup>. It
            is a process that takes as input a sequence of nodes
            and atomic values, and returns a sequence of atomic
            values, in which the nodes are replaced by their typed
            values as defined in <a href="index.html#xpath-datamodel">[Data
            Model]</a>.<span class="definition">]</span> For some
            nodes (for example, elements with element-only
            content), atomization generates a <a title=
            "dynamic error" href="index.html#dt-dynamic-error">dynamic
            error</a>.</p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-typed-value" id="dt-typed-value" title=
            "typed value"></a>The term <b>typed value</b> is
            defined in <a href=
            "http://www.w3.org/TR/xpath-datamodel/#dm-typed-value">Section
            5.15 typed-value
            Accessor</a><sup><small>DM</small></sup>. Every node
            except an element defined in the schema with
            element-only content has a <a title="string value"
            href="index.html#dt-string-value">typed value</a>. For example,
            the <a title="typed value" href="index.html#dt-typed-value">typed
            value</a> of an attribute of type
            <code>xs:IDREFS</code> is a sequence of zero or more
            <code>xs:IDREF</code> values.<span class=
            "definition">]</span></p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-string-value" id="dt-string-value" title=
            "string value"></a>The term <b>string value</b> is
            defined in <a href=
            "http://www.w3.org/TR/xpath-datamodel/#dm-string-value">
            Section 5.13 string-value
            Accessor</a><sup><small>DM</small></sup>. Every node
            has a <a title="string value" href=
            "index.html#dt-string-value">string value</a>. For example, the
            <a title="string value" href="index.html#dt-string-value">string
            value</a> of an element is the concatenation of the
            <a title="string value" href="index.html#dt-string-value">string
            values</a> of all its descendant text
            nodes.<span class="definition">]</span></p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-compatibility-mode" id="dt-compatibility-mode"
            title="XPath 1.0 compatibility mode"></a>The term
            <b>XPath 1.0 compatibility mode</b> is defined in
            <a href=
            "http://www.w3.org/TR/xpath20/#static_context">Section
            2.1.1 Static Context</a><sup><small>XP</small></sup>.
            This is a setting in the static context of an XPath
            expression; it has two values, <code>true</code> and
            <code>false</code>. When the value is set to true, the
            semantics of function calls and certain other
            operations are adjusted to give a greater degree of
            backwards compatibility between XPath 2.0 and XPath
            1.0.<span class="definition">]</span></p>
          </li>
        </ul>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-core-function" id="dt-core-function" title=
        "core function"></a>The term <b>core function</b> means a
        function that is specified in <a href=
        "index.html#xpath-functions">[Functions and Operators]</a> and that
        is in the <a title="standard function namespace" href=
        "index.html#dt-standard-function-namespace">standard function
        namespace</a>.<span class="definition">]</span></p>
      </div>

      <div class="div2">
        <h3><a name="notation" id="notation"></a>2.2 Notation</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-xslt-element" id="dt-xslt-element" title=
        "XSLT element"></a>An <b>XSLT element</b> is an element in
        the <a title="XSLT namespace" href=
        "index.html#dt-xslt-namespace">XSLT namespace</a> whose syntax and
        semantics are defined in this specification.<span class=
        "definition">]</span> For a non-normative list of XSLT
        elements, see <a href="index.html#element-syntax-summary"><i>D
        Element Syntax Summary</i></a>.</p>

        <p>In this document the specification of each <a title=
        "XSLT element" href="index.html#dt-xslt-element">XSLT element</a> is
        preceded by a summary of its syntax in the form of a model
        for elements of that element type. A full list of all these
        specifications can be found in <a href=
        "index.html#element-syntax-summary"><i>D Element Syntax
        Summary</i></a>. The meaning of syntax summary notation is
        as follows:</p>

        <ul>
          <li>
            <p>An attribute that is <span class=
            "verb">required</span> is shown with its name in bold.
            An attribute that may be omitted is shown with a
            question mark following its name.</p>
          </li>

          <li>
            <p>An attribute that is <a title="deprecated" href=
            "index.html#dt-deprecated">deprecated</a> is shown in a grayed
            font within square brackets.</p>
          </li>

          <li>
            <p>The string that occurs in the place of an attribute
            value specifies the allowed values of the attribute. If
            this is surrounded by curly brackets
            (<code>{...}</code>), then the attribute value is
            treated as an <a title="attribute value template" href=
            "index.html#dt-attribute-value-template">attribute value
            template</a>, and the string occurring within curly
            brackets specifies the allowed values of the result of
            evaluating the attribute value template. Alternative
            allowed values are separated by <code>|</code>. A
            quoted string indicates a value equal to that specific
            string. An unquoted, italicized name specifies a
            particular type of value.</p>

            <p>In all cases where this specification states that
            the value of an attribute <span class=
            "verb">must</span> be one of a limited set of values,
            leading and trailing whitespace in the attribute value
            is ignored. In the case of an <a title=
            "attribute value template" href=
            "index.html#dt-attribute-value-template">attribute value
            template</a>, this applies to the <a title=
            "effective value" href="index.html#dt-effective-value">effective
            value</a> obtained when the attribute value template is
            expanded.</p>
          </li>

          <li>
            <p>Unless the element is <span class=
            "verb">required</span> to be empty, the model element
            contains a comment specifying the allowed content. The
            allowed content is specified in a similar way to an
            element type declaration in XML; <em>sequence
            constructor</em> means that any mixture of text nodes,
            <a title="literal result element" href=
            "index.html#dt-literal-result-element">literal result
            elements</a>, <a title="extension instruction" href=
            "index.html#dt-extension-instruction">extension instructions</a>,
            and <a title="XSLT element" href=
            "index.html#dt-xslt-element">XSLT elements</a> from the <a title=
            "instruction" href="index.html#dt-instruction">instruction</a>
            category is allowed; <em>other-declarations</em> means
            that any mixture of XSLT elements from the <a title=
            "declaration" href="index.html#dt-declaration">declaration</a>
            category, other than <a href=
            "index.html#element-import"><code>xsl:import</code></a>, is
            allowed, together with <a title=
            "user-defined data element" href=
            "index.html#dt-data-element">user-defined data elements</a>.</p>
          </li>

          <li>
            <p>The element is prefaced by comments indicating if it
            belongs to the <code>instruction</code> category or
            <code>declaration</code> category or both. The category
            of an element only affects whether it is allowed in the
            content of elements that allow a <a title=
            "sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a> or
            <em>other-declarations</em>.</p>
          </li>
        </ul>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e659" id="d5e659"></a>Example: Syntax
            Notation
          </div>

          <p>This example illustrates the notation used to describe
          <a title="XSLT element" href="index.html#dt-xslt-element">XSLT
          elements</a>.</p>

          <p class="element-syntax"><a name=
          "element-example-element" id=
          "element-example-element"></a><code>&lt;!-- Category:
          instruction --&gt;<br />
          &lt;xsl:example-element<br />
          &#160;&#160;<b>select</b> = <var>expression</var><br />
          &#160;&#160;debug? = { "yes" | "no" }&gt;<br />
          &#160;&#160;&lt;!-- Content: ((<a href=
          "index.html#element-variable">xsl:variable</a> | <a href=
          "index.html#element-param">xsl:param</a>)*, <a href=
          "index.html#element-sequence">xsl:sequence</a>) --&gt;<br />
          &lt;/xsl:example-element&gt;</code></p>

          <p>This example defines a (non-existent) element
          <code>xsl:example-element</code>. The element is
          classified as an instruction. It takes a mandatory
          <code>select</code> attribute, whose value is an XPath
          <a title="expression" href=
          "index.html#dt-expression">expression</a>, and an optional
          <code>debug</code> attribute, whose value <span class=
          "verb">must</span> be either <code>yes</code> or
          <code>no</code>; the curly brackets indicate that the
          value can be defined as an <a title=
          "attribute value template" href=
          "index.html#dt-attribute-value-template">attribute value
          template</a>, allowing a value such as
          <code>debug="{$debug}"</code>, where the <a title=
          "variable" href="index.html#dt-variable">variable</a>
          <code>debug</code> is evaluated to yield
          <code>"yes"</code> or <code>"no"</code> at run-time.</p>

          <p>The content of an <code>xsl:example-element</code>
          instruction is defined to be a sequence of zero or more
          <a href="index.html#element-variable"><code>xsl:variable</code></a>
          and <a href="index.html#element-param"><code>xsl:param</code></a>
          elements, followed by an <a href=
          "index.html#element-sequence"><code>xsl:sequence</code></a>
          element.</p>
        </div>

        <p><a name="err-XTSE0010" id="err-XTSE0010"><span class=
        "error">[ERR XTSE0010]</span></a> A <a title="static error"
        href="index.html#dt-static-error">static error</a> is signaled if an
        XSLT-defined element is used in a context where it is not
        permitted, if a <span class="verb">required</span>
        attribute is omitted, or if the content of the element does
        not correspond to the content that is allowed for the
        element.</p>

        <p>Attributes are validated as follows. These rules apply
        to the value of the attribute after removing leading and
        trailing whitespace.</p>

        <ul>
          <li>
            <p><a name="err-XTSE0020" id=
            "err-XTSE0020"><span class="error">[ERR
            XTSE0020]</span></a> It is a <a title="static error"
            href="index.html#dt-static-error">static error</a> if an
            attribute (other than an attribute written using curly
            brackets in a position where an <a title=
            "attribute value template" href=
            "index.html#dt-attribute-value-template">attribute value
            template</a> is permitted) contains a value that is not
            one of the permitted values for that attribute.</p>
          </li>

          <li>
            <p><a name="err-XTDE0030" id=
            "err-XTDE0030"><span class="error">[ERR
            XTDE0030]</span></a> It is a <a title=
            "non-recoverable dynamic error" href=
            "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
            error</a> if the <a title="effective value" href=
            "index.html#dt-effective-value">effective value</a> of an
            attribute written using curly brackets, in a position
            where an <a title="attribute value template" href=
            "index.html#dt-attribute-value-template">attribute value
            template</a> is permitted, is a value that is not one
            of the permitted values for that attribute. If the
            processor is able to detect the error statically (for
            example, when any XPath expressions within the curly
            brackets can be evaluated statically), then the
            processor may optionally signal this as a static
            error.</p>
          </li>
        </ul>

        <p>Special rules apply if the construct appears in part of
        the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> that is processed with
        <a title="forwards-compatible behavior" href=
        "index.html#dt-forwards-compatible-behavior">forwards-compatible
        behavior</a>: see <a href="index.html#forwards"><i>3.9
        Forwards-Compatible Processing</i></a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-deprecated" id="dt-deprecated" title=
        "deprecated"></a>Some constructs defined in this
        specification are described as being <b>deprecated</b>. The
        use of this term implies that stylesheet authors
        <span class="verb">should not</span> use the construct, and
        that the construct may be removed in a later version of
        this specification.<span class="definition">]</span> All
        constructs that are <a title="deprecated" href=
        "index.html#dt-deprecated">deprecated</a> in this specification are
        also (as it happens) optional features that <a title=
        "implementation" href=
        "index.html#dt-implementation">implementations</a> are <span class=
        "verb">not required</span> to provide.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This working draft includes a non-normative XML Schema
          for XSLT <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a> (see
          <a href="index.html#schema-for-xslt"><i>G Schema for XSLT
          Stylesheets</i></a>). The syntax summaries described in
          this section are normative.</p>
        </div>

        <p>XSLT defines a set of standard functions which are
        additional to those defined in <a href=
        "index.html#xpath-functions">[Functions and Operators]</a>. The
        signatures of these functions are described using the same
        notation as used in <a href="index.html#xpath-functions">[Functions
        and Operators]</a>. The names of these functions are all in
        the <a title="standard function namespace" href=
        "index.html#dt-standard-function-namespace">standard function
        namespace</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="initiating" id="initiating"></a>2.3 Initiating
        a Transformation</h3>

        <p>This document does not specify any application
        programming interfaces or other interfaces for initiating a
        transformation. This section, however, describes the
        information that is supplied when a transformation is
        initiated. Except where otherwise indicated, the
        information is <span class="verb">required</span>.</p>

        <p>Implementations <span class="verb">may</span> allow a
        transformation to run as two or more phases, for example
        parsing, compilation and execution. Such a distinction is
        outside the scope of this specification, which treats
        transformation as a single process controlled using a set
        of <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet modules</a>, supplied in
        the form of XML documents.</p>

        <p>The following information is supplied to execute a
        transformation:</p>

        <ul>
          <li>
            <p>The <a title="stylesheet module" href=
            "index.html#dt-stylesheet-module">stylesheet module</a> that is
            to act as the <a title="principal stylesheet module"
            href="index.html#dt-principal-stylesheet-module">principal
            stylesheet module</a> for the transformation. The
            complete <a title="stylesheet" href=
            "index.html#dt-stylesheet">stylesheet</a> is assembled by
            recursively expanding the <a href=
            "index.html#element-import"><code>xsl:import</code></a> and
            <a href="index.html#element-include"><code>xsl:include</code></a>
            declarations in the principal stylesheet module, as
            described in <a href="index.html#include"><i>3.10.2 Stylesheet
            Inclusion</i></a> and <a href="index.html#import"><i>3.10.3
            Stylesheet Import</i></a>.</p>
          </li>

          <li>
            <p>A set (possibly empty) of values for <a title=
            "stylesheet parameter" href=
            "index.html#dt-stylesheet-parameter">stylesheet parameters</a>
            (see <a href="index.html#global-variables"><i>9.5 Global
            Variables and Parameters</i></a>). These values are
            available for use within <a title="expression" href=
            "index.html#dt-expression">expressions</a> in the <a title=
            "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>.</p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-initial-context-node" id="dt-initial-context-node"
            title="initial context node"></a>A node that acts as
            the <b>initial context node</b> for the transformation.
            This node is accessible within the <a title=
            "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> as
            the initial value of the XPath <a title="expression"
            href="index.html#dt-expression">expressions</a> <code>.</code>
            (dot) and <code>self::node()</code>, as described in
            <a href="index.html#focus"><i>5.4.3.1 Maintaining Position: the
            Focus</i></a><span class="definition">]</span>.</p>

            <p>If no initial context node is supplied, then the
            <a title="context item" href="index.html#dt-context-item">context
            item</a>, <a title="context position" href=
            "index.html#dt-context-position">context position</a>, and
            <a title="context size" href="index.html#dt-context-size">context
            size</a> will initially be undefined, and the
            evaluation of any expression that references these
            values will result in a dynamic error. (Note that the
            initial context size and context position will always
            be 1 (one) when an initial context node is supplied,
            and will be undefined if no initial context node is
            supplied).</p>
          </li>

          <li>
            <p>Optionally, the name of a <a title="named template"
            href="index.html#dt-named-template">named template</a> which is
            to be executed as the entry point to the
            transformation. This template <span class=
            "verb">must</span> exist within the <a title=
            "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>. If
            no named template is supplied, then the transformation
            starts with the <a title="template rule" href=
            "index.html#dt-template-rule">template rule</a> that best matches
            the <a title="initial context node" href=
            "index.html#dt-initial-context-node">initial context node</a>,
            according to the rules defined in <a href=
            "index.html#conflict"><i>6.4 Conflict Resolution for Template
            Rules</i></a>. Either a named template, or an initial
            context node, or both, <span class="verb">must</span>
            be supplied.</p>
          </li>

          <li>
            <p>Optionally, an initial <a title="mode" href=
            "index.html#dt-mode">mode</a>. <span>This <span class=
            "verb">must</span> either be the default mode, or a
            mode that is explicitly named in the <code>mode</code>
            attribute of an <a href=
            "index.html#element-template"><code>xsl:template</code></a>
            declaration within the stylesheet</span>. If an initial
            mode is supplied, then in searching for the <a title=
            "template rule" href="index.html#dt-template-rule">template
            rule</a> that best matches the <a title=
            "initial context node" href=
            "index.html#dt-initial-context-node">initial context node</a>,
            the processor considers only those rules that apply to
            the initial mode. If no initial mode is supplied, the
            <a title="default mode" href="index.html#dt-default-mode">default
            mode</a> is used.</p>
          </li>

          <li>
            <p>A base output URI. <span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-base-output-uri" id="dt-base-output-uri" title=
            "base output URI"></a> The <b>base output URI</b> is a
            URI to be used as the base URI when resolving a
            relative URI allocated to a <a title=
            "final result tree" href="index.html#dt-final-result-tree">final
            result tree</a>. If the transformation generates more
            than one final result tree, then typically each one
            will be allocated a URI relative to this base URI.
            <span class="definition">]</span> <span>The way in
            which a base output URI is established is <a title=
            "implementation-defined" href=
            "index.html#dt-implementation-defined">implementation-defined</a>.</span></p>
          </li>

          <li>
            <p>A mechanism for obtaining a document node and a
            media type, given an absolute URI. The total set of
            available documents (modeled as a mapping from URIs to
            document nodes) forms part of the context for
            evaluating XPath expressions, specifically the <a href=
            "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
            <small>FO</small></sup> function. The XSLT <a href=
            "index.html#function-document"><code>document</code></a> function
            additionally requires the media type of the resource
            representation, for use in interpreting any fragment
            identifier present within a URI Reference.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>The set of documents that are available to the
              stylesheet is <a title="implementation-dependent"
              href=
              "index.html#dt-implementation-dependent">implementation-dependent</a>,
              as is the processing that is carried out to construct
              a tree representing the resource retrieved using a
              given URI. Some possible ways of constructing a
              document (specifically, rules for constructing a
              document from an Infoset or from a PSVI) are
              described in <a href="index.html#xpath-datamodel">[Data
              Model]</a>.</p>
            </div>
          </li>
        </ul>

        <p><a name="err-XTDE0040" id="err-XTDE0040"><span class=
        "error">[ERR XTDE0040]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the invocation of the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> specifies a template
        name that does not match the <a title="expanded-QName"
        href="index.html#dt-expanded-qname">expanded-QName</a> of a named
        template defined in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>.</p>

        <p><a name="err-XTDE0045" id="err-XTDE0045"><span class=
        "error">[ERR XTDE0045]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the invocation of the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> specifies an initial
        <a title="mode" href="index.html#dt-mode">mode</a> (other than the
        default mode) that does not match the <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> in the
        <code>mode</code> attribute of any template defined in the
        <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>.</p>

        <p><a name="err-XTDE0047" id="err-XTDE0047"><span class=
        "error">[ERR XTDE0047]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the invocation of the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> specifies both an
        initial <a title="mode" href="index.html#dt-mode">mode</a> and an
        initial template.</p>

        <p><a name="err-XTDE0050" id="err-XTDE0050"><span class=
        "error">[ERR XTDE0050]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the stylesheet that is invoked declares a
        visible <a title="stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameter</a> with
        <code>required="yes"</code> and no value for this parameter
        is supplied during the invocation of the stylesheet. A
        stylesheet parameter is visible if it is not masked by
        another global variable or parameter with the same name and
        higher <a title="import precedence" href=
        "index.html#dt-import-precedence">import precedence</a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-initial-template" id="dt-initial-template" title=
        "initial template"></a>The transformation is performed by
        evaluating an <b>initial template</b>. If a <a title=
        "named template" href="index.html#dt-named-template">named
        template</a> is supplied when the transformation is
        initiated, then this is the initial template;
        <span>otherwise, the initial template is the <a title=
        "template rule" href="index.html#dt-template-rule">template rule</a>
        selected according to the rules of the <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction for processing the <a title=
        "initial context node" href=
        "index.html#dt-initial-context-node">initial context node</a> in the
        initial <a title="mode" href=
        "index.html#dt-mode">mode</a>.</span><span class=
        "definition">]</span></p>

        <p>Parameters passed to the transformation by the client
        application are matched against <a title=
        "stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameters</a> (see
        <a href="index.html#global-variables"><i>9.5 Global Variables and
        Parameters</i></a>), not against the <a title=
        "template parameter" href="index.html#dt-template-parameter">template
        parameters</a> declared within the <a title=
        "initial template" href="index.html#dt-initial-template">initial
        template</a>. All <a title="template parameter" href=
        "index.html#dt-template-parameter">template parameters</a> within the
        initial template to be executed will take their default
        values.</p>

        <p><a name="err-XTDE0060" id="err-XTDE0060"><span class=
        "error">[ERR XTDE0060]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="initial template" href=
        "index.html#dt-initial-template">initial template</a> defines a
        <a title="template parameter" href=
        "index.html#dt-template-parameter">template parameter</a> that
        specifies <code>required="yes"</code>.</p>

        <p>A <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> can process further source
        documents in addition to those supplied when the
        transformation is invoked. These additional documents can
        be loaded using the functions <a href=
        "index.html#function-document"><code>document</code></a> (see
        <a href="index.html#document"><i>16.1 Multiple Source
        Documents</i></a>) or <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
        <small>FO</small></sup> or <a href=
        "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
        collection</code></a><sup><small>FO</small></sup> (see
        <a href="index.html#xpath-functions">[Functions and Operators]</a>),
        or they can be supplied as <a title="stylesheet parameter"
        href="index.html#dt-stylesheet-parameter">stylesheet parameters</a>
        (see <a href="index.html#global-variables"><i>9.5 Global Variables
        and Parameters</i></a>), or as the result of an <a title=
        "extension function" href=
        "index.html#dt-extension-function">extension function</a> (see
        <a href="index.html#extension-functions"><i>18.1 Extension
        Functions</i></a>).</p>
      </div>

      <div class="div2">
        <h3><a name="executing-a-transformation" id=
        "executing-a-transformation"></a>2.4 Executing a
        Transformation</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-template-rule" id="dt-template-rule" title=
        "template rule"></a>A stylesheet contains a set of
        <b>template rules</b> (see <a href="index.html#rules"><i>6 Template
        Rules</i></a>). A template rule has three parts: a
        <a title="pattern" href="index.html#dt-pattern">pattern</a> that is
        matched against nodes, a (possibly empty) set of <a title=
        "template parameter" href="index.html#dt-template-parameter">template
        parameters</a>, and a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> that is
        evaluated to produce a sequence of items.<span class=
        "definition">]</span> In many cases these items are newly
        constructed nodes, which are then written to a <a title=
        "result tree" href="index.html#dt-result-tree">result tree</a>.</p>

        <p>A transformation as a whole is executed by evaluating
        the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> of the
        <a title="initial template" href=
        "index.html#dt-initial-template">initial template</a> as described in
        <a href="index.html#sequence-constructors"><i>5.7 Sequence
        Constructors</i></a>.</p>

        <p>If the initial template has an <code>as</code>
        attribute, then the result sequence of the initial template
        is checked against the required type in the same way as for
        any other template. If this result sequence is non-empty,
        then it is used to construct an implicit <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a>, following the rules described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>: the effect is as if the initial
        template <var>T</var> were called by an implicit template
        of the form:</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:template name="IMPLICIT"&gt;
  &lt;xsl:result-document href=""&gt;
    &lt;xsl:call-template name="T"/&gt;
  &lt;/xsl:result-document&gt;
&lt;/xsl:template&gt;
</pre>
        </div>

        <p>An implicit result tree is also created when the result
        sequence is empty, provided that no <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction has been evaluated during the course of the
        transformation. In this situation the implicit result tree
        will consist of a document node with no children.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This means that there is always at least one result
          tree. It also means that if the content of the initial
          template is a single <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction, as in the example above, then only one
          result tree is produced, not two. It is useful to make
          the result document explicit as this is the only way of
          invoking document-level validation.</p>

          <p>If the result of the initial template is non-empty,
          and an explicit <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction has been evaluated with the empty attribute
          <code>href=""</code>, then an error will occur
          <span class="error">[see <a href="index.html#err-XTDE1490">ERR
          XTDE1490</a>]</span>, since it is not possible to create
          two final result trees with the same URI.</p>
        </div>

        <p>A <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> is a
        sequence of sibling nodes in the stylesheet, each of which
        is either an <a title="XSLT instruction" href=
        "index.html#dt-xslt-instruction">XSLT instruction</a>, a <a title=
        "literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>, a
        text node, or an <a title="extension instruction" href=
        "index.html#dt-extension-instruction">extension instruction</a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-instruction" id="dt-instruction" title=
        "instruction"></a>An <b>instruction</b> is either an
        <a title="XSLT instruction" href=
        "index.html#dt-xslt-instruction">XSLT instruction</a> or an <a title=
        "extension instruction" href=
        "index.html#dt-extension-instruction">extension
        instruction</a>.<span class="definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-xslt-instruction" id="dt-xslt-instruction" title=
        "XSLT instruction"></a>An <b>XSLT instruction</b> is an
        <a title="XSLT element" href="index.html#dt-xslt-element">XSLT
        element</a> whose syntax summary in this specification
        contains the annotation <code>&lt;!-- category: instruction
        --&gt;</code>.<span class="definition">]</span></p>

        <p><a title="extension instruction" href=
        "index.html#dt-extension-instruction">Extension instructions</a> are
        described in <a href="index.html#extension-instruction"><i>18.2
        Extension Instructions</i></a>.</p>

        <p>The main categories of <a title="XSLT instruction" href=
        "index.html#dt-xslt-instruction">XSLT instruction</a> are as
        follows:</p>

        <ul>
          <li>
            <p>instructions that create new nodes: <span><a href=
            "index.html#element-document"><code>xsl:document</code></a></span>,
            <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href=
            "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>,
            <a href=
            "index.html#element-comment"><code>xsl:comment</code></a>,
            <a href=
            "index.html#element-value-of"><code>xsl:value-of</code></a>,
            <a href="index.html#element-text"><code>xsl:text</code></a>,
            <a href=
            "index.html#element-namespace"><code>xsl:namespace</code></a>;</p>
          </li>

          <li>
            <p>an instruction that returns an arbitrary sequence by
            evaluating an XPath expression: <a href=
            "index.html#element-sequence"><code>xsl:sequence</code></a>;</p>
          </li>

          <li>
            <p>instructions that cause conditional or repeated
            evaluation of nested instructions: <a href=
            "index.html#element-if"><code>xsl:if</code></a>, <a href=
            "index.html#element-choose"><code>xsl:choose</code></a>, <a href=
            "index.html#element-for-each"><code>xsl:for-each</code></a>,
            <a href=
            "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>;</p>
          </li>

          <li>
            <p>instructions that invoke templates: <a href=
            "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
            <a href=
            "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
            <a href=
            "index.html#element-call-template"><code>xsl:call-template</code></a>,
            <a href=
            "index.html#element-next-match"><code>xsl:next-match</code></a>;</p>
          </li>

          <li>
            <p>Instructions that declare variables: <a href=
            "index.html#element-variable"><code>xsl:variable</code></a>,
            <a href=
            "index.html#element-param"><code>xsl:param</code></a>;</p>
          </li>

          <li>
            <p>other specialized instructions: <a href=
            "index.html#element-number"><code>xsl:number</code></a>, <a href=
            "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>,
            <a href=
            "index.html#element-message"><code>xsl:message</code></a>,
            <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>.</p>
          </li>
        </ul>

        <p>Often, a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> will
        include an <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction, which selects a sequence of nodes to be
        processed. Each of the selected nodes is processed by
        searching the stylesheet for a matching <a title=
        "template rule" href="index.html#dt-template-rule">template rule</a>
        and evaluating the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> of that
        template rule. The resulting sequences of items are
        concatenated, in order, to give the result of the <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction, as described in <a href=
        "index.html#applying-templates"><i>6.3 Applying Template
        Rules</i></a>; this sequence is often added to a <a title=
        "result tree" href="index.html#dt-result-tree">result tree</a>. Since
        the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructors</a> of the
        selected <a title="template rule" href=
        "index.html#dt-template-rule">template rules</a> may themselves
        contain <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instructions, this results in a cycle of selecting nodes,
        identifying <a title="template rule" href=
        "index.html#dt-template-rule">template rules</a>, constructing
        sequences, and constructing <a title="result tree" href=
        "index.html#dt-result-tree">result trees</a>, that recurses through a
        <a title="source tree" href="index.html#dt-source-tree">source
        tree</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="context" id="context"></a>2.5 The Evaluation
        Context</h3>

        <p>The results of some expressions and instructions in a
        stylesheet may depend on information provided contextually.
        This context information is divided into two categories:
        the static context, which is known during static analysis
        of the stylesheet, and the dynamic context, which is not
        known until the stylesheet is evaluated. Although
        information in the static context is known at analysis
        time, it is sometimes used during stylesheet
        evaluation.</p>

        <p>Some context information can be set by means of
        declarations within the stylesheet itself. For example, the
        namespace bindings used for any XPath expression are
        determined by the namespace declarations present in
        containing elements in the stylesheet. Other information
        may be supplied externally or implicitly: an example is the
        current date and time.</p>

        <p>The context information used in processing an XSLT
        stylesheet includes as a subset all the context information
        required when evaluating XPath expressions. The XPath 2.0
        specification defines a static and dynamic context that the
        host language (in this case, XSLT) may initialize, which
        affects the results of XPath expressions used in that
        context. XSLT augments the context with additional
        information: this additional information is used firstly by
        XSLT constructs outside the scope of XPath (for example,
        the <a href="index.html#element-sort"><code>xsl:sort</code></a>
        element), and secondly, by functions that are defined in
        the XSLT specification (such as <a href=
        "index.html#function-key"><code>key</code></a> and <a href=
        "index.html#function-format-number"><code>format-number</code></a>)
        that are available for use in XPath expressions appearing
        within a stylesheet.</p>

        <p>The static context for an expression or other construct
        in a stylesheet is determined by the place in which it
        appears lexically. The details vary for different
        components of the static context, but in general, elements
        within a stylesheet module affect the static context for
        their descendant elements within the same stylesheet
        module.</p>

        <p>The dynamic context is maintained as a stack. When an
        instruction or expression is evaluated, it may add dynamic
        context information to the stack; when evaluation is
        complete, the dynamic context reverts to its previous
        state. An expression that accesses information from the
        dynamic context always uses the value at the top of the
        stack.</p>

        <p>The most commonly used component of the dynamic context
        is the <a title="context item" href=
        "index.html#dt-context-item">context item</a>. This is an implicit
        variable whose value is the item (it may be a node or an
        atomic value) currently being processed. The value of the
        context item can be referenced within an XPath expression
        using the expression <code>.</code> (dot).</p>

        <p>Full details of the static and dynamic context are
        provided in <a href="index.html#static-and-dynamic-context"><i>5.4
        The Static and Dynamic Context</i></a>.</p>
      </div>

      <div class="div2">
        <h3><a name="parsing-and-serialization" id=
        "parsing-and-serialization"></a>2.6 Parsing and
        Serialization</h3>

        <p>An XSLT <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> describes a process that
        constructs a set of <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result trees</a> from a set
        of <a title="source tree" href="index.html#dt-source-tree">source
        trees</a>.</p>

        <p>The <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> does not describe how a
        <a title="source tree" href="index.html#dt-source-tree">source
        tree</a> is constructed. <span>Some possible ways of
        constructing source trees are described in <a href=
        "index.html#xpath-datamodel">[Data Model]</a>.</span> Frequently an
        <a title="implementation" href=
        "index.html#dt-implementation">implementation</a> will operate in
        conjunction with an XML parser (or more strictly, in the
        terminology of <a href="index.html#REC-xml">[XML 1.0]</a>, an <em>XML
        processor</em>), to build a source tree from an input XML
        document. An implementation <span class="verb">may</span>
        also provide an application programming interface allowing
        the tree to be constructed directly, or allowing it to be
        supplied in the form of a DOM Document object (see <a href=
        "index.html#DOM-Level-2-Core">[DOM Level 2]</a>). This is outside the
        scope of this specification. Users should be aware,
        however, that since the input to the transformation is a
        tree conforming to the <span>XDM</span> data model as
        described in <a href="index.html#xpath-datamodel">[Data Model]</a>,
        constructs that might exist in the original XML document,
        or in the DOM, but which are not within the scope of the
        data model, cannot be processed by the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> and
        cannot be guaranteed to remain unchanged in the
        transformation output. Such constructs include CDATA
        section boundaries, the use of entity references, and the
        DOCTYPE declaration and internal DTD subset.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-serialization" id="dt-serialization" title=
        "serialization"></a>A frequent requirement is to output a
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> as an XML
        document (or in other formats such as HTML). This process
        is referred to as <b>serialization</b>.<span class=
        "definition">]</span></p>

        <p>Like parsing, serialization is not part of the
        transformation process, and it is not <span class=
        "verb">required</span> that an XSLT processor <span class=
        "verb">must</span> be able to perform serialization.
        However, for pragmatic reasons, this specification
        describes declarations (the <a href=
        "index.html#element-output"><code>xsl:output</code></a> element and
        the <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        declarations, see <a href="index.html#serialization"><i>20
        Serialization</i></a>), and attributes on the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction, that allow a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> to specify the desired
        properties of a serialized output file. <span>When
        serialization is not being performed, either because the
        implementation does not support the serialization option,
        or because the user is executing the transformation in a
        way that does not invoke serialization, then the content of
        the <a href="index.html#element-output"><code>xsl:output</code></a>
        and <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        declarations has no effect. Under these circumstances the
        processor <span class="verb">may</span> report any errors
        in an <a href="index.html#element-output"><code>xsl:output</code></a>
        or <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        declaration, or in the serialization attributes of <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>,</span>
        but is not <span class="verb">required</span> to do so.</p>
      </div>

      <div class="div2">
        <h3><a name="extensibility" id="extensibility"></a>2.7
        Extensibility</h3>

        <p>XSLT defines a number of features that allow the
        language to be extended by implementers, or, if
        implementers choose to provide the capability, by users.
        These features have been designed, so far as possible, so
        that they can be used without sacrificing interoperability.
        Extensions other than those explicitly defined in this
        specification are not permitted.</p>

        <p>These features are all based on XML namespaces;
        namespaces are used to ensure that the extensions provided
        by one implementer do not clash with those of a different
        implementer.</p>

        <p>The most common way of extending the language is by
        providing additional functions, which can be invoked from
        XPath expressions. These are known as <a title=
        "extension function" href=
        "index.html#dt-extension-function">extension functions</a>, and are
        described in <a href="index.html#extension-functions"><i>18.1
        Extension Functions</i></a>.</p>

        <p>It is also permissible to extend the language by
        providing new <a title="instruction" href=
        "index.html#dt-instruction">instructions</a>. These are referred to
        as <a title="extension instruction" href=
        "index.html#dt-extension-instruction">extension instructions</a>, and
        are described in <a href="index.html#extension-instruction"><i>18.2
        Extension Instructions</i></a>. A stylesheet that uses
        extension instructions must declare that it is doing so by
        using the <code>[xsl:]extension-element-prefixes</code>
        attribute.</p>

        <p>Extension instructions and extension functions defined
        according to these rules <span class="verb">may</span> be
        provided by the implementer of the XSLT processor, and the
        implementer <span class="verb">may</span> also provide
        facilities to allow users to create further extension
        instructions and extension functions.</p>

        <p>This specification defines how extension instructions
        and extension functions are invoked, but the facilities for
        creating new extension instructions and extension functions
        are <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>.
        For further details, see <a href="index.html#extension"><i>18
        Extensibility and Fallback</i></a>.</p>

        <p>The XSLT language can also be extended by the use of
        <a title="extension attribute" href=
        "index.html#dt-extension-attribute">extension attributes</a> (see
        <a href="index.html#extension-attributes"><i>3.3 Extension
        Attributes</i></a>), and by means of <a title=
        "user-defined data element" href=
        "index.html#dt-data-element">user-defined data elements</a> (see
        <a href="index.html#user-defined-top-level"><i>3.6.2 User-defined
        Data Elements</i></a>).</p>
      </div>

      <div class="div2">
        <h3><a name="stylesheets-and-schemas" id=
        "stylesheets-and-schemas"></a>2.8 Stylesheets and
        <span>XML</span> Schemas</h3>

        <p>An XSLT <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> can make use of information
        from a schema. An XSLT transformation can take place in the
        absence of a schema (and, indeed, in the absence of a DTD),
        but where the source document has undergone schema validity
        assessment, the XSLT processor has access to the type
        information associated with individual nodes, not merely to
        the untyped text.</p>

        <p>Information from a schema can be used both statically
        (when the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> is compiled), and
        dynamically (during evaluation of the stylesheet to
        transform a source document).</p>

        <p>There are places within a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, and within XPath <a title=
        "expression" href="index.html#dt-expression">expressions</a> and
        <a title="pattern" href="index.html#dt-pattern">patterns</a> in a
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>,
        where it is possible to refer to named type definitions in
        a schema, or to element and attribute declarations. For
        example, it is possible to declare the types expected for
        the parameters of a function. This is done using the
        <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-SequenceType">SequenceType</a><sup>
        <small>XP</small></sup> syntax defined in <a href=
        "index.html#xpath20">[XPath 2.0]</a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-schema-component" id="dt-schema-component" title=
        "schema component"></a>Type definitions and element and
        attribute declarations are referred to collectively as
        <b>schema components</b>.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-in-scope-schema-component" id=
        "dt-in-scope-schema-component" title=
        "in-scope schema component"></a>The <a title=
        "schema component" href="index.html#dt-schema-component">schema
        components</a> that may be referenced by name in a
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        are referred to as the <b>in-scope schema components</b>.
        This set is the same throughout all the modules of a
        stylesheet.<span class="definition">]</span></p>

        <p>The conformance rules for XSLT 2.0, defined in <a href=
        "index.html#conformance"><i>21 Conformance</i></a>, distinguish
        between a <a title="basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a> and a
        <a title="schema-aware XSLT processor" href=
        "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
        processor</a>. As the names suggest, a basic XSLT processor
        does not support the features of XSLT that require access
        to schema information, either statically or dynamically. A
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        that works with a basic XSLT processor will produce the
        same results with a schema-aware XSLT processor
        <span>provided that the source documents are untyped (that
        is, they are not validated against a schema). However, if
        source documents are validated against a schema then the
        results may be different from the case where they are not
        validated. Some constructs that work on untyped data may
        fail with typed data (for example, an attribute of type
        <code>xs:date</code> cannot be used as an argument of the
        <a href=
        "http://www.w3.org/TR/xpath-functions/#func-substring"><code>
        substring</code></a><sup><small>FO</small></sup> function)
        and other constructs may produce different results
        depending on the data type (for example, given the element
        <code>&lt;product price="10.00"
        discount="2.00"/&gt;</code>, the expression <code>@price gt
        @discount</code> will return true if the attributes have
        type <code>xs:decimal</code>, but will return false if they
        are untyped).</span></p>

        <p>There is a standard set of type definitions that are
        always available as <a title="in-scope schema component"
        href="index.html#dt-in-scope-schema-component">in-scope schema
        components</a> in every stylesheet. These are defined in
        <a href="index.html#built-in-types"><i>3.13 Built-in Types</i></a>.
        The set of built-in types varies between a <a title=
        "basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a> and a
        <a title="schema-aware XSLT processor" href=
        "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
        processor</a>.</p>

        <p>The remainder of this section describes facilities that
        are available only with a <a title=
        "schema-aware XSLT processor" href=
        "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
        processor</a>.</p>

        <p>Additional <a title="schema component" href=
        "index.html#dt-schema-component">schema components</a> (type
        definitions, element declarations, and attribute
        declarations) may be added to the <a title=
        "in-scope schema component" href=
        "index.html#dt-in-scope-schema-component">in-scope schema
        components</a> by means of the <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration in a stylesheet.</p>

        <p>The <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration may reference an external schema document by
        means of a URI, or it may contain an inline
        <code>xs:schema</code> element.</p>

        <p>It is only necessary to import a schema explicitly if
        <span>one or more of its <a title="schema component" href=
        "index.html#dt-schema-component">schema components</a> are referenced
        explicitly by name</span> in the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a>; it is not necessary
        to import a schema merely because the stylesheet is used to
        process a source document that has been assessed against
        that schema. It is possible to make use of the information
        resulting from schema assessment (for example, the fact
        that a particular attribute holds a date) even if no schema
        has been imported by the stylesheet.</p>

        <p>Further, importing a schema does not of itself say
        anything about the type of the source document that the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        is expected to process. The imported type definitions can
        be used for temporary nodes or for nodes on a <a title=
        "result tree" href="index.html#dt-result-tree">result tree</a> just
        as much as for nodes <span>in source documents. It is
        possible to make assertions about the type of an input
        document by means of tests within the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a>. For
        example:</span></p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e1763" id="d5e1763"></a>Example: Asserting
            the Required Type of the Source Document
          </div>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="document-node(schema-element(my:invoice))" priority="2"&gt;
. . .
&lt;/xsl:template&gt;

&lt;xsl:template match="document-node()" priority="1"&gt;
  &lt;xsl:message terminate="yes"&gt;Source document is not an invoice&lt;/xsl:message&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>This example will cause the transformation to fail
          with an error message unless the document element of the
          source document is valid against the top-level element
          declaration <code>my:invoice</code>, and has been
          annotated as such.</p>
        </div>

        <p>It is possible that a source document may contain nodes
        whose <a title="type annotation" href="index.html#dt-annotation">type
        annotation</a> is not one of the types imported by the
        stylesheet. This creates a potential problem because in the
        case of an expression such as <code>data(.) instance of
        xs:integer</code> the system needs to know whether the type
        named in the type annotation of the context node is derived
        by restriction from the type <code>xs:integer</code>. This
        information is not explicitly available in an <span>XDM
        tree</span>, as defined in <a href="index.html#xpath-datamodel">[Data
        Model]</a>. The implementation may choose one of several
        strategies for dealing with this situation:</p>

        <ol class="enumar">
          <li>
            <p>The processor may signal a <a title=
            "non-recoverable dynamic error" href=
            "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
            error</a> if a source document is found to contain a
            <a title="type annotation" href="index.html#dt-annotation">type
            annotation</a> that is not known to the processor.</p>
          </li>

          <li>
            <p>The processor may maintain additional metadata,
            beyond that described in <a href=
            "index.html#xpath-datamodel">[Data Model]</a>, that allows the
            source document to be processed as if all the necessary
            schema information had been imported using <a href=
            "index.html#element-import-schema"><code>xsl:import-schema</code></a>.
            Such metadata might be held in the data structure
            representing the source document itself, or it might be
            held in a system catalog or repository.</p>
          </li>

          <li>
            <p>The processor may be configured to use a fixed set
            of schemas, which are automatically used to validate
            all source documents before they can be supplied as
            input to a transformation. In this case it is
            impossible for a source document to have a <a title=
            "type annotation" href="index.html#dt-annotation">type
            annotation</a> that the processor is not aware of.</p>
          </li>

          <li>
            <p>The processor may be configured to treat the source
            document as if no schema processing had been performed,
            that is, effectively to strip all type annotations from
            elements and attributes on input, marking them instead
            as having type <span><code>xs:untyped</code></span> and
            <span><code>xs:untypedAtomic</code></span>
            respectively.</p>
          </li>
        </ol>

        <p>Where a stylesheet author chooses to make assertions
        about the types of nodes or of <a title="variable" href=
        "index.html#dt-variable">variables</a> and <a title="parameter" href=
        "index.html#dt-parameter">parameters</a>, it is possible for an XSLT
        processor to perform static analysis of the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> (that is,
        analysis in the absence of any source document). Such
        analysis <span class="verb">may</span> reveal errors that
        would otherwise not be discovered until the transformation
        is actually executed. An XSLT processor is not <span class=
        "verb">required</span> to perform such static
        type-checking. <span>Under some circumstances (see <a href=
        "index.html#errors"><i>2.9 Error Handling</i></a>) type errors that
        are detected early <span class="verb">may</span> be
        reported as static errors. In addition an implementation
        <span class="verb">may</span> report any condition found
        during static analysis as a warning, provided that this
        does not prevent the stylesheet being evaluated as
        described by this specification.</span></p>

        <p>A <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> can also control the
        <a title="type annotation" href="index.html#dt-annotation">type
        annotations</a> of nodes that it constructs in a <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a>, or in <a title="temporary tree" href=
        "index.html#dt-temporary-tree">temporary trees</a>. This can be done
        in a number of ways.</p>

        <ul>
          <li>
            <p>It is possible to request explicit validation of a
            complete document, that is, a tree rooted at a document
            node. This applies both to temporary trees constructed
            using the <a href=
            "index.html#element-document"><code>xsl:document</code></a> (or
            <a href="index.html#element-copy"><code>xsl:copy</code></a>)
            instruction and also to <a title="final result tree"
            href="index.html#dt-final-result-tree">final result trees</a>
            constructed using <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>.
            Validation is either strict or lax, as described in
            <a href="index.html#xmlschema-1">[XML Schema Part 1]</a>. If
            validation of a <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a> fails (strictly
            speaking, if the outcome of the validity assessment is
            <code>invalid</code>), then the transformation fails,
            but in all other cases, the element and attribute nodes
            of the tree will be annotated with the names of the
            types to which these nodes conform. These <a title=
            "type annotation" href="index.html#dt-annotation">type
            annotations</a> will be discarded if the result tree is
            serialized as an XML document, but they remain
            available when the result tree is passed to an
            application (perhaps another <a title="stylesheet"
            href="index.html#dt-stylesheet">stylesheet</a>) for further
            processing.</p>
          </li>

          <li>
            <p>It is also possible to validate individual element
            and attribute nodes as they are constructed. This is
            done using the <code>type</code> and
            <code>validation</code> attributes of the <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>, and
            <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>
            instructions, or the <code>xsl:type</code> and
            <code>xsl:validation</code> attributes of a literal
            result element.</p>
          </li>

          <li>
            <p>When elements, attributes, or document nodes are
            copied, either explicitly using the <a href=
            "index.html#element-copy"><code>xsl:copy</code></a> or <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>
            instructions, or implicitly when nodes in a sequence
            are attached to a new parent node, the options
            <code>validation="strip"</code> and
            <code>validation="preserve"</code> are available, to
            control whether existing <a title="type annotation"
            href="index.html#dt-annotation">type annotations</a> are to be
            retained or not.</p>
          </li>
        </ul>

        <p>When nodes in a <a title="temporary tree" href=
        "index.html#dt-temporary-tree">temporary tree</a> are validated, type
        information is available for use by operations carried out
        on the temporary tree, in the same way as for a source
        document that has undergone schema assessment.</p>

        <p>For details of how validation of element and attribute
        nodes works, see <a href="index.html#validation"><i>19.2
        Validation</i></a>.</p>
      </div>

      <div class="div2">
        <h3><a name="errors" id="errors"></a>2.9 Error
        Handling</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-static-error" id="dt-static-error" title=
        "static error"></a>An error that is detected by examining a
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        before execution starts (that is, before the source
        document and values of stylesheet parameters are available)
        is referred to as a <b>static error</b>.<span class=
        "definition">]</span></p>

        <p>Errors classified in this specification as static errors
        <span class="verb">must</span> be signaled by all
        implementations: that is, the <a title="processor" href=
        "index.html#dt-processor">processor</a> <span class=
        "verb">must</span> indicate that the error is present. A
        static error <span class="verb">must</span> be signaled
        even if it occurs in a part of the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> that is never
        evaluated. Static errors are never recoverable. After
        signaling a static error, a processor <span class=
        "verb">may</span> continue for the purpose of signaling
        additional errors, but it <span class="verb">must</span>
        eventually terminate abnormally without producing any
        <span><a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a></span>.</p>

        <p>There is an exception to this rule when the stylesheet
        specifies <a title="forwards-compatible behavior" href=
        "index.html#dt-forwards-compatible-behavior">forwards-compatible
        behavior</a> (see <a href="index.html#forwards"><i>3.9
        Forwards-Compatible Processing</i></a>).</p>

        <p>Generally, errors in the structure of the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>, or in
        the syntax of XPath <a title="expression" href=
        "index.html#dt-expression">expressions</a> contained in the
        stylesheet, are classified as <a title="static error" href=
        "index.html#dt-static-error">static errors</a>. Where this
        specification states that an element in the stylesheet
        <span class="verb">must</span> or <span class="verb">must
        not</span> appear in a certain position, or that it
        <span class="verb">must</span> or <span class="verb">must
        not</span> have a particular attribute, or that an
        attribute <span class="verb">must</span> or <span class=
        "verb">must not</span> have a value satisfying specified
        conditions, then any contravention of this rule is a static
        error unless otherwise specified.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-dynamic-error" id="dt-dynamic-error" title=
        "dynamic error"></a>An error that is not detected until a
        source document is being transformed is referred to as a
        <b>dynamic error</b>.<span class="definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-recoverable-error" id="dt-recoverable-error" title=
        "recoverable error"></a>Some dynamic errors are classed as
        <b>recoverable errors</b>. When a recoverable error occurs,
        this specification allows the processor either to signal
        the error (by reporting the error condition and terminating
        execution) or to take a defined recovery action and
        continue processing.<span class="definition">]</span> It is
        <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        whether the error is signaled or the recovery action is
        taken.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-optional-recovery-action" id=
        "dt-optional-recovery-action" title=
        "optional recovery action"></a>If an implementation chooses
        to recover from a <a title="recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a>, it
        <span class="verb">must</span> take the <b>optional
        recovery action</b> defined for that error condition in
        this specification.<span class="definition">]</span></p>

        <p>When the implementation makes the choice between
        signaling a dynamic error or recovering, it is not
        restricted in how it makes the choice; for example, it
        <span class="verb">may</span> provide options that can be
        set by the user. When an implementation chooses to recover
        from a dynamic error, it <span><span class=
        "verb">may</span></span> also take other action, such as
        logging a warning message.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-nonrec-dynamic-error" id="dt-nonrec-dynamic-error"
        title="non-recoverable dynamic error"></a>A <a title=
        "dynamic error" href="index.html#dt-dynamic-error">dynamic error</a>
        that is not recoverable is referred to as a
        <b>non-recoverable dynamic error</b>. When a
        non-recoverable dynamic error occurs, the <a title=
        "processor" href="index.html#dt-processor">processor</a> <span class=
        "verb">must</span> signal the error, and the transformation
        fails.<span class="definition">]</span></p>

        <p>Because different implementations may optimize execution
        of the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> in different ways, the
        detection of dynamic errors is to some degree <a title=
        "implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>.
        In cases where an implementation is able to produce the
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result trees</a> without
        evaluating a particular construct, the implementation is
        never <span class="verb">required</span> to evaluate that
        construct solely in order to determine whether doing so
        causes a dynamic error. For example, if a <a title=
        "variable" href="index.html#dt-variable">variable</a> is declared but
        never referenced, an implementation <span class=
        "verb">may</span> choose whether or not to evaluate the
        variable declaration, which means that if evaluating the
        variable declaration causes a dynamic error, some
        implementations will signal this error and others will
        not.</p>

        <p>There are some cases where this specification requires
        that a construct <span class="verb">must not</span> be
        evaluated: for example, the content of an <a href=
        "index.html#element-if"><code>xsl:if</code></a> instruction
        <span class="verb">must not</span> be evaluated if the test
        condition is false. This means that an implementation
        <span class="verb">must not</span> signal any dynamic
        errors that would arise if the construct were
        evaluated.</p>

        <p>An implementation <span class="verb">may</span> signal a
        <a title="dynamic error" href="index.html#dt-dynamic-error">dynamic
        error</a> before any source document is available, but only
        if it can determine that the error would be signaled for
        every possible source document and every possible set of
        parameter values. For example, some <a title="" href=
        "index.html#circularity">circularity</a> errors fall into this
        category: see <a href="index.html#circularity"><i>9.8 Circular
        Definitions</i></a>.</p>

        <p>The XPath specification states (see <a href=
        "http://www.w3.org/TR/xpath20/#id-kinds-of-errors">Section
        2.3.1 Kinds of Errors</a><sup><small>XP</small></sup>) that
        if any expression (at any level) can be evaluated during
        the analysis phase (because all its explicit operands are
        known and it has no dependencies on the dynamic context),
        then any error in performing this evaluation <span class=
        "verb">may</span> be reported as a static error. For XPath
        expressions used in an XSLT stylesheet, however, any such
        errors <span class="verb">must not</span> be reported as
        static errors in the stylesheet unless they would occur in
        every possible evaluation of that stylesheet; instead, they
        must be signaled as dynamic errors, and signaled only if
        the XPath expression is actually evaluated.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e2144" id="d5e2144"></a>Example: Errors in
            Constant Subexpressions
          </div>

          <p>An XPath processor may report statically that the
          expression <code>1 div 0</code> fails with a "divide by
          zero" error. But suppose this XPath expression occurs in
          an XSLT construct such as:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:choose&gt;
  &lt;xsl:when test="system-property('xsl:version') = '1.0'"&gt;
    &lt;xsl:value-of select="1 div 0"/&gt;
  &lt;/xsl:when&gt;
  &lt;xsl:otherwise&gt;
    &lt;xsl:value-of select="xs:double('INF')"/&gt;
  &lt;/xsl:otherwise&gt;
&lt;/xsl:choose&gt;
</pre>
          </div>

          <p>Then the XSLT processor must not report an error,
          because the relevant XPath construct appears in a context
          where it will never be executed by an XSLT 2.0 processor.
          (An XSLT 1.0 processor will execute this code
          successfully, returning positive infinity, because it
          uses double arithmetic rather than decimal
          arithmetic.)</p>
        </div>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-type-error" id="dt-type-error" title=
        "type errors"></a>Certain errors are classified as <b>type
        errors</b>. A type error occurs when the value supplied as
        input to an operation is of the wrong type for that
        operation, for example when an integer is supplied to an
        operation that expects a node.<span class=
        "definition">]</span> If a type error occurs in an
        instruction that is actually evaluated, then it
        <span class="verb">must</span> be signaled <span>in the
        same way as a <a title="non-recoverable dynamic error"
        href="index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a>. Alternatively, an implementation <span class=
        "verb">may</span> signal a type error during the analysis
        phase</span> in the same way as a <a title="static error"
        href="index.html#dt-static-error">static error</a>, even if it occurs
        in part of the stylesheet that is never evaluated, provided
        it can establish that execution of a particular construct
        would never succeed.</p>

        <p>It is <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        whether type errors are signaled statically.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e2186" id="d5e2186"></a>Example: A Type
            Error
          </div>

          <p>The following construct contains a type error, because
          <code>42</code> is not allowed as an operand of the
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction. An implementation <span class=
          "verb">may</span> optionally signal this as a static
          error, even though the offending instruction will never
          be evaluated, and the type error would therefore never be
          signaled as a dynamic error.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:if test="false()"&gt;
  &lt;xsl:apply-templates select="42"/&gt;
&lt;/xsl:if&gt;
</pre>
          </div>

          <p>On the other hand, in the following example it is not
          possible to determine statically whether the operand of
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          will have a suitable dynamic type. An implementation
          <span class="verb">may</span> produce a warning in such
          cases, but it <span class="verb">must not</span> treat it
          as an error.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="para"&gt;
  &lt;xsl:param name="p" as="item()"/&gt;
  &lt;xsl:apply-templates select="$p"/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>If more than one error arises, an implementation is not
        <span class="verb">required</span> to signal any errors
        other than the first one that it detects. It is <a title=
        "implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>
        which of the several errors is signaled. This applies both
        to static errors and to dynamic errors. An implementation
        is allowed to signal more than one error, but if any errors
        have been signaled, it <span class="verb">must not</span>
        finish as if the transformation were successful.</p>

        <p>When a transformation signals one or more dynamic
        errors, the final state of any persistent resources updated
        by the transformation is <a title=
        "implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>.
        Implementations are not <span class="verb">required</span>
        to restore such resources to their initial state. In
        particular, where a transformation produces multiple result
        documents, it is possible that one or more serialized
        result documents <span class="verb">may</span> be written
        successfully before the transformation terminates, but the
        application cannot rely on this behavior.</p>

        <p>Everything said above about error handling applies
        equally to errors in evaluating XSLT instructions, and
        errors in evaluating XPath <a title="expression" href=
        "index.html#dt-expression">expressions</a>. Static errors and dynamic
        errors may occur in both cases.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-serialization-error" id="dt-serialization-error" title=
        "serialization error"></a>If a transformation has
        successfully produced a <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a>, it is still
        possible that errors may occur in serializing the result
        tree. For example, it may be impossible to serialize the
        result tree using the encoding selected by the user. Such
        an error is referred to as a <b>serialization
        error</b>.<span class="definition">]</span> <span>If the
        processor performs serialization, then it <span class=
        "verb">must</span> do so as specified in <a href=
        "index.html#serialization"><i>20 Serialization</i></a>, and in
        particular it <span class="verb">must</span> signal any
        serialization errors that occur.</span></p>

        <p>Errors are identified by a QName. For errors defined in
        this specification, the namespace of the QName is always
        <code>http://www.w3.org/2005/xqt-errors</code> (and is
        therefore not given explicitly), while the local part is an
        8-character code in the form <var>PPSSNNNN</var>. Here
        <var>PP</var> is always <code>XT</code> (meaning XSLT), and
        <var>SS</var> is one of <code>SE</code> (static error),
        <code>DE</code> (dynamic error), <code>RE</code>
        (recoverable dynamic error), or <code>TE</code> (type
        error). Note that the allocation of an error to one of
        these categories is purely for convenience and carries no
        normative implications about the way the error is handled.
        Many errors, for example, can be reported either
        dynamically or statically.</p>

        <p>These error codes are used to label error conditions in
        this specification, and are summarized in <a href=
        "index.html#error-summary"><i>E Summary of Error Conditions</i></a>).
        They are provided primarily for ease of reference.
        Implementations <span class="verb">may</span> use these
        codes when signaling errors, but they are not <span class=
        "verb">required</span> to do so. An API specification,
        however, <span class="verb">may</span> require the use of
        error codes based on these QNames. Additional errors
        defined by an implementation (or by an application)
        <span class="verb">may</span> use QNames in an
        implementation-defined (or user-defined) namespace without
        risk of collision.</p>

        <p>Errors defined in the <a href="index.html#xpath20">[XPath 2.0]</a>
        and <a href="index.html#xpath-functions">[Functions and
        Operators]</a> specifications use QNames with a similar
        structure, in the same namespace. When errors occur in
        processing XPath expressions, an XSLT processor
        <span class="verb">should</span> use the original error
        code reported by the XPath processor, unless a more
        specific XSLT error code is available.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="stylesheet-structure" id=
      "stylesheet-structure"></a>3 Stylesheet Structure</h2>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-stylesheet-module" id="dt-stylesheet-module" title=
      "stylesheet module"></a>A <a title="stylesheet" href=
      "index.html#dt-stylesheet">stylesheet</a> consists of one or more
      <b>stylesheet modules</b>, each one forming all or part of an
      XML document.<span class="definition">]</span></p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>A stylesheet module is represented by an <span>XDM
        element node</span> (see <a href="index.html#xpath-datamodel">[Data
        Model]</a>). <span>In the case of a standard stylesheet
        module, this will be an <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> or
        <a href="index.html#element-transform"><code>xsl:transform</code></a>
        element. In the case of a simplified stylesheet module, it
        can be any element (not in the <a title="XSLT namespace"
        href="index.html#dt-xslt-namespace">XSLT namespace</a>) that has an
        <code>xsl:version</code> attribute.</span></p>

        <p>Although stylesheet modules will commonly be maintained
        in the form of documents conforming to XML 1.0 or XML 1.1,
        this specification does not mandate such a representation.
        As with <a title="source tree" href=
        "index.html#dt-source-tree">source trees</a>, the way in which
        stylesheet modules are constructed, from textual XML or
        otherwise, is outside the scope of this specification.</p>
      </div>

      <p>A stylesheet module is either a standard stylesheet module
      or a simplified stylesheet module:</p>

      <ul>
        <li>
          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-standard-stylesheet-module" id=
          "dt-standard-stylesheet-module" title=
          "standard stylesheet module"></a>A <b>standard stylesheet
          module</b> is a tree, or part of a tree, consisting of an
          <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> or
          <a href=
          "index.html#element-transform"><code>xsl:transform</code></a>
          element (see <a href="index.html#stylesheet-element"><i>3.6
          Stylesheet Element</i></a>) together with its descendant
          nodes and associated attributes and
          namespaces.<span class="definition">]</span></p>
        </li>

        <li>
          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-simplified-stylesheet-module" id=
          "dt-simplified-stylesheet-module" title=
          "simplified stylesheet module"></a>A <b>simplified
          stylesheet module</b> is a tree, or part of a tree,
          consisting of a <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>
          together with its descendant nodes and associated
          attributes and namespaces. This element is not itself in
          the XSLT namespace, but it <span class="verb">must</span>
          have an <code>xsl:version</code> attribute, which implies
          that it <span class="verb">must</span> have a namespace
          node that declares a binding for the XSLT namespace. For
          further details see <a href=
          "index.html#simplified-stylesheet"><i>3.7 Simplified Stylesheet
          Modules</i></a>. <span class="definition">]</span></p>
        </li>
      </ul>

      <p>Both forms of stylesheet module (standard and simplified)
      can exist either as an entire XML document, or embedded as
      part of another XML document, typically <span>but not
      necessarily</span> a source document that is to be processed
      using the stylesheet.</p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-standalone-stylesheet-module" id=
      "dt-standalone-stylesheet-module" title=
      "standalone stylesheet module"></a>A <b>standalone stylesheet
      module</b> is a stylesheet module that comprises the whole of
      an XML document.<span class="definition">]</span></p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-embedded-stylesheet-module" id=
      "dt-embedded-stylesheet-module" title=
      "embedded stylesheet module"></a>An <b>embedded stylesheet
      module</b> is a stylesheet module that is embedded within
      another XML document, typically the source document that is
      being transformed.<span class="definition">]</span> (see
      <a href="index.html#embedded"><i>3.11 Embedded Stylesheet
      Modules</i></a>).</p>

      <p>There are thus four kinds of stylesheet module:</p>

      <blockquote>
        <p>standalone standard stylesheet modules<br />
        standalone simplified stylesheet modules<br />
        embedded standard stylesheet modules<br />
        embedded simplified stylesheet modules</p>
      </blockquote>

      <div class="div2">
        <h3><a name="xslt-namespace" id="xslt-namespace"></a>3.1
        XSLT Namespace</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-xslt-namespace" id="dt-xslt-namespace" title=
        "XSLT namespace"></a>The <b>XSLT namespace</b> has the URI
        <code>http://www.w3.org/1999/XSL/Transform</code>. It is
        used to identify elements, attributes, and other names that
        have a special meaning defined in this
        specification.<span class="definition">]</span></p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The <code>1999</code> in the URI indicates the year in
          which the URI was allocated by the W3C. It does not
          indicate the version of XSLT being used, which is
          specified by attributes (see <a href=
          "index.html#stylesheet-element"><i>3.6 Stylesheet Element</i></a>
          and <a href="index.html#simplified-stylesheet"><i>3.7 Simplified
          Stylesheet Modules</i></a>).</p>
        </div>

        <p>XSLT <a title="processor" href=
        "index.html#dt-processor">processors</a> <span class=
        "verb">must</span> use the XML namespaces mechanism
        <a href="index.html#REC-xml-names">[Namespaces in XML 1.0]</a> to
        recognize elements and attributes from this namespace.
        Elements from the XSLT namespace are recognized only in the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        and not in the source document. The complete list of
        XSLT-defined elements is specified in <a href=
        "index.html#element-syntax-summary"><i>D Element Syntax
        Summary</i></a>. <a title="implementation" href=
        "index.html#dt-implementation">Implementations</a> <span class=
        "verb">must not</span> extend the XSLT namespace with
        additional elements or attributes. Instead, any extension
        <span class="verb">must</span> be in a separate namespace.
        Any namespace that is used for additional instruction
        elements <span class="verb">must</span> be identified by
        means of the <a title="extension instruction" href=
        "index.html#dt-extension-instruction">extension instruction</a>
        mechanism specified in <a href=
        "index.html#extension-instruction"><i>18.2 Extension
        Instructions</i></a>.</p>

        <p>This specification uses a prefix of <code>xsl:</code>
        for referring to elements in the XSLT namespace. However,
        XSLT stylesheets are free to use any prefix, provided that
        there is a namespace declaration that binds the prefix to
        the URI of the XSLT namespace.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Throughout this specification, an element or attribute
          that is in no namespace, or an <a title="expanded-QName"
          href="index.html#dt-expanded-qname">expanded-QName</a> whose
          namespace part is an empty sequence, is referred to as
          having a <b>null namespace URI</b>.</p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The conventions used for the names of <a title=
          "XSLT element" href="index.html#dt-xslt-element">XSLT elements</a>,
          attributes and functions are that names are all
          lower-case, use hyphens to separate words, and use
          abbreviations only if they already appear in the syntax
          of a related language such as XML or HTML. Names of types
          defined in XML Schema however, are regarded as single
          words and are capitalized exactly as in XML Schema. This
          sometimes leads to composite function names such as
          <a href=
          "http://www.w3.org/TR/xpath-functions/#func-current-dateTime">
          <code>current-dateTime</code></a><sup><small>FO</small></sup>.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="reserved-namespaces" id=
        "reserved-namespaces"></a>3.2 Reserved Namespaces</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-reserved-namespace" id="dt-reserved-namespace" title=
        "reserved namespace"></a>The XSLT namespace, together with
        certain other namespaces recognized by an XSLT processor,
        are classified as <b>reserved namespaces</b> and
        <span class="verb">must</span> be used only as specified in
        this and related specifications.<span class=
        "definition">]</span> The reserved namespaces are those
        listed below.</p>

        <ul>
          <li>
            <p>The <a title="XSLT namespace" href=
            "index.html#dt-xslt-namespace">XSLT namespace</a>, described in
            <a href="index.html#xslt-namespace"><i>3.1 XSLT
            Namespace</i></a>, is reserved.</p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-standard-function-namespace" id=
            "dt-standard-function-namespace" title=
            "standard function namespace"></a>The <b>standard
            function namespace</b>
            <code>http://www.w3.org/2005/xpath-functions</code> is
            used for functions in the function library defined in
            <a href="index.html#xpath-functions">[Functions and
            Operators]</a> and standard functions defined in this
            specification.<span class="definition">]</span></p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "xml-namespace" id="xml-namespace" title=
            "XML namespace"></a>The <b>XML namespace</b>,
            <span>defined in <a href="index.html#REC-xml-names">[Namespaces
            in XML 1.0]</a> as
            <code>http://www.w3.org/XML/1998/namespace</code></span>,
            is used for attributes such as <code>xml:lang</code>,
            <code>xml:space</code>, and
            <code>xml:id</code>.<span class=
            "definition">]</span></p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-schema-namespace" id="dt-schema-namespace" title=
            "schema namespace"></a>The <b>schema namespace</b>
            <code>http://www.w3.org/2001/XMLSchema</code> is used
            as defined in <a href="index.html#xmlschema-1">[XML Schema Part
            1]</a> <span class="definition">]</span>. In a
            <a title="stylesheet" href=
            "index.html#dt-stylesheet">stylesheet</a> this namespace may be
            used to refer to built-in schema datatypes and to the
            constructor functions associated with those
            datatypes.</p>
          </li>

          <li>
            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-schema-instance-namespace" id=
            "dt-schema-instance-namespace" title=
            "schema instance namespace"></a>The <b>schema instance
            namespace</b>
            <code>http://www.w3.org/2001/XMLSchema-instance</code>
            is used as defined in <a href="index.html#xmlschema-1">[XML
            Schema Part 1]</a> <span class="definition">]</span>.
            Attributes in this namespace, if they appear in a
            <a title="stylesheet" href=
            "index.html#dt-stylesheet">stylesheet</a>, are treated by the
            XSLT processor in the same way as any other
            attributes.</p>
          </li>
        </ul>

        <p>Reserved namespaces may be used without restriction to
        refer to the names of elements and attributes in source
        documents and result documents. As far as the XSLT
        processor is concerned, reserved namespaces other than the
        XSLT namespace may be used without restriction in the names
        of <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result elements</a>
        and <a title="user-defined data element" href=
        "index.html#dt-data-element">user-defined data elements</a>, and in
        the names of attributes of literal result elements or of
        <a title="XSLT element" href="index.html#dt-xslt-element">XSLT
        <span>elements</span></a>: but other processors
        <span class="verb">may</span> impose restrictions or attach
        special meaning to them. Reserved namespaces <span class=
        "verb">must not</span> be used, however, in the names of
        stylesheet-defined objects such as <a title="variable"
        href="index.html#dt-variable">variables</a> and <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet functions</a>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>With the exception of the XML namespace, any of the
          above namespaces that are used in a stylesheet must be
          explicitly declared with a namespace declaration.
          Although conventional prefixes are used for these
          namespaces in this specification, any prefix may be used
          in a user stylesheet.</p>
        </div>

        <p><a name="err-XTSE0080" id="err-XTSE0080"><span class=
        "error">[ERR XTSE0080]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> to
        use a <a title="reserved namespace" href=
        "index.html#dt-reserved-namespace">reserved namespace</a> in the name
        of a <a title="named template" href=
        "index.html#dt-named-template">named template</a>, a <a title="mode"
        href="index.html#dt-mode">mode</a>, an <a title="attribute set" href=
        "index.html#dt-attribute-set">attribute set</a>, a <a title="key"
        href="index.html#dt-key">key</a>, a <a title="decimal format" href=
        "index.html#dt-decimal-format">decimal-format</a>, a <a title=
        "variable" href="index.html#dt-variable">variable</a> or <a title=
        "parameter" href="index.html#dt-parameter">parameter</a>, a <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a>, a named
        <a title="output definition" href=
        "index.html#dt-output-definition">output definition</a>, or a
        <a title="character map" href="index.html#dt-character-map">character
        map</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="extension-attributes" id=
        "extension-attributes"></a>3.3 Extension Attributes</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-extension-attribute" id="dt-extension-attribute" title=
        "extension attribute"></a>An element from the XSLT
        namespace may have any attribute not from the XSLT
        namespace, provided that the <a title="expanded-QName"
        href="index.html#dt-expanded-qname">expanded-QName</a> (see <a href=
        "index.html#xpath20">[XPath 2.0]</a>) of the attribute has a non-null
        namespace URI. These attributes are referred to as
        <b>extension attributes</b>.<span class=
        "definition">]</span> The presence of an extension
        attribute <span class="verb">must not</span> cause the
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result trees</a> produced by
        the transformation to be different from the result trees
        that a conformant XSLT 2.0 processor might produce. They
        <span class="verb">must not</span> cause the processor to
        fail to signal an error that a conformant processor is
        required to signal. This means that an extension attribute
        <span class="verb">must not</span> change the effect of any
        <a title="instruction" href=
        "index.html#dt-instruction">instruction</a> except to the extent that
        the effect is <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a> or
        <a title="implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>.</p>

        <p>Furthermore, if serialization is performed using one of
        the serialization methods <code>xml</code>,
        <code>xhtml</code>, <code>html</code>, or <code>text</code>
        described in <a href="index.html#serialization"><i>20
        Serialization</i></a>, the presence of an extension
        attribute must not cause the serializer to behave in a way
        that is inconsistent with the mandatory provisions of that
        specification.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p><a title="extension attribute" href=
          "index.html#dt-extension-attribute">Extension attributes</a> may be
          used to modify the behavior of <a title=
          "extension function" href=
          "index.html#dt-extension-function">extension functions</a> and
          <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instructions</a>.
          They may be used to select processing options in cases
          where the specification leaves the behavior <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          or <a title="implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>.
          They may also be used for optimization hints, for
          diagnostics, or for documentation.</p>

          <p><a title="extension attribute" href=
          "index.html#dt-extension-attribute">Extension attributes</a>
          <span class="verb">may</span> also be used to influence
          the behavior of the serialization methods
          <code>xml</code>, <code>xhtml</code>, <code>html</code>,
          or <code>text</code>, to the extent that the behavior of
          the serialization method is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          or <a title="implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>.
          For example, an extension attribute might be used to
          define the amount of indentation to be used when
          <code>indent="yes"</code> is specified. If a
          serialization method other than one of these four is
          requested (using a prefixed QName in the method
          parameter) then extension attributes may influence its
          behavior in arbitrary ways. Extension attributes
          <span class="verb">must not</span> be used to cause the
          four standard serialization methods to behave in a
          non-conformant way, for example by failing to report
          serialization errors that a serializer is <span class=
          "verb">required</span> to report. An implementation that
          wishes to provide such options must create a new
          serialization method for the purpose.</p>

          <p>An implementation that does not recognize the name of
          an extension attribute, or that does not recognize its
          value, <span class="verb">must</span> perform the
          transformation as if the extension attribute were not
          present. As always, it is permissible to produce warning
          messages.</p>

          <p>The namespace used for an extension attribute will be
          copied to the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a> in the normal way if it
          is in scope for a <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>.
          This can be prevented using the
          <code>[xsl:]exclude-result-prefixes</code> attribute.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e2801" id="d5e2801"></a>Example: An
            Extension Attribute for <code>xsl:message</code>
          </div>

          <p>The following code might be used to indicate to a
          particular implementation that the <a href=
          "index.html#element-message"><code>xsl:message</code></a>
          instruction is to ask the user for confirmation before
          continuing with the transformation:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:message
    abc:pause="yes"
    xmlns:abc="http://vendor.example.com/xslt/extensions"&gt;Phase 1 complete&lt;/xsl:message&gt;
</pre>
          </div>

          <p>Implementations that do not recognize the namespace
          <code>http://vendor.example.com/xslt/extensions</code>
          will simply ignore the extra attribute, and evaluate the
          <a href="index.html#element-message"><code>xsl:message</code></a>
          instruction in the normal way.</p>
        </div>

        <p><a name="err-XTSE0090" id="err-XTSE0090"><span class=
        "error">[ERR XTSE0090]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> for
        an element from the XSLT namespace to have an attribute
        whose namespace is either null (that is, an attribute with
        an unprefixed name) or the XSLT namespace, other than
        attributes defined for the element in this document.</p>
      </div>

      <div class="div2">
        <h3><a name="xslt-media-type" id="xslt-media-type"></a>3.4
        XSLT Media Type</h3>

        <p>The media type <code>application/xslt+xml</code> will be
        registered for XSLT stylesheet modules.</p>

        <p>The proposed definition of the media type is at <a href=
        "index.html#xslt-mime-definition"><i>B The XSLT Media
        Type</i></a></p>

        <p>This media type <span class="verb">should</span> be used
        for an XML document containing a <a title=
        "standard stylesheet module" href=
        "index.html#dt-standard-stylesheet-module">standard stylesheet
        module</a> at its top level, and it <span class=
        "verb">may</span> also be used for a <a title=
        "simplified stylesheet module" href=
        "index.html#dt-simplified-stylesheet-module">simplified stylesheet
        module</a>. It <span class="verb">should not</span> be used
        for an XML document containing an <a title=
        "embedded stylesheet module" href=
        "index.html#dt-embedded-stylesheet-module">embedded stylesheet
        module</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="standard-attributes" id=
        "standard-attributes"></a>3.5 Standard Attributes</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-standard-attributes" id="dt-standard-attributes" title=
        "standard attributes"></a>There are a number of <b>standard
        attributes</b> that may appear on any <a title=
        "XSLT element" href="index.html#dt-xslt-element">XSLT element</a>:
        specifically <code>version</code>,
        <code>exclude-result-prefixes</code>,
        <code>extension-element-prefixes</code>,
        <code>xpath-default-namespace</code><span>,
        <code>default-collation</code>, and
        <code>use-when</code>.</span><span class=
        "definition">]</span></p>

        <p>These attributes may also appear on a <a title=
        "literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>,
        but in this case, to distinguish them from user-defined
        attributes, the names of the attributes are in the
        <a title="XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
        namespace</a>. They are thus typically written as
        <code>xsl:version</code>,
        <code>xsl:exclude-result-prefixes</code>,
        <code>xsl:extension-element-prefixes</code>,
        <code>xsl:xpath-default-namespace</code><span>,
        <code>xsl:default-collation</code>, or
        <code>xsl:use-when</code></span>.</p>

        <p>It is <span class="verb">recommended</span> that all
        these attributes should also be permitted on <a title=
        "extension instruction" href=
        "index.html#dt-extension-instruction">extension instructions</a>, but
        this is at the discretion of the implementer of each
        extension instruction. They <span class="verb">may</span>
        also be permitted on <a title="user-defined data element"
        href="index.html#dt-data-element">user-defined data elements</a>,
        though they will only have any useful effect in the case of
        data elements that are designed to behave like XSLT
        declarations or instructions.</p>

        <p>In the following descriptions, these attributes are
        referred to generically as <code>[xsl:]version</code>, and
        so on.</p>

        <p>These attributes all affect the element they appear on,
        <span>together with any elements and attributes that have
        that element as an ancestor</span>. The two forms with and
        without the XSLT namespace have the same effect; the XSLT
        namespace is used for the attribute if and only if its
        parent element is <em>not</em> in the XSLT namespace.</p>

        <p>In the case of <code>[xsl:]version</code>,
        <code>[xsl:]xpath-default-namespace</code>, and
        <code>[xsl:]default-collation</code>, the value can be
        overridden by a different value for the same attribute
        appearing on a descendant element. The effective value of
        the attribute for a particular stylesheet element is
        determined by the innermost <span>ancestor-or-self</span>
        element on which the attribute appears.</p>

        <p>In an <a title="embedded stylesheet module" href=
        "index.html#dt-embedded-stylesheet-module">embedded stylesheet
        module</a>, <a title="standard attributes" href=
        "index.html#dt-standard-attributes">standard attributes</a> appearing
        on ancestors of the outermost element of the stylesheet
        module have no effect.</p>

        <p>In the case of
        <code>[xsl:]exclude-result-prefixes</code> and
        <code>[xsl:]extension-element-prefixes</code> the values
        are cumulative. For these attributes, the value is given as
        a whitespace-separated list of namespace prefixes, and the
        effective value for an element is the combined set of
        namespace URIs designated by the prefixes that appear in
        this attribute for that element and any of its ancestor
        elements. Again, the two forms with and without the XSLT
        namespace are equivalent.</p>

        <p>The effect of the <code>[xsl:]use-when</code> attribute
        is described in <a href="index.html#conditional-inclusion"><i>3.12
        Conditional Element Inclusion</i></a>.</p>

        <p>Because these attributes may appear on any <a title=
        "XSLT element" href="index.html#dt-xslt-element">XSLT element</a>,
        they are not listed in the syntax summary of each
        individual element. Instead they are listed and described
        in the entry for the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> and
        <a href="index.html#element-transform"><code>xsl:transform</code></a>
        elements only. This reflects the fact that these attributes
        are often used on the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element only, in which case they apply to the entire
        <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet module</a>.</p>

        <p>Note that the effect of these attributes does
        <em>not</em> extend to <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet modules</a> referenced
        by <a href="index.html#element-include"><code>xsl:include</code></a>
        or <a href="index.html#element-import"><code>xsl:import</code></a>
        declarations.</p>

        <p>For the detailed effect of each attribute, see the
        following sections:</p>

        <dl>
          <dt class="label"><code>[xsl:]version</code></dt>

          <dd>
            <p>see <a href="index.html#backwards"><i>3.8 Backwards-Compatible
            Processing</i></a> and <a href="index.html#forwards"><i>3.9
            Forwards-Compatible Processing</i></a></p>
          </dd>

          <dt class="label">
          <code>[xsl:]xpath-default-namespace</code></dt>

          <dd>
            <p>see <a href="index.html#unprefixed-qnames"><i>5.2 Unprefixed
            QNames in Expressions and Patterns</i></a></p>
          </dd>

          <dt class="label">
          <code>[xsl:]exclude-result-prefixes</code></dt>

          <dd>
            <p>see <a href="index.html#lre-namespaces"><i>11.1.3 Namespace
            Nodes for Literal Result Elements</i></a></p>
          </dd>

          <dt class="label">
          <code>[xsl:]extension-element-prefixes</code></dt>

          <dd>
            <p>see <a href="index.html#extension-instruction"><i>18.2
            Extension Instructions</i></a></p>
          </dd>

          <dt class="label"><code>[xsl:]use-when</code></dt>

          <dd>
            <p>see <a href="index.html#conditional-inclusion"><i>3.12
            Conditional Element Inclusion</i></a></p>
          </dd>

          <dt class="label">
          <code>[xsl:]default-collation</code></dt>

          <dd>
            <p>see <a href="index.html#default-collation-attribute"><i>3.6.1
            The default-collation attribute</i></a></p>
          </dd>
        </dl>
      </div>

      <div class="div2">
        <h3><a name="stylesheet-element" id=
        "stylesheet-element"></a>3.6 Stylesheet Element</h3>

        <p class="element-syntax"><a name="element-stylesheet" id=
        "element-stylesheet"></a><code>&lt;xsl:stylesheet<br />
        &#160;&#160;id? = <var>id</var><br />
        &#160;&#160;extension-element-prefixes? =
        <var>tokens</var><br />
        &#160;&#160;exclude-result-prefixes? =
        <var>tokens</var><br />
        &#160;&#160;<b>version</b> = <var>number</var><br />
        &#160;&#160;xpath-default-namespace? = <var>uri</var><br />
        &#160;&#160;default-validation? = "preserve" |
        "strip"<br />
        &#160;&#160;default-collation? = <var>uri-list</var><br />
        &#160;&#160;input-type-annotations? = "preserve" | "strip"
        | "unspecified"&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-import">xsl:import</a>*,
        <var>other-declarations</var>) --&gt;<br />
        &lt;/xsl:stylesheet&gt;</code></p>

        <p class="element-syntax"><a name="element-transform" id=
        "element-transform"></a><code>&lt;xsl:transform<br />
        &#160;&#160;id? = <var>id</var><br />
        &#160;&#160;extension-element-prefixes? =
        <var>tokens</var><br />
        &#160;&#160;exclude-result-prefixes? =
        <var>tokens</var><br />
        &#160;&#160;<b>version</b> = <var>number</var><br />
        &#160;&#160;xpath-default-namespace? = <var>uri</var><br />
        &#160;&#160;default-validation? = "preserve" |
        "strip"<br />
        &#160;&#160;default-collation? = <var>uri-list</var><br />
        &#160;&#160;input-type-annotations? = "preserve" | "strip"
        | "unspecified"&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-import">xsl:import</a>*,
        <var>other-declarations</var>) --&gt;<br />
        &lt;/xsl:transform&gt;</code></p>

        <p>A stylesheet module is represented by an <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element in an XML document. <a href=
        "index.html#element-transform"><code>xsl:transform</code></a> is
        allowed as a synonym for <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>;
        everything this specification says about the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element applies equally to <a href=
        "index.html#element-transform"><code>xsl:transform</code></a>.</p>

        <p>An <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element <span class="verb">must</span> have a
        <code>version</code> attribute, indicating the version of
        XSLT that the stylesheet <span>module</span> requires.</p>

        <p><a name="err-XTSE0110" id="err-XTSE0110"><span class=
        "error">[ERR XTSE0110]</span></a> The value of the
        <code>version</code> attribute <span class=
        "verb">must</span> be a number: specifically, it
        <span class="verb">must</span> be a <span>a valid instance
        of the type <code>xs:decimal</code> as defined in <a href=
        "index.html#xmlschema-2">[XML Schema Part 2]</a></span>. For this
        version of XSLT, the value <span class="verb">should</span>
        normally be <code>2.0</code>. A value of <code>1.0</code>
        indicates that the stylesheet module was written with the
        intention that it <span class="verb">should</span> be
        processed using an XSLT 1.0 processor.</p>

        <p>If a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> that specifies
        <code>[xsl:]version="1.0"</code> in the outermost element
        of the <a title="principal stylesheet module" href=
        "index.html#dt-principal-stylesheet-module">principal stylesheet
        module</a> (that is, <code>version="1.0"</code> in the case
        of a <a title="standard stylesheet module" href=
        "index.html#dt-standard-stylesheet-module">standard stylesheet
        module</a>, or <code>xsl:version="1.0"</code> in the case
        of a <a title="simplified stylesheet module" href=
        "index.html#dt-simplified-stylesheet-module">simplified stylesheet
        module</a>) is submitted to an XSLT 2.0 processor, the
        processor <span class="verb">should</span> output a warning
        advising the user of possible incompatibilities, unless the
        user has requested otherwise. The processor <span class=
        "verb">must</span> then process the stylesheet using the
        rules for <a title="backwards compatible behavior" href=
        "index.html#dt-backwards-compatible-behavior">backwards-compatible
        behavior</a>. These rules require that if the processor
        does not support <a title="backwards compatible behavior"
        href=
        "index.html#dt-backwards-compatible-behavior">backwards-compatible
        behavior</a>, it <span class="verb">must</span> signal an
        error and <span class="verb">must not</span> execute the
        transformation.</p>

        <p>When the value of the <code>version</code> attribute is
        greater than 2.0, <a title="forwards-compatible behavior"
        href="index.html#dt-forwards-compatible-behavior">forwards-compatible
        behavior</a> is enabled (see <a href="index.html#forwards"><i>3.9
        Forwards-Compatible Processing</i></a>).</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>XSLT 1.0 allowed the <code>[xsl:]version</code>
          attribute to take any numeric value, and specified that
          if the value was not equal to 1.0, the <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> would
          be executed in forwards compatible mode. XSLT 2.0
          continues to allow the attribute to take any unsigned
          decimal value. A software product that includes both an
          XSLT 1.0 processor and an XSLT 2.0 processor (or that can
          execute as either) may use the <code>[xsl:]version</code>
          attribute to decide which processor to invoke; such
          behavior is outside the scope of this specification. When
          the stylesheet is executed with an XSLT 2.0 processor,
          the value <code>1.0</code> is taken to indicate that the
          stylesheet <span>module</span> was written with XSLT 1.0
          in mind: if this value appears on the outermost element
          of the principal stylesheet module then an XSLT 2.0
          processor will either reject the stylesheet or execute it
          in backwards compatible mode, as described above. Setting
          <code>version="2.0"</code> indicates that the <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> is to
          be executed with neither backwards nor forwards
          compatible behavior enabled. Any other value less than
          <code>2.0</code> enables backwards compatible behavior,
          while any value greater than <code>2.0</code> enables
          forwards compatible behavior.</p>

          <p>When developing a <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> that is designed to
          execute under either XSLT 1.0 or XSLT 2.0, the
          recommended practice is to create two alternative
          <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a>, one
          specifying <code>version="1.0"</code>, and the other
          specifying <code>version="2.0"</code>; these modules can
          use <a href=
          "index.html#element-include"><code>xsl:include</code></a> or
          <a href="index.html#element-import"><code>xsl:import</code></a> to
          incorporate the common code. When running under an XSLT
          1.0 processor, the <code>version="1.0"</code> module can
          be selected as the <a title="principal stylesheet module"
          href="index.html#dt-principal-stylesheet-module">principal
          stylesheet module</a>; when running under an XSLT 2.0
          processor, the <code>version="2.0"</code> module can be
          selected as the <a title="principal stylesheet module"
          href="index.html#dt-principal-stylesheet-module">principal
          stylesheet module</a>. Stylesheet modules that are
          included or imported should specify
          <code>version="2.0"</code> if they make use of XSLT 2.0
          facilities, and <code>version="1.0"</code> otherwise.</p>
        </div>

        <p>The effect of the <code>input-type-annotations</code>
        attribute is described in <a href=
        "index.html#stripping-annotations"><i>4.3 Stripping Type Annotations
        from a Source Tree</i></a>.</p>

        <p>The <code>default-validation</code> attribute defines
        the default value of the <code>validation</code> attribute
        of all <span><a href=
        "index.html#element-document"><code>xsl:document</code></a></span>,
        <a href="index.html#element-element"><code>xsl:element</code></a>,
        <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>,
        <a href="index.html#element-copy"><code>xsl:copy</code></a>, <a href=
        "index.html#element-copy-of"><code>xsl:copy-of</code></a>, and
        <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instructions, and of the <code>xsl:validation</code>
        attribute of all <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result elements</a>.
        It also determines the validation applied to the implicit
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> created in
        the absence of an <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction. This default applies within the <a title=
        "stylesheet module" href="index.html#dt-stylesheet-module">stylesheet
        module</a>: it does not extend to included or imported
        stylesheet modules. If the attribute is omitted, the
        default is <code>strip</code>. <span>The permitted values
        are <code>preserve</code> and <code>strip</code>.</span>
        For details of the effect of this attribute, see <a href=
        "index.html#validation"><i>19.2 Validation</i></a>.</p>

        <p><a name="err-XTSE0120" id="err-XTSE0120"><span class=
        "error">[ERR XTSE0120]</span></a> An <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element <span class="verb">must not</span> have any text
        node children. (This rule applies after stripping of
        <a title="whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text nodes</a> as
        described in <a href="index.html#stylesheet-stripping"><i>4.2
        Stripping Whitespace from the Stylesheet</i></a>.)</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-top-level" id="dt-top-level" title="top-level"></a>An
        element occurring as a child of an <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element is called a <b>top-level</b> element.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-declaration" id="dt-declaration" title=
        "declaration"></a>Top-level elements fall into two
        categories: declarations, and user-defined data elements.
        Top-level elements whose names are in the <a title=
        "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
        namespace</a> are <b>declarations</b>. Top-level elements
        in any other namespace are <a title=
        "user-defined data element" href=
        "index.html#dt-data-element">user-defined data elements</a> (see
        <a href="index.html#user-defined-top-level"><i>3.6.2 User-defined
        Data Elements</i></a>)<span class=
        "definition">]</span>.</p>

        <p>The <a title="declaration" href=
        "index.html#dt-declaration">declaration</a> elements permitted in the
        <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element are:</p>

        <blockquote>
          <p><a href=
          "index.html#element-import"><code>xsl:import</code></a><br />
          <a href=
          "index.html#element-include"><code>xsl:include</code></a><br />
          <a href=
          "index.html#element-attribute-set"><code>xsl:attribute-set</code></a><br />

          <a href=
          "index.html#element-character-map"><code>xsl:character-map</code></a><br />

          <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a><br />

          <a href=
          "index.html#element-function"><code>xsl:function</code></a><br />
          <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a><br />

          <a href="index.html#element-key"><code>xsl:key</code></a><br />
          <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a><br />

          <a href=
          "index.html#element-output"><code>xsl:output</code></a><br />
          <a href="index.html#element-param"><code>xsl:param</code></a><br />
          <a href=
          "index.html#element-preserve-space"><code>xsl:preserve-space</code></a><br />

          <a href=
          "index.html#element-strip-space"><code>xsl:strip-space</code></a><br />

          <a href=
          "index.html#element-template"><code>xsl:template</code></a><br />
          <a href=
          "index.html#element-variable"><code>xsl:variable</code></a></p>
        </blockquote>

        <p>Note that the <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> and
        <a href="index.html#element-param"><code>xsl:param</code></a>
        elements can act either as <a title="declaration" href=
        "index.html#dt-declaration">declarations</a> or as <a title=
        "instruction" href="index.html#dt-instruction">instructions</a>. A
        global variable or parameter is defined using a
        declaration; a local variable or parameter using an
        instruction.</p>

        <p>If there are <a href=
        "index.html#element-import"><code>xsl:import</code></a> elements,
        these <span class="verb">must</span> come before any other
        elements. Apart from this, the child elements of the
        <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element may appear in any order. The ordering of these
        elements does not affect the results of the transformation
        unless there are conflicting declarations (for example, two
        template rules with the same priority that match the same
        node). In general, it is an error for a <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> to
        contain such conflicting declarations, but in some cases
        the processor is allowed to recover from the error by
        choosing the declaration that appears last in the
        stylesheet.</p>

        <div class="div3">
          <h4><a name="default-collation-attribute" id=
          "default-collation-attribute"></a>3.6.1 The
          <code>default-collation</code> attribute</h4>

          <p>The <code>default-collation</code> attribute is a
          <a title="standard attributes" href=
          "index.html#dt-standard-attributes">standard attribute</a> that may
          appear on any element in the XSLT namespace, or (as
          <code>xsl:default-collation</code>) on a <a title=
          "literal result element" href=
          "index.html#dt-literal-result-element">literal result
          element</a>.</p>

          <p>The attribute is used to specify the default collation
          used by all XPath expressions appearing in the attributes
          of this element, or attributes of descendant elements,
          unless overridden by another
          <code>default-collation</code> attribute on an inner
          element. It also determines the collation used by certain
          XSLT constructs (such as <a href=
          "index.html#element-key"><code>xsl:key</code></a> and <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>)
          within its scope.</p>

          <p>The value of the attribute is a whitespace-separated
          list of collation URIs. <span>If any of these URIs is a
          relative URI, then it is resolved relative to the base
          URI of the attribute's parent element. If the
          implementation recognizes one or more of the resulting
          absolute collation URIs</span>, then it uses the first
          one that it recognizes as the default collation.</p>

          <p><a name="err-XTSE0125" id="err-XTSE0125"><span class=
          "error">[ERR XTSE0125]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the value of an <code>[xsl:]default-collation</code>
          attribute<span>, after resolving against the base
          URI,</span> contains no URI that the implementation
          recognizes as a collation URI.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The reason the attribute allows a list of collation
            URIs is that collation URIs will often be meaningful
            only to one particular XSLT implementation. Stylesheets
            designed to run with several different implementations
            can therefore specify several different collation URIs,
            one for use with each. To avoid the above error
            condition, it is possible to specify the Unicode
            Codepoint Collation as the last collation URI in the
            list.</p>
          </div>

          <p>The <code>[xsl:]default-collation</code> attribute
          does not affect the collation used by
          <code>xsl:sort</code>.</p>
        </div>

        <div class="div3">
          <h4><a name="user-defined-top-level" id=
          "user-defined-top-level"></a>3.6.2 User-defined Data
          Elements</h4>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-data-element" id="dt-data-element" title=
          "user-defined data element"></a>In addition to <a title=
          "declaration" href="index.html#dt-declaration">declarations</a>,
          the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element may contain any element not from the <a title=
          "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>, provided that the <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> of the element
          has a non-null namespace URI. Such elements are referred
          to as <b>user-defined data elements</b>.<span class=
          "definition">]</span></p>

          <p><a name="err-XTSE0130" id="err-XTSE0130"><span class=
          "error">[ERR XTSE0130]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element has a child element whose name has a null
          namespace URI.</p>

          <p>An implementation <span class="verb">may</span> attach
          <span>an <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a></span>
          meaning to user-defined data elements that appear in
          <span>particular namespaces</span>. The set of namespaces
          that are recognized for such data elements is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          The presence of a user-defined data element <span class=
          "verb">must not</span> change the behavior of <a title=
          "XSLT element" href="index.html#dt-xslt-element">XSLT elements</a>
          and functions defined in this document; for example, it
          is not permitted for a user-defined data element to
          specify that <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          should use different rules to resolve conflicts.
          <span>The constraints on what user-defined data elements
          can and cannot do are exactly the same as the constraints
          on <a title="extension attribute" href=
          "index.html#dt-extension-attribute">extension attributes</a>,
          described in <a href="index.html#extension-attributes"><i>3.3
          Extension Attributes</i></a>.</span> Thus, an
          implementation is always free to ignore user-defined data
          elements, and <span class="verb">must</span> ignore such
          data elements without giving an error if it does not
          recognize the namespace URI.</p>

          <p>User-defined data elements can provide, for
          example,</p>

          <ul>
            <li>
              <p>information used by <a title=
              "extension instruction" href=
              "index.html#dt-extension-instruction">extension
              instructions</a> or <a title="extension function"
              href="index.html#dt-extension-function">extension functions</a>
              (see <a href="index.html#extension"><i>18 Extensibility and
              Fallback</i></a>),</p>
            </li>

            <li>
              <p>information about what to do with any <a title=
              "final result tree" href=
              "index.html#dt-final-result-tree">final result tree</a>,</p>
            </li>

            <li>
              <p>information about how to construct <a title=
              "source tree" href="index.html#dt-source-tree">source
              trees</a>,</p>
            </li>

            <li>
              <p>optimization hints for the <a title="processor"
              href="index.html#dt-processor">processor</a>,</p>
            </li>

            <li>
              <p>metadata about the stylesheet,</p>
            </li>

            <li>
              <p>structured documentation for the stylesheet.</p>
            </li>
          </ul>

          <p>A <a title="user-defined data element" href=
          "index.html#dt-data-element">user-defined data element</a>
          <span class="verb">must not</span> precede an <a href=
          "index.html#element-import"><code>xsl:import</code></a> element
          within a <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet module</a>
          <span><span class="error">[see <a href=
          "index.html#err-XTSE0200">ERR XTSE0200</a>]</span></span></p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="simplified-stylesheet" id=
        "simplified-stylesheet"></a>3.7 Simplified Stylesheet
        Modules</h3>

        <p>A simplified syntax is allowed for a <a title=
        "stylesheet module" href="index.html#dt-stylesheet-module">stylesheet
        module</a> that defines only a single template rule for the
        document node. The stylesheet module may consist of just a
        <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>
        (see <a href="index.html#literal-result-element"><i>11.1 Literal
        Result Elements</i></a>) together with its contents.
        <span>The literal result element must have an
        <code>xsl:version</code> attribute (and it must therefore
        also declare the XSLT namespace).</span> Such a stylesheet
        <span>module</span> is equivalent to a standard stylesheet
        module whose <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element contains a <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> containing the
        literal result element, <span>minus its
        <code>xsl:version</code> attribute</span>; the template
        rule has a match <a title="pattern" href=
        "index.html#dt-pattern">pattern</a> of <code>/</code>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e3741" id="d5e3741"></a>Example: A
            Simplified Stylesheet
          </div>

          <p>For example:</p>

          <div class="exampleInner">
            <pre>
&lt;html xsl:version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
    &lt;title&gt;Expense Report Summary&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;Total Amount: &lt;xsl:value-of select="expense-report/total"/&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
          </div>

          <p>has the same meaning as</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;xsl:template match="/"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Expense Report Summary&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;Total Amount: &lt;xsl:value-of select="expense-report/total"/&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
          </div>

          <p>Note that it is not possible, using a simplified
          stylesheet, to request that the serialized output
          contains a <code>DOCTYPE</code> declaration. This can
          only be done by using a standard stylesheet module, and
          using the <a href=
          "index.html#element-output"><code>xsl:output</code></a>
          element.</p>
        </div>

        <p>More formally, a simplified stylesheet module is
        equivalent to the standard stylesheet module that would be
        generated by applying the following transformation to the
        simplified stylesheet module, invoking the transformation
        by calling the <a title="named template" href=
        "index.html#dt-named-template">named template</a>
        <code>expand</code>, with the containing literal result
        element as the <a title="context node" href=
        "index.html#dt-context-node">context node</a>:</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

&lt;xsl:template name="expand"&gt;
  &lt;xsl:element name="xsl:stylesheet"&gt;
    &lt;xsl:attribute name="version" select="@xsl:version"/&gt;
    &lt;xsl:element name="xsl:template"&gt;
      &lt;xsl:attribute name="match"&gt;/&lt;/xsl:attribute&gt;
      &lt;xsl:copy-of select="."/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:element&gt;
&lt;/xsl:template&gt;  

&lt;/xsl:stylesheet&gt;
</pre>
        </div>

        <p><a name="err-XTSE0150" id="err-XTSE0150"><span class=
        "error">[ERR XTSE0150]</span></a> A <a title=
        "literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>
        that is used as the outermost element of a simplified
        stylesheet module <span class="verb">must</span> have an
        <code>xsl:version</code> attribute. This indicates the
        version of XSLT that the stylesheet requires. For this
        version of XSLT, the value will normally be
        <code>2.0</code>; the value <span class="verb">must</span>
        be a <span>valid instance of the type
        <code>xs:decimal</code> as defined in <a href=
        "index.html#xmlschema-2">[XML Schema Part 2]</a></span>.</p>

        <p>Other <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result elements</a>
        may also have an <code>xsl:version</code> attribute. When
        the <code>xsl:version</code> attribute is numerically less
        than <code>2.0</code>, backwards-compatible processing
        behavior is enabled (see <a href="index.html#backwards"><i>3.8
        Backwards-Compatible Processing</i></a>). When the
        <code>xsl:version</code> attribute is numerically greater
        than <code>2.0</code>, <a title=
        "forwards-compatible behavior" href=
        "index.html#dt-forwards-compatible-behavior">forwards-compatible
        behavior</a> is enabled (see <a href="index.html#forwards"><i>3.9
        Forwards-Compatible Processing</i></a>).</p>

        <p>The allowed content of a literal result element when
        used as a simplified stylesheet is the same as when it
        occurs within a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>. Thus,
        a literal result element used as the document element of a
        simplified stylesheet cannot contain <a title="declaration"
        href="index.html#dt-declaration">declarations</a>. <span>Simplified
        stylesheets therefore cannot use <a title="global variable"
        href="index.html#dt-global-variable">global variables</a>, <a title=
        "stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameters</a>,
        <a title="stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet functions</a>,
        <a title="key" href="index.html#dt-key">keys</a>, <a title=
        "attribute set" href=
        "index.html#dt-attribute-set">attribute-sets</a>, or <a title=
        "output definition" href="index.html#dt-output-definition">output
        definitions</a>. In turn this means that the only useful
        way to initiate the transformation is to supply a document
        node as the <a title="initial context node" href=
        "index.html#dt-initial-context-node">initial context node</a>, to be
        matched by the implicit <code>match="/"</code> template
        rule using the <a title="default mode" href=
        "index.html#dt-default-mode">default mode</a>.</span></p>
      </div>

      <div class="div2">
        <h3><a name="backwards" id="backwards"></a>3.8
        Backwards-Compatible Processing</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-backwards-compatible-behavior" id=
        "dt-backwards-compatible-behavior" title=
        "backwards compatible behavior"></a>An element enables
        backwards-compatible behavior for itself, its attributes,
        its descendants and their attributes if it has an
        <code>[xsl:]version</code> attribute (see <a href=
        "index.html#standard-attributes"><i>3.5 Standard Attributes</i></a>)
        whose value is less than <code>2.0</code>.<span class=
        "definition">]</span></p>

        <p>An element that has an <code>[xsl:]version</code>
        attribute whose value is greater than or equal to
        <code>2.0</code> disables backwards-compatible behavior for
        itself, its attributes, its descendants and their
        attributes. The compatibility behavior established by an
        element overrides any compatibility behavior established by
        an ancestor element.</p>

        <p>If an attribute containing an XPath <a title=
        "expression" href="index.html#dt-expression">expression</a> is
        processed with backwards-compatible behavior, then the
        expression is evaluated with <a title=
        "XPath 1.0 compatibility mode" href=
        "index.html#dt-compatibility-mode">XPath 1.0 compatibility mode</a>
        set to <code>true</code>. For details of this mode, see
        <a href=
        "http://www.w3.org/TR/xpath20/#static_context">Section
        2.1.1 Static Context</a><sup><small>XP</small></sup>.
        <span>Furthermore, in such an expression any function call
        for which no implementation is available (unless it uses
        the <a title="standard function namespace" href=
        "index.html#dt-standard-function-namespace">standard function
        namespace</a>) is bound to a fallback error function whose
        effect when evaluated is to raise a dynamic error
        <span class="error">[see <a href="index.html#err-XTDE1425">ERR
        XTDE1425</a>]</span> . The effect is that with
        backwards-compatible behavior enabled, calls on <a title=
        "extension function" href=
        "index.html#dt-extension-function">extension functions</a> that are
        not available in a particular implementation do not cause
        an error unless the function call is actually evaluated.
        For further details, see <a href=
        "index.html#extension-functions"><i>18.1 Extension
        Functions</i></a>.</span></p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This might appear to contradict the specification of
          XPath 2.0, which states that a static error [XPST0017] is
          raised when an expression contains a call to a function
          that is not present (with matching name and arity) in the
          static context. This apparent contradiction is resolved
          by specifying that the XSLT processor constructs a static
          context for the expression in which every possible
          function name and arity (other than names in the
          <a title="standard function namespace" href=
          "index.html#dt-standard-function-namespace">standard function
          namespace</a>) is present; when no other implementation
          of the function is available, the function call is bound
          to a fallback error function whose run-time effect is to
          raise a dynamic error.</p>
        </div>

        <p>Certain XSLT constructs also produce different results
        when backwards-compatible behavior is enabled. This is
        described separately for each such construct.</p>

        <p>These rules do not apply to the <a href=
        "index.html#element-output"><code>xsl:output</code></a> element,
        whose <code>version</code> attribute has an entirely
        different purpose: it is used to define the version of the
        output method to be used for serialization.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p><span>By making use of backwards-compatible behavior,
          it is possible to write the stylesheet in a way that
          ensures that its results when processed with an XSLT 2.0
          processor are identical to the effects of processing the
          same stylesheet using an XSLT 1.0 processor.</span> The
          differences are described (non-normatively) in <a href=
          "index.html#incompatibilities"><i>J.1 Incompatible Changes</i></a>.
          To assist with transition, some parts of a stylesheet may
          be processed with backwards compatible behavior enabled,
          and other parts with this behavior disabled. All data
          values manipulated by an XSLT 2.0 processor are defined
          by the <span>XDM</span> data model, whether or not the
          relevant expressions use backwards compatible behavior.
          Because the same data model is used in both cases,
          expressions are fully composable. The result of
          evaluating instructions or expressions with backwards
          compatible behavior is fully defined in the XSLT 2.0 and
          XPath 2.0 specifications, it is not defined by reference
          to the XSLT 1.0 and XPath 1.0 specifications.</p>
        </div>

        <p>It is <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        whether a particular XSLT 2.0 implementation supports
        backwards-compatible behavior.</p>

        <p><a name="err-XTDE0160" id="err-XTDE0160"><span class=
        "error">[ERR XTDE0160]</span></a> If an implementation does
        not support backwards-compatible behavior, then it is a
        <a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if any element is evaluated that enables
        backwards-compatible behavior.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>To write a stylesheet that works with both XSLT 1.0
          and 2.0 processors, while making selective use of XSLT
          2.0 facilities, it is necessary to understand both the
          rules for backwards-compatible behavior in XSLT 2.0, and
          the rules for forwards-compatible behavior in XSLT 1.0.
          If the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element specifies <code>version="2.0"</code>, then an
          XSLT 1.0 processor will ignore XSLT 2.0 <a title=
          "declaration" href="index.html#dt-declaration">declarations</a>
          that were not defined in XSLT 1.0, for example <a href=
          "index.html#element-function"><code>xsl:function</code></a> and
          <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>.
          If any new XSLT 2.0 instructions are used (for example
          <a href=
          "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
          or <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>), or
          if new XPath 2.0 features are used (for example, new
          functions, or syntax such as conditional expressions, or
          calls to a function defined using <a href=
          "index.html#element-function"><code>xsl:function</code></a>), then
          the stylesheet must provide fallback behavior that relies
          on XSLT 1.0 and XPath 1.0 facilities only. The fallback
          behavior can be invoked by using the <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          instruction, or by testing the results of the <a href=
          "index.html#function-function-available"><code>function-available</code></a>
          or <a href=
          "index.html#function-element-available"><code>element-available</code></a>
          functions, or by testing the value of the
          <code>xsl:version</code> property returned by the
          <a href="index.html#function-system-property"><code>system-property</code></a>
          function.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="forwards" id="forwards"></a>3.9
        Forwards-Compatible Processing</h3>

        <p>The intent of forwards-compatible behavior is to make it
        possible to write a stylesheet that takes advantage of
        features introduced in some version of XSLT subsequent to
        XSLT 2.0, while retaining the ability to execute the
        stylesheet with an XSLT 2.0 processor using appropriate
        fallback behavior.</p>

        <p>It is always possible to write conditional code to run
        under different XSLT versions by using the
        <code>use-when</code> feature described in <a href=
        "index.html#conditional-inclusion"><i>3.12 Conditional Element
        Inclusion</i></a>. The rules for forwards-compatible
        behavior supplement this mechanism in two ways:</p>

        <ul>
          <li>
            <p>certain constructs in the stylesheet that mean
            nothing to an XSLT 2.0 processor are ignored, rather
            than being treated as errors.</p>
          </li>

          <li>
            <p>explicit fallback behavior can be defined for
            instructions defined in a future XSLT release, using
            the <a href=
            "index.html#element-fallback"><code>xsl:fallback</code></a>
            instruction.</p>
          </li>
        </ul>

        <p>The detailed rules follow.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-forwards-compatible-behavior" id=
        "dt-forwards-compatible-behavior" title=
        "forwards-compatible behavior"></a>An element enables
        <b>forwards-compatible behavior</b> for itself, its
        attributes, its descendants and their attributes if it has
        an <code>[xsl:]version</code> attribute (see <a href=
        "index.html#standard-attributes"><i>3.5 Standard Attributes</i></a>)
        whose value is greater than <code>2.0</code>.<span class=
        "definition">]</span></p>

        <p>An element that has an <code>[xsl:]version</code>
        attribute whose value is less than or equal to
        <code>2.0</code> disables forwards-compatible behavior for
        itself, its attributes, its descendants and their
        attributes. The compatibility behavior established by an
        element overrides any compatibility behavior established by
        an ancestor element.</p>

        <p>These rules do not apply to the <code>version</code>
        attribute of the <a href=
        "index.html#element-output"><code>xsl:output</code></a> element,
        which has an entirely different purpose: it is used to
        define the version of the output method to be used for
        serialization.</p>

        <p>Within a section of a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> where forwards-compatible
        behavior is enabled:</p>

        <ul>
          <li>
            <p>if an element in the XSLT namespace appears as a
            child of the <a href=
            "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
            element, and XSLT 2.0 does not allow such elements to
            occur as children of the <a href=
            "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
            element, then the element and its content <span class=
            "verb">must</span> be ignored.</p>
          </li>

          <li>
            <p>if an element has an attribute that XSLT 2.0 does
            not allow the element to have, then the attribute
            <span class="verb">must</span> be ignored.</p>
          </li>

          <li>
            <p>if an element in the XSLT namespace appears as part
            of a <a title="sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a>,
            and XSLT 2.0 does not allow such elements to appear as
            part of a sequence constructor, then:</p>

            <ol class="enumar">
              <li>
                <p>If the element has one or more <a href=
                "index.html#element-fallback"><code>xsl:fallback</code></a>
                children, then no error is reported either
                statically or dynamically, and the result of
                evaluating the instruction is the concatenation of
                the sequences formed by evaluating the sequence
                constructors within its <a href=
                "index.html#element-fallback"><code>xsl:fallback</code></a>
                children, in document order. Siblings of the
                <a href=
                "index.html#element-fallback"><code>xsl:fallback</code></a>
                elements are ignored, even if they are valid XSLT
                2.0 instructions.</p>
              </li>

              <li>
                <p>If the element has no <a href=
                "index.html#element-fallback"><code>xsl:fallback</code></a>
                children, then a static error is reported in the
                same way as if forwards-compatible behavior were
                not enabled.</p>
              </li>
            </ol>
          </li>
        </ul>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e4106" id="d5e4106"></a>Example: Forwards
            Compatible Behavior
          </div>

          <p><span>For example, an XSLT 2.0 <a title="processor"
          href="index.html#dt-processor">processor</a> will</span> process
          the following stylesheet without error, although the
          stylesheet includes elements from the <a title=
          "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a> that are not defined in this
          specification:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:stylesheet version="17.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:template match="/"&gt;
    &lt;xsl:exciting-new-17.0-feature&gt;
      &lt;xsl:fly-to-the-moon/&gt;
      &lt;xsl:fallback&gt;
        &lt;html&gt;
          &lt;head&gt;
            &lt;title&gt;XSLT 17.0 required&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
            &lt;p&gt;Sorry, this stylesheet requires XSLT 17.0.&lt;/p&gt;
          &lt;/body&gt;
        &lt;/html&gt;
      &lt;/xsl:fallback&gt;
    &lt;/xsl:exciting-new-17.0-feature&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
          </div>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>If a stylesheet depends crucially on a <a title=
          "declaration" href="index.html#dt-declaration">declaration</a>
          introduced by a version of XSLT after 2.0, then the
          stylesheet can use an <a href=
          "index.html#element-message"><code>xsl:message</code></a> element
          with <code>terminate="yes"</code> (see <a href=
          "index.html#message"><i>17 Messages</i></a>) to ensure that
          implementations that conform to an earlier version of
          XSLT will not silently ignore the <a title="declaration"
          href="index.html#dt-declaration">declaration</a>.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e4139" id="d5e4139"></a>Example: Testing the
            XSLT Version
          </div>

          <p>For example,</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:stylesheet version="18.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

  &lt;xsl:important-new-17.0-declaration/&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="number(system-property('xsl:version')) lt 17.0"&gt;
        &lt;xsl:message terminate="yes"&gt;
          &lt;xsl:text&gt;Sorry, this stylesheet requires XSLT 17.0.&lt;/xsl:text&gt;
        &lt;/xsl:message&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        ...
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  ...
&lt;/xsl:stylesheet&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="combining-modules" id=
        "combining-modules"></a>3.10 Combining Stylesheet
        Modules</h3>

        <p>XSLT provides two mechanisms to construct a <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> from
        multiple <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet modules</a>:</p>

        <ul>
          <li>
            <p>an inclusion mechanism that allows stylesheet
            modules to be combined without changing the semantics
            of the modules being combined, and</p>
          </li>

          <li>
            <p>an import mechanism that allows stylesheet modules
            to override each other.</p>
          </li>
        </ul>

        <div class="div3">
          <h4><a name="locating-modules" id=
          "locating-modules"></a>3.10.1 Locating Stylesheet
          Modules</h4>

          <p>The include and import mechanisms use two
          declarations, <a href=
          "index.html#element-include"><code>xsl:include</code></a> and
          <a href="index.html#element-import"><code>xsl:import</code></a>,
          which are defined in the sections that follow.</p>

          <p>These declarations use an <code>href</code> attribute,
          whose value is a <a title="URI Reference" href=
          "index.html#dt-uri-reference">URI reference</a>, to identify the
          <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet module</a> to be
          included or imported. If the value of this attribute is a
          relative URI, it is resolved <span>as described in
          <a href="index.html#uri-references"><i>5.8 URI
          References</i></a></span>.</p>

          <p>After resolving against the base URI, the way in which
          the URI reference is used to locate a
          <span>representation of a <a title="stylesheet module"
          href="index.html#dt-stylesheet-module">stylesheet module</a>, and
          the way in which the stylesheet module is constructed
          from that representation, are</span> <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          In particular, it is implementation-defined which URI
          schemes are supported, whether fragment identifiers are
          supported, and what media types are supported.
          Conventionally, the URI is a reference to a resource
          containing the stylesheet module as a source XML
          document, or it may include a fragment identifier that
          selects an embedded stylesheet module within a source XML
          document; but the implementation is free to use other
          mechanisms to locate the stylesheet module identified by
          the URI reference.</p>

          <p>The referenced <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet module</a> may be any
          of the four kinds of stylesheet module: that is, it may
          be <a title="standalone stylesheet module" href=
          "index.html#dt-standalone-stylesheet-module">standalone</a> or
          <a title="embedded stylesheet module" href=
          "index.html#dt-embedded-stylesheet-module">embedded</a>, and it may
          be <a title="standard stylesheet module" href=
          "index.html#dt-standard-stylesheet-module">standard</a> or
          <a title="simplified stylesheet module" href=
          "index.html#dt-simplified-stylesheet-module">simplified</a>. If it
          is a <a title="simplified stylesheet module" href=
          "index.html#dt-simplified-stylesheet-module">simplified stylesheet
          module</a> then it is transformed into the equivalent
          <a title="standard stylesheet module" href=
          "index.html#dt-standard-stylesheet-module">standard stylesheet
          module</a> by applying the transformation described in
          <a href="index.html#simplified-stylesheet"><i>3.7 Simplified
          Stylesheet Modules</i></a>.</p>

          <p>Implementations <span class="verb">may</span> choose
          to accept URI references containing a fragment identifier
          defined by reference to the XPointer specification (see
          <a href="index.html#xptr-framework">[XPointer Framework]</a>). Note
          that if the implementation does not support the use of
          fragment identifiers in the URI reference, then it will
          not be possible to include an <a title=
          "embedded stylesheet module" href=
          "index.html#dt-embedded-stylesheet-module">embedded stylesheet
          module</a>.</p>

          <p><a name="err-XTSE0165" id="err-XTSE0165"><span class=
          "error">[ERR XTSE0165]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the processor is not able to retrieve the resource
          identified by the URI reference, or if the resource that
          is retrieved does not contain a stylesheet module
          conforming to this specification.</p>
        </div>

        <div class="div3">
          <h4><a name="include" id="include"></a>3.10.2 Stylesheet
          Inclusion</h4>

          <p class="element-syntax"><a name="element-include" id=
          "element-include"></a><code>&lt;!-- Category: declaration
          --&gt;<br />
          &lt;xsl:include<br />
          &#160;&#160;<b>href</b> =
          <var>uri-reference</var>&#160;/&gt;</code></p>

          <p>A stylesheet module may include another stylesheet
          module using an <a href=
          "index.html#element-include"><code>xsl:include</code></a>
          declaration.</p>

          <p>The <a href=
          "index.html#element-include"><code>xsl:include</code></a>
          declaration has a <span class="verb">required</span>
          <code>href</code> attribute whose value is a URI
          reference identifying the stylesheet module to be
          included. This attribute is used as described in <a href=
          "index.html#locating-modules"><i>3.10.1 Locating Stylesheet
          Modules</i></a>.</p>

          <p><a name="err-XTSE0170" id="err-XTSE0170"><span class=
          "error">[ERR XTSE0170]</span></a> An <a href=
          "index.html#element-include"><code>xsl:include</code></a> element
          <span class="verb">must</span> be a <a title="top-level"
          href="index.html#dt-top-level">top-level</a> element.</p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-stylesheet-level" id="dt-stylesheet-level" title=
          "stylesheet level"></a>A <b>stylesheet level</b> is a
          collection of <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a> connected
          using <a href=
          "index.html#element-include"><code>xsl:include</code></a>
          declarations: specifically, two stylesheet modules
          <var>A</var> and <var>B</var> are part of the same
          stylesheet level if one of them includes the other by
          means of an <a href=
          "index.html#element-include"><code>xsl:include</code></a>
          declaration, or if there is a third stylesheet module
          <var>C</var> that is in the same stylesheet level as both
          <var>A</var> and <var>B</var>.<span class=
          "definition">]</span></p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-declaration-order" id="dt-declaration-order" title=
          "declaration order"></a>The <a title="declaration" href=
          "index.html#dt-declaration">declarations</a> within a <a title=
          "stylesheet level" href="index.html#dt-stylesheet-level">stylesheet
          level</a> have a total ordering known as <b>declaration
          order</b>. The order of declarations within a stylesheet
          level is the same as the document order that would result
          if each stylesheet module were inserted textually in
          place of the <a href=
          "index.html#element-include"><code>xsl:include</code></a> element
          that references it.<span class="definition">]</span> In
          other respects, however, the effect of <a href=
          "index.html#element-include"><code>xsl:include</code></a> is not
          equivalent to the effect that would be obtained by
          textual inclusion.</p>

          <p><a name="err-XTSE0180" id="err-XTSE0180"><span class=
          "error">[ERR XTSE0180]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if a stylesheet module directly or indirectly includes
          itself.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>It is not intrinsically an error for a <a title=
            "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> to
            include the same module more than once. However, doing
            so can cause errors because of duplicate definitions.
            Such multiple inclusions are less obvious when they are
            indirect. For example, if stylesheet <var>B</var>
            includes stylesheet <var>A</var>, stylesheet
            <var>C</var> includes stylesheet <var>A</var>, and
            stylesheet <var>D</var> includes both stylesheet
            <var>B</var> and stylesheet <var>C</var>, then
            <var>A</var> will be included indirectly by
            <var>D</var> twice. If all of <var>B</var>,
            <var>C</var> and <var>D</var> are used as independent
            stylesheets, then the error can be avoided by
            separating everything in <var>B</var> other than the
            inclusion of <var>A</var> into a separate stylesheet
            <var>B'</var> and changing <var>B</var> to contain just
            inclusions of <var>B'</var> and <var>A</var>, similarly
            for <var>C</var>, and then changing <var>D</var> to
            include <var>A</var>, <var>B'</var>, <var>C'</var>.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="import" id="import"></a>3.10.3 Stylesheet
          Import</h4>

          <p class="element-syntax"><a name="element-import" id=
          "element-import"></a><code>&lt;!-- Category: declaration
          --&gt;<br />
          &lt;xsl:import<br />
          &#160;&#160;<b>href</b> =
          <var>uri-reference</var>&#160;/&gt;</code></p>

          <p>A stylesheet module may import another <a title=
          "stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet module</a> using an
          <a href="index.html#element-import"><code>xsl:import</code></a>
          <a title="declaration" href=
          "index.html#dt-declaration">declaration</a>. Importing a stylesheet
          <span>module</span> is the same as including it (see
          <a href="index.html#include"><i>3.10.2 Stylesheet
          Inclusion</i></a>) except that <a title="template rule"
          href="index.html#dt-template-rule">template rules</a> and other
          <a title="declaration" href=
          "index.html#dt-declaration">declarations</a> in the importing
          <span>module</span> take precedence over template rules
          and declarations in the imported <span>module</span>;
          this is described in more detail below.</p>

          <p>The <a href=
          "index.html#element-import"><code>xsl:import</code></a> declaration
          has a <span class="verb">required</span>
          <code>href</code> attribute whose value is a URI
          reference identifying the stylesheet module to be
          included. This attribute is used as described in <a href=
          "index.html#locating-modules"><i>3.10.1 Locating Stylesheet
          Modules</i></a>.</p>

          <p><a name="err-XTSE0190" id="err-XTSE0190"><span class=
          "error">[ERR XTSE0190]</span></a> An <a href=
          "index.html#element-import"><code>xsl:import</code></a> element
          <span class="verb">must</span> be a <a title="top-level"
          href="index.html#dt-top-level">top-level</a> element.</p>

          <p><a name="err-XTSE0200" id="err-XTSE0200"><span class=
          "error">[ERR XTSE0200]</span></a> The <a href=
          "index.html#element-import"><code>xsl:import</code></a> element
          children <span class="verb">must</span> precede all other
          element children of an <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element, including any <a href=
          "index.html#element-include"><code>xsl:include</code></a> element
          children and any <a title="user-defined data element"
          href="index.html#dt-data-element">user-defined data
          elements</a>.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e4538" id="d5e4538"></a>Example: Using
              <code>xsl:import</code>
            </div>

            <p>For example,</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:import href="article.xsl"/&gt;
  &lt;xsl:import href="bigfont.xsl"/&gt;
  &lt;xsl:attribute-set name="note-style"&gt;
    &lt;xsl:attribute name="font-style"&gt;italic&lt;/xsl:attribute&gt;
  &lt;/xsl:attribute-set&gt;
&lt;/xsl:stylesheet&gt;
</pre>
            </div>
          </div>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-import-tree" id="dt-import-tree" title=
          "import tree"></a>The <a title="stylesheet level" href=
          "index.html#dt-stylesheet-level">stylesheet levels</a> making up a
          <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> are treated as forming an
          <b>import tree</b>. In the import tree, each stylesheet
          level has one child for each <a href=
          "index.html#element-import"><code>xsl:import</code></a> declaration
          that it contains.<span class="definition">]</span> The
          ordering of the children is the <a title=
          "declaration order" href=
          "index.html#dt-declaration-order">declaration order</a> of the
          <a href="index.html#element-import"><code>xsl:import</code></a>
          declarations within their stylesheet level.</p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-import-precedence" id="dt-import-precedence" title=
          "import precedence"></a>A <a title="declaration" href=
          "index.html#dt-declaration">declaration</a> <var>D</var> in the
          stylesheet is defined to have lower <b>import
          precedence</b> than another declaration <var>E</var> if
          the stylesheet level containing <var>D</var> would be
          visited before the stylesheet level containing
          <var>E</var> in a post-order traversal of the import tree
          (that is, a traversal of the import tree in which a
          stylesheet level is visited after its children). Two
          declarations within the same stylesheet level have the
          same import precedence.<span class=
          "definition">]</span></p>

          <p>For example, suppose</p>

          <ul>
            <li>
              <p>stylesheet module <var>A</var> imports stylesheet
              modules <var>B</var> and <var>C</var> in that
              order;</p>
            </li>

            <li>
              <p>stylesheet module <var>B</var> imports stylesheet
              module <var>D</var>;</p>
            </li>

            <li>
              <p>stylesheet module <var>C</var> imports stylesheet
              module <var>E</var>.</p>
            </li>
          </ul>

          <p>Then the import tree has the following structure:</p>

          <div class="exampleInner">
            <pre>
         A
         |
     +---+---+
     |       |
     B       C
     |       |
     D       E
</pre>
          </div>

          <p>The order of import precedence (lowest first) is
          <var>D</var>, <var>B</var>, <var>E</var>, <var>C</var>,
          <var>A</var>.</p>

          <p>In general, a <a title="declaration" href=
          "index.html#dt-declaration">declaration</a> with higher import
          precedence takes precedence over a declaration with lower
          import precedence. This is defined in detail for each
          kind of declaration.</p>

          <p><a name="err-XTSE0210" id="err-XTSE0210"><span class=
          "error">[ERR XTSE0210]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if a stylesheet module directly or indirectly imports
          itself.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The case where a stylesheet module with a particular
            URI is imported several times is not treated specially.
            The effect is exactly the same as if several stylesheet
            modules with different URIs but identical content were
            imported. This might or might not cause an error,
            depending on the content of the stylesheet module.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="embedded" id="embedded"></a>3.11 Embedded
        Stylesheet Modules</h3>

        <p>An <a title="embedded stylesheet module" href=
        "index.html#dt-embedded-stylesheet-module">embedded stylesheet
        module</a> is a <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet module</a> whose
        containing element is not the outermost element of the
        containing XML document. Both <a title=
        "standard stylesheet module" href=
        "index.html#dt-standard-stylesheet-module">standard stylesheet
        modules</a> and <a title="simplified stylesheet module"
        href="index.html#dt-simplified-stylesheet-module">simplified
        stylesheet modules</a> may be embedded in this way.</p>

        <p>Two situations where embedded stylesheets may be useful
        are:</p>

        <ul>
          <li>
            <p>The stylesheet may be embedded in the source
            document to be transformed.</p>
          </li>

          <li>
            <p>The stylesheet may be embedded in an XML document
            that describes a sequence of processing of which the
            XSLT transformation forms just one part.</p>
          </li>
        </ul>

        <p>The <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element <span class="verb">may</span> have an
        <code>id</code> attribute to facilitate reference to the
        stylesheet module within the containing document.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>In order for such an attribute value to be used as a
          fragment identifier in a URI, the <span>XDM attribute
          node</span> must generally have the <code>is-id</code>
          property: see <a href=
          "http://www.w3.org/TR/xpath-datamodel/#dm-is-id">Section
          5.5 is-id Accessor</a><sup><small>DM</small></sup>. This
          property will typically be set if the attribute is
          defined in a DTD as being of type <code>ID</code>, or if
          is defined in a schema as being of type
          <code>xs:ID</code>. It is also necessary that the media
          type of the containing document should support the use of
          ID values as fragment identifiers. Such support is
          widespread in existing products, and is expected to be
          endorsed in respect of the media type
          <code>application/xml</code> by a future revision of
          <a href="index.html#RFC3023">[RFC3023]</a>.</p>

          <p>An alternative, if the implementation supports it, is
          to use an <code>xml:id</code> attribute. XSLT allows this
          attribute (like other namespaced attributes) to appear on
          any <a title="XSLT element" href="index.html#dt-xslt-element">XSLT
          element</a>.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e4734" id="d5e4734"></a>Example: The
            <code>xml-stylesheet</code> Processing Instruction
          </div>

          <p>The following example shows how the
          <code>xml-stylesheet</code> processing instruction (see
          <a href="index.html#xml-stylesheet">[XML Stylesheet]</a>) can be
          used to allow a source document to contain its own
          stylesheet. The URI reference uses a relative URI with a
          fragment identifier to locate the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element:</p>

          <div class="exampleInner">
            <pre>
&lt;?xml-stylesheet type="application/xslt+xml" href="#style1"?&gt;
&lt;!DOCTYPE doc SYSTEM "doc.dtd"&gt;
&lt;doc&gt;
&lt;head&gt;
&lt;xsl:stylesheet id="style1"
                version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
&lt;xsl:import href="doc.xsl"/&gt;
&lt;xsl:template match="id('foo')"&gt;
  &lt;fo:block font-weight="bold"&gt;&lt;xsl:apply-templates/&gt;&lt;/fo:block&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xsl:stylesheet"&gt;
  &lt;!-- ignore --&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;para id="foo"&gt;
...
&lt;/para&gt;
&lt;/body&gt;
&lt;/doc&gt;
</pre>
          </div>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>A stylesheet module that is embedded in the document
          to which it is to be applied typically needs to contain a
          <a title="template rule" href=
          "index.html#dt-template-rule">template rule</a> that specifies that
          <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          elements are to be ignored.</p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The above example uses the pseudo-attribute
          <code>type="application/xslt+xml"</code> in the
          <code>xml-stylesheet</code> processing instruction to
          denote an XSLT stylesheet. This usage is subject to
          <span>confirmation</span>: see <a href=
          "index.html#xslt-media-type"><i>3.4 XSLT Media Type</i></a>. In the
          absence of a registered media type for XSLT stylesheets,
          some vendors' products have adopted different
          conventions, notably <code>type="text/xsl"</code>.</p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Support for the <code>xml-stylesheet</code> processing
          instruction is not required for conformance with this
          Recommendation. <span>Implementations are not constrained
          in the mechanisms they use to identify a stylesheet when
          a transformation is initiated: see <a href=
          "index.html#initiating"><i>2.3 Initiating a
          Transformation</i></a>.</span></p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="conditional-inclusion" id=
        "conditional-inclusion"></a>3.12 Conditional Element
        Inclusion</h3>

        <p>Any element in the XSLT namespace may have a
        <code>use-when</code> attribute whose value is an XPath
        expression that can be evaluated statically. If the
        attribute is present and the <a href=
        "http://www.w3.org/TR/xpath20/#dt-ebv">effective boolean
        value</a><sup><small>XP</small></sup> of the expression is
        false, then the element, together with all the nodes having
        that element as an ancestor, is effectively excluded from
        the <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet module</a>. When a node
        is effectively excluded from a stylesheet module the
        stylesheet module has the same effect as if the node were
        not there. Among other things this means that no static or
        dynamic errors will be reported in respect of the element
        and its contents, other than errors in the
        <code>use-when</code> attribute itself.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This does not apply to XML parsing or validation
          errors, which will be reported in the usual way. <span>It
          also does not apply to attributes that are necessarily
          processed before <code>[xsl:]use-when</code>, examples
          being <code>xml:space</code> and
          <code>[xsl:]xpath-default-namespace</code></span>.</p>
        </div>

        <p>A <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>,
        <span>or any other element within a <a title=
        "stylesheet module" href="index.html#dt-stylesheet-module">stylesheet
        module</a> that is not in the XSLT namespace,</span> may
        similarly carry an <code>xsl:use-when</code> attribute.</p>

        <p>If the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> or
        <a href="index.html#element-transform"><code>xsl:transform</code></a>
        element itself is effectively excluded, the effect is to
        exclude all the children of the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> or
        <a href="index.html#element-transform"><code>xsl:transform</code></a>
        element, but not the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> or
        <a href="index.html#element-transform"><code>xsl:transform</code></a>
        element or its attributes.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This allows all the declarations that depend on the
          same condition to be included in one stylesheet module,
          and for their inclusion or exclusion to be controlled by
          a single <code>use-when</code> attribute at the level of
          the module.</p>
        </div>

        <p>Conditional element exclusion happens after stripping of
        whitespace text nodes from the stylesheet, as described in
        <a href="index.html#stylesheet-stripping"><i>4.2 Stripping Whitespace
        from the Stylesheet</i></a>.</p>

        <p>There are no syntactic constraints on the XPath
        expression that can be used as the value of the
        <code>use-when</code> attribute. However, there are severe
        constraints on the information provided in its evaluation
        context. These constraints are designed to ensure that the
        expression can be evaluated at the earliest possible stage
        of stylesheet processing, without any dependency on
        information contained in the stylesheet itself or in any
        source document.</p>

        <p>Specifically, the components of the static and dynamic
        context are defined by the following two tables:</p>

        <table border="1" cellpadding="5" width="100%">
          <caption>
            Static Context Components for <code>use-when</code>
            Expressions
          </caption>
          <col align="left" width="30%" span="1" />
          <col align="left" span="1" />

          <thead>
            <tr>
              <th>Component</th>

              <th>Value</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td valign="top">XPath 1.0 compatibility mode</td>

              <td>false</td>
            </tr>

            <tr>
              <td valign="top">In scope namespaces</td>

              <td>determined by the in-scope namespaces for the
              containing element in the stylesheet</td>
            </tr>

            <tr>
              <td valign="top">Default element/type namespace</td>

              <td>determined by the
              <code>xpath-default-namespace</code> attribute if
              present (see <a href="index.html#unprefixed-qnames"><i>5.2
              Unprefixed QNames in Expressions and
              Patterns</i></a>); otherwise the null namespace</td>
            </tr>

            <tr>
              <td valign="top">Default function namespace</td>

              <td>The <a title="standard function namespace" href=
              "index.html#dt-standard-function-namespace">standard function
              namespace</a></td>
            </tr>

            <tr>
              <td valign="top">In scope type definitions</td>

              <td>The type definitions that would be available in
              the absence of any <a href=
              "index.html#element-import-schema"><code>xsl:import-schema</code></a>
              declaration</td>
            </tr>

            <tr>
              <td valign="top">In scope element declarations</td>

              <td>None</td>
            </tr>

            <tr>
              <td valign="top">In scope attribute declarations</td>

              <td>None</td>
            </tr>

            <tr>
              <td valign="top">In scope variables</td>

              <td>None</td>
            </tr>

            <tr>
              <td valign="top">In scope functions</td>

              <td>The <a title="core function" href=
              "index.html#dt-core-function">core functions</a> defined in
              <a href="index.html#xpath-functions">[Functions and
              Operators]</a>, together with the functions <a href=
              "index.html#function-element-available"><code>element-available</code></a>,
              <a href=
              "index.html#function-function-available"><code>function-available</code></a>,
              <span><a href=
              "index.html#function-type-available"><code>type-available</code></a>,</span>
              and <a href=
              "index.html#function-system-property"><code>system-property</code></a>
              defined in this specification, plus <span>the set of
              extension functions that are present in the static
              context of every XPath expression (other than a
              use-when expression) within the content of the
              element that is the parent of the
              <code>use-when</code> attribute</span>. Note that
              <a title="stylesheet function" href=
              "index.html#dt-stylesheet-function">stylesheet functions</a>
              are <em>not</em> included in the context, which means
              that the function <a href=
              "index.html#function-function-available"><code>function-available</code></a>
              will return <code>false</code> in respect of such
              functions. <span>The effect of this rule is to ensure
              that <a href=
              "index.html#function-function-available"><code>function-available</code></a>
              returns true in respect of functions that can be
              called within the scope of the <code>use-when</code>
              attribute. It also has the effect that these
              extensions functions will be recognized within the
              <code>use-when</code> attribute itself; however, the
              fact that a function is available in this sense gives
              no guarantee that a call on the function will
              succeed.</span></td>
            </tr>

            <tr>
              <td valign="top">In scope collations</td>

              <td>Implementation-defined</td>
            </tr>

            <tr>
              <td valign="top">Default collation</td>

              <td>The Unicode Codepoint Collation</td>
            </tr>

            <tr>
              <td valign="top">Base URI</td>

              <td>The base URI of the containing element in the
              stylesheet</td>
            </tr>

            <tr>
              <td valign="top">Statically known documents</td>

              <td>None</td>
            </tr>

            <tr>
              <td valign="top">Statically known collections</td>

              <td>None</td>
            </tr>
          </tbody>
        </table>

        <p>&#160;</p>

        <table border="1" cellpadding="5" width="100%">
          <caption>
            Dynamic Context Components for <code>use-when</code>
            Expressions
          </caption>
          <col align="left" width="30%" span="1" />
          <col align="left" span="1" />

          <thead>
            <tr>
              <th>Component</th>

              <th>Value</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td valign="top">Context item, position, and
              size</td>

              <td>Undefined</td>
            </tr>

            <tr>
              <td valign="top">Dynamic variables</td>

              <td>None</td>
            </tr>

            <tr>
              <td valign="top">Current date and time</td>

              <td>Implementation-defined</td>
            </tr>

            <tr>
              <td valign="top">Implicit timezone</td>

              <td>Implementation-defined</td>
            </tr>

            <tr>
              <td valign="top">Available documents</td>

              <td>None</td>
            </tr>

            <tr>
              <td valign="top">Available collections</td>

              <td>None</td>
            </tr>
          </tbody>
        </table>

        <p>Within a <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet module</a>, all
        expressions contained in <code>[xsl:]use-when</code>
        attributes are evaluated in a single <a href=
        "http://www.w3.org/TR/xpath-functions/#execution-scope">execution
        scope</a><sup><small>FO</small></sup>. This need not be the
        same execution scope as that used for
        <code>[xsl]:use-when</code> expressions in other stylesheet
        modules, or as that used when evaluating XPath expressions
        appearing elsewhere in the stylesheet module. This means
        that a function such as <a href=
        "http://www.w3.org/TR/xpath-functions/#func-current-date"><code>
        current-date</code></a><sup><small>FO</small></sup> will
        return the same result when called in different
        <code>[xsl:]use-when</code> expressions within the same
        stylesheet module, but will not necessarily return the same
        result as the same call in an <code>[xsl:]use-when</code>
        expression within a different stylesheet module, or as a
        call on the same function executed during the
        transformation proper.</p>

        <p>The use of <code>[xsl:]use-when</code> is illustrated in
        the following examples.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e5094" id="d5e5094"></a>Example: Using
            Conditional Exclusion to Achieve Portability
          </div>

          <p>This example demonstrates the use of the
          <code>use-when</code> attribute to achieve portability of
          a stylesheet across schema-aware and non-schema-aware
          processors.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:import-schema schema-location="http://example.com/schema"
              use-when="system-property('xsl:is-schema-aware')='yes'"/&gt;

&lt;xsl:template match="/" 
              use-when="system-property('xsl:is-schema-aware')='yes'" 
              priority="2"&gt;
  &lt;xsl:result-document validation="strict"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:result-document&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="/"&gt;
  &lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>The effect of these declarations is that a
          non-schema-aware processor ignores the <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          declaration and the first template rule, and therefore
          generates no errors in respect of the schema-related
          constructs in these declarations.</p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e5109" id="d5e5109"></a>Example: Including
            Variant Stylesheet Modules
          </div>

          <p>This example includes different stylesheet modules
          depending on which XSLT processor is in use.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:include href="module-A.xsl" 
     use-when="system-property('xsl:vendor')='vendor-A'"/&gt;
&lt;xsl:include href="module-B.xsl" 
     use-when="system-property('xsl:vendor')='vendor-B'"/&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="built-in-types" id="built-in-types"></a>3.13
        Built-in Types</h3>

        <p>Every XSLT 2.0 processor includes the following named
        type definitions in the <a title=
        "in-scope schema component" href=
        "index.html#dt-in-scope-schema-component">in-scope schema
        components</a>:</p>

        <ul>
          <li>
            <p>All the primitive atomic types defined in <a href=
            "index.html#xmlschema-2">[XML Schema Part 2]</a>, with the
            exception of <code>xs:NOTATION</code>. That is:
            <code>xs:string</code>, <code>xs:boolean</code>,
            <code>xs:decimal</code>, <code>xs:double</code>,
            <code>xs:float</code>, <code>xs:date</code>,
            <code>xs:time</code>, <code>xs:dateTime</code>,
            <code>xs:duration</code>, <code>xs:QName</code>,
            <code>xs:anyURI</code>, <code>xs:gDay</code>,
            <code>xs:gMonthDay</code>, <code>xs:gMonth</code>,
            <code>xs:gYearMonth</code>, <code>xs:gYear</code>,
            <code>xs:base64Binary</code>, and
            <code>xs:hexBinary</code>.</p>
          </li>

          <li>
            <p>The derived atomic type <code>xs:integer</code>
            defined in <a href="index.html#xmlschema-2">[XML Schema Part
            2]</a>.</p>
          </li>

          <li>
            <p>The types <code>xs:anyType</code> and
            <code>xs:anySimpleType</code>.</p>
          </li>

          <li>
            <p>The following types defined in <a href=
            "index.html#xpath20">[XPath 2.0]</a>:
            <span><code>xs:yearMonthDuration</code></span>,
            <span><code>xs:dayTimeDuration</code></span>,
            <span><code>xs:anyAtomicType</code></span>,
            <span><code>xs:untyped</code></span>, and
            <span><code>xs:untypedAtomic</code></span>.</p>
          </li>
        </ul>

        <p>A <a title="schema-aware XSLT processor" href=
        "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
        processor</a> additionally supports:</p>

        <ul>
          <li>
            <p>All other built-in types defined in <a href=
            "index.html#xmlschema-2">[XML Schema Part 2]</a></p>
          </li>

          <li>
            <p>User-defined types, and element and attribute
            declarations, that are imported using an <a href=
            "index.html#element-import-schema"><code>xsl:import-schema</code></a>
            declaration as described in <a href=
            "index.html#import-schema"><i>3.14 Importing Schema
            Components</i></a>. These may include both simple and
            complex types.</p>
          </li>
        </ul>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The names that are imported from the XML Schema
          namespace do not include all the names of top-level types
          defined in either the Schema for Schemas or the Schema
          for Datatypes. The Schema for Datatypes, as well as
          defining built-in types such as <code>xs:integer</code>
          and <code>xs:double</code>, also defines types that are
          intended for use only within the Schema for DataTypes,
          such as <code>xs:derivationControl</code>. A <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> that is
          designed to process XML Schema documents as its input or
          output may import the Schema for Schemas.</p>
        </div>

        <p>An implementation may define mechanisms that allow
        additional <a title="schema component" href=
        "index.html#dt-schema-component">schema components</a> to be added to
        the <a title="in-scope schema component" href=
        "index.html#dt-in-scope-schema-component">in-scope schema
        components</a> for the stylesheet. For example, the
        mechanisms used to define <a title="extension function"
        href="index.html#dt-extension-function">extension functions</a> (see
        <a href="index.html#extension-functions"><i>18.1 Extension
        Functions</i></a>) may also be used to import the types
        used in the interface to such functions.</p>

        <p>These <a title="schema component" href=
        "index.html#dt-schema-component">schema components</a> are the only
        ones that may be referenced in XPath expressions within the
        stylesheet, or in the <code>[xsl:]type</code> and
        <code>as</code> attributes of those elements that permit
        these attributes.</p>

        <p>For a Basic XSLT Processor, schema built-in types that
        are not included in the static context (for example,
        <code>xs:NCName</code>) are "unknown types" in the sense of
        <a href=
        "http://www.w3.org/TR/xpath20/#id-sequencetype-matching">Section
        2.5.4 SequenceType
        Matching</a><sup><small>XP</small></sup>. In the language
        of that section, a Basic XSLT Processor <span class=
        "verb">must</span> be able to determine whether these
        unknown types are derived from known schema types such as
        <code>xs:string</code>. The purpose of this rule is to
        ensure that system functions such as <a href=
        "http://www.w3.org/TR/xpath-functions/#func-local-name-from-QName">
        <code>local-name-from-QName</code></a><sup><small>FO</small></sup>,
        which is defined to return an <code>xs:NCName</code>,
        behave correctly. A stylesheet that uses a Basic XSLT
        Processor will not be able to test whether the returned
        value is an <code>xs:NCName</code>, but it will be able to
        use it as if it were an <code>xs:string</code>.</p>
      </div>

      <div class="div2">
        <h3><a name="import-schema" id="import-schema"></a>3.14
        Importing Schema Components</h3>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The facilities described in this section are not
          available with a <a title="basic XSLT processor" href=
          "index.html#dt-basic-xslt-processor">basic XSLT processor</a>. They
          require a <a title="schema-aware XSLT processor" href=
          "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
          processor</a>, as described in <a href=
          "index.html#conformance"><i>21 Conformance</i></a>.</p>
        </div>

        <p class="element-syntax"><a name="element-import-schema"
        id="element-import-schema"></a><code>&lt;!-- Category:
        declaration --&gt;<br />
        &lt;xsl:import-schema<br />
        &#160;&#160;namespace? = <var>uri-reference</var><br />
        &#160;&#160;schema-location? =
        <var>uri-reference</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: xs:schema? --&gt;<br />
        &lt;/xsl:import-schema&gt;</code></p>

        <p>The <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration is used to identify <a title="schema component"
        href="index.html#dt-schema-component">schema components</a> (that is,
        top-level type definitions and top-level element and
        attribute declarations) that need to be available
        statically, that is, before any source document is
        available. Names of such components used statically within
        the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> must refer to an <a title=
        "in-scope schema component" href=
        "index.html#dt-in-scope-schema-component">in-scope schema
        component</a>, which means they must either be built-in
        types as defined in <a href="index.html#built-in-types"><i>3.13
        Built-in Types</i></a>, or they must be imported using an
        <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration.</p>

        <p>The <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration identifies a namespace containing the names of
        the components to be imported (or indicates that components
        whose names are in no namespace are to be imported). The
        effect is that the names of top-level element and attribute
        declarations and type definitions from this namespace (or
        non-namespace) become available for use within XPath
        expressions in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, and within other
        stylesheet constructs such as the <code>type</code> and
        <code>as</code> attributes of various <a title=
        "XSLT element" href="index.html#dt-xslt-element">XSLT
        elements</a>.</p>

        <p>The same schema components are available in all
        stylesheet modules; importing components in one stylesheet
        module makes them available throughout the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>.</p>

        <p>The <code>namespace</code> and
        <code>schema-location</code> attributes are both
        optional.</p>

        <p>If the <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        element contains an <code>xs:schema</code> element, then
        the <code>schema-location</code> attribute must be absent,
        and the <code>namespace</code> attribute must either have
        the same value as the <code>targetNamespace</code>
        attribute of the <code>xs:schema</code> element (if
        present), or must be absent, in which case its effective
        value is that of the <code>targetNamespace</code> attribute
        of the <code>xs:schema</code> element if present or the
        zero-length string otherwise.</p>

        <p><a name="err-XTSE0215" id="err-XTSE0215"><span class=
        "error">[ERR XTSE0215]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        element that contains an <code>xs:schema</code> element has
        a <code>schema-location</code> attribute, or if it has a
        <code>namespace</code> attribute that conflicts with the
        target namespace of the contained schema.</p>

        <p>If two <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declarations specify the same namespace, or if both specify
        no namespace, then only the one with highest <a title=
        "import precedence" href="index.html#dt-import-precedence">import
        precedence</a> is used. If this leaves more than one, then
        all the declarations at the highest import precedence are
        used (which may cause conflicts, as described below).</p>

        <p>After discarding any <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declarations under the above rule, the effect of the
        remaining <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declarations is defined in terms of a hypothetical document
        called the synthetic schema document, which is constructed
        as follows. The synthetic schema document defines an
        arbitrary target namespace that is different from any
        namespace actually used by the application, and it contains
        <code>xs:import</code> elements corresponding one-for-one
        with the <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declarations in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, with the following
        correspondence:</p>

        <ul>
          <li>
            <p>The <code>namespace</code> attribute of the
            <code>xs:import</code> element is copied from the
            <code>namespace</code> attribute of the <a href=
            "index.html#element-import-schema"><code>xsl:import-schema</code></a>
            declaration if it is <span>explicitly present, or is
            implied by the <code>targetNamespace</code> attribute
            of a contained <code>xs:schema</code> element,</span>
            and is absent if it is absent.</p>
          </li>

          <li>
            <p>The <code>schemaLocation</code> attribute of the
            <code>xs:import</code> element is copied from the
            <code>schema-location</code> attribute of the <a href=
            "index.html#element-import-schema"><code>xsl:import-schema</code></a>
            declaration if present, and is absent if it is absent.
            <span>If there is a contained <code>xs:schema</code>
            element, the effective value of the
            <code>schemaLocation</code> attribute is a URI
            referencing a document containing a copy of the
            <code>xs:schema</code> element.</span></p>
          </li>

          <li>
            <p>The base URI of the <code>xs:import</code> element
            is the same as the base URI of the <a href=
            "index.html#element-import-schema"><code>xsl:import-schema</code></a>
            declaration.</p>
          </li>
        </ul>

        <p>The schema components included in the <a title=
        "in-scope schema component" href=
        "index.html#dt-in-scope-schema-component">in-scope schema
        components</a> (that is, the components whose names are
        available for use within the stylesheet) are the top-level
        element and attribute declarations and type definitions
        that are available for reference within the synthetic
        schema document. See <a href="index.html#xmlschema-1">[XML Schema
        Part 1]</a> (section 4.2.3, <em>References to schema
        components across namespaces</em>).</p>

        <p><a name="err-XTSE0220" id="err-XTSE0220"><span class=
        "error">[ERR XTSE0220]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the synthetic schema document does not satisfy the
        constraints described in <a href="index.html#xmlschema-1">[XML Schema
        Part 1]</a> (section 5.1, <em>Errors in Schema Construction
        and Structure</em>). This includes, without loss of
        generality, conflicts such as multiple definitions of the
        same name.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The synthetic schema document does not need to be
          constructed by a real implementation. It is purely a
          mechanism for defining the semantics of <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          in terms of rules that already exist within the XML
          Schema specification. In particular, it implicitly
          defines the rules that determine whether the set of
          <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          declarations are mutually consistent.</p>

          <p>These rules do not cause names to be imported
          transitively. The fact that a name is available for
          reference within a schema document A does not of itself
          make the name available for reference in a stylesheet
          that imports the target namespace of schema document A.
          (See <a href="index.html#xmlschema-1">[XML Schema Part 1]</a>
          section 3.15.3, Constraints on XML Representations of
          Schemas.) The stylesheet must import all the namespaces
          containing names that it actually references.</p>

          <p>The <code>namespace</code> attribute indicates that a
          schema for the given namespace is required by the
          <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>. This information may be
          enough on its own to enable an implementation to locate
          the required schema components. The
          <code>namespace</code> attribute may be omitted to
          indicate that a schema for names in no namespace is being
          imported. The zero-length string is not a valid namespace
          URI, and is therefore not a valid value for the
          <code>namespace</code> attribute.</p>

          <p>The <code>schema-location</code> attribute is a
          <a title="URI Reference" href="index.html#dt-uri-reference">URI
          Reference</a> that gives a hint indicating where a schema
          document or other resource containing the required
          definitions may be found. It is likely that a <a title=
          "schema-aware XSLT processor" href=
          "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
          processor</a> will be able to process a schema document
          found at this location.</p>

          <p>The XML Schema specification gives implementations
          flexibility in how to handle multiple imports for the
          same namespace. Multiple imports do not cause errors if
          the definitions do not conflict.</p>

          <p>A consequence of these rules is that it is not
          intrinsically an error if no schema document can be
          located for a namespace identified in an <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          declaration. This will cause an error only if it results
          in the stylesheet containing references to names that
          have not been imported.</p>

          <p>An inline schema document (using an
          <code>xs:schema</code> element as a child of the
          <code>xsl:import-schema</code> element) has the same
          status as an external schema document, in the sense that
          it acts as a hint for a source of schema components in
          the relevant namespace. To ensure that the inline schema
          document is always used, it is advisable to use a target
          namespace that is unique to this schema document.</p>
        </div>

        <p>The use of a namespace in an <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration does not by itself associate any namespace
        prefix with the namespace. If names from the namespace are
        used within the stylesheet module then a namespace
        declaration must be included in the stylesheet module, in
        the usual way.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e5611" id="d5e5611"></a>Example: An Inline
            Schema Document
          </div>

          <p>The following example shows an inline schema document.
          This declares a simple type <code>local:yes-no</code>,
          which the stylesheet then uses in the declaration of a
          variable.</p>

          <p>The example assumes the namespace declaration
          <code>xmlns:local="http://localhost/ns/yes-no"</code></p>

          <div class="exampleInner">
            <pre>
&lt;xsl:import-schema&gt;
  &lt;xs:schema targetNamespace="http://localhost/ns/yes-no"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:simpleType name="local:yes-no"&gt;
      &lt;xs:restriction base="xs:string"&gt;
        &lt;xs:enumeration value="yes"/&gt;
        &lt;xs:enumeration value="no"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:schema&gt;
&lt;/xsl:import-schema&gt;

&lt;xs:variable name="condition" select="'yes'" as="local:yes-no"/&gt;
</pre>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="data-model" id="data-model"></a>4 Data
      Model</h2>

      <p>The data model used by XSLT is the XPath 2.0 and XQuery
      1.0 data model <span>(XDM)</span>, as defined in <a href=
      "index.html#xpath-datamodel">[Data Model]</a>. XSLT operates on source,
      result and stylesheet documents using the same data
      model.</p>

      <p>This section elaborates on some particular features of
      <span>XDM</span> as it is used by XSLT:</p>

      <p>The rules in <a href="index.html#stylesheet-stripping"><i>4.2
      Stripping Whitespace from the Stylesheet</i></a> and <a href=
      "index.html#strip"><i>4.4 Stripping Whitespace from a Source
      Tree</i></a> make use of the concept of a whitespace text
      node.</p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-whitespace-text-node" id="dt-whitespace-text-node" title=
      "whitespace text node"></a>A <b>whitespace text node</b> is a
      text node whose content consists entirely of whitespace
      characters (that is, #x09, #x0A, #x0D, or #x20).<span class=
      "definition">]</span></p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>Features of a source XML document that are not
        represented in the <span>XDM tree</span> will have no
        effect on the operation of an XSLT stylesheet. Examples of
        such features are entity references, CDATA sections,
        character references, whitespace within element tags, and
        the choice of single or double quotes around attribute
        values.</p>
      </div>

      <div class="div2">
        <h3><a name="xml-versions" id="xml-versions"></a>4.1 XML
        Versions</h3>

        <p>The <span>XDM</span> data model defined in <a href=
        "index.html#xpath-datamodel">[Data Model]</a> is capable of
        representing either an XML 1.0 document (conforming to
        <a href="index.html#REC-xml">[XML 1.0]</a> and <a href=
        "index.html#REC-xml-names">[Namespaces in XML 1.0]</a>) or an XML 1.1
        document (conforming to <a href="index.html#xml11">[XML 1.1]</a> and
        <a href="index.html#xml-names11">[Namespaces in XML 1.1]</a>), and it
        makes no distinction between the two. In principle,
        therefore, XSLT 2.0 can be used with either of these XML
        versions.</p>

        <p>Construction of the <span>XDM tree</span> is outside the
        scope of this specification, so XSLT 2.0 places no formal
        requirements on an XSLT processor to accept input from
        either XML 1.0 documents or XML 1.1 documents or both. This
        specification does define a serialization capability (see
        <a href="index.html#serialization"><i>20 Serialization</i></a>),
        though from a conformance point of view it is an optional
        feature. Although facilities are described for serializing
        the <span>XDM tree</span> as either XML 1.0 or XML 1.1 (and
        controlling the choice), there is again no formal
        requirement on an XSLT processor to support either or both
        of these XML versions as serialization targets.</p>

        <p>Because the <span>XDM tree</span> is the same whether
        the original document was XML 1.0 or XML 1.1, the semantics
        of XSLT processing do not depend on the version of XML used
        by the original document. There is no reason in principle
        why all the input and output documents used in a single
        transformation must conform to the same version of XML.</p>

        <p>Some of the syntactic constructs in XSLT 2.0 and XPath
        2.0, for example the productions <a href=
        "http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char">Char</a><sup>
        <small>XML</small></sup> and <a href=
        "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
        <small>Names</small></sup>, are defined by reference to the
        XML and XML Namespaces specifications. There are slight
        variations between the XML 1.0 and XML 1.1 versions of
        these productions. <span>Implementations <span class=
        "verb">may</span> support either version; it is
        <span class="verb">recommended</span> that an XSLT 2.0
        processor that implements the 1.1 versions <span class=
        "verb">should</span> also provide a mode that supports the
        1.0 versions. It is thus <a title="implementation-defined"
        href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        whether the XSLT processor supports XML 1.0 with XML
        Namespaces 1.0, or XML 1.1 with XML Namespaces 1.1, or
        supports both versions at user option.</span></p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The specification referenced as <a href=
          "index.html#REC-xml-names">[Namespaces in XML 1.0]</a> was actually
          published without a version number.</p>
        </div>

        <p>At the time of writing there is no published version of
        <a href="index.html#xmlschema-2">[XML Schema Part 2]</a> that
        references the XML 1.1 specifications. This means that data
        types such as <code>xs:NCName</code> and <code>xs:ID</code>
        are constrained by the XML 1.0 rules, and do not allow the
        full range of values permitted by XML 1.1. This situation
        will not be resolved until a new version of <a href=
        "index.html#xmlschema-2">[XML Schema Part 2]</a> becomes available;
        in the meantime, it is <span class=
        "verb">recommended</span> that implementers wishing to
        support XML 1.1 should consult <a href=
        "index.html#SCHEMA-AND-XML-1.1">[XML Schema 1.0 and XML 1.1]</a> for
        guidance. An XSLT 2.0 processor that supports XML 1.1
        <span class="verb">should</span> implement the rules in
        later versions of <a href="index.html#xmlschema-2">[XML Schema Part
        2]</a> as they become available.</p>
      </div>

      <div class="div2">
        <h3><a name="stylesheet-stripping" id=
        "stylesheet-stripping"></a>4.2 Stripping Whitespace from
        the Stylesheet</h3>

        <p>The tree representing the stylesheet is preprocessed as
        follows:</p>

        <ol class="enumar">
          <li>
            <p>All comments and processing instructions are
            removed.</p>
          </li>

          <li>
            <p>Any text nodes that are now adjacent to each other
            are merged.</p>
          </li>

          <li>
            <p>Any <a title="whitespace text node" href=
            "index.html#dt-whitespace-text-node">whitespace text node</a>
            that satisfies both the following conditions is removed
            from the tree:</p>

            <ul>
              <li>
                <p>The parent of the text node is not an <a href=
                "index.html#element-text"><code>xsl:text</code></a>
                element</p>
              </li>

              <li>
                <p>The text node does not have an ancestor element
                that has an <code>xml:space</code> attribute with a
                value of <code>preserve</code>, unless there is a
                closer ancestor element having an
                <code>xml:space</code> attribute with a value of
                <code>default</code>.</p>
              </li>
            </ul>
          </li>

          <li>
            <p>Any <a title="whitespace text node" href=
            "index.html#dt-whitespace-text-node">whitespace text node</a>
            whose parent is one of the following elements is
            removed from the tree, regardless of any
            <code>xml:space</code> attributes:</p>

            <blockquote>
              <p><a href=
              "index.html#element-analyze-string"><code>xsl:analyze-string</code></a><br />

              <a href=
              "index.html#element-apply-imports"><code>xsl:apply-imports</code></a><br />

              <a href=
              "index.html#element-apply-templates"><code>xsl:apply-templates</code></a><br />

              <a href=
              "index.html#element-attribute-set"><code>xsl:attribute-set</code></a><br />

              <a href=
              "index.html#element-call-template"><code>xsl:call-template</code></a><br />

              <a href=
              "index.html#element-character-map"><code>xsl:character-map</code></a><br />

              <a href=
              "index.html#element-choose"><code>xsl:choose</code></a><br />
              <a href=
              "index.html#element-next-match"><code>xsl:next-match</code></a><br />

              <a href=
              "index.html#element-stylesheet"><code>xsl:stylesheet</code></a><br />

              <a href=
              "index.html#element-transform"><code>xsl:transform</code></a></p>
            </blockquote>
          </li>

          <li>
            <p>Any <a title="whitespace text node" href=
            "index.html#dt-whitespace-text-node">whitespace text node</a>
            whose following-sibling node is an <a href=
            "index.html#element-param"><code>xsl:param</code></a> or <a href=
            "index.html#element-sort"><code>xsl:sort</code></a> element is
            removed from the tree, regardless of any
            <code>xml:space</code> attributes.</p>
          </li>
        </ol>

        <p><a name="err-XTSE0260" id="err-XTSE0260"><span class=
        "error">[ERR XTSE0260]</span></a> Within an <a title=
        "XSLT element" href="index.html#dt-xslt-element">XSLT element</a>
        that is <span class="verb">required</span> to be empty, any
        content other than comments or processing instructions,
        including any <a title="whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text node</a>
        preserved using the <code>xml:space="preserve"</code>
        attribute, is a <a title="static error" href=
        "index.html#dt-static-error">static error</a>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Using <code>xml:space="preserve"</code> in parts of
          the stylesheet that contain <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructors</a> will
          cause all text nodes in that part of the stylesheet,
          including those that contain whitespace only, to be
          copied to the result of the sequence constructor. When
          the result of the sequence constructor is used to form
          the content of an element, this can cause errors if such
          text nodes are followed by attribute nodes generated
          using <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>.</p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>If an <code>xml:space</code> attribute is specified on
          a <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>,
          it will be copied to the result tree in the same way as
          any other attribute.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="stripping-annotations" id=
        "stripping-annotations"></a>4.3 Stripping Type Annotations
        from a Source Tree</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-annotation" id="dt-annotation" title=
        "type annotation"></a>The term <b>type annotation</b> is
        used in this specification to refer to the value returned
        by the <code>dm:type-name</code> accessor of a node: see
        <a href=
        "http://www.w3.org/TR/xpath-datamodel/#dm-type-name">Section
        5.14 type-name
        Accessor</a><sup><small>DM</small></sup>.<span class=
        "definition">]</span></p>

        <p>There is sometimes a requirement to write stylesheets
        that produce the same results whether or not the source
        documents have been validated against a schema. To achieve
        this, an option is provided to remove any <a title=
        "type annotation" href="index.html#dt-annotation">type
        annotations</a> on element and attribute nodes in a
        <a title="source tree" href="index.html#dt-source-tree">source
        tree</a>, replacing them with an annotation of
        <span><code>xs:untyped</code></span> in the case of element
        nodes, and <span><code>xs:untypedAtomic</code></span> in
        the case of attribute nodes.</p>

        <p>Such stripping of <a title="type annotation" href=
        "index.html#dt-annotation">type annotations</a> can be requested by
        specifying <code>input-type-annotations="strip"</code> on
        the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element. This attribute has three permitted values:
        <code>strip</code>, <code>preserve</code>, and
        <code>unspecified</code>. The default value is
        <code>unspecified</code>. Stripping of type annotations
        takes place if at least one <a title="stylesheet module"
        href="index.html#dt-stylesheet-module">stylesheet module</a> in the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        specifies <code>input-type-annotations="strip"</code>.</p>

        <p><a name="err-XTSE0265" id="err-XTSE0265"><span class=
        "error">[ERR XTSE0265]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        there is a <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet module</a> in the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        that specifies <code>input-type-annotations="strip"</code>
        and another <a title="stylesheet module" href=
        "index.html#dt-stylesheet-module">stylesheet module</a> that
        specifies
        <code>input-type-annotations="preserve"</code>.</p>

        <p>The <a title="source tree" href="index.html#dt-source-tree">source
        trees</a> to which this applies are the same as those
        affected by <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> and
        <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>:
        see <a href="index.html#strip"><i>4.4 Stripping Whitespace from a
        Source Tree</i></a>.</p>

        <p>When type annotations are stripped, the following
        changes are made to the source tree:</p>

        <ul>
          <li>
            <p>The type annotation of every element node is changed
            to <code>xs:untyped</code></p>
          </li>

          <li>
            <p>The type annotation of every attribute node is
            changed to <code>xs:untypedAtomic</code></p>
          </li>

          <li>
            <p>The typed value of every element and attribute node
            is set to be the same as its string value, as an
            instance of <code>xs:untypedAtomic</code>.</p>
          </li>

          <li>
            <p>The <code>is-nilled</code> property of every element
            node is set to <code>false</code>.</p>
          </li>
        </ul>

        <p>The values of the <code>is-id</code> and
        <code>is-idrefs</code> properties are not changed.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Stripping type annotations does not necessarily return
          the document to the state it would be in had validation
          not taken place. In particular, any defaulted elements
          and attributes that were added to the tree by the
          validation process will still be present <span>, and
          elements and attributes validated as IDs will still be
          accessible using the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-id"><code>id</code></a><sup>
          <small>FO</small></sup> function</span>.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="strip" id="strip"></a>4.4 Stripping Whitespace
        from a Source Tree</h3>

        <p>A <a title="source tree" href="index.html#dt-source-tree">source
        tree</a> supplied as input to the transformation process
        may contain <a title="whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text nodes</a> that
        are of no interest, and that do not need to be retained by
        the transformation. Conceptually, an XSLT <a title=
        "processor" href="index.html#dt-processor">processor</a> makes a copy
        of the source tree from which unwanted <a title=
        "whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text nodes</a> have
        been removed. This process is referred to as whitespace
        stripping.</p>

        <p>For the purposes of this section, the term <b>source
        tree</b> means the document containing the <a title=
        "initial context node" href=
        "index.html#dt-initial-context-node">initial context node</a>, and
        any document returned by the functions <a href=
        "index.html#function-document"><code>document</code></a>, <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
        <small>FO</small></sup>, or <a href=
        "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
        collection</code></a><sup><small>FO</small></sup>. It does
        not include documents passed as the values of <a title=
        "stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameters</a> or
        returned from <a title="extension function" href=
        "index.html#dt-extension-function">extension functions</a>.</p>

        <p>The stripping process takes as input a set of element
        names whose child <a title="whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text nodes</a> are to
        be preserved. The way in which this set of element names is
        established using the <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> and
        <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        declarations is described later in this section.</p>

        <p>A <a title="whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text node</a> is
        preserved if either of the following apply:</p>

        <ul>
          <li>
            <p>The element name of the parent of the text node is
            in the set of whitespace-preserving element names.</p>
          </li>

          <li>
            <p>An ancestor element of the text node has an
            <code>xml:space</code> attribute with a value of
            <code>preserve</code>, and no closer ancestor element
            has <code>xml:space</code> with a value of
            <code>default</code>.</p>
          </li>
        </ul>

        <p>Otherwise, the <a title="whitespace text node" href=
        "index.html#dt-whitespace-text-node">whitespace text node</a> is
        stripped.</p>

        <p>The <code>xml:space</code> attributes are not removed
        from the tree.</p>

        <p class="element-syntax"><a name="element-strip-space" id=
        "element-strip-space"></a><code>&lt;!-- Category:
        declaration --&gt;<br />
        &lt;xsl:strip-space<br />
        &#160;&#160;<b>elements</b> =
        <var>tokens</var>&#160;/&gt;</code></p>

        <p class="element-syntax"><a name="element-preserve-space"
        id="element-preserve-space"></a><code>&lt;!-- Category:
        declaration --&gt;<br />
        &lt;xsl:preserve-space<br />
        &#160;&#160;<b>elements</b> =
        <var>tokens</var>&#160;/&gt;</code></p>

        <p>The set of whitespace-preserving element names is
        specified by <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> and
        <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        <a title="declaration" href=
        "index.html#dt-declaration">declarations</a>. Whether an element name
        is included in the set of whitespace-preserving names is
        determined by the best match among all the <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> or
        <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        declarations: it is included if and only if there is no
        match or the best match is an <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        element. The <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> and
        <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        elements each have an <code>elements</code> attribute whose
        value is a whitespace-separated list of <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-NameTest">NameTests</a><sup>
        <small>XP</small></sup>; an element name matches an
        <a href="index.html#element-strip-space"><code>xsl:strip-space</code></a>
        or <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        element if it matches one of the <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-NameTest">NameTests</a><sup>
        <small>XP</small></sup>. An element matches a <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-NameTest">NameTest</a><sup>
        <small>XP</small></sup> if and only if the <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-NameTest">NameTest</a><sup>
        <small>XP</small></sup> would be true for the element as an
        XPath node test. When more than one <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> and
        <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
        element matches, the best matching element is determined by
        the best matching <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-NameTest">NameTest</a><sup>
        <small>XP</small></sup>. This is determined in the same way
        as with <a title="template rule" href=
        "index.html#dt-template-rule">template rules</a>:</p>

        <ul>
          <li>
            <p>First, any match with lower <a title=
            "import precedence" href="index.html#dt-import-precedence">import
            precedence</a> than another match is ignored.</p>
          </li>

          <li>
            <p>Next, any match that has a lower <a title=
            "default priority" href="index.html#dt-default-priority">default
            priority</a> than the <a title="default priority" href=
            "index.html#dt-default-priority">default priority</a> of another
            match is ignored.</p>
          </li>
        </ul>

        <p><a name="err-XTRE0270" id="err-XTRE0270"><span class=
        "error">[ERR XTRE0270]</span></a> It is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> if
        this leaves more than one match<span>, unless all the
        matched declarations are equivalent (that is, they are all
        <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a> or
        they are all <a href=
        "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>)</span>.
        <span>The <a title="optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is to select, from the matches that are left, the one that
        occurs last in <a title="declaration order" href=
        "index.html#dt-declaration-order">declaration order</a>.</span></p>

        <p>If an element in a source document has a <a title=
        "type annotation" href="index.html#dt-annotation">type annotation</a>
        that is a simple type or a complex type with simple
        content, then any whitespace text nodes among its children
        are preserved, regardless of any <a href=
        "index.html#element-strip-space"><code>xsl:strip-space</code></a>
        declarations. The reason for this is that stripping a
        whitespace text node from an element with simple content
        could make the element invalid: for example, it could cause
        the <code>minLength</code> facet to be violated.</p>

        <p>Stripping of <a title="type annotation" href=
        "index.html#dt-annotation">type annotations</a> happens before
        stripping of whitespace text nodes, so this
        <span>situation</span> will not occur if
        <code>input-type-annotations="strip"</code> is
        specified.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>In <a href="index.html#xpath-datamodel">[Data Model]</a>,
          processes are described for constructing an <span>XDM
          tree</span> from an Infoset or from a PSVI. Those
          processes deal with whitespace according to their own
          rules, and the provisions in this section apply to the
          resulting tree. In practice this means that elements that
          are defined in a DTD or a Schema to contain element-only
          content will have <a title="whitespace text node" href=
          "index.html#dt-whitespace-text-node">whitespace text nodes</a>
          stripped, regardless of the <a href=
          "index.html#element-strip-space"><code>xsl:strip-space</code></a>
          and <a href=
          "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
          declarations in the stylesheet.</p>

          <p>However, source trees are not necessarily constructed
          using those processes; indeed, they are not necessarily
          constructed by parsing XML documents. Nothing in the XSLT
          specification constrains how the source tree is
          constructed, or what happens to <a title=
          "whitespace text node" href=
          "index.html#dt-whitespace-text-node">whitespace text nodes</a>
          during its construction. The provisions in this section
          relate only to whitespace text nodes that are present in
          the tree supplied as input to the XSLT processor. The
          XSLT processor cannot preserve whitespace text nodes
          unless they were actually present in the supplied
          tree.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="id-in-data-model" id=
        "id-in-data-model"></a>4.5 Attribute Types and DTD
        Validation</h3>

        <p>The mapping from the Infoset to the <span>XDM</span>
        data model, described in <a href="index.html#xpath-datamodel">[Data
        Model]</a>, does not retain attribute types. This means,
        for example, that an attribute described in the DTD as
        having attribute type <code>NMTOKENS</code> will be
        annotated in <span>the XDM tree</span> as
        <span><code>xs:untypedAtomic</code></span> rather than
        <code>xs:NMTOKENS</code>, and its typed value will consist
        of a single <span><code>xs:untypedAtomic</code></span>
        value rather than a sequence of <code>xs:NMTOKEN</code>
        values.</p>

        <p>Attributes with a DTD-derived type of ID, IDREF, or
        IDREFS will be marked in the <span>XDM tree</span> as
        having the <code>is-id</code> or <code>is-idrefs</code>
        properties. It is these properties, rather than any
        <a title="type annotation" href="index.html#dt-annotation">type
        annotation</a>, that are examined by the functions <a href=
        "http://www.w3.org/TR/xpath-functions/#func-id"><code>id</code></a><sup>
        <small>FO</small></sup> and <a href=
        "http://www.w3.org/TR/xpath-functions/#func-idref"><code>idref</code></a><sup>
        <small>FO</small></sup> described in <a href=
        "index.html#xpath-functions">[Functions and Operators]</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="limits" id="limits"></a>4.6 Limits</h3>

        <p>The XDM data model (see <a href="index.html#xpath-datamodel">[Data
        Model]</a>) leaves it to the host language to define
        limits. This section describes the limits that apply to
        XSLT.</p>

        <p>Limits on some primitive data types are defined in
        <a href="index.html#xmlschema-2">[XML Schema Part 2]</a>. Other
        limits, listed below, are <a title="implementation-defined"
        href=
        "index.html#dt-implementation-defined">implementation-defined</a>.
        Note that this does not necessarily mean that each limit
        must be a simple constant: it may vary depending on
        environmental factors such as available resources.</p>

        <p>The following limits are <a title=
        "implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>:</p>

        <ol class="enumar">
          <li>
            <p>For the <code>xs:decimal</code> type, the maximum
            number of decimal digits (the <code>totalDigits</code>
            facet). This must be at least 18 digits. (Note,
            however, that support for the full value range of
            <code>xs:unsignedLong</code> requires 20 digits.)</p>
          </li>

          <li>
            <p>For the types <code>xs:date</code>,
            <code>xs:time</code>, <code>xs:dateTime</code>,
            <code>xs:gYear</code>, and <code>xs:gYearMonth</code>:
            the range of values of the year component, which must
            be at least +0001 to +9999; and the maximum number of
            fractional second digits, which must be at least 3.</p>
          </li>

          <li>
            <p>For the <code>xs:duration</code> type: the maximum
            absolute values of the years, months, days, hours,
            minutes, and seconds components.</p>
          </li>

          <li>
            <p>For the
            <span><code>xs:yearMonthDuration</code></span> type:
            the maximum absolute value, expressed as an integer
            number of months.</p>
          </li>

          <li>
            <p>For the <span><code>xs:dayTimeDuration</code></span>
            type: the maximum absolute value, expressed as a
            decimal number of seconds.</p>
          </li>

          <li>
            <p>For the types <code>xs:string</code>,
            <code>xs:hexBinary</code>,
            <code>xs:base64Binary</code>, <code>xs:QName</code>,
            <code>xs:anyURI</code>, <code>xs:NOTATION</code>, and
            types derived from them: the maximum length of the
            value.</p>
          </li>

          <li>
            <p>For sequences, the maximum number of items in a
            sequence.</p>
          </li>
        </ol>
      </div>

      <div class="div2">
        <h3><a name="d-o-e-in-data-model" id=
        "d-o-e-in-data-model"></a>4.7 Disable Output Escaping</h3>

        <p>For backwards compatibility reasons, XSLT 2.0 continues
        to support the <code>disable-output-escaping</code> feature
        introduced in XSLT 1.0. This is an optional feature and
        implementations are not <span class="verb">required</span>
        to support it. A new facility, that of named <a title=
        "character map" href="index.html#dt-character-map">character maps</a>
        (see <a href="index.html#character-maps"><i>20.1 Character
        Maps</i></a>) is introduced in XSLT 2.0. It provides
        similar capabilities to
        <code>disable-output-escaping</code>, but without
        distorting the data model.</p>

        <p>If an <a title="implementation" href=
        "index.html#dt-implementation">implementation</a> supports the
        <code>disable-output-escaping</code> attribute of <a href=
        "index.html#element-text"><code>xsl:text</code></a> and <a href=
        "index.html#element-value-of"><code>xsl:value-of</code></a>, (see
        <a href="index.html#disable-output-escaping"><i>20.2 Disabling Output
        Escaping</i></a>), then the data model for trees
        constructed by the <a title="processor" href=
        "index.html#dt-processor">processor</a> is augmented with a boolean
        value representing the value of this property. <span>This
        boolean value, however, can be set only within a <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a> that is being passed to the
        serializer.</span></p>

        <p>Conceptually, each character in a text node on
        <span>such</span> a result tree has a boolean property
        indicating whether the serializer <span>is to</span>
        disable the normal rules for escaping of special characters
        (for example, outputting of <code>&amp;</code> as
        <code>&amp;amp;</code>) in respect of this character or
        attribute node.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>In practice, the nodes in a <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a> will often be streamed directly from the
          XSLT processor to the serializer. In such an
          implementation, <code>disable-output-escaping</code> can
          be viewed not so much a property stored with nodes in the
          tree, but rather as additional information passed across
          the interface between the XSLT processor and the
          serializer.</p>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="constructs" id="constructs"></a>5 Features of
      the XSLT Language</h2>

      <div class="div2">
        <h3><a name="qname" id="qname"></a>5.1 Qualified Names</h3>

        <p>The name of a stylesheet-defined object, specifically a
        <a title="named template" href="index.html#dt-named-template">named
        template</a>, a <a title="mode" href="index.html#dt-mode">mode</a>,
        an <a title="attribute set" href=
        "index.html#dt-attribute-set">attribute set</a>, a <a title="key"
        href="index.html#dt-key">key</a>, a <a title="decimal format" href=
        "index.html#dt-decimal-format">decimal-format</a>, a <a title=
        "variable" href="index.html#dt-variable">variable</a> or <a title=
        "parameter" href="index.html#dt-parameter">parameter</a>, a <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a>, a named
        <a title="output definition" href=
        "index.html#dt-output-definition">output definition</a>, <span>or a
        <a title="character map" href="index.html#dt-character-map">character
        map</a></span> is specified as a <a title="QName" href=
        "index.html#dt-qname">QName</a> <span>using the syntax for <a href=
        "http://www.w3.org/TR/REC-xml-names/#NT-QName">QName</a><sup>
        <small>Names</small></sup> as defined in <a href=
        "index.html#REC-xml-names">[Namespaces in XML 1.0]</a></span>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-qname"
        id="dt-qname" title="QName"></a>A <b>QName</b> is always
        written in the form <code>(NCName ":")? NCName</code>, that
        is, a local name optionally preceded by a namespace prefix.
        When two QNames are compared, however, they are considered
        equal if the corresponding <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QNames</a> are the same, as
        described below.<span class="definition">]</span></p>

        <p>Because an atomic value of type <code>xs:QName</code> is
        sometimes referred to loosely as a QName, this
        specification also uses the term <a title="lexical QName"
        href="index.html#dt-lexical-qname">lexical QName</a> to emphasize
        that it is referring to a <a href=
        "http://www.w3.org/TR/REC-xml-names/#NT-QName">QName</a><sup>
        <small>Names</small></sup> in its lexical form rather than
        its expanded form. This term is used especially when
        strings containing lexical QNames are manipulated as
        run-time values.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-lexical-qname" id="dt-lexical-qname" title=
        "lexical QName"></a>A <b>lexical QName</b> is a string
        representing a <a title="QName" href="index.html#dt-qname">QName</a>
        in the form <code>(NCName ":")? NCName</code>, that is, a
        local name optionally preceded by a namespace
        prefix.<span class="definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-defining-element" id="dt-defining-element" title=
        "defining element"></a><span>A string in the form of a
        lexical QName</span> may occur as the value of an attribute
        node in a stylesheet module, or within an XPath <a title=
        "expression" href="index.html#dt-expression">expression</a> contained
        in such an attribute node, or as the result of evaluating
        an XPath expression contained in such an attribute node.
        The element containing this attribute node is referred to
        as the <b>defining element</b> of the QName.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-expanded-qname" id="dt-expanded-qname" title=
        "expanded-QName"></a>An <b>expanded-QName</b>
        <span>contains a pair of values, namely a local name and an
        optional namespace URI. It may also contain a namespace
        prefix.</span> Two expanded-QNames are equal if the
        namespace URIs are the same (or both absent) and the local
        names are the same. <span>The prefix plays no part in the
        comparison, but is used only if the expanded-QName needs to
        be converted back to a string.</span><span class=
        "definition">]</span></p>

        <p>If the QName has a prefix, then the prefix is expanded
        into a URI reference using the namespace declarations in
        effect on its <a title="defining element" href=
        "index.html#dt-defining-element">defining element</a>. The <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> consisting of the
        local part of the name and the possibly null URI reference
        is used as the name of the object. The default namespace of
        the defining element (<span>see <a href=
        "http://www.w3.org/TR/xpath-datamodel/#ElementNode">Section
        6.2 Element Nodes</a><sup><small>DM</small></sup></span>)
        is <em>not</em> used for unprefixed names.</p>

        <p>There are <span>three</span> cases where the default
        namespace <span>of the <a title="defining element" href=
        "index.html#dt-defining-element">defining element</a></span>
        <em>is</em> used when expanding an unprefixed QName:</p>

        <ol class="enumar">
          <li>
            <p>Where a QName is used to define the name of an
            element being constructed. This applies both to cases
            where the name is known statically (that is, the name
            of a literal result element) and to cases where it is
            computed dynamically (the value of the
            <code>name</code> attribute of the <a href=
            "index.html#element-element"><code>xsl:element</code></a>
            instruction).</p>
          </li>

          <li>
            <p>The default namespace is used when expanding the
            first argument of the function <a href=
            "index.html#function-element-available"><code>element-available</code></a>.</p>
          </li>

          <li>
            <p>The default namespace applies to any unqualified
            element names appearing in the
            <code>cdata-section-elements</code> attribute of
            <a href="index.html#element-output"><code>xsl:output</code></a>
            or <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a></p>
          </li>
        </ol>

        <p>In the case of an unprefixed QName used as a
        <code>NameTest</code> within an XPath <a title="expression"
        href="index.html#dt-expression">expression</a> (see <a href=
        "index.html#expressions"><i>5.3 Expressions</i></a>) <span>, and in
        certain other contexts</span>, the namespace to be used in
        expanding the QName may be specified by means of the
        <code>[xsl:]xpath-default-namespace</code> attribute, as
        specified in <a href="index.html#unprefixed-qnames"><i>5.2 Unprefixed
        QNames in Expressions and Patterns</i></a>.</p>

        <p><a name="err-XTSE0280" id="err-XTSE0280"><span class=
        "error">[ERR XTSE0280]</span></a> In the case of a
        <span>prefixed</span> <a title="QName" href=
        "index.html#dt-qname">QName</a> used as the value of an attribute in
        the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, or appearing within an
        XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> in the stylesheet, it is a
        <a title="static error" href="index.html#dt-static-error">static
        error</a> if the <a title="defining element" href=
        "index.html#dt-defining-element">defining element</a> has no
        namespace node whose name matches the prefix of the
        <a title="QName" href="index.html#dt-qname">QName</a>.</p>

        <p><a name="err-XTDE0290" id="err-XTDE0290"><span class=
        "error">[ERR XTDE0290]</span></a> Where the result of
        evaluating an XPath expression (or an attribute value
        template) is required to be a <a title="lexical QName"
        href="index.html#dt-lexical-qname">lexical QName</a>, <span>then
        unless otherwise specified</span> it is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="defining element" href=
        "index.html#dt-defining-element">defining element</a> has no
        namespace node whose name matches the prefix of the
        <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
        QName</a>. <span>This error <span class="verb">may</span>
        be signaled as a <a title="static error" href=
        "index.html#dt-static-error">static error</a> if the value of the
        expression can be determined statically.</span></p>
      </div>

      <div class="div2">
        <h3><a name="unprefixed-qnames" id=
        "unprefixed-qnames"></a>5.2 Unprefixed QNames in
        Expressions and Patterns</h3>

        <p>The attribute <code>[xsl:]xpath-default-namespace</code>
        (see <a href="index.html#standard-attributes"><i>3.5 Standard
        Attributes</i></a>) may be used on an element in the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        to define the namespace that will be used for an unprefixed
        element name <span>or type name</span> within an XPath
        expression, and in certain other contexts listed below.</p>

        <p>The value of the attribute is the namespace URI to be
        used.</p>

        <p>For any element in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, this attribute has an
        effective value, which is the value of the
        <code>[xsl:]xpath-default-namespace</code> on that element
        or on the innermost containing element that specifies such
        an attribute, or the zero-length string if no containing
        element specifies such an attribute.</p>

        <p>For any element in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, the effective value of
        this attribute determines the value of the <em>default
        namespace for element and type names</em> in the static
        context of any XPath expression contained in an attribute
        of that element <span>(including XPath expressions in
        <a title="attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        templates</a>)</span>. The effect of this is specified in
        <a href="index.html#xpath20">[XPath 2.0]</a>; in summary, it
        determines the namespace used for any unprefixed type name
        in the SequenceType production, and for any element name
        appearing in a path expression or in the SequenceType
        production.</p>

        <p>The effective value of this attribute similarly applies
        to <span>any of the following constructs appearing within
        its scope</span>:</p>

        <ul>
          <li>
            <p>any unprefixed element name or type name used in a
            <a title="pattern" href="index.html#dt-pattern">pattern</a></p>
          </li>

          <li>
            <p>any unprefixed element name used in the
            <code>elements</code> attribute of the <a href=
            "index.html#element-strip-space"><code>xsl:strip-space</code></a>
            or <a href=
            "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
            instructions</p>
          </li>

          <li>
            <p>any unprefixed element name or type name used in the
            <code>as</code> attribute of an <a title="XSLT element"
            href="index.html#dt-xslt-element">XSLT element</a></p>
          </li>

          <li>
            <p>any unprefixed type name used in the
            <code>type</code> attribute of an <a title=
            "XSLT element" href="index.html#dt-xslt-element">XSLT
            element</a></p>
          </li>

          <li>
            <p>any unprefixed type name used in the
            <code>xsl:type</code> attribute of a <a title=
            "literal result element" href=
            "index.html#dt-literal-result-element">literal result
            element</a>.</p>
          </li>
        </ul>

        <p>The <code>[xsl:]xpath-default-namespace</code> attribute
        <span class="verb">must</span> be in the <a title=
        "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
        namespace</a> if and only if its parent element is
        <em>not</em> in the XSLT namespace.</p>

        <p>If the effective value of the attribute is a zero-length
        string, which will be the case if it is explicitly set to a
        zero-length string or if it is not specified at all, then
        an unprefixed element name or type name refers to a name
        that is in no namespace. The default namespace <span>of the
        parent element (see <a href=
        "http://www.w3.org/TR/xpath-datamodel/#ElementNode">Section
        6.2 Element Nodes</a><sup><small>DM</small></sup>)</span>
        is <em>not</em> used.</p>

        <p>The attribute does not affect other names, for example
        function names, variable names, or template names, or
        strings that are interpreted as <a title="lexical QName"
        href="index.html#dt-lexical-qname">lexical QNames</a> during
        stylesheet evaluation, such as the <a title=
        "effective value" href="index.html#dt-effective-value">effective
        value</a> of the <code>name</code> attribute of <a href=
        "index.html#element-element"><code>xsl:element</code></a> or the
        string supplied as the first argument to the <a href=
        "index.html#function-key"><code>key</code></a> function.</p>
      </div>

      <div class="div2">
        <h3><a name="expressions" id="expressions"></a>5.3
        Expressions</h3>

        <p>XSLT uses the expression language defined by XPath 2.0
        <a href="index.html#xpath20">[XPath 2.0]</a>. Expressions are used in
        XSLT for a variety of purposes including:</p>

        <ul>
          <li>
            <p>selecting nodes for processing;</p>
          </li>

          <li>
            <p>specifying conditions for different ways of
            processing a node;</p>
          </li>

          <li>
            <p>generating text to be inserted in a <a title=
            "result tree" href="index.html#dt-result-tree">result
            tree</a>.</p>
          </li>
        </ul>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-expression" id="dt-expression" title=
        "expression"></a>Within this specification, the term
        <b>XPath expression</b>, or simply <b>expression</b>, means
        a string that matches the production <span><a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-Expr">Expr</a><sup>
        <small>XP</small></sup></span> defined in <a href=
        "index.html#xpath20">[XPath 2.0]</a>.<span class=
        "definition">]</span></p>

        <p>An XPath expression may occur as the value of certain
        attributes on XSLT-defined elements, and also within curly
        brackets in <a title="attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        templates</a>.</p>

        <p>Except where <a title="forwards-compatible behavior"
        href="index.html#dt-forwards-compatible-behavior">forwards-compatible
        behavior</a> is enabled (see <a href="index.html#forwards"><i>3.9
        Forwards-Compatible Processing</i></a>), it is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the value of such an attribute, or the text between curly
        brackets in an attribute value template, does not match the
        XPath production <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-Expr">Expr</a><sup>
        <small>XP</small></sup>, or if it fails to satisfy other
        static constraints defined in the XPath specification, for
        example that all variable references <span class=
        "verb">must</span> refer to <a title="variable" href=
        "index.html#dt-variable">variables</a> that are in scope. <span>Error
        codes are defined in <a href="index.html#xpath20">[XPath
        2.0]</a>.</span></p>

        <p>The transformation fails with a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if any XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> is evaluated and raises a
        dynamic error. <span>Error codes are defined in <a href=
        "index.html#xpath20">[XPath 2.0]</a>.</span></p>

        <p>The transformation fails with a <a title="type errors"
        href="index.html#dt-type-error">type error</a> if an XPath <a title=
        "expression" href="index.html#dt-expression">expression</a> raises a
        type error, or if the result of evaluating the XPath
        <a title="expression" href="index.html#dt-expression">expression</a>
        is evaluated and raises a type error, or if the XPath
        processor signals a type error during static analysis of an
        <a title="expression" href="index.html#dt-expression">expression</a>.
        <span>Error codes are defined in <a href="index.html#xpath20">[XPath
        2.0]</a>.</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-required-type" id="dt-required-type" title=
        "required type"></a>The context within a <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> where an
        XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> <span>appears may
        specify</span> the <b>required type</b> of the expression.
        The required type indicates the type of the value that the
        expression is expected to return.<span class=
        "definition">]</span> If no required type is specified, the
        expression may return any value: in effect, the required
        type is then <code>item()*</code>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-function-conversion-rules" id=
        "dt-function-conversion-rules" title=
        "function conversion rules"></a>Except where otherwise
        indicated, the actual value of an <a title="expression"
        href="index.html#dt-expression">expression</a> is converted to the
        <a title="required type" href="index.html#dt-required-type">required
        type</a> using the <b>function conversion rules</b>. These
        are the rules defined in <a href="index.html#xpath20">[XPath 2.0]</a>
        for converting the supplied argument of a function call to
        the required type of that argument, as defined in the
        function signature. The relevant rules are those that apply
        when <a title="XPath 1.0 compatibility mode" href=
        "index.html#dt-compatibility-mode">XPath 1.0 compatibility mode</a>
        is set to <code>false</code>.<span class=
        "definition">]</span></p>

        <p>This specification also invokes the XPath 2.0 <a title=
        "function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a> to convert the result of evaluating an XSLT
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> to a
        required type (for example, the sequence constructor
        enclosed in an <a href=
        "index.html#element-variable"><code>xsl:variable</code></a>, <a href=
        "index.html#element-template"><code>xsl:template</code></a>, or
        <a href="index.html#element-function"><code>xsl:function</code></a>
        element).</p>

        <p>Any <a title="dynamic error" href=
        "index.html#dt-dynamic-error">dynamic error</a> or <a title=
        "type errors" href="index.html#dt-type-error">type error</a> that
        occurs when applying the <a title=
        "function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a> to convert a value to a required type results in
        the transformation failing, in the same way as if the error
        had occurred while evaluating an expression.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Note the distinction between the two kinds of error
          that may occur. Attempting to convert an integer to a
          date is a type error, because such a conversion is never
          possible. Type errors can be reported statically if they
          can be detected statically, whether or not the construct
          in question is ever evaluated. Attempting to convert the
          string <code>2003-02-29</code> to a date is a dynamic
          error rather than a type error, because the problem is
          with this particular value, not with its type. Dynamic
          errors are reported only if the instructions or
          expressions that cause them are actually evaluated.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="static-and-dynamic-context" id=
        "static-and-dynamic-context"></a>5.4 The Static and Dynamic
        Context</h3>

        <p>XPath defines the concept of an <a href=
        "http://www.w3.org/TR/xpath20/#dt-expression-context">expression
        context</a><sup><small>XP</small></sup> which contains all
        the information that can affect the result of evaluating an
        <a title="expression" href="index.html#dt-expression">expression</a>.
        The expression context has two parts, the <a href=
        "http://www.w3.org/TR/xpath20/#dt-static-context">static
        context</a><sup><small>XP</small></sup>, and the <a href=
        "http://www.w3.org/TR/xpath20/#dt-dynamic-context">dynamic
        context</a><sup><small>XP</small></sup>. The components
        that make up the expression context are defined in the
        XPath specification (see <a href=
        "http://www.w3.org/TR/xpath20/#context">Section 2.1
        Expression Context</a><sup><small>XP</small></sup>). This
        section describes the way in which these components are
        initialized when an XPath expression is contained within an
        XSLT stylesheet.</p>

        <p>As well as providing values for the static and dynamic
        context components defined in the XPath specification, XSLT
        defines additional context components of its own. These
        context components are used by XSLT instructions (for
        example, <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a> and
        <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>),
        and also by the functions in the extended function library
        described in this specification.</p>

        <p>The following four sections describe:</p>

        <blockquote>
          <p><a href="index.html#static-context"><i>5.4.1 Initializing the
          Static Context</i></a><br />
          <a href="index.html#additional-static-context"><i>5.4.2 Additional
          Static Context Components used by XSLT</i></a><br />
          <a href="index.html#xpath-dynamic-context"><i>5.4.3 Initializing
          the Dynamic Context</i></a><br />
          <a href="index.html#additional-dynamic-context"><i>5.4.4 Additional
          Dynamic Context Components used by XSLT</i></a></p>
        </blockquote>

        <div class="div3">
          <h4><a name="static-context" id=
          "static-context"></a>5.4.1 Initializing the Static
          Context</h4>

          <p>The <a href=
          "http://www.w3.org/TR/xpath20/#dt-static-context">static
          context</a><sup><small>XP</small></sup> of an XPath
          expression appearing in an XSLT stylesheet is initialized
          as follows. In these rules, the term <b>containing
          element</b> means the element within the stylesheet that
          is the parent of the attribute whose value contains the
          XPath expression in question, and the term <b>enclosing
          element</b> means the containing element or any of its
          ancestors.</p>

          <ul>
            <li>
              <p><a title="XPath 1.0 compatibility mode" href=
              "index.html#dt-compatibility-mode">XPath 1.0 compatibility
              mode</a> is set to true if and only if the containing
              element occurs in part of the <a title="stylesheet"
              href="index.html#dt-stylesheet">stylesheet</a> where <a title=
              "backwards compatible behavior" href=
              "index.html#dt-backwards-compatible-behavior">backwards
              compatible behavior</a> is enabled (see <a href=
              "index.html#backwards"><i>3.8 Backwards-Compatible
              Processing</i></a>).</p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-static-namespaces">statically
              known namespaces</a><sup><small>XP</small></sup> are
              the namespace declarations that are in scope for the
              containing element.</p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-def-elemtype-ns">default
              element/type
              namespace</a><sup><small>XP</small></sup> is the
              namespace defined by the
              <code>[xsl:]xpath-default-namespace</code> attribute
              on the innermost enclosing element that has such an
              attribute, as described in <a href=
              "index.html#unprefixed-qnames"><i>5.2 Unprefixed QNames in
              Expressions and Patterns</i></a>. The value of this
              attribute is a namespace URI. <span>If there is no
              <code>[xsl:]xpath-default-namespace</code> attribute
              on an enclosing element, the default namespace for
              element names and type names is the null
              namespace.</span></p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-def-fn-ns">default
              function namespace</a><sup><small>XP</small></sup> is
              the <a title="standard function namespace" href=
              "index.html#dt-standard-function-namespace">standard function
              namespace</a>, defined in <a href=
              "index.html#xpath-functions">[Functions and Operators]</a>.
              This means that it is not necessary to declare this
              namespace in the <a title="stylesheet" href=
              "index.html#dt-stylesheet">stylesheet</a>, nor is it necessary
              to use the prefix <code>fn</code> (or any other
              prefix) in calls to the <a title="core function"
              href="index.html#dt-core-function">core functions</a>.</p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-issd">in-scope
              schema definitions</a><sup><small>XP</small></sup>
              for the XPath expression are the same as the
              <a title="in-scope schema component" href=
              "index.html#dt-in-scope-schema-component">in-scope schema
              components</a> for the <a title="stylesheet" href=
              "index.html#dt-stylesheet">stylesheet</a>, and are as specified
              in <a href="index.html#built-in-types"><i>3.13 Built-in
              Types</i></a>.</p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-in-scope-variables">
              in-scope variables</a><sup><small>XP</small></sup>
              are <span>defined by</span> the <a title=
              "variable-binding element" href=
              "index.html#dt-variable-binding-element">variable binding
              elements</a> that are in scope for the containing
              element (see <a href="index.html#variables-and-parameters"><i>9
              Variables and Parameters</i></a>).</p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-function-signature">
              function signatures</a><sup><small>XP</small></sup>
              are the <a title="core function" href=
              "index.html#dt-core-function">core functions</a> defined in
              <a href="index.html#xpath-functions">[Functions and
              Operators]</a>, the constructor functions for all the
              atomic types in the <a href=
              "http://www.w3.org/TR/xpath20/#dt-issd">in-scope
              schema definitions</a><sup><small>XP</small></sup>,
              the additional functions defined in this
              specification, the <a title="stylesheet function"
              href="index.html#dt-stylesheet-function">stylesheet
              functions</a> defined in the stylesheet, plus any
              <a title="extension function" href=
              "index.html#dt-extension-function">extension functions</a>
              bound using <a title="implementation-defined" href=
              "index.html#dt-implementation-defined">implementation-defined</a>
              mechanisms (see <a href="index.html#extension"><i>18
              Extensibility and Fallback</i></a>).</p>

              <div class="note">
                <p class="prefix"><b>Note:</b></p>

                <p>It follows from the above that a conformant XSLT
                processor must implement the entire library of
                <a title="core function" href=
                "index.html#dt-core-function">core functions</a> defined in
                <a href="index.html#xpath-functions">[Functions and
                Operators]</a>.</p>
              </div>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-static-collations">statically
              known collations</a><sup><small>XP</small></sup> are
              <a title="implementation-defined" href=
              "index.html#dt-implementation-defined">implementation-defined</a>.
              <span>However, the set of in-scope collations
              <span class="verb">must</span> always include the
              Unicode codepoint collation, defined in <a href=
              "http://www.w3.org/TR/xpath-functions/#string-compare">
              Section 7.3 Equality and Comparison of
              Strings</a><sup><small>FO</small></sup>.</span></p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-def-collation">default
              collation</a><sup><small>XP</small></sup> is defined
              by the value of the
              <code>[xsl:]default-collation</code> attribute on the
              innermost enclosing element that has such an
              attribute. For details, see <a href=
              "index.html#default-collation-attribute"><i>3.6.1 The
              default-collation attribute</i></a>.</p>

              <p><span class=
              "definition">[Definition:&#160;</span><a name=
              "dt-default-collation" id="dt-default-collation"
              title="default collation"></a>In this specification
              the term <b>default collation</b> means the collation
              that is used by XPath operators such as
              <code>eq</code> and <code>lt</code> appearing in
              XPath expressions within the stylesheet.<span class=
              "definition">]</span></p>

              <p>This collation is also used by default when
              comparing strings in the evaluation of the <a href=
              "index.html#element-key"><code>xsl:key</code></a> and <a href=
              "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
              elements. This <span class="verb">may</span> also
              (but need not necessarily) be the same as the default
              collation used for <a href=
              "index.html#element-sort"><code>xsl:sort</code></a> elements
              within the stylesheet. Collations used by <a href=
              "index.html#element-sort"><code>xsl:sort</code></a> are
              described in <a href="index.html#collating-sequences"><i>13.1.3
              Sorting Using Collations</i></a>.</p>
            </li>

            <li>
              <p>The <a href=
              "http://www.w3.org/TR/xpath20/#dt-base-uri">base
              URI</a><sup><small>XP</small></sup> is the base URI
              of the containing element. The concept of the base
              URI of a node is defined in <a href=
              "http://www.w3.org/TR/xpath-datamodel/#dm-base-uri">Section
              5.2 base-uri
              Accessor</a><sup><small>DM</small></sup></p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="additional-static-context" id=
          "additional-static-context"></a>5.4.2 Additional Static
          Context Components used by XSLT</h4>

          <p>Some of the components of the XPath static context are
          used also by <a title="XSLT element" href=
          "index.html#dt-xslt-element">XSLT elements</a>. For example, the
          <a href="index.html#element-sort"><code>xsl:sort</code></a> element
          makes use of the collations defined in the static
          context, and attributes such as <code>type</code> and
          <code>as</code> may reference types defined in the
          <a title="in-scope schema component" href=
          "index.html#dt-in-scope-schema-component">in-scope schema
          components</a>.</p>

          <p>Many top-level declarations in a stylesheet, and
          attributes on the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element, affect the behavior of instructions within the
          stylesheet. Each of these constructs is described in its
          appropriate place in this specification.</p>

          <p>A number of these constructs are of particular
          significance because they are used by functions defined
          in XSLT, which are added to the library of functions
          available for use in XPath expressions within the
          stylesheet. These are:</p>

          <ul>
            <li>
              <p>The set of named keys, used by the <a href=
              "index.html#function-key"><code>key</code></a> function</p>
            </li>

            <li>
              <p>The set of named decimal formats, used by the
              <a href=
              "index.html#function-format-number"><code>format-number</code></a>
              function</p>
            </li>

            <li>
              <p>The values of system properties, used by the
              <a href=
              "index.html#function-system-property"><code>system-property</code></a>
              function</p>
            </li>

            <li>
              <p>The set of available instructions, used by the
              <a href=
              "index.html#function-element-available"><code>element-available</code></a>
              function</p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="xpath-dynamic-context" id=
          "xpath-dynamic-context"></a>5.4.3 Initializing the
          Dynamic Context</h4>

          <p>For convenience, the dynamic context is described in
          two parts: the <a title="focus" href=
          "index.html#dt-focus">focus</a>, which represents the place in the
          source document that is currently being processed, and a
          collection of additional context variables.</p>

          <p>A number of functions specified in <a href=
          "index.html#xpath-functions">[Functions and Operators]</a> are
          defined to be <a href=
          "http://www.w3.org/TR/xpath-functions/#stable">stable</a><sup>
          <small>FO</small></sup>, meaning that if they are called
          twice during the same <a href=
          "http://www.w3.org/TR/xpath-functions/#execution-scope">execution
          scope</a><sup><small>FO</small></sup>, with the same
          arguments, then they return the same results (see
          <a href="http://www.w3.org/TR/xpath-functions/#terminology">
          Section 1.7 Terminology</a><sup><small>FO</small></sup>).
          In XSLT, the execution of a stylesheet defines the
          execution scope. This means, for example, that if the
          function <a href=
          "http://www.w3.org/TR/xpath-functions/#func-current-dateTime">
          <code>current-dateTime</code></a><sup><small>FO</small></sup>
          is called repeatedly during a transformation, it produces
          the same result each time. By implication, the components
          of the dynamic context on which these functions depend
          are also stable for the duration of the transformation.
          Specifically, the following components defined in
          <a href="http://www.w3.org/TR/xpath20/#eval_context">Section
          2.1.2 Dynamic Context</a><sup><small>XP</small></sup>
          must be stable: <em>function implementations</em>,
          <em>current dateTime</em>, <em>implicit timezone</em>,
          <em>available documents</em>, <em>available
          collections</em>, and <em>default collection</em>. The
          values of global variables and stylesheet parameters are
          also stable for the duration of a transformation. The
          focus is <em>not</em> stable; the additional dynamic
          context components defined in <a href=
          "index.html#additional-dynamic-context"><i>5.4.4 Additional Dynamic
          Context Components used by XSLT</i></a> are also
          <em>not</em> stable.</p>

          <p>As specified in <a href="index.html#xpath-functions">[Functions
          and Operators]</a>, implementations may provide user
          options that relax the requirement for the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
          <small>FO</small></sup> and <a href=
          "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
          collection</code></a><sup><small>FO</small></sup>
          functions (and therefore, by implication, the <a href=
          "index.html#function-document"><code>document</code></a> function)
          to return stable results. By default, however, the
          functions must be stable. The manner in which such user
          options are provided, if at all, is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.</p>

          <p>XPath expressions contained in
          <code>[xsl:]use-when</code> attributes are not considered
          to be evaluated "during the transformation" as defined
          above. For details see <a href=
          "index.html#conditional-inclusion"><i>3.12 Conditional Element
          Inclusion</i></a>.</p>

          <div class="div4">
            <h5><a name="focus" id="focus"></a>5.4.3.1 Maintaining
            Position: the Focus</h5>

            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-focus" id="dt-focus" title="focus"></a>When a
            <a title="sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a> is
            evaluated, the <a title="processor" href=
            "index.html#dt-processor">processor</a> keeps track of which
            items are being processed by means of a set of implicit
            variables referred to collectively as the
            <b>focus</b>.<span class="definition">]</span> More
            specifically, the focus consists of the following three
            values:</p>

            <ul>
              <li>
                <p><span class=
                "definition">[Definition:&#160;</span><a name=
                "dt-context-item" id="dt-context-item" title=
                "context item"></a>The <b>context item</b> is the
                item currently being processed. An item (see
                <a href="index.html#xpath-datamodel">[Data Model]</a>) is
                either an atomic value (such as an integer, date,
                or string), or a node. The context item is
                initially set to the <a title=
                "initial context node" href=
                "index.html#dt-initial-context-node">initial context node</a>
                supplied when the transformation is invoked (see
                <a href="index.html#initiating"><i>2.3 Initiating a
                Transformation</i></a>). It changes whenever
                instructions such as <a href=
                "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
                and <a href=
                "index.html#element-for-each"><code>xsl:for-each</code></a>
                are used to process a sequence of items; each item
                in such a sequence becomes the context item while
                that item is being processed.<span class=
                "definition">]</span> The context item is returned
                by the XPath <a title="expression" href=
                "index.html#dt-expression">expression</a> <code>.</code>
                (dot).</p>
              </li>

              <li>
                <p><span class=
                "definition">[Definition:&#160;</span><a name=
                "dt-context-position" id="dt-context-position"
                title="context position"></a>The <b>context
                position</b> is the position of the context item
                within the sequence of items currently being
                processed. It changes whenever the context item
                changes. When an instruction such as <a href=
                "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
                or <a href=
                "index.html#element-for-each"><code>xsl:for-each</code></a>
                is used to process a sequence of items, the first
                item in the sequence is processed with a context
                position of 1, the second item with a context
                position of 2, and so on.<span class=
                "definition">]</span> The context position is
                returned by the XPath <a title="expression" href=
                "index.html#dt-expression">expression</a>
                <code>position()</code>.</p>
              </li>

              <li>
                <p><span class=
                "definition">[Definition:&#160;</span><a name=
                "dt-context-size" id="dt-context-size" title=
                "context size"></a>The <b>context size</b> is the
                number of items in the sequence of items currently
                being processed. It changes whenever instructions
                such as <a href=
                "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
                and <a href=
                "index.html#element-for-each"><code>xsl:for-each</code></a>
                are used to process a sequence of items; during the
                processing of each one of those items, the context
                size is set to the count of the number of items in
                the sequence (or equivalently, the position of the
                last item in the sequence).<span class=
                "definition">]</span> The context size is returned
                by the XPath <a title="expression" href=
                "index.html#dt-expression">expression</a>
                <code>last()</code>.</p>
              </li>
            </ul>

            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-context-node" id="dt-context-node" title=
            "context node"></a>If the <a title="context item" href=
            "index.html#dt-context-item">context item</a> is a node (as
            distinct from an atomic value such as an integer), then
            it is also referred to as the <b>context node</b>. The
            context node is not an independent variable, it changes
            whenever the context item changes. When the context
            item is an atomic value, there is no context
            node.<span class="definition">]</span> The context node
            is returned by the XPath <a title="expression" href=
            "index.html#dt-expression">expression</a>
            <code>self::node()</code>, and it is used as the
            starting node for all relative path expressions.</p>

            <p>Where the containing element of an XPath expression
            is an <a title="instruction" href=
            "index.html#dt-instruction">instruction</a> or a <a title=
            "literal result element" href=
            "index.html#dt-literal-result-element">literal result
            element</a>, the initial context item, context
            position, and context size for the XPath <a title=
            "expression" href="index.html#dt-expression">expression</a> are
            the same as the <a title="context item" href=
            "index.html#dt-context-item">context item</a>, <a title=
            "context position" href="index.html#dt-context-position">context
            position</a>, and <a title="context size" href=
            "index.html#dt-context-size">context size</a> for the evaluation
            of the containing instruction or literal result
            element.</p>

            <p>In other cases (for example, where the containing
            element is <a href=
            "index.html#element-sort"><code>xsl:sort</code></a>, <a href=
            "index.html#element-with-param"><code>xsl:with-param</code></a>,
            or <a href="index.html#element-key"><code>xsl:key</code></a>),
            the rules are given in the specification of the
            containing element.</p>

            <p>The <a href=
            "index.html#function-current"><code>current</code></a> function
            can be used within any XPath <a title="expression"
            href="index.html#dt-expression">expression</a> to select the item
            that was supplied as the context item to the XPath
            expression by the XSLT processor. Unlike <code>.</code>
            (dot) this is unaffected by changes to the context item
            that occur within the XPath expression. The <a href=
            "index.html#function-current"><code>current</code></a> function
            is described in <a href="index.html#current-function"><i>16.6.1
            current</i></a>.</p>

            <p>On completion of an instruction that changes the
            <a title="focus" href="index.html#dt-focus">focus</a> (such as
            <a href=
            "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
            or <a href=
            "index.html#element-for-each"><code>xsl:for-each</code></a>), the
            focus reverts to its previous value.</p>

            <p>When a <a title="stylesheet function" href=
            "index.html#dt-stylesheet-function">stylesheet function</a> is
            called, the focus within the body of the function is
            initially undefined. <span>The focus is also undefined
            on initial entry to the <a title="stylesheet" href=
            "index.html#dt-stylesheet">stylesheet</a> if no <a title=
            "initial context node" href=
            "index.html#dt-initial-context-node">initial context node</a> is
            supplied.</span></p>

            <p>When the focus is undefined, evaluation of any
            <a title="expression" href=
            "index.html#dt-expression">expression</a> that references the
            context item, context position, or context size results
            in a <a title="non-recoverable dynamic error" href=
            "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
            error</a> [XPDY0002]</p>

            <p>The description above gives an outline of the way
            the <a title="focus" href="index.html#dt-focus">focus</a> works.
            Detailed rules for the effect of each instruction are
            given separately with the description of that
            instruction. In the absence of specific rules, an
            instruction uses the same focus as its parent
            instruction.</p>

            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-singleton-focus" id="dt-singleton-focus" title=
            "singleton focus"></a>A <b>singleton focus</b> based on
            a node <var>N</var> has the <a title="context item"
            href="index.html#dt-context-item">context item</a> (and therefore
            the <a title="context node" href=
            "index.html#dt-context-node">context node</a>) set to
            <var>N</var>, and the <a title="context position" href=
            "index.html#dt-context-position">context position</a> and
            <a title="context size" href="index.html#dt-context-size">context
            size</a> both set to 1 (one).<span class=
            "definition">]</span></p>
          </div>

          <div class="div4">
            <h5><a name="evaluation-context" id=
            "evaluation-context"></a>5.4.3.2 Other components of
            the XPath Dynamic Context</h5>

            <p>The previous section explained how the <a title=
            "focus" href="index.html#dt-focus">focus</a> for an XPath
            expression appearing in an XSLT stylesheet is
            initialized. This section explains how the other
            components of the <a href=
            "http://www.w3.org/TR/xpath20/#dt-dynamic-context">dynamic
            context</a><sup><small>XP</small></sup> of an XPath
            expression are initialized.</p>

            <ul>
              <li>
                <p>The <a href=
                "http://www.w3.org/TR/xpath20/#dt-variable-values">dynamic
                variables</a><sup><small>XP</small></sup> are the
                current values of the in-scope <a title=
                "variable-binding element" href=
                "index.html#dt-variable-binding-element">variable binding
                elements</a>.</p>
              </li>

              <li>
                <p>The <em>current date and time</em> represents an
                <a title="implementation-dependent" href=
                "index.html#dt-implementation-dependent">implementation-dependent</a>
                point in time during processing of the
                transformation; it does not change during the
                course of the transformation.</p>
              </li>

              <li>
                <p>The <a href=
                "http://www.w3.org/TR/xpath20/#dt-timezone">implicit
                timezone</a><sup><small>XP</small></sup> is
                <a title="implementation-defined" href=
                "index.html#dt-implementation-defined">implementation-defined</a>.</p>
              </li>

              <li>
                <p>The <a href=
                "http://www.w3.org/TR/xpath20/#dt-known-docs">available
                documents</a><sup><small>XP</small></sup>, and the
                <a href=
                "http://www.w3.org/TR/xpath20/#dt-known-collections">
                available
                collections</a><sup><small>XP</small></sup> are
                determined as part of the process for initiating a
                transformation (see <a href="index.html#initiating"><i>2.3
                Initiating a Transformation</i></a>).</p>

                <p>The <a href=
                "http://www.w3.org/TR/xpath20/#dt-known-docs">available
                documents</a><sup><small>XP</small></sup> are
                defined as part of the XPath 2.0 dynamic context to
                support the <a href=
                "http://www.w3.org/TR/xpath-functions/#func-doc"><code>
                doc</code></a><sup><small>FO</small></sup>
                function, but this component is also referenced by
                the similar XSLT <a href=
                "index.html#function-document"><code>document</code></a>
                function: see <a href="index.html#document"><i>16.1 Multiple
                Source Documents</i></a>. This variable defines a
                mapping between URIs passed to the <a href=
                "http://www.w3.org/TR/xpath-functions/#func-doc"><code>
                doc</code></a><sup><small>FO</small></sup> or
                <a href=
                "index.html#function-document"><code>document</code></a>
                function and the document nodes that are
                returned.</p>

                <div class="note">
                  <p class="prefix"><b>Note:</b></p>

                  <p>Defining this as part of the evaluation
                  context is a formal way of specifying that the
                  way in which URIs get turned into document nodes
                  is outside the control of the language
                  specification, and depends entirely on the
                  run-time environment in which the transformation
                  takes place.</p>
                </div>

                <p>The XSLT-defined <a href=
                "index.html#function-document"><code>document</code></a>
                function allows the use of URI references
                containing fragment identifiers. The interpretation
                of a fragment identifier depends on the media type
                of the resource representation. Therefore, the
                information supplied in <a href=
                "http://www.w3.org/TR/xpath20/#dt-known-docs">available
                documents</a><sup><small>XP</small></sup> for XSLT
                processing must provide not only a mapping from
                URIs to document nodes as required by XPath, but
                also a mapping from URIs to media types.</p>
              </li>

              <li>
                <p>The <a href=
                "http://www.w3.org/TR/xpath20/#dt-default-collection">
                default collection</a><sup><small>XP</small></sup>
                is <a title="implementation-defined" href=
                "index.html#dt-implementation-defined">implementation-defined</a>.
                This allows options such as setting the default
                collection to be an empty sequence, or to be
                undefined.</p>
              </li>
            </ul>
          </div>
        </div>

        <div class="div3">
          <h4><a name="additional-dynamic-context" id=
          "additional-dynamic-context"></a>5.4.4 Additional Dynamic
          Context Components used by XSLT</h4>

          <p>In addition to the values that make up the <a title=
          "focus" href="index.html#dt-focus">focus</a>, an XSLT processor
          maintains a number of other dynamic context components
          that reflect aspects of the evaluation context. These
          components are fully described in the sections of the
          specification that maintain and use them. They are:</p>

          <ul>
            <li>
              <p>The <a title="current template rule" href=
              "index.html#dt-current-template-rule">current template
              rule</a>, which is the <a title="template rule" href=
              "index.html#dt-template-rule">template rule</a> most recently
              invoked by an <a href=
              "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
              <a href=
              "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
              or <a href=
              "index.html#element-next-match"><code>xsl:next-match</code></a>
              instruction: see <a href="index.html#apply-imports"><i>6.7
              Overriding Template Rules</i></a>;</p>
            </li>

            <li>
              <p>The <a title="current mode" href=
              "index.html#dt-current-mode">current mode</a>, which is the
              <a title="mode" href="index.html#dt-mode">mode</a> set by the
              most recent call of <a href=
              "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
              (for a full definition see <a href="index.html#modes"><i>6.5
              Modes</i></a>);</p>
            </li>

            <li>
              <p>The <a title="current group" href=
              "index.html#dt-current-group">current group</a> and <a title=
              "current grouping key" href=
              "index.html#dt-current-grouping-key">current grouping key</a>,
              which provide information about the collection of
              items currently being processed by an <a href=
              "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
              instruction: see <a href="index.html#current-group"><i>14.1 The
              Current Group</i></a> and <a href=
              "index.html#current-grouping-key"><i>14.2 The Current Grouping
              Key</i></a>;</p>
            </li>

            <li>
              <p>The <a title="current captured substrings" href=
              "index.html#dt-current-captured-substrings">current captured
              substrings</a>: this is a sequence of strings, which
              is maintained when a string is matched against a
              regular expression using the <a href=
              "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
              instruction, and which is accessible using the
              <a href=
              "index.html#function-regex-group"><code>regex-group</code></a>
              function: see <a href="index.html#regex-group"><i>15.2 Captured
              Substrings</i></a>.</p>
            </li>

            <li>
              <p>The <a title="output state" href=
              "index.html#dt-output-state">output state</a>: this is a flag
              whose two possible values are <a title=
              "final output state" href=
              "index.html#dt-final-output-state">final output state</a> and
              <a title="temporary output state" href=
              "index.html#dt-temporary-output-state">temporary output
              state</a>. This flag indicates whether instructions
              are currently writing to a <a title=
              "final result tree" href=
              "index.html#dt-final-result-tree">final result tree</a> or to
              an internal data structure. The initial setting is
              <a title="final output state" href=
              "index.html#dt-final-output-state">final output state</a>, and
              it is switched to <a title="temporary output state"
              href="index.html#dt-temporary-output-state">temporary output
              state</a> by instructions such as <a href=
              "index.html#element-variable"><code>xsl:variable</code></a>.
              For more details, see <a href=
              "index.html#creating-result-trees"><i>19.1 Creating Final
              Result Trees</i></a>.</p>
            </li>
          </ul>

          <p>The following non-normative table summarizes the
          initial state of each of the components in the evaluation
          context, and the instructions which cause the state of
          the component to change.</p>

          <table border="1" cellpadding="5">
            <thead>
              <tr>
                <th align="left">Component</th>

                <th align="left">Initial Setting</th>

                <th align="left">Set by</th>

                <th align="left">Cleared by</th>
              </tr>
            </thead>

            <tbody>
              <tr>
                <td valign="top"><a title="focus" href=
                "index.html#dt-focus">focus</a></td>

                <td valign="top">singleton focus based on the
                <a title="initial context node" href=
                "index.html#dt-initial-context-node">initial context node</a>
                if supplied</td>

                <td valign="top"><a href=
                "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
                <a href=
                "index.html#element-for-each"><code>xsl:for-each</code></a>,
                <a href=
                "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
                <a href=
                "index.html#element-analyze-string"><code>xsl:analyze-string</code></a></td>

                <td valign="top">calls on <a title=
                "stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet
                functions</a></td>
              </tr>

              <tr>
                <td valign="top"><a title="current template rule"
                href="index.html#dt-current-template-rule">current template
                rule</a></td>

                <td valign="top"><span>If a <a title=
                "named template" href="index.html#dt-named-template">named
                template</a> is supplied as the entry point to the
                transformation, then null; otherwise the <a title=
                "initial template" href=
                "index.html#dt-initial-template">initial
                template</a></span></td>

                <td valign="top"><a href=
                "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
                <a href=
                "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
                <a href=
                "index.html#element-next-match"><code>xsl:next-match</code></a></td>

                <td valign="top"><a href=
                "index.html#element-for-each"><code>xsl:for-each</code></a>,
                <a href=
                "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
                and <span><a href=
                "index.html#element-analyze-string"><code>xsl:analyze-string</code></a></span>,
                and calls on <a title="stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet functions</a>.
                Also cleared while evaluating global variables or
                default values of stylesheet parameters, and the
                sequence constructors contained in <a href=
                "index.html#element-key"><code>xsl:key</code></a> and
                <a href="index.html#element-sort"><code>xsl:sort</code></a>.</td>
              </tr>

              <tr>
                <td valign="top"><a title="current mode" href=
                "index.html#dt-current-mode">current mode</a></td>

                <td valign="top">the initial <a title="mode" href=
                "index.html#dt-mode">mode</a></td>

                <td valign="top"><a href=
                "index.html#element-apply-templates"><code>xsl:apply-templates</code></a></td>

                <td valign="top">calls on <a title=
                "stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet
                functions</a></td>
              </tr>

              <tr>
                <td valign="top"><a title="current group" href=
                "index.html#dt-current-group">current group</a></td>

                <td valign="top">empty sequence</td>

                <td valign="top"><a href=
                "index.html#element-for-each-group"><code>xsl:for-each-group</code></a></td>

                <td valign="top">calls on <a title=
                "stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet
                functions</a></td>
              </tr>

              <tr>
                <td valign="top"><a title="current grouping key"
                href="index.html#dt-current-grouping-key">current grouping
                key</a></td>

                <td valign="top">empty sequence</td>

                <td valign="top"><a href=
                "index.html#element-for-each-group"><code>xsl:for-each-group</code></a></td>

                <td valign="top">calls on <a title=
                "stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet
                functions</a></td>
              </tr>

              <tr>
                <td valign="top"><a title=
                "current captured substrings" href=
                "index.html#dt-current-captured-substrings">current captured
                substrings</a></td>

                <td valign="top">empty sequence</td>

                <td valign="top"><a href=
                "index.html#element-matching-substring"><code>xsl:matching-substring</code></a></td>

                <td valign="top"><a href=
                "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>;
                calls on <a title="stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet
                functions</a></td>
              </tr>

              <tr>
                <td valign="top"><a title="output state" href=
                "index.html#dt-output-state">output state</a></td>

                <td valign="top"><a title="final output state"
                href="index.html#dt-final-output-state">final output
                state</a></td>

                <td valign="top">Set to <a title=
                "temporary output state" href=
                "index.html#dt-temporary-output-state">temporary output
                state</a> by instructions such as <a href=
                "index.html#element-variable"><code>xsl:variable</code></a>,
                <a href=
                "index.html#element-attribute"><code>xsl:attribute</code></a>,
                etc., and by calls on <a title=
                "stylesheet function" href=
                "index.html#dt-stylesheet-function">stylesheet
                functions</a></td>

                <td valign="top">None</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>

      <div class="div2">
        <h3><a name="patterns" id="patterns"></a>5.5 Patterns</h3>

        <p>A <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> identifies the nodes
        to which it applies by means of a pattern. As well as being
        used in template rules, patterns are used for numbering
        (see <a href="index.html#number"><i>12 Numbering</i></a>), for
        grouping (see <a href="index.html#grouping"><i>14 Grouping</i></a>),
        and for declaring <a title="" href="index.html#key">keys</a> (see
        <a href="index.html#key"><i>16.3 Keys</i></a>).</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-pattern"
        id="dt-pattern" title="pattern"></a>A <b>pattern</b>
        specifies a set of conditions on a node. A node that
        satisfies the conditions matches the pattern; a node that
        does not satisfy the conditions does not match the pattern.
        The syntax for patterns is a subset of the syntax for
        <a title="expression" href=
        "index.html#dt-expression">expressions</a>.<span class=
        "definition">]</span> As explained in detail below, a node
        matches a pattern if the node can be selected by
        <span>deriving an equivalent expression, and</span>
        evaluating this expression with respect to some possible
        context.</p>

        <div class="div3">
          <h4><a name="pattern-examples" id=
          "pattern-examples"></a>5.5.1 Examples of Patterns</h4>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e8032" id="d5e8032"></a>Example: Patterns
            </div>

            <p>Here are some examples of patterns:</p>

            <ul>
              <li>
                <p><code>para</code> matches any <code>para</code>
                element.</p>
              </li>

              <li>
                <p><code>*</code> matches any element.</p>
              </li>

              <li>
                <p><code>chapter|appendix</code> matches any
                <code>chapter</code> element and any
                <code>appendix</code> element.</p>
              </li>

              <li>
                <p><code>olist/entry</code> matches any
                <code>entry</code> element with an
                <code>olist</code> parent.</p>
              </li>

              <li>
                <p><code>appendix//para</code> matches any
                <code>para</code> element with an
                <code>appendix</code> ancestor element.</p>
              </li>

              <li>
                <p><code>schema-element(us:address)</code> matches
                any element that is annotated as an instance of the
                type defined by the schema element declaration
                <code>us:address</code>, and whose name is either
                <code>us:address</code> or the name of another
                element in its substitution group.</p>
              </li>

              <li>
                <p><code>attribute(*, xs:date)</code> matches any
                attribute annotated as being of type
                <code>xs:date</code>.</p>
              </li>

              <li>
                <p><code>/</code> matches a document node.</p>
              </li>

              <li>
                <p><code>document-node()</code> matches a document
                node.</p>
              </li>

              <li>
                <p>
                <code>document-node(schema-element(my:invoice))</code>
                matches the document node of a document whose
                document element <span>is named
                <code>my:invoice</code> and matches the type
                defined by the global element declaration</span>
                <code>my:invoice</code>.</p>
              </li>

              <li>
                <p><code>text()</code> matches any text node.</p>
              </li>

              <li>
                <p><code>node()</code> matches any node other than
                an attribute node, namespace node, or document
                node.</p>
              </li>

              <li>
                <p><code>id("W33")</code> matches the element with
                unique ID <code>W33</code>.</p>
              </li>

              <li>
                <p><code>para[1]</code> matches any
                <code>para</code> element that is the first
                <code>para</code> child element of its parent.
                <span>It also matches a parentless
                <code>para</code> element.</span></p>
              </li>

              <li>
                <p><code>//para</code> matches any
                <code>para</code> element that has a parent
                node.</p>
              </li>

              <li>
                <p><code>bullet[position() mod 2 = 0]</code>
                matches any <code>bullet</code> element that is an
                even-numbered <code>bullet</code> child of its
                parent.</p>
              </li>

              <li>
                <p><code>div[@class="appendix"]//p</code> matches
                any <code>p</code> element with a <code>div</code>
                ancestor element that has a <code>class</code>
                attribute with value <code>appendix</code>.</p>
              </li>

              <li>
                <p><code>@class</code> matches any
                <code>class</code> attribute (<em>not</em> any
                element that has a <code>class</code>
                attribute).</p>
              </li>

              <li>
                <p><code>@*</code> matches any attribute node.</p>
              </li>
            </ul>
          </div>
        </div>

        <div class="div3">
          <h4><a name="pattern-syntax" id=
          "pattern-syntax"></a>5.5.2 Syntax of Patterns</h4>

          <p><a name="err-XTSE0340" id="err-XTSE0340"><span class=
          "error">[ERR XTSE0340]</span></a> Where an attribute is
          defined to contain a <a title="pattern" href=
          "index.html#dt-pattern">pattern</a>, it is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the pattern does not match the production <a href=
          "index.html#NT-Pattern">Pattern</a>. Every pattern is a legal XPath
          <a title="expression" href=
          "index.html#dt-expression">expression</a>, but the converse is not
          true: <code>2+2</code> is an example of a legal XPath
          expression that is not a pattern. The XPath expressions
          that can be used as patterns are those that match the
          grammar for <a href="index.html#NT-Pattern">Pattern</a>, given
          below.</p>

          <p>Informally, a <a href="index.html#NT-Pattern">Pattern</a> is a
          set of path expressions separated by <code>|</code>,
          where each step in the path expression is constrained to
          be an <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-AxisStep">AxisStep</a><sup>
          <small>XP</small></sup> that uses only the
          <code>child</code> or <code>attribute</code> axes.
          Patterns may also use the <code>//</code> operator. A
          <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-Predicate">Predicate</a><sup>
          <small>XP</small></sup> within the <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-PredicateList">PredicateList</a><sup>
          <small>XP</small></sup> in a pattern can contain
          arbitrary XPath expressions (enclosed between square
          brackets) in the same way as a <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-Predicate">predicate</a><sup>
          <small>XP</small></sup> in a path expression.</p>

          <p>Patterns may start with an <a href=
          "http://www.w3.org/TR/xpath-functions/#func-id"><code>id</code></a><sup>
          <small>FO</small></sup> or <a href=
          "index.html#function-key"><code>key</code></a> function call,
          provided that the value to be matched is supplied as
          either a literal or a reference to a <a title="variable"
          href="index.html#dt-variable">variable</a> or <a title="parameter"
          href="index.html#dt-parameter">parameter</a>, and the key name (in
          the case of the <a href=
          "index.html#function-key"><code>key</code></a> function) is
          supplied as a string literal. <span>These patterns will
          never match a node in a tree whose root is not a document
          node.</span></p>

          <p>If a pattern occurs in part of the <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> where
          <a title="backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled (see <a href="index.html#backwards"><i>3.8
          Backwards-Compatible Processing</i></a>), then <span>the
          semantics of the pattern are defined on the basis that
          the equivalent XPath expression is evaluated with
          <a title="XPath 1.0 compatibility mode" href=
          "index.html#dt-compatibility-mode">XPath 1.0 compatibility mode</a>
          set to true.</span></p>

          <h5><a name="d5e8328" id="d5e8328"></a>Patterns</h5>

          <table class="scrap" summary="Scrap">
            <tbody>
              <tr valign="baseline">
                <td><a name="NT-Pattern" id=
                "NT-Pattern"></a>[1]&#160;&#160;&#160;</td>

                <td><code>Pattern</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code><a href=
                "index.html#NT-PathPattern">PathPattern</a></code></td>
              </tr>

              <tr valign="baseline">
                <td></td>

                <td></td>

                <td></td>

                <td><code>| <a href="index.html#NT-Pattern">Pattern</a> '|'
                <a href=
                "index.html#NT-PathPattern">PathPattern</a></code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-PathPattern" id=
                "NT-PathPattern"></a>[2]&#160;&#160;&#160;</td>

                <td><code>PathPattern</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code><a href=
                "index.html#NT-RelativePathPattern">RelativePathPattern</a></code></td>
              </tr>

              <tr valign="baseline">
                <td></td>

                <td></td>

                <td></td>

                <td><code>| '/' <a href=
                "index.html#NT-RelativePathPattern">RelativePathPattern</a>?</code></td>
              </tr>

              <tr valign="baseline">
                <td></td>

                <td></td>

                <td></td>

                <td><code>| '//' <a href=
                "index.html#NT-RelativePathPattern">RelativePathPattern</a></code></td>
              </tr>

              <tr valign="baseline">
                <td></td>

                <td></td>

                <td></td>

                <td><code>| <a href=
                "index.html#NT-IdKeyPattern">IdKeyPattern</a> (('/' | '//')
                <a href=
                "index.html#NT-RelativePathPattern">RelativePathPattern</a>)?</code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-RelativePathPattern" id=
                "NT-RelativePathPattern"></a>[3]&#160;&#160;&#160;</td>

                <td><code>RelativePathPattern</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code><a href="index.html#NT-PatternStep">PatternStep</a>
                (('/' | '//') <a href=
                "index.html#NT-RelativePathPattern">RelativePathPattern</a>)?</code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-PatternStep" id=
                "NT-PatternStep"></a>[4]&#160;&#160;&#160;</td>

                <td><code>PatternStep</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code><a href=
                "index.html#NT-PatternAxis">PatternAxis</a>? <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-NodeTest">NodeTest</a><sup>
                <small>XP</small></sup> <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-PredicateList">
                PredicateList</a><sup><small>XP</small></sup></code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-PatternAxis" id=
                "NT-PatternAxis"></a>[5]&#160;&#160;&#160;</td>

                <td><code>PatternAxis</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code>('child' '::' | 'attribute' '::' |
                '@')</code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-IdKeyPattern" id=
                "NT-IdKeyPattern"></a>[6]&#160;&#160;&#160;</td>

                <td><code>IdKeyPattern</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code>'id' '(' <a href=
                "index.html#NT-IdValue">IdValue</a> ')'</code></td>
              </tr>

              <tr valign="baseline">
                <td></td>

                <td></td>

                <td></td>

                <td><code>| 'key' '(' <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-StringLiteral">
                StringLiteral</a><sup><small>XP</small></sup> ','
                <a href="index.html#NT-KeyValue">KeyValue</a> ')'</code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-IdValue" id=
                "NT-IdValue"></a>[7]&#160;&#160;&#160;</td>

                <td><code>IdValue</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code><a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-StringLiteral">
                StringLiteral</a><sup><small>XP</small></sup> |
                <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-VarRef">VarRef</a><sup>
                <small>XP</small></sup></code></td>
              </tr>

              <tr valign="baseline">
                <td><a name="NT-KeyValue" id=
                "NT-KeyValue"></a>[8]&#160;&#160;&#160;</td>

                <td><code>KeyValue</code></td>

                <td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>

                <td><code><a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-Literal">Literal</a><sup>
                <small>XP</small></sup> | <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-VarRef">VarRef</a><sup>
                <small>XP</small></sup></code></td>
              </tr>
            </tbody>
          </table>

          <p>The constructs <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-NodeTest">NodeTest</a><sup>
          <small>XP</small></sup>, <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-PredicateList">PredicateList</a><sup>
          <small>XP</small></sup>, <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-VarRef">VarRef</a><sup>
          <small>XP</small></sup>, <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-Literal">Literal</a><sup>
          <small>XP</small></sup>, and <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-StringLiteral">StringLiteral</a><sup>
          <small>XP</small></sup> are part of the XPath expression
          language, and are defined in <a href="index.html#xpath20">[XPath
          2.0]</a>.</p>
        </div>

        <div class="div3">
          <h4><a name="pattern-semantics" id=
          "pattern-semantics"></a>5.5.3 The Meaning of a
          Pattern</h4>

          <p>The meaning of a pattern is defined formally as
          follows.</p>

          <p>First we define the concept of an <em>equivalent
          expression</em>. In general, the equivalent expression is
          the XPath expression that takes the same lexical form as
          the pattern as written. However, if the pattern contains
          a <code>PathPattern</code> that is a
          <code>RelativePathPattern</code>, then the first
          <code>PatternStep</code> <var>PS</var> of this
          <code>RelativePathPattern</code> is adjusted to allow it
          to match a parentless element or attribute node, as
          follows:</p>

          <ul>
            <li>
              <p>If the <code>NodeTest</code> in <var>PS</var> is
              <code>document-node()</code> (optionally with
              arguments), and if no explicit axis is specified,
              then the axis in step <var>PS</var> is taken as
              <code>self</code> rather than <code>child</code>.</p>
            </li>

            <li>
              <p>If <var>PS</var> uses the child axis (explicitly
              or implicitly), and if the <code>NodeTest</code> in
              <var>PS</var> is not <code>document-node()</code>
              (optionally with arguments), then the axis in step
              <var>PS</var> is replaced by
              <code>child-or-top</code>, which is defined as
              follows. If the context node is a parentless element,
              comment, processing-instruction, or text node then
              the <code>child-or-top</code> axis selects the
              context node; otherwise it selects the children of
              the context node. It is a forwards axis whose
              principal node kind is element.</p>
            </li>

            <li>
              <p>If <var>PS</var> uses the attribute axis, then the
              axis in step <var>PS</var> is replaced by
              <code>attribute-or-top</code>, which is defined as
              follows. If the context node is an attribute node
              with no parent, then the
              <code>attribute-or-top</code> axis selects the
              context node; otherwise it selects the attributes of
              the context node. It is a forwards axis whose
              principal node kind is attribute.</p>
            </li>
          </ul>

          <p>The axes <code>child-or-top</code> and
          <code>attribute-or-top</code> are introduced only for
          definitional purposes. They cannot be used explicitly in
          a user-written pattern or expression.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The purpose of these adjustments is to ensure that a
            pattern such as <code>person</code> matches any element
            named <code>person</code>, even if it has no parent;
            and similarly, that the pattern <code>@width</code>
            matches any attribute named <code>width</code>, even a
            parentless attribute. The rule also ensures that a
            pattern using a <code>NodeTest</code> of the form
            <code>document-node(...)</code> matches a document
            node. The pattern <code>node()</code> will match any
            element, text node, comment, or processing instruction,
            whether or not it has a parent. For backwards
            compatibility reasons, the pattern <code>node()</code>,
            when used without an explicit axis, does not match
            document nodes, attribute nodes, or namespace nodes.
            The rules are also phrased to ensure that positional
            patterns of the form <code>para[1]</code> continue to
            count nodes relative to their parent, if they have
            one.</p>
          </div>

          <p>Let the equivalent expression, calculated according to
          these rules, be <var>EE</var>.</p>

          <p>To determine whether a node <var>N</var> matches the
          pattern, evaluate the <a title="expression" href=
          "index.html#dt-expression">expression</a>
          <code>root(.)//(<var>EE</var>)</code> with a <a title=
          "singleton focus" href="index.html#dt-singleton-focus">singleton
          focus</a> based on <var>N</var>. If the result is a
          sequence of nodes that includes <var>N</var>, then node
          <var>N</var> matches the pattern; otherwise node
          <var>N</var> does not match the pattern.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e8624" id="d5e8624"></a>Example: The
              Semantics of Patterns
            </div>

            <p>The pattern <code>p</code> matches any
            <code>p</code> element, because a <code>p</code>
            element will always be present in the result of
            evaluating the <a title="expression" href=
            "index.html#dt-expression">expression</a>
            <code>root(.)//(child-or-top::p)</code>. Similarly,
            <code>/</code> matches <span>a document node, and only
            a document node,</span> because the result of the
            <a title="expression" href=
            "index.html#dt-expression">expression</a>
            <code>root(.)//(/)</code> returns the root node of the
            tree containing the context node <span>if and only if
            it is a document node.</span></p>

            <p>The pattern <code>node()</code> matches all nodes
            selected by the expression
            <code>root(.)//(child-or-top::node())</code>, that is,
            all element, text, comment, and processing instruction
            nodes, whether or not they have a parent. It does not
            match attribute or namespace nodes because the
            expression does not select nodes using the attribute or
            namespace axes. <span>It does not match document nodes
            because for backwards compatibility reasons the
            <code>child-or-top</code> axis does not match a
            document node.</span></p>
          </div>

          <p>Although the semantics of patterns are specified
          formally in terms of expression evaluation, it is
          possible to understand pattern matching using a different
          model. In a pattern, <code>|</code> indicates
          alternatives; a pattern with one or more <code>|</code>
          separated alternatives matches if any one of the
          alternatives matches. A pattern such as
          <code>book/chapter/section</code> can be examined from
          right to left. A node will only match this pattern if it
          is a <code>section</code> element; and then, only if its
          parent is a <code>chapter</code>; and then, only if the
          parent of that <code>chapter</code> is a
          <code>book</code>. When the pattern uses the
          <code>//</code> operator, one can still read it from
          right to left, but this time testing the ancestors of a
          node rather than its parent. For example
          <code>appendix//section</code> matches every
          <code>section</code> element that has an ancestor
          <code>appendix</code> element.</p>

          <p>The formal definition, however, is useful for
          understanding the meaning of a pattern such as
          <code>para[1]</code>. This matches any node selected by
          the expression
          <code>root(.)//(child-or-top::para[1])</code>: that is,
          any <code>para</code> element that is the first
          <code>para</code> child of its parent, <span>or a
          <code>para</code> element that has no parent.</span></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>An implementation, of course, may use any algorithm
            it wishes for evaluating patterns, so long as the
            result corresponds with the formal definition above. An
            implementation that followed the formal definition by
            evaluating the equivalent expression and then testing
            the membership of a specific node in the result would
            probably be very inefficient.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="pattern-errors" id=
          "pattern-errors"></a>5.5.4 Errors in Patterns</h4>

          <p>Any <a title="dynamic error" href=
          "index.html#dt-dynamic-error">dynamic error</a> or <a title=
          "type errors" href="index.html#dt-type-error">type error</a> that
          occurs during the evaluation of a <a title="pattern"
          href="index.html#dt-pattern">pattern</a> against a particular node
          is treated as a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable error</a> even if the
          error would not be recoverable under other circumstances.
          The <a title="optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to treat the pattern as not matching that
          node.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The reason for this provision is that it is
            difficult for the stylesheet author to predict which
            predicates in a pattern will actually be evaluated. In
            the case of match patterns in template rules, it is not
            even possible to predict which patterns will be
            evaluated against a particular node. Making errors in
            patterns recoverable enables an implementation, if it
            chooses to do so, to report such errors while
            stylesheets are under development, while masking them
            if they occur during production running.</p>
          </div>

          <p>One particular optimization is <span class=
          "verb">required</span> by this specification: for a
          <a href="index.html#NT-PathPattern">PathPattern</a> that starts
          with <code>/</code> or <code>//</code> or with an
          <a href="index.html#NT-IdKeyPattern">IdKeyPattern</a>, the result
          of testing this pattern against a node in a tree whose
          root is not a document node must be a non-match, rather
          than a dynamic error. This rule applies to each <a href=
          "index.html#NT-PathPattern">PathPattern</a> within a <a href=
          "index.html#NT-Pattern">Pattern</a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Without the above rule, any attempt to apply
            templates to a parentless element node would create the
            risk of a dynamic error if the stylesheet has a
            template rule specifying <code>match="/"</code>.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="attribute-value-templates" id=
        "attribute-value-templates"></a>5.6 Attribute Value
        Templates</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-attribute-value-template" id=
        "dt-attribute-value-template" title=
        "attribute value template"></a>In an attribute that is
        designated as an <b>attribute value template</b>, such as
        an attribute of a <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>, an
        <a title="expression" href="index.html#dt-expression">expression</a>
        can be used by surrounding the expression with curly
        brackets (<code>{}</code>)<span class=
        "definition">]</span>.</p>

        <p>An attribute value template consists of an alternating
        sequence of fixed parts and variable parts. A variable part
        consists of an XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> enclosed in curly brackets
        (<code>{}</code>). A fixed part may contain any characters,
        except that a left curly bracket <span class=
        "verb">must</span> be written as <code>{{</code> and a
        right curly bracket <span class="verb">must</span> be
        written as <code>}}</code>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>An expression within a variable part may contain an
          unescaped curly bracket within a <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-StringLiteral">StringLiteral</a><sup>
          <small>XP</small></sup> <span>or within a
          comment</span>.</p>
        </div>

        <p><a name="err-XTSE0350" id="err-XTSE0350"><span class=
        "error">[ERR XTSE0350]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an unescaped left curly bracket appears in a fixed part of
        an attribute value template without a matching right curly
        bracket.</p>

        <p>It is a <a title="static error" href=
        "index.html#dt-static-error">static error</a> if the string contained
        between matching curly brackets in an attribute value
        template does not match the XPath production <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-Expr">Expr</a><sup>
        <small>XP</small></sup>, or if it contains other XPath
        static errors. The error is signaled using the appropriate
        XPath error code.</p>

        <p><a name="err-XTSE0370" id="err-XTSE0370"><span class=
        "error">[ERR XTSE0370]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an unescaped right curly bracket occurs in a fixed part of
        an attribute value template.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-effective-value" id="dt-effective-value" title=
        "effective value"></a>The result of evaluating an attribute
        value template is referred to as the <b>effective value</b>
        of the attribute.<span class="definition">]</span> The
        effective value is the string obtained by concatenating the
        expansions of the fixed and variable parts:</p>

        <ul>
          <li>
            <p>The expansion of a fixed part is obtained by
            replacing any double curly brackets (<code>{{</code> or
            <code>}}</code>) by the corresponding single curly
            bracket.</p>
          </li>

          <li>
            <p>The expansion of a variable part is obtained by
            evaluating the enclosed XPath <a title="expression"
            href="index.html#dt-expression">expression</a> and converting the
            resulting value to a string. <span>This conversion is
            done using the rules given in <a href=
            "index.html#constructing-simple-content"><i>5.7.2 Constructing
            Simple Content</i></a>.</span></p>
          </li>
        </ul>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This process can generate dynamic errors, for example
          if the sequence contains an element with a complex
          content type (which cannot be atomized).</p>
        </div>

        <p>If <a title="backwards compatible behavior" href=
        "index.html#dt-backwards-compatible-behavior">backwards compatible
        behavior</a> is enabled for the attribute, the rules for
        converting the value of the expression to a string are
        modified as follows. After <a title="atomize" href=
        "index.html#dt-atomization">atomizing</a> the result of the
        expression, all items other than the first item in the
        resulting sequence are discarded, and the effective value
        is obtained by converting the first item in the sequence to
        a string. If the atomized sequence is empty, the result is
        a zero-length string.</p>

        <p>Curly brackets are not treated specially in an attribute
        value in an XSLT <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> unless the attribute is
        specifically designated as one that permits an attribute
        value template; in an element syntax summary, the value of
        such attributes is surrounded by curly brackets.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Not all attributes are designated as attribute value
          templates. Attributes whose value is an <a title=
          "expression" href="index.html#dt-expression">expression</a> or
          <a title="pattern" href="index.html#dt-pattern">pattern</a>,
          attributes of <a title="declaration" href=
          "index.html#dt-declaration">declaration</a> elements and attributes
          that refer to named XSLT objects are
          <span>generally</span> not designated as attribute value
          templates <span>(an exception is the <code>format</code>
          attribute of <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>)</span>.
          Namespace declarations are not <span>XDM attribute
          nodes</span> and are therefore never treated as attribute
          value templates.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e8932" id="d5e8932"></a>Example: Attribute
            Value Templates
          </div>

          <p>The following example creates an <code>img</code>
          result element from a <code>photograph</code> element in
          the source; the value of the <code>src</code> and
          <code>width</code> attributes are computed using XPath
          expressions enclosed in attribute value templates:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="image-dir" select="'/images'"/&gt;

&lt;xsl:template match="photograph"&gt;
  &lt;img src="{$image-dir}/{href}" width="{size/@width}"/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>With this source</p>

          <div class="exampleInner">
            <pre>
&lt;photograph&gt;
  &lt;href&gt;headquarters.jpg&lt;/href&gt;
  &lt;size width="300"/&gt;
&lt;/photograph&gt;
</pre>
          </div>

          <p>the result would be</p>

          <div class="exampleInner">
            <pre>
&lt;img src="/images/headquarters.jpg" width="300"/&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e8959" id="d5e8959"></a>Example: Producing a
            Space-Separated List
          </div>

          <p>The following example shows how the values in a
          sequence are output as a space-separated list. The
          following literal result element:</p>

          <div class="exampleInner">
            <pre>
&lt;temperature readings="{10.32, 5.50, 8.31}"/&gt;
</pre>
          </div>

          <p>produces the output node:</p>

          <div class="exampleInner">
            <pre>
&lt;temperature readings="10.32 5.5 8.31"/&gt;
</pre>
          </div>
        </div>

        <p>Curly brackets are <em>not</em> recognized recursively
        inside expressions.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e8975" id="d5e8975"></a>Example: Curly
            Brackets can not be Nested
          </div>

          <p>For example:</p>

          <div class="exampleInner">
            <pre>
&lt;a href="#{id({@ref})/title}"&gt;
</pre>
          </div>

          <p>is <em>not</em> allowed. Instead, use simply:</p>

          <div class="exampleInner">
            <pre>
&lt;a href="#{id(@ref)/title}"&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="sequence-constructors" id=
        "sequence-constructors"></a>5.7 Sequence Constructors</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-sequence-constructor" id="dt-sequence-constructor"
        title="sequence constructor"></a>A <b>sequence
        constructor</b> is a sequence of zero or more sibling nodes
        in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> that can be evaluated to
        return a sequence of nodes and atomic values. The way that
        the resulting sequence is used depends on the containing
        instruction.<span class="definition">]</span></p>

        <p>Many <a title="XSLT element" href=
        "index.html#dt-xslt-element">XSLT elements</a>, <span>and also</span>
        <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result elements</a>,
        are defined to take a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> as
        their content.</p>

        <p>Four kinds of nodes may be encountered in a sequence
        constructor:</p>

        <ul>
          <li>
            <p><em>Text nodes</em> appearing in the <a title=
            "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> (if
            they have not been removed in the process of whitespace
            stripping: see <a href="index.html#stylesheet-stripping"><i>4.2
            Stripping Whitespace from the Stylesheet</i></a>) are
            copied to create a new parentless text node in the
            result sequence.</p>
          </li>

          <li>
            <p><a title="literal result element" href=
            "index.html#dt-literal-result-element">Literal result
            elements</a> are evaluated to create a new parentless
            element node, having the same <a title="expanded-QName"
            href="index.html#dt-expanded-qname">expanded-QName</a> as the
            literal result element, which is added to the result
            sequence: see <a href="index.html#literal-result-element"><i>11.1
            Literal Result Elements</i></a></p>
          </li>

          <li>
            <p>XSLT <a title="instruction" href=
            "index.html#dt-instruction">instructions</a> produce a sequence
            of zero, one, or more items as their result. These
            items are added to the result sequence. For most XSLT
            instructions, these items are nodes, but some
            instructions (<a href=
            "index.html#element-sequence"><code>xsl:sequence</code></a> and
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>) can
            also produce atomic values. Several instructions, such
            as <a href=
            "index.html#element-element"><code>xsl:element</code></a>, return
            a newly constructed parentless node (which may have its
            own attributes, namespaces, children, and other
            descendants). Other instructions, such as <a href=
            "index.html#element-if"><code>xsl:if</code></a>, pass on the
            items produced by their own nested sequence
            constructors. The <a href=
            "index.html#element-sequence"><code>xsl:sequence</code></a>
            instruction may return atomic values, or existing
            nodes.</p>
          </li>

          <li>
            <p><a title="extension instruction" href=
            "index.html#dt-extension-instruction">Extension instructions</a>
            (see <a href="index.html#extension-instruction"><i>18.2 Extension
            Instructions</i></a>) also produce a sequence of items
            as their result. The items in this sequence are added
            to the result sequence.</p>
          </li>
        </ul>

        <p>There are several ways the result of a sequence
        constructor may be used.</p>

        <ul>
          <li>
            <p>The sequence may be bound to a variable or returned
            from a stylesheet function, in which case it becomes
            available as a value to be manipulated in arbitrary
            ways by XPath expressions. The sequence is bound to a
            variable when the sequence constructor appears within
            one of the elements <a href=
            "index.html#element-variable"><code>xsl:variable</code></a>,
            <a href="index.html#element-param"><code>xsl:param</code></a>, or
            <a href=
            "index.html#element-with-param"><code>xsl:with-param</code></a>,
            when this instruction has an <code>as</code> attribute.
            The sequence is returned from a stylesheet function
            when the sequence constructor appears within the
            <a href=
            "index.html#element-function"><code>xsl:function</code></a>
            element.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>This will typically expose to the stylesheet
              elements, attributes, and other nodes that have not
              yet been attached to a parent node in a <a title=
              "result tree" href="index.html#dt-result-tree">result tree</a>.
              The semantics of XPath expressions when applied to
              parentless nodes are well-defined; however, such
              expressions should be used with care. For example,
              the expression <code>/</code> <span>causes a type
              error if the root of the tree containing the context
              node is not a document node.</span>.</p>

              <p>Parentless attribute nodes require particular care
              because they have no namespace nodes associated with
              them. <span>A parentless attribute node is not
              permitted to contain namespace-sensitive content (for
              example, a QName or an XPath expression) because
              there is no information enabling the prefix to be
              resolved to a namespace URI.</span> Parentless
              attributes can be useful in an application (for
              example, they provide an alternative to the use of
              attribute sets: see <a href="index.html#attribute-sets"><i>10.2
              Named Attribute Sets</i></a>) but they need to be
              handled with care.</p>
            </div>
          </li>

          <li>
            <p>The sequence may be returned as the result of the
            containing element. This happens when the instruction
            containing the sequence constructor is <a href=
            "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>,
            <a href=
            "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
            <a href=
            "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
            <a href=
            "index.html#element-call-template"><code>xsl:call-template</code></a>,
            <a href="index.html#element-choose"><code>xsl:choose</code></a>,
            <a href=
            "index.html#element-fallback"><code>xsl:fallback</code></a>,
            <a href=
            "index.html#element-for-each"><code>xsl:for-each</code></a>,
            <a href=
            "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
            <a href="index.html#element-if"><code>xsl:if</code></a>, <a href=
            "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>,
            <a href=
            "index.html#element-next-match"><code>xsl:next-match</code></a>,
            <a href=
            "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>,
            <a href=
            "index.html#element-otherwise"><code>xsl:otherwise</code></a>,
            <a href=
            "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>,
            <a href=
            "index.html#element-sequence"><code>xsl:sequence</code></a>, or
            <a href="index.html#element-when"><code>xsl:when</code></a></p>
          </li>

          <li>
            <p>The sequence may be used to construct the content of
            a new element or document node. This happens when the
            sequence constructor appears as the content of a
            <a title="literal result element" href=
            "index.html#dt-literal-result-element">literal result
            element</a>, or of one of the instructions <a href=
            "index.html#element-copy"><code>xsl:copy</code></a>, <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <span><a href=
            "index.html#element-document"><code>xsl:document</code></a>,
            <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>,</span>
            or <a href=
            "index.html#element-message"><code>xsl:message</code></a>. It
            also happens when the sequence constructor is contained
            in one of the elements <a href=
            "index.html#element-variable"><code>xsl:variable</code></a>,
            <a href="index.html#element-param"><code>xsl:param</code></a>, or
            <a href=
            "index.html#element-with-param"><code>xsl:with-param</code></a>,
            when this instruction has no <code>as</code> attribute.
            For details, see <a href=
            "index.html#constructing-complex-content"><i>5.7.1 Constructing
            Complex Content</i></a>.</p>
          </li>

          <li>
            <p>The sequence may be used to construct the <a title=
            "string value" href="index.html#dt-string-value">string value</a>
            of an attribute node, <span>text node</span>, namespace
            node, comment node, or processing instruction node.
            This happens when the sequence constructor is contained
            in one of the elements <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <span><a href=
            "index.html#element-value-of"><code>xsl:value-of</code></a></span>,
            <a href=
            "index.html#element-namespace"><code>xsl:namespace</code></a>,
            <a href=
            "index.html#element-comment"><code>xsl:comment</code></a>, or
            <a href=
            "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>.
            For details, see <a href=
            "index.html#constructing-simple-content"><i>5.7.2 Constructing
            Simple Content</i></a>.</p>
          </li>
        </ul>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The term <em><span>sequence</span> constructor</em>
          replaces <em>template</em> as used in XSLT 1.0. The
          change is made partly for clarity (to avoid confusion
          with <a title="template rule" href=
          "index.html#dt-template-rule">template rules</a> and <a title=
          "named template" href="index.html#dt-named-template">named
          templates</a>), but also to reflect a more formal
          definition of the semantics. Whereas XSLT 1.0 described a
          template as a sequence of instructions that write to the
          result tree, XSLT 2.0 describes a <span>sequence</span>
          constructor as something that can be evaluated to return
          a sequence of <span>items</span>; what happens to these
          items depends on the containing instruction.</p>
        </div>

        <div class="div3">
          <h4><a name="constructing-complex-content" id=
          "constructing-complex-content"></a>5.7.1 Constructing
          Complex Content</h4>

          <p>This section describes how the sequence obtained by
          evaluating a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> may
          be used to construct the children of a newly constructed
          document node, or the children, attributes and namespaces
          of a newly constructed element node. The sequence of
          items may be obtained by evaluating the <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>
          contained in an instruction such as <a href=
          "index.html#element-copy"><code>xsl:copy</code></a>, <a href=
          "index.html#element-element"><code>xsl:element</code></a>,
          <span><a href=
          "index.html#element-document"><code>xsl:document</code></a></span>,
          <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>,
          or a <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result
          element</a>.</p>

          <p>When constructing the content of an element, the
          <code>inherit-namespaces</code> attribute of the <a href=
          "index.html#element-element"><code>xsl:element</code></a> or
          <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction, or the <code>xsl:inherit-namespaces</code>
          property of the literal result element, determines
          whether namespace nodes are to be inherited. The effect
          of this attribute is described in the rules that
          follow.</p>

          <p>The sequence is processed as follows <span>(applying
          the rules in the order they are listed)</span>:</p>

          <ol class="enumar">
            <li>
              <p>The containing instruction may generate attribute
              nodes and/or namespace nodes, as specified in the
              rules for the individual instruction. For example,
              these nodes may be produced by expanding an
              <code>[xsl:]use-attribute-sets</code> attribute, or
              by expanding the attributes of a <a title=
              "literal result element" href=
              "index.html#dt-literal-result-element">literal result
              element</a>. Any such nodes are prepended to the
              sequence produced by evaluating the <a title=
              "sequence constructor" href=
              "index.html#dt-sequence-constructor">sequence
              constructor</a>.</p>
            </li>

            <li>
              <p>Any atomic value in the sequence is cast to a
              string.</p>

              <div class="note">
                <p class="prefix"><b>Note:</b></p>

                <p>Casting from <code>xs:QName</code> or
                <code>xs:NOTATION</code> to <code>xs:string</code>
                always succeeds, because these values retain a
                prefix for this purpose. However, there is no
                guarantee that the prefix used will always be
                meaningful in the context where the resulting
                string is used.</p>
              </div>
            </li>

            <li>
              <p>Any consecutive sequence of strings within the
              result sequence is converted to a single text node,
              whose <a title="string value" href=
              "index.html#dt-string-value">string value</a> contains the
              content of each of the strings in turn, with a single
              space (#x20) used as a separator between successive
              strings.</p>
            </li>

            <li>
              <p>Any document node within the result sequence is
              replaced by a sequence containing each of its
              children, in document order.</p>
            </li>

            <li>
              <p>Zero-length text nodes within the result sequence
              are removed.</p>
            </li>

            <li>
              <p>Adjacent text nodes within the result sequence are
              merged into a single text node.</p>
            </li>

            <li>
              <p>Invalid namespace and attribute nodes are detected
              as follows.</p>

              <p><a name="err-XTDE0410" id=
              "err-XTDE0410"><span class="error">[ERR
              XTDE0410]</span></a> It is a <a title=
              "non-recoverable dynamic error" href=
              "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
              error</a> if the result sequence used to construct
              the content of an element node contains a namespace
              node or attribute node that is preceded in the
              sequence by a node that is neither a namespace node
              nor an attribute node.</p>

              <p><a name="err-XTDE0420" id=
              "err-XTDE0420"><span class="error">[ERR
              XTDE0420]</span></a> It is a <a title=
              "non-recoverable dynamic error" href=
              "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
              error</a> if the result sequence used to construct
              the content of a document node contains a namespace
              node or attribute node.</p>

              <p><a name="err-XTDE0430" id=
              "err-XTDE0430"><span class="error">[ERR
              XTDE0430]</span></a> It is a <a title=
              "non-recoverable dynamic error" href=
              "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
              error</a> if the result sequence contains two or more
              namespace nodes having the same name but different
              <a title="string value" href=
              "index.html#dt-string-value">string values</a> (that is,
              namespace nodes that map the same prefix to different
              namespace URIs).</p>

              <p><a name="err-XTDE0440" id=
              "err-XTDE0440"><span class="error">[ERR
              XTDE0440]</span></a> It is a <a title=
              "non-recoverable dynamic error" href=
              "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
              error</a> if the result sequence contains a namespace
              node with no name and the element node being
              constructed has a null namespace URI (that is, it is
              an error to define a default namespace when the
              element is in no namespace).</p>
            </li>

            <li>
              <p>If the result sequence contains two or more
              namespace nodes with the same name (or no name) and
              the same <a title="string value" href=
              "index.html#dt-string-value">string value</a> (that is, two
              namespace nodes mapping the same prefix to the same
              namespace URI), then all but one of the duplicate
              nodes are discarded.</p>

              <div class="note">
                <p class="prefix"><b>Note:</b></p>

                <p>Since the order of namespace nodes is undefined,
                it is not significant which of the duplicates is
                retained.</p>
              </div>
            </li>

            <li>
              <p>If an attribute <var>A</var> in the result
              sequence has the same name as another attribute
              <var>B</var> that appears later in the result
              sequence, then attribute <var>A</var> is discarded
              from the result sequence.</p>
            </li>

            <li>
              <p>Each node in the resulting sequence is attached as
              a namespace, attribute, or child of the newly
              constructed element or document node. Conceptually
              this involves making a deep copy of the node; in
              practice, however, copying the node will only be
              necessary if the existing node can be referenced
              independently of the parent to which it is being
              attached. When copying an element or processing
              instruction node, its base URI property is changed to
              be the same as that of its new parent, unless it has
              an <code>xml:base</code> attribute (see <a href=
              "index.html#xmlbase">[XML Base]</a>) that overrides this. If
              the <span>copied</span> element has an
              <code>xml:base</code> attribute, its base URI is the
              value of that attribute, resolved (if it is relative)
              against the base URI of the new parent node.</p>
            </li>

            <li>
              <p>If the newly constructed node is an element node,
              then namespace fixup is applied to this node, as
              described in <a href="index.html#namespace-fixup"><i>5.7.3
              Namespace Fixup</i></a>.</p>
            </li>

            <li>
              <p>If the newly constructed node is an element node,
              and if namespaces are inherited, then each namespace
              node of the newly constructed element (including any
              produced as a result of the namespace fixup process)
              is copied to each descendant element of the newly
              constructed element, unless that element or an
              intermediate element already has a namespace node
              with the same name (or absence of a name) <span>or
              that descendant element or an intermediate element is
              in no namespace and the namespace node has no
              name</span>.</p>
            </li>
          </ol>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e9419" id="d5e9419"></a>Example: A
              Sequence Constructor for Complex Content
            </div>

            <p>Consider the following stylesheet fragment:</p>

            <div class="exampleInner">
              <pre>
&lt;td&gt;
  &lt;xsl:attribute name="valign"&gt;top&lt;/xsl:attribute&gt;
  &lt;xsl:value-of select="@description"/&gt;
&lt;/td&gt;
</pre>
            </div>

            <p>This fragment consists of a literal result element
            <code>td</code>, containing a sequence constructor that
            consists of two instructions: <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a> and
            <a href=
            "index.html#element-value-of"><code>xsl:value-of</code></a>. The
            sequence constructor is evaluated to produce a sequence
            of two nodes: a parentless attribute node, and a
            parentless text node. The <code>td</code> instruction
            causes a <code>td</code> element to be created; the new
            attribute therefore becomes an attribute of the new
            <code>td</code> element, while the text node created by
            the <a href=
            "index.html#element-value-of"><code>xsl:value-of</code></a>
            instruction becomes a child of the <code>td</code>
            element (unless it is zero-length, in which case it is
            discarded).</p>
          </div>

          <p>&#160;</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e9453" id="d5e9453"></a>Example: Space
              Separators in Element Content
            </div>

            <p>Consider the following stylesheet fragment:</p>

            <div class="exampleInner">
              <pre>
&lt;doc&gt;
  &lt;e&gt;&lt;xsl:sequence select="1 to 5"/&gt;&lt;/e&gt;
  &lt;f&gt;
    &lt;xsl:for-each select="1 to 5"&gt;
      &lt;xsl:value-of select="."/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/f&gt;
&lt;/doc&gt;
</pre>
            </div>

            <p>This produces the output (when indented):</p>

            <div class="exampleInner">
              <pre>
&lt;doc&gt;
  &lt;e&gt;1 2 3 4 5&lt;/e&gt;
  &lt;f&gt;12345&lt;/f&gt;
&lt;/doc&gt;
</pre>
            </div>

            <p>The difference between the two cases is that for the
            <code>e</code> element, the sequence constructor
            generates a sequence of five atomic values, which are
            therefore separated by spaces. For the <code>f</code>
            element, the content is a sequence of five text nodes,
            which are concatenated without space separation.</p>

            <p>It is important to be aware of the distinction
            between <a href=
            "index.html#element-sequence"><code>xsl:sequence</code></a>,
            which returns the value of its <code>select</code>
            expression unchanged, and <a href=
            "index.html#element-value-of"><code>xsl:value-of</code></a>,
            which constructs a text node.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="constructing-simple-content" id=
          "constructing-simple-content"></a>5.7.2 Constructing
          Simple Content</h4>

          <p>The <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-comment"><code>xsl:comment</code></a>,
          <a href=
          "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>,
          <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a><span>,
          and <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a></span>
          elements create nodes that cannot have children.
          <span>Specifically, the <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction creates an attribute node, <a href=
          "index.html#element-comment"><code>xsl:comment</code></a> creates a
          comment node, <a href=
          "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
          creates a processing instruction node, <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          creates a namespace node, and <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a> creates
          a text node. The string value of the new node is
          constructed using either the <code>select</code>
          attribute of the instruction, or the <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> that
          forms the content of the instruction. The
          <code>select</code> attribute allows the content to be
          specified by means of an XPath expression, while the
          sequence constructor allows it to be specified by means
          of a sequence of XSLT instructions. The
          <code>select</code> attribute or sequence constructor is
          evaluated to produce a result sequence,</span> and the
          <a title="string value" href="index.html#dt-string-value">string
          value</a> of the new node is derived from this result
          sequence according to the rules below.</p>

          <p>These rules are also used to compute the <a title=
          "effective value" href="index.html#dt-effective-value">effective
          value</a> of an <a title="attribute value template" href=
          "index.html#dt-attribute-value-template">attribute value
          template</a>. In this case the sequence being processed
          is the result of evaluating an XPath expression enclosed
          between curly brackets, and the separator is a single
          space character.</p>

          <ol class="enumar">
            <li>
              <p>Zero-length text nodes in the sequence are
              discarded.</p>
            </li>

            <li>
              <p>Adjacent text nodes in the sequence are merged
              into a single text node.</p>
            </li>

            <li>
              <p>The sequence is <a title="atomize" href=
              "index.html#dt-atomization">atomized</a>.</p>
            </li>

            <li>
              <p>Every value in the atomized sequence is cast to a
              string.</p>
            </li>

            <li>
              <p>The strings within the resulting sequence are
              concatenated, with a (possibly zero-length) separator
              inserted between successive strings. <span>The
              default separator is a single space.</span> In the
              case of <a href=
              "index.html#element-attribute"><code>xsl:attribute</code></a>
              and <a href=
              "index.html#element-value-of"><code>xsl:value-of</code></a>, a
              different separator can be specified using the
              <code>separator</code> attribute of the instruction;
              it is permissible for this to be a zero-length
              string, in which case the strings are concatenated
              with no separator. In the case of <a href=
              "index.html#element-comment"><code>xsl:comment</code></a>,
              <a href=
              "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>,
              and <a href=
              "index.html#element-namespace"><code>xsl:namespace</code></a><span>
              , and when expanding an <a title=
              "attribute value template" href=
              "index.html#dt-attribute-value-template">attribute value
              template</a></span>, the default separator cannot be
              changed.</p>
            </li>

            <li>
              <p>In the case of <a href=
              "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>,
              any leading spaces in the resulting string are
              removed.</p>
            </li>

            <li>
              <p>The <span>resulting string</span> forms the
              <a title="string value" href=
              "index.html#dt-string-value">string value</a> of the new
              attribute, namespace, comment,
              processing-instruction, or text node.</p>
            </li>
          </ol>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e9607" id="d5e9607"></a>Example: Space
              Separators in Attribute Content
            </div>

            <p>Consider the following stylesheet fragment:</p>

            <div class="exampleInner">
              <pre>
&lt;doc&gt;
  &lt;xsl:attribute name="e" select="1 to 5"/&gt;
  &lt;xsl:attribute name="f"&gt;
    &lt;xsl:for-each select="1 to 5"&gt;
      &lt;xsl:value-of select="."/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:attribute&gt;
&lt;/doc&gt;
</pre>
            </div>

            <p>This produces the output:</p>

            <div class="exampleInner">
              <pre>
&lt;doc e="1 2 3 4 5" f="12345"/&gt;
</pre>
            </div>

            <p>The difference between the two cases is that for the
            <code>e</code> attribute, the sequence constructor
            generates a sequence of five atomic values, which are
            therefore separated by spaces. For the <code>f</code>
            attribute, the content is supplied as a sequence of
            five text nodes, which are concatenated without space
            separation.</p>

            <p>Specifying <code>separator=""</code> on the first
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>
            instruction would cause the attribute value to be
            <code>e="12345"</code>. A <code>separator</code>
            attribute on the second <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>
            instruction would have no effect, since the separator
            only affects the way adjacent atomic values are
            handled: separators are never inserted between adjacent
            text nodes.</p>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>If an attribute value template contains a sequence
            of fixed and variable parts, no additional whitespace
            is inserted between the expansions of the fixed and
            variable parts. For example, the <a title=
            "effective value" href="index.html#dt-effective-value">effective
            value</a> of the attribute <code>a="chapters{4 to
            6}"</code> is <code>a="chapters4 5 6"</code>.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="namespace-fixup" id=
          "namespace-fixup"></a>5.7.3 Namespace Fixup</h4>

          <p>In a tree supplied to or constructed by an XSLT
          processor, the constraints relating to namespace nodes
          that are specified in <a href="index.html#xpath-datamodel">[Data
          Model]</a> <span class="verb">must</span> be satisfied.
          For example</p>

          <ul>
            <li>
              <p>If an element node has an <a title=
              "expanded-QName" href=
              "index.html#dt-expanded-qname">expanded-QName</a> with a
              non-null namespace URI, then that element node
              <span><span class="verb">must</span></span> have at
              least one namespace node whose <a title=
              "string value" href="index.html#dt-string-value">string
              value</a> is the same as that namespace URI.</p>
            </li>

            <li>
              <p>If an element node has an attribute node whose
              <a title="expanded-QName" href=
              "index.html#dt-expanded-qname">expanded-QName</a> has a
              non-null namespace URI, then the element <span class=
              "verb">must</span> have at least one namespace node
              whose <a title="string value" href=
              "index.html#dt-string-value">string value</a> is the same as
              that namespace URI and whose name is non-empty.</p>
            </li>

            <li>
              <p>Every element <span class="verb">must</span> have
              a namespace node whose <a title="expanded-QName"
              href="index.html#dt-expanded-qname">expanded-QName</a> has
              local-part <code>xml</code> and whose <a title=
              "string value" href="index.html#dt-string-value">string
              value</a> is
              <code>http://www.w3.org/XML/1998/namespace</code>.
              The namespace prefix <code>xml</code> must not be
              associated with any other namespace URI, and the
              namespace URI
              <code>http://www.w3.org/XML/1998/namespace</code>
              must not be associated with any other prefix.</p>
            </li>

            <li>
              <p>A namespace node <span class="verb">must
              not</span> have the name <code>xmlns</code>.</p>
            </li>
          </ul>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-namespace-fixup" id="dt-namespace-fixup" title=
          "namespace fixup"></a>The rules for the individual XSLT
          instructions that construct a <a title="result tree"
          href="index.html#dt-result-tree">result tree</a> (see <a href=
          "index.html#creating-new-nodes"><i>11 Creating Nodes and
          Sequences</i></a>) prescribe some of the situations in
          which namespace nodes are written to the tree. These
          rules, however, are not sufficient to ensure that the
          prescribed constraints are always satisfied. The XSLT
          processor <span class="verb">must</span> therefore add
          additional namespace nodes to satisfy these constraints.
          This process is referred to as <b>namespace
          fixup</b>.<span class="definition">]</span></p>

          <p>The actual namespace nodes that are added to the tree
          by the namespace fixup process are <a title=
          "implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>,
          provided firstly, that at the end of the process the
          above constraints <span class="verb">must</span> all be
          satisfied, and secondly, that a namespace node
          <span class="verb">must not</span> be added to the tree
          unless the namespace node is necessary either to satisfy
          these constraints, or to enable the tree to be serialized
          using the original namespace prefixes from the source
          document or <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>.</p>

          <p>Namespace fixup <span class="verb">must not</span>
          result in an element having multiple namespace nodes with
          the same name.</p>

          <p>Namespace fixup <span class="verb">may</span>, if
          necessary to resolve conflicts, change the namespace
          prefix contained in the QName value that holds the name
          of an element or attribute node. <span>This includes the
          option to add or remove a prefix.</span> However,
          namespace fixup <span class="verb">must not</span> change
          the prefix component contained in a value of type
          <code>xs:QName</code> or <code>xs:NOTATION</code> that
          forms the typed value of an element or attribute
          node.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Namespace fixup is not used to create namespace
            declarations for <code>xs:QName</code> or
            <code>xs:NOTATION</code> values appearing in the
            content of an element or attribute.</p>

            <p>Where values acquire such types as the result of
            validation, namespace fixup does not come into play,
            because namespace fixup happens before validation: in
            this situation, it is the user's responsibility to
            ensure that the element being validated has the
            required namespace nodes to enable validation to
            succeed.</p>

            <p>Where existing elements are copied along with their
            existing type annotations
            (<code>validation="preserve"</code>) the rules require
            that existing namespace nodes are also copied, so that
            any namespace-sensitive values remain valid.</p>

            <p>Where existing attributes are copied along with
            their existing type annotations, the rules of the XDM
            data model require that a parentless attribute node
            cannot contain a namespace-sensitive typed value; this
            means that it is an error to copy an attribute using
            <code>validation="preserve"</code> if it contains
            namespace-sensitive content.</p>
          </div>

          <p><a name="err-XTDE0485" id="err-XTDE0485"><span class=
          "error">[ERR XTDE0485]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if namespace fixup is performed on an element
          that contains among the typed values of the element and
          its attributes two values of type <code>xs:QName</code>
          or <code>xs:NOTATION</code> containing conflicting
          namespace prefixes, that is, two values that use the same
          prefix to refer to different namespace URIs.</p>

          <p>Namespace fixup is applied to every element that is
          constructed using a <a title="literal result element"
          href="index.html#dt-literal-result-element">literal result
          element</a>, or one of the instructions <a href=
          "index.html#element-element"><code>xsl:element</code></a>, <a href=
          "index.html#element-copy"><code>xsl:copy</code></a>, or <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a>. An
          implementation is not <span class="verb">required</span>
          to perform namespace fixup for elements in any source
          document, that is, for a document in the initial input
          sequence, documents loaded using the <a href=
          "index.html#function-document"><code>document</code></a>, <a href=
          "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
          <small>FO</small></sup> or <a href=
          "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
          collection</code></a><sup><small>FO</small></sup>
          function, documents supplied as the value of a <a title=
          "stylesheet parameter" href=
          "index.html#dt-stylesheet-parameter">stylesheet parameter</a>, or
          documents returned by an <a title="extension function"
          href="index.html#dt-extension-function">extension function</a> or
          <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension
          instruction</a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>A source document (an input document, a document
            returned by the <a href=
            "index.html#function-document"><code>document</code></a>,
            <a href="http://www.w3.org/TR/xpath-functions/#func-doc">
            <code>doc</code></a><sup><small>FO</small></sup> or
            <a href=
            "http://www.w3.org/TR/xpath-functions/#func-collection">
            <code>collection</code></a><sup><small>FO</small></sup>
            functions, a document returned by an extension function
            or extension instruction, or a document supplied as a
            stylesheet parameter) is required to satisfy the
            constraints described in <a href=
            "index.html#xpath-datamodel">[Data Model]</a>, including the
            constraints imposed by the namespace fixup process. The
            effect of supplying a pseudo-document that does not
            meet these constraints is undefined.</p>
          </div>

          <p>In an Infoset (see <a href="index.html#xml-infoset">[XML
          Information Set]</a>) created from a document conforming
          to <a href="index.html#REC-xml-names">[Namespaces in XML 1.0]</a>,
          it will always be true that if a parent element has an
          in-scope namespace with a non-empty namespace prefix,
          then its child elements will also have an in-scope
          namespace with the same namespace prefix, though possibly
          with a different namespace URI. This constraint is
          removed in <a href="index.html#xml-names11">[Namespaces in XML
          1.1]</a>. XSLT 2.0 supports the creation of result trees
          that do not satisfy this constraint: the namespace fixup
          process does not add a namespace node to an element
          merely because its parent node in the <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a> has
          such a namespace node. <span>However, the process of
          constructing the children of a new element, which is
          described in <a href=
          "index.html#constructing-complex-content"><i>5.7.1 Constructing
          Complex Content</i></a>, does cause the namespaces of a
          parent element to be inherited by its children unless
          this is prevented using
          <code>[xsl:]inherit-namespaces="no"</code> on the
          instruction that creates the parent element.</span></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>This has implications on serialization, defined in
            <a href="index.html#xslt-xquery-serialization">[XSLT and XQuery
            Serialization]</a>. It means that it is possible to
            create <a title="final result tree" href=
            "index.html#dt-final-result-tree">final result trees</a> that
            cannot be faithfully serialized as XML 1.0 documents.
            When such a result tree is serialized as XML 1.0,
            namespace declarations written for the parent element
            will be inherited by its child elements as if the
            corresponding namespace nodes were present on the child
            element<span>, except in the case of the default
            namespace, which can be undeclared using the construct
            <code>xmlns=""</code></span>. When the same result tree
            is serialized as XML 1.1, however, it is possible to
            undeclare any namespace on the child element <span>(for
            example, <code>xmlms:foo=""</code>)</span> to prevent
            this inheritance taking place.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="uri-references" id="uri-references"></a>5.8
        URI References</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-uri-reference" id="dt-uri-reference" title=
        "URI Reference"></a>Within this specification, the term
        <b>URI Reference</b>, unless otherwise stated, refers to a
        string in the lexical space of the <code>xs:anyURI</code>
        data type as defined in <a href="index.html#xmlschema-2">[XML Schema
        Part 2]</a>.<span class="definition">]</span> Note that
        this is a wider definition than that in <a href=
        "index.html#RFC3986">[RFC3986]</a>: <span>in particular, it is
        designed to accommodate Internationalized Resource
        Identifiers (IRIs) as described in <a href=
        "index.html#RFC3987">[RFC3987]</a>, and thus allows the use of
        non-ASCII characters without escaping.</span></p>

        <p>URI References are used in XSLT with three main
        roles:</p>

        <blockquote>
          <p>As namespace URIs<br />
          As collation URIs<br />
          As identifiers for resources such as stylesheet modules;
          these resources are typically accessible using a protocol
          such as HTTP. Examples of such identifiers are the URIs
          used in the <code>href</code> attributes of <a href=
          "index.html#element-import"><code>xsl:import</code></a>, <a href=
          "index.html#element-include"><code>xsl:include</code></a>, and
          <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>.</p>
        </blockquote>

        <p>The rules for namespace URIs are given in <a href=
        "index.html#REC-xml-names">[Namespaces in XML 1.0]</a> and <a href=
        "index.html#xml-names11">[Namespaces in XML 1.1]</a>. Those
        specifications deprecate the use of relative URIs as
        namespace URIs.</p>

        <p>The rules for collation URIs are given in <a href=
        "index.html#xpath-functions">[Functions and Operators]</a>.</p>

        <p>URI references used to identify external resources must
        conform to the same rules as the locator attribute
        (<code>href</code>) defined in section 5.4 of <a href=
        "index.html#xlink">[XLink]</a>. If the URI reference is relative,
        then it is resolved (unless otherwise specified) against
        the base URI of the containing element node, according to
        the rules of <span><a href="index.html#RFC3986">[RFC3986]</a></span>,
        after first escaping all characters that need to be escaped
        to make it a valid RFC3986 URI reference. (But a relative
        URI in the <code>href</code> attribute of <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        is resolved against the <a title="base output URI" href=
        "index.html#dt-base-output-uri">Base Output URI</a>.)</p>

        <p>Other URI references appearing in an XSLT stylesheet
        document, for example the system identifiers of external
        entities or the value of the <code>xml:base</code>
        attribute, must follow the rules in their respective
        specifications.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="rules" id="rules"></a>6 Template Rules</h2>

      <p>Template rules define the processing that can be applied
      to nodes that match a particular <a title="pattern" href=
      "index.html#dt-pattern">pattern</a>.</p>

      <div class="div2">
        <h3><a name="defining-templates" id=
        "defining-templates"></a>6.1 Defining Templates</h3>

        <p class="element-syntax"><a name="element-template" id=
        "element-template"></a><code>&lt;!-- Category: declaration
        --&gt;<br />
        &lt;xsl:template<br />
        &#160;&#160;match? = <var>pattern</var><br />
        &#160;&#160;name? = <var>qname</var><br />
        &#160;&#160;priority? = <var>number</var><br />
        &#160;&#160;mode? = <var>tokens</var><br />
        &#160;&#160;as? = <var>sequence-type</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-param">xsl:param</a>*,
        <var>sequence-constructor</var>) --&gt;<br />
        &lt;/xsl:template&gt;</code></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-template"
        id="dt-template" title="template"></a>An <a href=
        "index.html#element-template"><code>xsl:template</code></a>
        declaration defines a <b>template</b>, which contains a
        <span><a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a></span>
        for creating nodes and/or atomic values. A template can
        serve either as a <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a>, invoked by matching
        nodes against a <a title="pattern" href=
        "index.html#dt-pattern">pattern</a>, or as a <a title=
        "named template" href="index.html#dt-named-template">named
        template</a>, invoked explicitly by name. It is also
        possible for the same template to serve in both
        capacities.<span class="definition">]</span></p>

        <p><a name="err-XTSE0500" id="err-XTSE0500"><span class=
        "error">[ERR XTSE0500]</span></a> An <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        <span class="verb">must</span> have either a
        <code>match</code> attribute or a <code>name</code>
        attribute, or both. An <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        that has no <code>match</code> attribute <span class=
        "verb">must</span> have no <code>mode</code> attribute and
        no <code>priority</code> attribute.</p>

        <p>If an <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        has a <code>match</code> attribute, then it is a <a title=
        "template rule" href="index.html#dt-template-rule">template rule</a>.
        If it has a <code>name</code> attribute, then it is a
        <a title="named template" href="index.html#dt-named-template">named
        template</a>.</p>

        <p>A <a title="template" href="index.html#dt-template">template</a>
        may be invoked in a number of ways, depending on whether it
        is a <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a>, a <a title=
        "named template" href="index.html#dt-named-template">named
        template</a>, or both. The result of invoking the template
        is the result of evaluating the <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>
        contained in the <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        (see <a href="index.html#sequence-constructors"><i>5.7 Sequence
        Constructors</i></a>).</p>

        <p>If an <code>as</code> attribute is present, the
        <code>as</code> attribute defines the required type of the
        result. The result of evaluating the <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> is then
        converted to the required type using the <a title=
        "function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a>. If no <code>as</code> attribute is specified,
        the default value is <code>item()*</code>, which permits
        any value. No conversion then takes place.</p>

        <p><a name="err-XTTE0505" id="err-XTTE0505"><span class=
        "error">[ERR XTTE0505]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        result of evaluating the <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a>
        cannot be converted to the required type.</p>
      </div>

      <div class="div2">
        <h3><a name="defining-template-rules" id=
        "defining-template-rules"></a>6.2 Defining Template
        Rules</h3>

        <p>This section describes <a title="template rule" href=
        "index.html#dt-template-rule">template rules</a>. <a title=
        "named template" href="index.html#dt-named-template">Named
        templates</a> are described in <a href=
        "index.html#named-templates"><i>10.1 Named Templates</i></a>.</p>

        <p>A <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> is specified using
        the <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        <span>with a <code>match</code> attribute</span>. The
        <code>match</code> attribute is a <a href=
        "index.html#NT-Pattern">Pattern</a> that identifies the node or nodes
        to which the rule applies. The result of applying the
        template rule is the result of evaluating the
        <span>sequence</span> constructor contained in the <a href=
        "index.html#element-template"><code>xsl:template</code></a> element,
        with the matching node used as the <a title="context node"
        href="index.html#dt-context-node">context node</a>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10170" id="d5e10170"></a>Example: A simple
            Template Rule
          </div>

          <p>For example, an XML document might contain:</p>

          <div class="exampleInner">
            <pre>
This is an &lt;emph&gt;important&lt;/emph&gt; point.
</pre>
          </div>

          <p>The following <a title="template rule" href=
          "index.html#dt-template-rule">template rule</a> matches
          <code>emph</code> elements and produces a
          <code>fo:wrapper</code> element with a
          <code>font-weight</code> property of
          <code>bold</code>.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="emph"&gt;
  &lt;fo:wrapper font-weight="bold" xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/fo:wrapper&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>A <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> is evaluated when an
        <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction selects a node that matches the pattern
        specified in the <code>match</code> attribute. The <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction is described in the next section. If several
        template rules match a selected node, only one of them is
        evaluated, as described in <a href="index.html#conflict"><i>6.4
        Conflict Resolution for Template Rules</i></a>.</p>
      </div>

      <div class="div2">
        <h3><a name="applying-templates" id=
        "applying-templates"></a>6.3 Applying Template Rules</h3>

        <p class="element-syntax"><a name="element-apply-templates"
        id="element-apply-templates"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:apply-templates<br />
        &#160;&#160;select? = <var>expression</var><br />
        &#160;&#160;mode? = <var>token</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-sort">xsl:sort</a> | <a href=
        "index.html#element-with-param">xsl:with-param</a>)* --&gt;<br />
        &lt;/xsl:apply-templates&gt;</code></p>

        <p>The <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction takes as input a sequence of nodes (typically
        nodes in a <a title="source tree" href=
        "index.html#dt-source-tree">source tree</a>), and produces as output
        a sequence of items; these will often be nodes to be added
        to a <a title="result tree" href="index.html#dt-result-tree">result
        tree</a>.</p>

        <p>If the instruction has one or more <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> children, then
        the input sequence is sorted as described in <a href=
        "index.html#sorting"><i>13 Sorting</i></a>. The result of this sort
        is referred to below as the <b>sorted sequence</b>; if
        there are no <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> elements, then
        the sorted sequence is the same as the input sequence.</p>

        <p>Each node in the input sequence is processed by finding
        a <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> whose <a title=
        "pattern" href="index.html#dt-pattern">pattern</a> matches that node.
        If there is more than one, the best among them is chosen,
        using rules described in <a href="index.html#conflict"><i>6.4
        Conflict Resolution for Template Rules</i></a>. If there is
        no template rule whose pattern matches the node, a built-in
        template rule is used (see <a href="index.html#built-in-rule"><i>6.6
        Built-in Template Rules</i></a>). The chosen template rule
        is evaluated. The rule that matches the <var>N</var>th node
        in the sorted sequence is evaluated with that node as the
        <a title="context item" href="index.html#dt-context-item">context
        item</a>, with <var>N</var> as the <a title=
        "context position" href="index.html#dt-context-position">context
        position</a>, and with the length of the sorted sequence as
        the <a title="context size" href="index.html#dt-context-size">context
        size</a>. Each template rule that is evaluated produces a
        sequence of items as its result. The resulting sequences
        (one for each node in the sorted sequence) are then
        concatenated, to form a single sequence. They are
        concatenated retaining the order of the nodes in the sorted
        sequence. The final concatenated sequence forms the result
        of the <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10281" id="d5e10281"></a>Example: Applying
            Template Rules
          </div>

          <p>Suppose the source document is as follows:</p>

          <div class="exampleInner">
            <pre>
&lt;message&gt;Proceed &lt;emph&gt;at once&lt;/emph&gt; to the exit!&lt;/message&gt;
</pre>
          </div>

          <p>This can be processed using the two template rules
          shown below.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="message"&gt;
  &lt;p&gt;
    &lt;xsl:apply-templates select="child::node()"/&gt;
  &lt;/p&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="emph"&gt;
  &lt;b&gt;
    &lt;xsl:apply-templates select="child::node()"/&gt;
  &lt;/b&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>There is no template rule for the document node; the
          built-in template rule for this node will cause the
          <code>message</code> element to be processed. The
          template rule for the <code>message</code> element causes
          a <code>p</code> element to be written to the <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a>; the
          contents of this <code>p</code> element are constructed
          as the result of the <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction. This instruction selects the three child
          nodes of the <code>message</code> element (a text node
          containing the value "<code>Proceed</code> ", an
          <code>emph</code> element node, and a text node
          containing the value " <code>to the exit!</code>"). The
          two text nodes are processed using the built-in template
          rule for text nodes, which returns a copy of the text
          node. The <code>emph</code> element is processed using
          the explicit template rule that specifies
          <code>match="emph"</code>.</p>

          <p>When the <code>emph</code> element is processed, this
          template rule constructs a <code>b</code> element. The
          contents of the <code>b</code> element are constructed by
          means of another <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction, which in this case selects a single node
          (the text node containing the value "<code>at
          once</code>"). This is again processed using the built-in
          template rule for text nodes, which returns a copy of the
          text node.</p>

          <p>The final result of the <code>match="message"</code>
          template rule thus consists of a <code>p</code> element
          node with three children: a text node containing the
          value "<code>Proceed</code> ", a <code>b</code> element
          that is the parent of a text node containing the value
          "<code>at once</code>", and a text node containing the
          value " <code>to the exit!</code>". This <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a>
          might be serialized as:</p>

          <div class="exampleInner">
            <pre>
&lt;p&gt;Proceed &lt;b&gt;at once&lt;/b&gt; to the exit!&lt;/p&gt;
</pre>
          </div>
        </div>

        <p>The default value of the <code>select</code> attribute
        is <code>child::node()</code>, which causes all the
        children of context node to be processed.</p>

        <p><a name="err-XTTE0510" id="err-XTTE0510"><span class=
        "error">[ERR XTTE0510]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if an
        <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction with no <code>select</code> attribute is
        evaluated when the <a title="context item" href=
        "index.html#dt-context-item">context item</a> is not a node.</p>

        <p>A <code>select</code> attribute can be used to process
        nodes selected by an expression instead of processing all
        children. The value of the <code>select</code> attribute is
        an <a title="expression" href=
        "index.html#dt-expression">expression</a>. The expression
        <span class="verb">must</span> evaluate to a sequence of
        nodes (it can contain zero, one, or more nodes).</p>

        <p><a name="err-XTTE0520" id="err-XTTE0520"><span class=
        "error">[ERR XTTE0520]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        sequence returned by the <code>select</code> expression
        contains an item that is not a node.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>In XSLT 1.0, the <code>select</code> attribute
          selected a set of nodes, which by default were processed
          in document order. In XSLT 2.0, it selects a sequence of
          nodes. In cases that would have been valid in XSLT 1.0,
          the expression will return a sequence of nodes in
          document order, so the effect is the same.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10435" id="d5e10435"></a>Example: Applying
            Templates to Selected Nodes
          </div>

          <p>The following example processes all of the
          <code>given-name</code> children of the
          <code>author</code> elements that are children of
          <code>author-group</code>:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="author-group"&gt;
  &lt;fo:wrapper&gt;
    &lt;xsl:apply-templates select="author/given-name"/&gt;
  &lt;/fo:wrapper&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10451" id="d5e10451"></a>Example: Applying
            Templates to Nodes that are not Descendants
          </div>

          <p>It is also possible to process elements that are not
          descendants of the context node. This example assumes
          that a <code>department</code> element has
          <code>group</code> children and <code>employee</code>
          descendants. It finds an employee's department and then
          processes the <code>group</code> children of the
          <code>department</code>.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="employee"&gt;
  &lt;fo:block&gt;
    Employee &lt;xsl:apply-templates select="name"/&gt; belongs to group
    &lt;xsl:apply-templates select="ancestor::department/group"/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10473" id="d5e10473"></a>Example: Matching
            by Schema-Defined Types
          </div>

          <p>It is possible to write template rules that are
          matched according to the schema-defined type of an
          element or attribute. The following example applies
          different formatting to the children of an element
          depending on their type:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="product"&gt;
  &lt;table&gt;
    &lt;xsl:apply-templates select="*"/&gt;
  &lt;/table&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="product/*" priority="3"&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;xsl:value-of select="name()"/&gt;&lt;/td&gt;
    &lt;td&gt;&lt;xsl:next-match/&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="product/element(*, xs:decimal) | 
                     product/element(*, xs:double)" priority="2"&gt;  
  &lt;xsl:value-of select="format-number(xs:double(.), '#,###0.00')"/&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="product/element(*, xs:date)" priority="2"&gt;
  &lt;xsl:value-of select="format-date(., '[Mn] [D], [Y]')"/&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="product/*" priority="1.5"&gt;
  &lt;xsl:value-of select="."/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>The <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a>
          instruction is described in <a href=
          "index.html#apply-imports"><i>6.7 Overriding Template
          Rules</i></a>.</p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10487" id="d5e10487"></a>Example:
            Re-ordering Elements in the Result Tree
          </div>

          <p>Multiple <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          elements can be used within a single template to do
          simple reordering. The following example creates two HTML
          tables. The first table is filled with domestic sales
          while the second table is filled with foreign sales.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="product"&gt;
  &lt;table&gt;
    &lt;xsl:apply-templates select="sales/domestic"/&gt;
  &lt;/table&gt;
  &lt;table&gt;
    &lt;xsl:apply-templates select="sales/foreign"/&gt;
  &lt;/table&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e10497" id="d5e10497"></a>Example:
            Processing Recursive Structures
          </div>

          <p>It is possible for there to be two matching
          descendants where one is a descendant of the other. This
          case is not treated specially: both descendants will be
          processed as usual.</p>

          <p>For example, given a source document</p>

          <div class="exampleInner">
            <pre>
&lt;doc&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/doc&gt;
</pre>
          </div>

          <p>the rule</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="doc"&gt;
  &lt;xsl:apply-templates select=".//div"/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>will process both the outer <code>div</code> and inner
          <code>div</code> elements.</p>

          <p>This means that if the template rule for the
          <code>div</code> element processes its own children, then
          these grandchildren will be processed more than once,
          which is probably not what is required. The solution is
          to process one level at a time in a recursive descent, by
          using <code>select="div"</code> in place of
          <code>select=".//div"</code></p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p><span>The <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction is most commonly used</span> to process nodes
          that are descendants of the context node. Such use of
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          cannot result in non-terminating processing loops.
          However, when <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          is used to process elements that are not descendants of
          the context node, the possibility arises of
          non-terminating loops. For example,</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="foo"&gt;
  &lt;xsl:apply-templates select="."/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>Implementations may be able to detect such loops in
          some cases, but the possibility exists that a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> may
          enter a non-terminating loop that an implementation is
          unable to detect. This may present a denial of service
          security risk.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="conflict" id="conflict"></a>6.4 Conflict
        Resolution for Template Rules</h3>

        <p>It is possible for a node in a source document to match
        more than one <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a>. <span>When this
        happens, only one template rule is evaluated for the
        node.</span> The template rule to be used is determined as
        follows:</p>

        <ol class="enumar">
          <li>
            <p>First, only the matching template rule or rules with
            the highest <a title="import precedence" href=
            "index.html#dt-import-precedence">import precedence</a> are
            considered. Other matching template rules with lower
            precedence are eliminated from consideration.</p>
          </li>

          <li>
            <p>Next, of the remaining matching rules, only those
            with the highest priority are considered. Other
            matching template rules with lower priority are
            eliminated from consideration. The priority of a
            template rule is specified by the <code>priority</code>
            attribute on the <a href=
            "index.html#element-template"><code>xsl:template</code></a>
            declaration.</p>

            <p><a name="err-XTSE0530" id=
            "err-XTSE0530"><span class="error">[ERR
            XTSE0530]</span></a> The value of this attribute
            <span class="verb">must</span> <span>conform to the
            rules for the <code>xs:decimal</code> type defined in
            <a href="index.html#xmlschema-2">[XML Schema Part 2]</a>.
            Negative values are permitted.</span>.</p>

            <p><span class=
            "definition">[Definition:&#160;</span><a name=
            "dt-default-priority" id="dt-default-priority" title=
            "default priority"></a>If no <code>priority</code>
            attribute is specified on the <a href=
            "index.html#element-template"><code>xsl:template</code></a>
            element, a <b>default priority</b> is computed, based
            on the syntax of the pattern supplied in the
            <code>match</code> attribute.<span class=
            "definition">]</span> The rules are as follows:</p>

            <ul>
              <li>
                <p>If the pattern contains multiple alternatives
                separated by <code>|</code> , then the template
                rule is treated equivalently to a set of template
                rules, one for each alternative. However, it is not
                an error if a node matches more than one of the
                alternatives.</p>
              </li>

              <li>
                <p>If the pattern has the form <code>/</code>, then
                the priority is −0.5.</p>
              </li>

              <li>
                <p>If the pattern has the form of a <a title=
                "QName" href="index.html#dt-qname">QName</a> optionally
                preceded by a <a href=
                "index.html#NT-PatternAxis">PatternAxis</a> or has the form
                <code>processing-instruction(</code><a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-StringLiteral">
                StringLiteral</a><sup><small>XP</small></sup><code>)</code>
                or <code>processing-instruction(</code><a href=
                "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
                <small>Names</small></sup><code>)</code> optionally
                preceded by a <a href=
                "index.html#NT-PatternAxis">PatternAxis</a>, then the
                priority is 0.</p>
              </li>

              <li>
                <p>If the pattern has the form of an <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-ElementTest">
                ElementTest</a><sup><small>XP</small></sup> or
                <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-AttributeTest">
                AttributeTest</a><sup><small>XP</small></sup>,
                optionally preceded by a <a href=
                "index.html#NT-PatternAxis">PatternAxis</a>, then the
                priority is as shown in the table below. In this
                table, the symbols <var>E</var>, <var>A</var>, and
                <var>T</var> represent an arbitrary element name,
                attribute name, and type name respectively, while
                the symbol <code>*</code> represents itself. The
                presence or absence of the <span>symbol
                <code>?</code> following a type name</span> does
                not affect the priority.</p>

                <table border="1" cellpadding="5">
                  <thead>
                    <tr>
                      <th align="left">Format</th>

                      <th align="left">Priority</th>

                      <th align="left">Notes</th>
                    </tr>
                  </thead>

                  <tbody>
                    <tr>
                      <td><code>element()</code></td>

                      <td>−0.5</td>

                      <td>(equivalent to <code>*</code>)</td>
                    </tr>

                    <tr>
                      <td><code>element(*)</code></td>

                      <td>−0.5</td>

                      <td>(equivalent to <code>*</code>)</td>
                    </tr>

                    <tr>
                      <td><code>attribute()</code></td>

                      <td>−0.5</td>

                      <td>(equivalent to <code>@*</code>)</td>
                    </tr>

                    <tr>
                      <td><code>attribute(*)</code></td>

                      <td>−0.5</td>

                      <td>(equivalent to <code>@*</code>)</td>
                    </tr>

                    <tr>
                      <td><code>element(<var>E</var>)</code></td>

                      <td>0</td>

                      <td>(equivalent to E)</td>
                    </tr>

                    <tr>
                      <td><code>element(*,<var>T</var>)</code></td>

                      <td>0</td>

                      <td>(matches by type only)</td>
                    </tr>

                    <tr>
                      <td><code>attribute(<var>A</var>)</code></td>

                      <td>0</td>

                      <td>(equivalent to <code>@A</code>)</td>
                    </tr>

                    <tr>
                      <td>
                      <code>attribute(*,<var>T</var>)</code></td>

                      <td>0</td>

                      <td>(matches by type only)</td>
                    </tr>

                    <tr>
                      <td>
                      <code>element(<var>E</var>,<var>T</var>)</code></td>

                      <td>0.25</td>

                      <td>(matches by name and type)</td>
                    </tr>

                    <tr>
                      <td>
                      <code>schema-element(<var>E</var>)</code></td>

                      <td>0.25</td>

                      <td>(matches by substitution group and
                      type)</td>
                    </tr>

                    <tr>
                      <td>
                      <code>attribute(<var>A</var>,<var>T</var>)</code></td>

                      <td>0.25</td>

                      <td>(matches by name and type)</td>
                    </tr>

                    <tr>
                      <td>
                      <code>schema-attribute(<var>A</var>)</code></td>

                      <td>0.25</td>

                      <td>(matches by name and type)</td>
                    </tr>
                  </tbody>
                </table>
              </li>

              <li>
                <p>If the pattern has the form of a <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-DocumentTest">
                DocumentTest</a><sup><small>XP</small></sup>, then
                if it includes no <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-ElementTest">
                ElementTest</a><sup><small>XP</small></sup>
                <span>or <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-SchemaElementTest">
                SchemaElementTest</a><sup><small>XP</small></sup></span>
                the priority is −0.5. If it does include an
                <a href="http://www.w3.org/TR/xpath20/#doc-xpath-ElementTest">
                ElementTest</a><sup><small>XP</small></sup>
                <span>or <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-SchemaElementTest">
                SchemaElementTest</a><sup><small>XP</small></sup></span>,
                then the priority is the same as the priority of
                that <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-ElementTest">
                ElementTest</a><sup><small>XP</small></sup>
                <span>or <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-SchemaElementTest">
                SchemaElementTest</a><sup><small>XP</small></sup></span>,
                computed according to the table above.</p>
              </li>

              <li>
                <p>If the pattern has the form <a href=
                "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
                <small>Names</small></sup><code>:*</code> or
                <code>*:</code><a href=
                "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
                <small>Names</small></sup>, optionally preceded by
                a <a href="index.html#NT-PatternAxis">PatternAxis</a>, then
                the priority is −0.25.</p>
              </li>

              <li>
                <p>If the pattern is any other <a href=
                "http://www.w3.org/TR/xpath20/#doc-xpath-NodeTest">NodeTest</a><sup>
                <small>XP</small></sup>, optionally preceded by a
                <a href="index.html#NT-PatternAxis">PatternAxis</a>, then the
                priority is −0.5.</p>
              </li>

              <li>
                <p>Otherwise, the priority is 0.5.</p>
              </li>
            </ul>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>In many cases this means that highly selective
              patterns have higher priority than less selective
              patterns. The most common kind of pattern (a pattern
              that tests for a node of a <span>particular kind,
              with a particular <a title="expanded-QName" href=
              "index.html#dt-expanded-qname">expanded-QName</a> or a
              particular type)</span> has priority 0. The next less
              specific kind of pattern (a pattern that tests for a
              node of a particular kind and an <a title=
              "expanded-QName" href=
              "index.html#dt-expanded-qname">expanded-QName</a> with a
              particular namespace URI) has priority −0.25.
              Patterns less specific than this (patterns that just
              test for nodes <span>of a given kind</span>) have
              priority −0.5. <span>Patterns that specify both the
              name and the required type have a priority of +0.25,
              putting them above patterns that only specify the
              name <em>or</em> the type.</span> Patterns more
              specific than <span>this, for example patterns that
              include predicates or that specify the ancestry of
              the required node,</span> have priority 0.5.</p>

              <p>However, it is not invariably true that a more
              selective pattern has higher priority than a less
              selective pattern. For example, the priority of the
              pattern <code>node()[self::*]</code> is higher than
              that of the pattern <code>salary</code>.
              <span>Similarly, the patterns <code>attribute(*,
              xs:decimal)</code> and <code>attribute(*,
              xs:short)</code> have the same priority, despite the
              fact that the latter pattern matches a subset of the
              nodes matched by the former.</span> Therefore, to
              achieve clarity in a <a title="stylesheet" href=
              "index.html#dt-stylesheet">stylesheet</a> it is good practice
              to allocate explicit priorities.</p>
            </div>
          </li>
        </ol>

        <p><a name="err-XTRE0540" id="err-XTRE0540"><span class=
        "error">[ERR XTRE0540]</span></a> It is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> if
        the conflict resolution algorithm for template rules leaves
        more than one matching template rule. The <a title=
        "optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is to select, from the matching template rules that are
        left, the one that occurs last in <a title=
        "declaration order" href=
        "index.html#dt-declaration-order">declaration order</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="modes" id="modes"></a>6.5 Modes</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-mode" id=
        "dt-mode" title="mode"></a><b>Modes</b> allow a node in a
        <a title="source tree" href="index.html#dt-source-tree">source
        tree</a> to be processed multiple times, each time
        producing a different result. They also allow different
        sets of <a title="template rule" href=
        "index.html#dt-template-rule">template rules</a> to be active when
        processing different trees, for example when processing
        documents loaded using the <a href=
        "index.html#function-document"><code>document</code></a> function
        (see <a href="index.html#document"><i>16.1 Multiple Source
        Documents</i></a>) or when processing <a title=
        "temporary tree" href="index.html#dt-temporary-tree">temporary
        trees</a>.<span class="definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-default-mode" id="dt-default-mode" title=
        "default mode"></a>There is always a <b>default mode</b>
        available. The default mode is an unnamed <a title="mode"
        href="index.html#dt-mode">mode</a>, and it is used when no
        <code>mode</code> attribute is specified on an <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction.<span class="definition">]</span></p>

        <p>Every <a title="mode" href="index.html#dt-mode">mode</a> other
        than the <a title="default mode" href=
        "index.html#dt-default-mode">default mode</a> is identified by a
        <a title="QName" href="index.html#dt-qname">QName</a>.</p>

        <p>A <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> is applicable to one
        or more modes. The modes to which it is applicable are
        defined by the <code>mode</code> attribute of the <a href=
        "index.html#element-template"><code>xsl:template</code></a> element.
        If the attribute is omitted, then the template rule is
        applicable to the <a title="default mode" href=
        "index.html#dt-default-mode">default mode</a>. If the attribute is
        present, then its value <span class="verb">must</span> be a
        non-empty whitespace-separated list of tokens, each of
        which defines a mode to which the template rule is
        applicable. Each token <span class="verb">must</span> be
        one of the following:</p>

        <ul>
          <li>
            <p>a <a title="QName" href="index.html#dt-qname">QName</a>, which
            is expanded as described in <a href="index.html#qname"><i>5.1
            Qualified Names</i></a> to define the name of the
            mode</p>
          </li>

          <li>
            <p>the token <code>#default</code>, to indicate that
            the template rule is applicable to the <a title=
            "default mode" href="index.html#dt-default-mode">default
            mode</a></p>
          </li>

          <li>
            <p>the token <code>#all</code>, to indicate that the
            template rule is applicable to all modes <span>(that
            is, to the default mode and to every mode that is named
            in an <a href=
            "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
            instruction or <a href=
            "index.html#element-template"><code>xsl:template</code></a>
            declaration anywhere in the stylesheet)</span>.</p>
          </li>
        </ul>

        <p><a name="err-XTSE0550" id="err-XTSE0550"><span class=
        "error">[ERR XTSE0550]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the list is empty, if the same token is included more than
        once in the list, if the list contains an invalid token, or
        if the token <code>#all</code> appears together with any
        other value.</p>

        <p>The <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        element also has an optional <code>mode</code> attribute.
        The value of this attribute <span class="verb">must</span>
        either be a <a title="QName" href="index.html#dt-qname">QName</a>,
        which is expanded as described in <a href="index.html#qname"><i>5.1
        Qualified Names</i></a> to define the name of a mode, or
        the token <code>#default</code>, to indicate that the
        <a title="default mode" href="index.html#dt-default-mode">default
        mode</a> is to be used, or the token <code>#current</code>,
        to indicate that the <a title="current mode" href=
        "index.html#dt-current-mode">current mode</a> is to be used. If the
        attribute is omitted, the <a title="default mode" href=
        "index.html#dt-default-mode">default mode</a> is used.</p>

        <p>When searching for a template rule to process each node
        selected by the <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction, only those template rules that are applicable
        to the selected mode are considered.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-current-mode" id="dt-current-mode" title=
        "current mode"></a>At any point in the processing of a
        stylesheet, there is a <b>current mode</b>. When the
        transformation is initiated, the current mode is the
        <a title="default mode" href="index.html#dt-default-mode">default
        mode</a>, <span>unless a different initial mode has been
        supplied, as described in <a href="index.html#initiating"><i>2.3
        Initiating a Transformation</i></a>.</span> Whenever an
        <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction is evaluated, the current mode becomes the mode
        selected by this instruction.<span class=
        "definition">]</span> When a stylesheet function is called,
        the current mode becomes the <a title="default mode" href=
        "index.html#dt-default-mode">default mode</a>. No other instruction
        changes the current mode. On completion of the <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction, <span>or on return from a stylesheet function
        call,</span> the current mode reverts to its previous
        value. The current mode is used when an <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction uses the syntax <code>mode="#current"</code>;
        it is also used by the <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        <span>and <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a></span>
        instructions (see <a href="index.html#apply-imports"><i>6.7
        Overriding Template Rules</i></a>).</p>
      </div>

      <div class="div2">
        <h3><a name="built-in-rule" id="built-in-rule"></a>6.6
        Built-in Template Rules</h3>

        <p>When a node is selected by <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        and there is no template rule in the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> that can be used to
        process that node, a built-in template rule is evaluated
        instead.</p>

        <p>The built-in template rules apply to all modes.</p>

        <p>The built-in rule for document nodes and element nodes
        is equivalent to calling <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        with no <code>select</code> attribute, and with the
        <code>mode</code> attribute set to <code>#current</code>.
        If the built-in rule was invoked with parameters, those
        parameters are passed on in the implicit <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e11192" id="d5e11192"></a>Example: Using a
            Built-In Template Rule
          </div>

          <p>For example, suppose the stylesheet contains the
          following instruction:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:apply-templates select="title" mode="mm"&gt;
  &lt;xsl:with-param name="init" select="10"/&gt;
&lt;/xsl:apply-templates&gt;
</pre>
          </div>

          <p>If there is no explicit template rule that matches the
          <code>title</code> element, then the following implicit
          rule is used:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="title" mode="#all"&gt;
  &lt;xsl:param name="init"/&gt;
  &lt;xsl:apply-templates mode="#current"&gt;
    &lt;xsl:with-param name="init" select="$init"/&gt;
  &lt;/xsl:apply-templates&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>The built-in <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> for text and
        attribute nodes returns a text node containing the
        <a title="string value" href="index.html#dt-string-value">string
        value</a> of the context node. It is effectively:</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:template match="text()|@*" mode="#all"&gt;
  &lt;xsl:value-of select="string(.)"/&gt;
&lt;/xsl:template&gt;
</pre>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This text node may have a string value that is
          zero-length.</p>
        </div>

        <p>The built-in <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> for processing
        instructions and comments does nothing (it returns the
        empty sequence).</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:template match="processing-instruction()|comment()" mode="#all"/&gt;
</pre>
        </div>

        <p>The built-in <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> for namespace nodes
        is also to do nothing. There is no pattern that can match a
        namespace node, <span>so the built-in template rule is
        always used when <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        selects a namespace node.</span></p>

        <p>The built-in <a title="template rule" href=
        "index.html#dt-template-rule">template rules</a> have lower <a title=
        "import precedence" href="index.html#dt-import-precedence">import
        precedence</a> than all other template rules. Thus, the
        stylesheet author can override a built-in template rule by
        including an explicit template rule.</p>
      </div>

      <div class="div2">
        <h3><a name="apply-imports" id="apply-imports"></a>6.7
        Overriding Template Rules</h3>

        <p class="element-syntax"><a name="element-apply-imports"
        id="element-apply-imports"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:apply-imports&gt;<br />
        &#160;&#160;&lt;!-- Content: <a href=
        "index.html#element-with-param">xsl:with-param</a>* --&gt;<br />
        &lt;/xsl:apply-imports&gt;</code></p>

        <p class="element-syntax"><a name="element-next-match" id=
        "element-next-match"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:next-match&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-with-param">xsl:with-param</a> | <a href=
        "index.html#element-fallback">xsl:fallback</a>)* --&gt;<br />
        &lt;/xsl:next-match&gt;</code></p>

        <p>A <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> that is being used to
        override another template rule (see <a href=
        "index.html#conflict"><i>6.4 Conflict Resolution for Template
        Rules</i></a>) can use the <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a>
        instruction to invoke the overridden template rule. The
        <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        instruction only considers template rules in imported
        stylesheet modules; the <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a>
        instruction considers all other template rules of lower
        <a title="import precedence" href=
        "index.html#dt-import-precedence">import precedence</a> and/or
        priority. <span>Both instructions will invoke the built-in
        template rule for the node (see <a href=
        "index.html#built-in-rule"><i>6.6 Built-in Template Rules</i></a>) if
        no other template rule is found.</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-current-template-rule" id="dt-current-template-rule"
        title="current template rule"></a>At any point in the
        processing of a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>, there may be a <b>current
        template rule</b>. Whenever a <a title="template rule"
        href="index.html#dt-template-rule">template rule</a> is chosen
        <span>as a result of evaluating <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
        or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a></span>,
        the template rule becomes the current template rule for the
        evaluation of the rule's sequence constructor. When an
        <a href="index.html#element-for-each"><code>xsl:for-each</code></a>,
        <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
        <span>or <a href=
        "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
        instruction is evaluated, or when evaluating a sequence
        constructor contained in an <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> or <a href=
        "index.html#element-key"><code>xsl:key</code></a> element, or
        when</span> a <a title="stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> is called
        (see <a href="index.html#stylesheet-functions"><i>10.3 Stylesheet
        Functions</i></a>), the current template rule becomes null
        for the evaluation of that instruction or
        function.<span class="definition">]</span></p>

        <p>The current template rule is not affected by invoking
        named templates (see <a href="index.html#named-templates"><i>10.1
        Named Templates</i></a>) or named attribute sets (see
        <a href="index.html#attribute-sets"><i>10.2 Named Attribute
        Sets</i></a>). While evaluating a <a title=
        "global variable" href="index.html#dt-global-variable">global
        variable</a> <span>or the default value of a <a title=
        "stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameter</a></span>
        (see <a href="index.html#global-variables"><i>9.5 Global Variables
        and Parameters</i></a>) the current template rule is
        null.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>These rules ensure that when <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
          or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a> is
          called, the <a title="context item" href=
          "index.html#dt-context-item">context item</a> is the same as when
          the current template rule was invoked, and is always a
          node.</p>
        </div>

        <p><span>Both <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        and <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a>
        search</span> for a <a title="template rule" href=
        "index.html#dt-template-rule">template rule</a> that matches the
        <a title="context node" href="index.html#dt-context-node">context
        node</a>, and that is applicable to the <a title=
        "current mode" href="index.html#dt-current-mode">current mode</a>
        (see <a href="index.html#modes"><i>6.5 Modes</i></a>). In choosing a
        template rule, <span>they use</span> the usual criteria
        such as the priority and <a title="import precedence" href=
        "index.html#dt-import-precedence">import precedence</a> of the
        template rules, but <span>they consider as candidates only
        a subset of the template rules in the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a>. This subset differs
        between the two instructions:</span></p>

        <ul>
          <li>
            <p>The <a href=
            "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
            instruction considers as candidates only those template
            rules contained in <a title="stylesheet level" href=
            "index.html#dt-stylesheet-level">stylesheet levels</a> that are
            descendants in the <a title="import tree" href=
            "index.html#dt-import-tree">import tree</a> of the <a title=
            "stylesheet level" href=
            "index.html#dt-stylesheet-level">stylesheet level</a> that
            contains the <a title="current template rule" href=
            "index.html#dt-current-template-rule">current template
            rule</a>.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>This is <em>not</em> the same as saying that the
              search considers all template rules whose import
              precedence is lower than that of the current template
              rule.</p>
            </div>
          </li>

          <li>
            <p>The <a href=
            "index.html#element-next-match"><code>xsl:next-match</code></a>
            instruction considers as candidates all those template
            rules that come after the <a title=
            "current template rule" href=
            "index.html#dt-current-template-rule">current template rule</a>
            in the ordering of template rules implied by the
            conflict resolution rules given in <a href=
            "index.html#conflict"><i>6.4 Conflict Resolution for Template
            Rules</i></a>. That is, it considers all template rules
            with lower <a title="import precedence" href=
            "index.html#dt-import-precedence">import precedence</a> than the
            <a title="current template rule" href=
            "index.html#dt-current-template-rule">current template rule</a>,
            plus the template rules that are at the same import
            precedence that have lower priority than the current
            template rule. If the processor has recovered from the
            error that occurs when two matching template rules have
            the same import precedence and priority, then it also
            considers all matching template rules with the same
            import precedence and priority that occur before the
            current template rule in <a title="declaration order"
            href="index.html#dt-declaration-order">declaration order</a>.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>As explained in <a href="index.html#conflict"><i>6.4
              Conflict Resolution for Template Rules</i></a>, a
              template rule whose match pattern contains multiple
              alternatives separated by <code>|</code> is treated
              equivalently to a set of template rules, one for each
              alternative. This means that where the same node
              matches more than one alternative, and the
              alternatives have different priority, it is possible
              for an <a href=
              "index.html#element-next-match"><code>xsl:next-match</code></a>
              instruction to cause the current template rule to be
              invoked recursively. This situation does not occur
              when the alternatives have the same priority.</p>
            </div>
          </li>
        </ul>

        <p>If no matching template rule is found that satisfies
        these criteria, the built-in template rule for the node
        <span>kind</span> is used (see <a href=
        "index.html#built-in-rule"><i>6.6 Built-in Template
        Rules</i></a>).</p>

        <p>An <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        <span>or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a></span>
        instruction may use <a href=
        "index.html#element-with-param"><code>xsl:with-param</code></a> child
        elements to pass parameters to the chosen <a title=
        "template rule" href="index.html#dt-template-rule">template rule</a>
        (see <a href="index.html#with-param"><i>10.1.1 Passing Parameters to
        Templates</i></a>). It also passes on any <a title=
        "tunnel parameter" href="index.html#dt-tunnel-parameter">tunnel
        parameters</a> as described in <a href=
        "index.html#tunnel-params"><i>10.1.2 Tunnel Parameters</i></a>.</p>

        <p><a name="err-XTDE0560" id="err-XTDE0560"><span class=
        "error">[ERR XTDE0560]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        <span>or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a></span>
        is evaluated when the <a title="current template rule"
        href="index.html#dt-current-template-rule">current template rule</a>
        is null.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e11507" id="d5e11507"></a>Example: Using
            <code>xsl:apply-imports</code>
          </div>

          <p>For example, suppose the stylesheet
          <code>doc.xsl</code> contains a <a title="template rule"
          href="index.html#dt-template-rule">template rule</a> for
          <code>example</code> elements:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="example"&gt;
  &lt;pre&gt;&lt;xsl:apply-templates/&gt;&lt;/pre&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>Another stylesheet could import <code>doc.xsl</code>
          and modify the treatment of <code>example</code> elements
          as follows:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:import href="doc.xsl"/&gt;

&lt;xsl:template match="example"&gt;
  &lt;div style="border: solid red"&gt;
     &lt;xsl:apply-imports/&gt;
  &lt;/div&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>The combined effect would be to transform an
          <code>example</code> into an element of the form:</p>

          <div class="exampleInner">
            <pre>
&lt;div style="border: solid red"&gt;&lt;pre&gt;...&lt;/pre&gt;&lt;/div&gt;
</pre>
          </div>
        </div>

        <p>An <a href=
        "index.html#element-fallback"><code>xsl:fallback</code></a>
        instruction appearing as a child of an <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a>
        instruction is ignored by an XSLT 2.0 processor, but can be
        used to define fallback behavior when the stylesheet is
        processed by an XSLT 1.0 processor in forwards-compatible
        mode.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="for-each" id="for-each"></a>7 Repetition</h2>

      <p class="element-syntax"><a name="element-for-each" id=
      "element-for-each"></a><code>&lt;!-- Category: instruction
      --&gt;<br />
      &lt;xsl:for-each<br />
      &#160;&#160;<b>select</b> = <var>expression</var>&gt;<br />
      &#160;&#160;&lt;!-- Content: (<a href=
      "index.html#element-sort">xsl:sort</a>*,
      <var>sequence-constructor</var>) --&gt;<br />
      &lt;/xsl:for-each&gt;</code></p>

      <p>The <a href=
      "index.html#element-for-each"><code>xsl:for-each</code></a> instruction
      processes each item in a sequence of items, evaluating the
      <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a> within
      the <a href="index.html#element-for-each"><code>xsl:for-each</code></a>
      instruction once for each item in that sequence.</p>

      <p>The <code>select</code> attribute is <span class=
      "verb">required</span>, and the <a title="expression" href=
      "index.html#dt-expression">expression</a> <span class=
      "verb">must</span> evaluate to a sequence, called the input
      sequence. If there is an <a href=
      "index.html#element-sort"><code>xsl:sort</code></a> element present
      (see <a href="index.html#sorting"><i>13 Sorting</i></a>) the input
      sequence is sorted to produce a sorted sequence. Otherwise,
      the sorted sequence is the same as the input sequence.</p>

      <p>The <a href=
      "index.html#element-for-each"><code>xsl:for-each</code></a> instruction
      contains a <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a>. The
      <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a> is
      evaluated once for each item in the sorted sequence, with the
      <a title="focus" href="index.html#dt-focus">focus</a> set as
      follows:</p>

      <ul>
        <li>
          <p>The <a title="context item" href=
          "index.html#dt-context-item">context item</a> is the item being
          processed. If this is a node, it will also be the
          <a title="context node" href="index.html#dt-context-node">context
          node</a>. If it is not a node, there will be no context
          node: that is, <span>any attempt to reference the context
          node will result in a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a>.</span></p>
        </li>

        <li>
          <p>The <a title="context position" href=
          "index.html#dt-context-position">context position</a> is the
          position of this item in the sorted sequence.</p>
        </li>

        <li>
          <p>The <a title="context size" href=
          "index.html#dt-context-size">context size</a> is the size of the
          sorted sequence (which is the same as the size of the
          input sequence).</p>
        </li>
      </ul>

      <p>For each item in the input sequence, evaluating the
      <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a> produces
      a sequence of items (see <a href=
      "index.html#sequence-constructors"><i>5.7 Sequence
      Constructors</i></a>). These output sequences are
      concatenated; <span>if item <var>Q</var> follows item
      <var>P</var> in the sorted sequence, then the result of
      evaluating the sequence constructor with <var>Q</var> as the
      context item is concatenated after the result of evaluating
      the sequence constructor with <var>P</var> as the context
      item.</span> The result of the <a href=
      "index.html#element-for-each"><code>xsl:for-each</code></a> instruction
      is the concatenated sequence of items.</p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>With XSLT 1.0, the selected nodes were processed in
        document order. With XSLT 2.0, XPath expressions that would
        have been valid under XPath 1.0 (such as path expressions
        and union expressions) will return a sequence of nodes that
        is already in document order, so backwards compatibility is
        maintained.</p>
      </div>

      <div class="example">
        <div class="exampleHeader">
          <a name="d5e11663" id="d5e11663"></a>Example: Using
          <code>xsl:for-each</code>
        </div>

        <p>For example, given an XML document with this
        structure</p>

        <div class="exampleInner">
          <pre>
&lt;customers&gt;
  &lt;customer&gt;
    &lt;name&gt;...&lt;/name&gt;
    &lt;order&gt;...&lt;/order&gt;
    &lt;order&gt;...&lt;/order&gt;
  &lt;/customer&gt;
  &lt;customer&gt;
    &lt;name&gt;...&lt;/name&gt;
    &lt;order&gt;...&lt;/order&gt;
    &lt;order&gt;...&lt;/order&gt;
  &lt;/customer&gt;
&lt;/customers&gt;
</pre>
        </div>

        <p>the following would create an HTML document containing a
        table with a row for each <code>customer</code> element</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:template match="/"&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Customers&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;table&gt;
        &lt;tbody&gt;
          &lt;xsl:for-each select="customers/customer"&gt;
            &lt;tr&gt;
              &lt;th&gt;
                &lt;xsl:apply-templates select="name"/&gt;
              &lt;/th&gt;
              &lt;xsl:for-each select="order"&gt;
                &lt;td&gt;
                  &lt;xsl:apply-templates/&gt;
                &lt;/td&gt;
              &lt;/xsl:for-each&gt;
            &lt;/tr&gt;
          &lt;/xsl:for-each&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/body&gt;
  &lt;/html&gt;
&lt;/xsl:template&gt;
</pre>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="conditionals" id="conditionals"></a>8
      Conditional Processing</h2>

      <p>There are two instructions in XSLT that support
      conditional processing: <a href=
      "index.html#element-if"><code>xsl:if</code></a> and <a href=
      "index.html#element-choose"><code>xsl:choose</code></a>. The <a href=
      "index.html#element-if"><code>xsl:if</code></a> instruction provides
      simple if-then conditionality; the <a href=
      "index.html#element-choose"><code>xsl:choose</code></a> instruction
      supports selection of one choice when there are several
      possibilities.</p>

      <div class="div2">
        <h3><a name="xsl-if" id="xsl-if"></a>8.1 Conditional
        Processing with <a href=
        "index.html#element-if"><code>xsl:if</code></a></h3>

        <p class="element-syntax"><a name="element-if" id=
        "element-if"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:if<br />
        &#160;&#160;<b>test</b> = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:if&gt;</code></p>

        <p>The <a href="index.html#element-if"><code>xsl:if</code></a>
        element has a mandatory <code>test</code> attribute, which
        specifies an <a title="expression" href=
        "index.html#dt-expression">expression</a>. The content is a <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

        <p>The result of the <a href=
        "index.html#element-if"><code>xsl:if</code></a> instruction depends
        on the <a href=
        "http://www.w3.org/TR/xpath20/#dt-ebv">effective boolean
        value</a><sup><small>XP</small></sup> of the expression in
        the <code>test</code> attribute. The rules for determining
        the effective boolean value of an expression are given in
        <a href="index.html#xpath20">[XPath 2.0]</a>: they are the same as
        the rules used for XPath conditional expressions.</p>

        <p>If the effective boolean value of the <a title=
        "expression" href="index.html#dt-expression">expression</a> is true,
        then the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> is
        evaluated (see <a href="index.html#sequence-constructors"><i>5.7
        Sequence Constructors</i></a>), and the resulting node
        sequence is returned as the result of the <a href=
        "index.html#element-if"><code>xsl:if</code></a> instruction;
        otherwise, <span>the sequence constructor is not evaluated,
        and</span> the empty sequence is returned.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e11752" id="d5e11752"></a>Example: Using
            <code>xsl:if</code>
          </div>

          <p>In the following example, the names in a group of
          names are formatted as a comma separated list:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="namelist/name"&gt;
  &lt;xsl:apply-templates/&gt;
  &lt;xsl:if test="not(position()=last())"&gt;, &lt;/xsl:if&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>The following colors every other table row yellow:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="item"&gt;
  &lt;tr&gt;
    &lt;xsl:if test="position() mod 2 = 0"&gt;
       &lt;xsl:attribute name="bgcolor"&gt;yellow&lt;/xsl:attribute&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/tr&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="xsl-choose" id="xsl-choose"></a>8.2
        Conditional Processing with <a href=
        "index.html#element-choose"><code>xsl:choose</code></a></h3>

        <p class="element-syntax"><a name="element-choose" id=
        "element-choose"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:choose&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-when">xsl:when</a>+, <a href=
        "index.html#element-otherwise">xsl:otherwise</a>?) --&gt;<br />
        &lt;/xsl:choose&gt;</code></p>

        <p class="element-syntax"><a name="element-when" id=
        "element-when"></a><code>&lt;xsl:when<br />
        &#160;&#160;<b>test</b> = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:when&gt;</code></p>

        <p class="element-syntax"><a name="element-otherwise" id=
        "element-otherwise"></a><code>&lt;xsl:otherwise&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:otherwise&gt;</code></p>

        <p>The <a href=
        "index.html#element-choose"><code>xsl:choose</code></a> element
        selects one among a number of possible alternatives. It
        consists of a sequence of one or more <a href=
        "index.html#element-when"><code>xsl:when</code></a> elements followed
        by an optional <a href=
        "index.html#element-otherwise"><code>xsl:otherwise</code></a>
        element. Each <a href=
        "index.html#element-when"><code>xsl:when</code></a> element has a
        single attribute, <code>test</code>, which specifies an
        <a title="expression" href="index.html#dt-expression">expression</a>.
        The content of the <a href=
        "index.html#element-when"><code>xsl:when</code></a> and <a href=
        "index.html#element-otherwise"><code>xsl:otherwise</code></a>
        elements is a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

        <p>When an <a href=
        "index.html#element-choose"><code>xsl:choose</code></a> element is
        processed, each of the <a href=
        "index.html#element-when"><code>xsl:when</code></a> elements is
        tested in turn (that is, in <span>the order that</span> the
        elements appear in the stylesheet), until one of the
        <a href="index.html#element-when"><code>xsl:when</code></a> elements
        is satisfied. <span>If none of the <a href=
        "index.html#element-when"><code>xsl:when</code></a> elements is
        satisfied, then the <a href=
        "index.html#element-otherwise"><code>xsl:otherwise</code></a> element
        is considered, as described below.</span></p>

        <p>An <a href="index.html#element-when"><code>xsl:when</code></a>
        element is satisfied if the <a href=
        "http://www.w3.org/TR/xpath20/#dt-ebv">effective boolean
        value</a><sup><small>XP</small></sup> of the <a title=
        "expression" href="index.html#dt-expression">expression</a> in its
        <code>test</code> attribute is <code>true</code>. The rules
        for determining the effective boolean value of an
        expression are given in <a href="index.html#xpath20">[XPath 2.0]</a>:
        they are the same as the rules used for XPath conditional
        expressions.</p>

        <p>The content of the first, and only the first, <a href=
        "index.html#element-when"><code>xsl:when</code></a> element that is
        satisfied is evaluated, and the resulting sequence is
        returned as the result of the <a href=
        "index.html#element-choose"><code>xsl:choose</code></a> instruction.
        If no <a href="index.html#element-when"><code>xsl:when</code></a>
        element is satisfied, the content of the <a href=
        "index.html#element-otherwise"><code>xsl:otherwise</code></a> element
        is evaluated, and the resulting sequence is returned as the
        result of the <a href=
        "index.html#element-choose"><code>xsl:choose</code></a> instruction.
        If no <a href="index.html#element-when"><code>xsl:when</code></a>
        element is satisfied, and no <a href=
        "index.html#element-otherwise"><code>xsl:otherwise</code></a> element
        is present, the result of the <a href=
        "index.html#element-choose"><code>xsl:choose</code></a> instruction
        is an empty sequence.</p>

        <p>Only the <span>sequence</span> constructor of the
        selected <a href="index.html#element-when"><code>xsl:when</code></a>
        or <a href=
        "index.html#element-otherwise"><code>xsl:otherwise</code></a>
        instruction is evaluated. The <code>test</code> expressions
        for <a href="index.html#element-when"><code>xsl:when</code></a>
        instructions after the selected one are not evaluated.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e11904" id="d5e11904"></a>Example: Using
            <code>xsl:choose</code>
          </div>

          <p>The following example enumerates items in an ordered
          list using arabic numerals, letters, or roman numerals
          depending on the depth to which the ordered lists are
          nested.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="orderedlist/listitem"&gt;
  &lt;fo:list-item indent-start='2pi'&gt;
    &lt;fo:list-item-label&gt;
      &lt;xsl:variable name="level"
                    select="count(ancestor::orderedlist) mod 3"/&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test='$level=1'&gt;
          &lt;xsl:number format="i"/&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:when test='$level=2'&gt;
          &lt;xsl:number format="a"/&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:number format="1"/&gt;
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
      &lt;xsl:text&gt;. &lt;/xsl:text&gt;
    &lt;/fo:list-item-label&gt;
    &lt;fo:list-item-body&gt;
      &lt;xsl:apply-templates/&gt;
    &lt;/fo:list-item-body&gt;
  &lt;/fo:list-item&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="variables-and-parameters" id=
      "variables-and-parameters"></a>9 Variables and
      Parameters</h2>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-variable-binding-element" id=
      "dt-variable-binding-element" title=
      "variable-binding element"></a>The two elements <a href=
      "index.html#element-variable"><code>xsl:variable</code></a> and
      <a href="index.html#element-param"><code>xsl:param</code></a> are
      referred to as <b>variable-binding elements</b> <span class=
      "definition">]</span>.</p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-variable" id="dt-variable" title="variable"></a>The
      <a href="index.html#element-variable"><code>xsl:variable</code></a>
      element declares a <b>variable</b>, which may be a <a title=
      "global variable" href="index.html#dt-global-variable">global
      variable</a> or a <a title="local variable" href=
      "index.html#dt-local-variable">local variable</a>.<span class=
      "definition">]</span></p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-parameter" id="dt-parameter" title="parameter"></a>The
      <a href="index.html#element-param"><code>xsl:param</code></a> element
      declares a <b>parameter</b>, which may be a <a title=
      "stylesheet parameter" href=
      "index.html#dt-stylesheet-parameter">stylesheet parameter</a>, a
      <a title="template parameter" href=
      "index.html#dt-template-parameter">template parameter</a>, or a
      <a title="function parameter" href=
      "index.html#dt-function-parameter">function parameter</a>. A parameter
      is a <a title="variable" href="index.html#dt-variable">variable</a>
      with the additional property that its value can be set by the
      caller when the stylesheet, the template, or the function is
      invoked.<span class="definition">]</span></p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-value" id="dt-value" title="value"></a>A variable is a
      binding between a name and a value. The <b>value</b> of a
      variable is any sequence (of nodes and/or atomic values), as
      defined in <a href="index.html#xpath-datamodel">[Data
      Model]</a>.<span class="definition">]</span></p>

      <div class="div2">
        <h3><a name="variables" id="variables"></a>9.1
        Variables</h3>

        <p class="element-syntax"><a name="element-variable" id=
        "element-variable"></a><code>&lt;!-- Category: declaration
        --&gt;<br />
        &lt;!-- Category: instruction --&gt;<br />
        &lt;xsl:variable<br />
        &#160;&#160;<b>name</b> = <var>qname</var><br />
        &#160;&#160;select? = <var>expression</var><br />
        &#160;&#160;as? = <var>sequence-type</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:variable&gt;</code></p>

        <p>The <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> element
        has a <span class="verb">required</span> <code>name</code>
        attribute, which specifies the name of the variable. The
        value of the <code>name</code> attribute is a <a title=
        "QName" href="index.html#dt-qname">QName</a>, which is expanded as
        described in <a href="index.html#qname"><i>5.1 Qualified
        Names</i></a>.</p>

        <p>The <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> element
        has an optional <code>as</code> attribute, which specifies
        the <a title="required type" href=
        "index.html#dt-required-type">required type</a> of the variable. The
        value of the <code>as</code> attribute is a <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-SequenceType">SequenceType</a><sup>
        <small>XP</small></sup>, as defined in <a href=
        "index.html#xpath20">[XPath 2.0]</a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-supplied-value" id="dt-supplied-value" title=
        "supplied value"></a>The value of the variable is computed
        using the <a title="expression" href=
        "index.html#dt-expression">expression</a> given in the
        <code>select</code> attribute or the contained <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, as
        described in <a href="index.html#variable-values"><i>9.3 Values of
        Variables and Parameters</i></a>. This value is referred to
        as the <b>supplied value</b> of the variable.<span class=
        "definition">]</span> <span>If the <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> element
        has a <code>select</code> attribute, then the sequence
        constructor <span class="verb">must</span> be
        empty.</span></p>

        <p>If the <code>as</code> attribute is specified, then the
        <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of the variable is
        converted to the required type, using the <a title=
        "function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a>.</p>

        <p><a name="err-XTTE0570" id="err-XTTE0570"><span class=
        "error">[ERR XTTE0570]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of a variable
        cannot be converted to the required type.</p>

        <p>If the <code>as</code> attribute is omitted, the
        <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of the variable is
        used directly, and no conversion takes place.</p>
      </div>

      <div class="div2">
        <h3><a name="parameters" id="parameters"></a>9.2
        Parameters</h3>

        <p class="element-syntax"><a name="element-param" id=
        "element-param"></a><code>&lt;!-- Category: declaration
        --&gt;<br />
        &lt;xsl:param<br />
        &#160;&#160;<b>name</b> = <var>qname</var><br />
        &#160;&#160;select? = <var>expression</var><br />
        &#160;&#160;as? = <var>sequence-type</var><br />
        &#160;&#160;required? = "yes" | "no"<br />
        &#160;&#160;tunnel? = "yes" | "no"&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:param&gt;</code></p>

        <p>The <a href="index.html#element-param"><code>xsl:param</code></a>
        element may be used as a child of <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>, to
        define a parameter to the transformation; or as a child of
        <a href="index.html#element-template"><code>xsl:template</code></a>
        to define a parameter to a template, which may be supplied
        when the template is invoked using <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>,
        <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        <span>or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a></span>;
        or as a child of <a href=
        "index.html#element-function"><code>xsl:function</code></a> to define
        a parameter to a stylesheet function, which may be supplied
        when the function is called from an XPath <a title=
        "expression" href="index.html#dt-expression">expression</a>.</p>

        <p>The <a href="index.html#element-param"><code>xsl:param</code></a>
        element has a <span class="verb">required</span>
        <code>name</code> attribute, which specifies the name of
        the parameter. The value of the <code>name</code> attribute
        is a <a title="QName" href="index.html#dt-qname">QName</a>, which is
        expanded as described in <a href="index.html#qname"><i>5.1 Qualified
        Names</i></a>.</p>

        <p><a name="err-XTSE0580" id="err-XTSE0580"><span class=
        "error">[ERR XTSE0580]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        two parameters of a template or of a stylesheet function
        have the same name.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>For rules concerning stylesheet parameters, see
          <a href="index.html#global-variables"><i>9.5 Global Variables and
          Parameters</i></a>. Local variables may <a title=
          "shadows" href="index.html#dt-shadows">shadow</a> template
          parameters and function parameters: see <a href=
          "index.html#scope-of-variables"><i>9.7 Scope of
          Variables</i></a>.</p>
        </div>

        <p>The <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of the parameter is
        the value supplied by the caller. If no value was supplied
        by the caller, and if the parameter is not mandatory, then
        the supplied value is computed using the <a title=
        "expression" href="index.html#dt-expression">expression</a> given in
        the <code>select</code> attribute or the contained
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, as
        described in <a href="index.html#variable-values"><i>9.3 Values of
        Variables and Parameters</i></a>. <span>If the <a href=
        "index.html#element-param"><code>xsl:param</code></a> element has a
        <code>select</code> attribute, then the sequence
        constructor <span class="verb">must</span> be
        empty.</span></p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This specification does not dictate whether and when
          the default value of a parameter is evaluated. For
          example, if the default is specified as
          <code>&lt;xsl:param
          name="p"&gt;&lt;foo/&gt;&lt;/xsl:param&gt;</code>, then
          it is not specified whether a distinct <code>foo</code>
          element node will be created on each invocation of the
          template, or whether the same <code>foo</code> element
          node will be used for each invocation. However, it is
          permissible for the default value to depend on the values
          of other parameters, or on the evaluation context, in
          which case the default must effectively be evaluated on
          each invocation.</p>
        </div>

        <p>The <a href="index.html#element-param"><code>xsl:param</code></a>
        element has an optional <code>as</code> attribute, which
        specifies the <a title="required type" href=
        "index.html#dt-required-type">required type</a> of the parameter. The
        value of the <code>as</code> attribute is a <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-SequenceType">SequenceType</a><sup>
        <small>XP</small></sup>, as defined in <a href=
        "index.html#xpath20">[XPath 2.0]</a>.</p>

        <p>If the <code>as</code> attribute is specified, then the
        <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of the parameter is
        converted to the required type, using the <a title=
        "function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a>.</p>

        <p><a name="err-XTTE0590" id="err-XTTE0590"><span class=
        "error">[ERR XTTE0590]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        conversion of the <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of a parameter to
        its required type fails.</p>

        <p>If the <code>as</code> attribute is omitted, the
        <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of the parameter is
        used directly, and no conversion takes place.</p>

        <p>The optional <code>required</code> attribute may be used
        to indicate that a parameter is mandatory. This attribute
        may be specified for <a title="stylesheet parameter" href=
        "index.html#dt-stylesheet-parameter">stylesheet parameters</a> and
        for <a title="template parameter" href=
        "index.html#dt-template-parameter">template parameters</a>; it
        <span class="verb">must not</span> be specified for
        <a title="function parameter" href=
        "index.html#dt-function-parameter">function parameters</a>, which are
        always mandatory. <span>A parameter is mandatory if it is a
        <a title="function parameter" href=
        "index.html#dt-function-parameter">function parameter</a> or if the
        <code>required</code> attribute is present and has the
        value <code>yes</code>. Otherwise, the parameter is
        optional. If the parameter is mandatory, then</span> the
        <a href="index.html#element-param"><code>xsl:param</code></a> element
        <span class="verb">must</span> be empty and <span class=
        "verb">must not</span> have a <code>select</code>
        attribute.</p>

        <p><a name="err-XTTE0600" id="err-XTTE0600"><span class=
        "error">[ERR XTTE0600]</span></a> If a default value is
        given explicitly, that is, if there is either a
        <code>select</code> attribute or a non-empty <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, then
        it is a <a title="type errors" href="index.html#dt-type-error">type
        error</a> if the default value cannot be converted to the
        required type, using the <a title=
        "function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a>.</p>

        <p>If an optional parameter has no <code>select</code>
        attribute and has an empty <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a>,
        and if there is no <code>as</code> attribute, then the
        default value of the parameter is a zero length string.</p>

        <p><a name="err-XTDE0610" id="err-XTDE0610"><span class=
        "error">[ERR XTDE0610]</span></a> If an optional parameter
        has no <code>select</code> attribute and has an empty
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, and if
        there is an <code>as</code> attribute, then the default
        value of the parameter is an empty sequence. If the empty
        sequence is not a valid instance of the required type
        defined in the <code>as</code> attribute, then the
        parameter is treated as a required parameter, which means
        that it is a <a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the caller supplies no value for the
        parameter.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The effect of these rules is that specifying
          <code>&lt;xsl:param name="p" as="xs:date"
          select="2"/&gt;</code> is an error, but if the default
          value of the parameter is never used, then the processor
          has discretion whether or not to report the error. By
          contrast, <code>&lt;xsl:param name="p"
          as="xs:date"/&gt;</code> is treated as if
          <code>required="yes"</code> had been specified: the empty
          sequence is not a valid instance of <code>xs:date</code>,
          so in effect there is no default value and the parameter
          is therefore treated as being mandatory.</p>
        </div>

        <p>The optional <code>tunnel</code> attribute may be used
        to indicate that a parameter is a <a title=
        "tunnel parameter" href="index.html#dt-tunnel-parameter">tunnel
        parameter</a>. The default is <code>no</code>; the value
        <code>yes</code> may be specified only for <a title=
        "template parameter" href="index.html#dt-template-parameter">template
        parameters</a>. Tunnel parameters are described in <a href=
        "index.html#tunnel-params"><i>10.1.2 Tunnel Parameters</i></a></p>
      </div>

      <div class="div2">
        <h3><a name="variable-values" id="variable-values"></a>9.3
        Values of Variables and Parameters</h3>

        <p>A <a title="variable-binding element" href=
        "index.html#dt-variable-binding-element">variable-binding element</a>
        may specify the <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a> of the <a title=
        "variable" href="index.html#dt-variable">variable</a> or <a title=
        "parameter" href="index.html#dt-parameter">parameter</a> in
        <span>four</span> different ways.</p>

        <ul>
          <li>
            <p>If the <a title="variable-binding element" href=
            "index.html#dt-variable-binding-element">variable-binding
            element</a> has a <code>select</code> attribute, then
            the value of the attribute <span class=
            "verb">must</span> be an <a title="expression" href=
            "index.html#dt-expression">expression</a> and the <a title=
            "supplied value" href="index.html#dt-supplied-value">supplied
            value</a> of the variable is the value that results
            from evaluating the expression. In this case, the
            content of the variable-binding element <span class=
            "verb">must</span> be empty.</p>
          </li>

          <li>
            <p>If the <a title="variable-binding element" href=
            "index.html#dt-variable-binding-element">variable-binding
            element</a> has empty content and <span>has neither a
            <code>select</code> attribute nor an <code>as</code>
            attribute</span>, then the <a title="supplied value"
            href="index.html#dt-supplied-value">supplied value</a> of the
            variable is a zero-length string. Thus</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:variable name="x"/&gt;
</pre>
            </div>

            <p>is equivalent to</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:variable name="x" select="''"/&gt;
</pre>
            </div>
          </li>

          <li>
            <p>If a <a title="variable-binding element" href=
            "index.html#dt-variable-binding-element">variable-binding
            element</a> has no <code>select</code> attribute and
            has non-empty content (that is, the variable-binding
            element has one or more child nodes), and has no
            <code>as</code> attribute, then the content of the
            variable-binding element specifies the <a title=
            "supplied value" href="index.html#dt-supplied-value">supplied
            value</a>. The content of the variable-binding element
            is a <a title="sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a>; a
            new document is constructed with a document node having
            as its children the sequence of nodes that results from
            evaluating the sequence constructor and then applying
            the rules given in <a href=
            "index.html#constructing-complex-content"><i>5.7.1 Constructing
            Complex Content</i></a>. The value of the variable is
            then a singleton sequence containing this document
            node. For further information, see <a href=
            "index.html#temporary-trees"><i>9.4 Creating implicit document
            nodes</i></a>.</p>
          </li>

          <li>
            <p>If a <a title="variable-binding element" href=
            "index.html#dt-variable-binding-element">variable-binding
            element</a> has an <code>as</code> attribute but no
            <code>select</code> attribute, then the <a title=
            "supplied value" href="index.html#dt-supplied-value">supplied
            value</a> is the sequence that results from evaluating
            the (possibly empty) <a title="sequence constructor"
            href="index.html#dt-sequence-constructor">sequence
            constructor</a> contained within the variable-binding
            element (see <a href="index.html#sequence-constructors"><i>5.7
            Sequence Constructors</i></a>).</p>
          </li>
        </ul>

        <p>These combinations are summarized in the table
        below.</p>

        <table border="1" cellpadding="5">
          <col width="12%" span="1" />
          <col width="12%" span="1" />
          <col width="12%" span="1" />
          <col span="1" />

          <thead>
            <tr>
              <th align="left">select attribute</th>

              <th align="left">as attribute</th>

              <th align="left">content</th>

              <th align="left">Effect</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td valign="top">present</td>

              <td valign="top">absent</td>

              <td valign="top">empty</td>

              <td valign="top">Value is obtained by evaluating the
              <code>select</code> attribute</td>
            </tr>

            <tr>
              <td valign="top">present</td>

              <td valign="top">present</td>

              <td valign="top">empty</td>

              <td valign="top">Value is obtained by evaluating the
              <code>select</code> attribute, adjusted to the type
              required by the <code>as</code> attribute</td>
            </tr>

            <tr>
              <td valign="top">present</td>

              <td valign="top">absent</td>

              <td valign="top">present</td>

              <td valign="top">Static error</td>
            </tr>

            <tr>
              <td valign="top">present</td>

              <td valign="top">present</td>

              <td valign="top">present</td>

              <td valign="top">Static error</td>
            </tr>

            <tr>
              <td valign="top">absent</td>

              <td valign="top">absent</td>

              <td valign="top">empty</td>

              <td valign="top">Value is a zero-length string</td>
            </tr>

            <tr>
              <td valign="top">absent</td>

              <td valign="top">present</td>

              <td valign="top">empty</td>

              <td valign="top">Value is an empty sequence, provided
              the <code>as</code> attribute permits an empty
              sequence</td>
            </tr>

            <tr>
              <td valign="top">absent</td>

              <td valign="top">absent</td>

              <td valign="top">present</td>

              <td valign="top"><span>Value is a document node whose
              content is obtained by evaluating the sequence
              constructor</span></td>
            </tr>

            <tr>
              <td valign="top">absent</td>

              <td valign="top">present</td>

              <td valign="top">present</td>

              <td valign="top">Value is obtained by evaluating the
              sequence constructor, adjusted to the type required
              by the <code>as</code> attribute</td>
            </tr>
          </tbody>
        </table>

        <p><a name="err-XTSE0620" id="err-XTSE0620"><span class=
        "error">[ERR XTSE0620]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        a <a title="variable-binding element" href=
        "index.html#dt-variable-binding-element">variable-binding element</a>
        has a <code>select</code> attribute and has non-empty
        content.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e12625" id="d5e12625"></a>Example: Values of
            Variables
          </div>

          <p>The value of the following variable is the sequence of
          integers (1, 2, 3):</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="i" as="xs:integer*" select="1 to 3"/&gt;
</pre>
          </div>

          <p>The value of the following variable is an integer,
          assuming that the attribute <code>@size</code> exists,
          and is annotated either as an integer, or as
          <span><code>xs:untypedAtomic</code></span>:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="i" as="xs:integer" select="@size"/&gt;
</pre>
          </div>

          <p>The value of the following variable is a zero-length
          string:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="z"/&gt;
</pre>
          </div>

          <p>The value of the following variable is document node
          containing an empty element as a child:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="doc"&gt;&lt;c/&gt;&lt;/xsl:variable&gt;
</pre>
          </div>

          <p>The value of the following variable is sequence of
          integers (2, 4, 6):</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="seq" as="xs:integer*"&gt;
  &lt;xsl:for-each select="1 to 3"&gt;
    &lt;xsl:sequence select=".*2"/&gt;
  &lt;/xsl:for-each&gt;
&lt;/xsl:variable&gt;
</pre>
          </div>

          <p>The value of the following variable is sequence of
          parentless attribute nodes:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="attset" as="attribute()+"&gt;
  &lt;xsl:attribute name="x"&gt;2&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="y"&gt;3&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="z"&gt;4&lt;/xsl:attribute&gt;    
&lt;/xsl:variable&gt;
</pre>
          </div>

          <p>The value of the following variable is an empty
          sequence:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="empty" as="empty-sequence()"/&gt;
</pre>
          </div>
        </div>

        <p>The actual value of the variable depends on the
        <a title="supplied value" href=
        "index.html#dt-supplied-value">supplied value</a>, as described
        above, and the required type, which is determined by the
        value of the <code>as</code> attribute.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e12672" id="d5e12672"></a>Example: Pitfalls
            with Numeric Predicates
          </div>

          <p>When a variable is used to select nodes by position,
          be careful not to do:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="n"&gt;2&lt;/xsl:variable&gt;
...
&lt;xsl:value-of select="td[$n]"/&gt;
</pre>
          </div>

          <p>This will output the values of all the <code>td</code>
          elements, space-separated (or in backwards compatibility
          mode, the value of the first <code>td</code> element),
          because the variable <code>n</code> will be bound to a
          node, not a number. Instead, do one of the following:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="n" select="2"/&gt;
...
&lt;xsl:value-of select="td[$n]"/&gt;
</pre>
          </div>

          <p>or</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="n"&gt;2&lt;/xsl:variable&gt;
...
&lt;xsl:value-of select="td[position()=$n]"/&gt;
</pre>
          </div>

          <p>or</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="n" as="xs:integer"&gt;2&lt;/xsl:variable&gt;
...
&lt;xsl:value-of select="td[$n]"/&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="temporary-trees" id="temporary-trees"></a>9.4
        <span>Creating implicit document nodes</span></h3>

        <p>A document node is created implicitly when evaluating an
        <a href="index.html#element-variable"><code>xsl:variable</code></a>,
        <a href="index.html#element-param"><code>xsl:param</code></a>, or
        <a href=
        "index.html#element-with-param"><code>xsl:with-param</code></a>
        element that has non-empty content and that has no
        <code>as</code> attribute. This element is referred to as
        the variable-binding element. The value of the <a title=
        "variable" href="index.html#dt-variable">variable</a> is a single
        node, the document node of the <a title="temporary tree"
        href="index.html#dt-temporary-tree">temporary tree</a>. The content
        of the document node is formed from the result of
        evaluating the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>
        contained within the variable-binding element, as described
        in <a href="index.html#constructing-complex-content"><i>5.7.1
        Constructing Complex Content</i></a>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The construct:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="tree"&gt;
  &lt;a/&gt;
&lt;/xsl:variable&gt;
</pre>
          </div>

          <p>can be regarded as a shorthand for:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="tree" as="document-node()"&gt;
  &lt;xsl:document validation="preserve"&gt;
    &lt;a/&gt;
  &lt;/xsl:document&gt;  
&lt;/xsl:variable&gt;
</pre>
          </div>
        </div>

        <p>The base URI of the document node is taken from the base
        URI of the variable binding element in the stylesheet. (See
        <a href=
        "http://www.w3.org/TR/xpath-datamodel/#dm-base-uri">Section
        5.2 base-uri Accessor</a><sup><small>DM</small></sup> in
        <a href="index.html#xpath-datamodel">[Data Model]</a>)</p>

        <p>No document-level validation takes place (which means,
        for example, that there is no checking that ID values are
        unique). However, type annotations on nodes within the new
        tree are copied unchanged.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The base URI of other nodes in the tree is determined
          by the rules for constructing complex content. The effect
          of these rules is that the base URI of a node in the
          temporary tree is determined as if all the nodes in the
          temporary tree came from a single entity whose URI was
          the base URI of the <a title="variable-binding element"
          href="index.html#dt-variable-binding-element">variable-binding
          element</a>. Thus, the base URI of the document node will
          be equal to the base URI of the variable-binding element;
          an <code>xml:base</code> attribute within the temporary
          tree will change the base URI for its parent element and
          that element's descendants, just as it would within a
          document constructed by parsing.</p>
        </div>

        <p>The <code>document-uri</code> and
        <code>unparsed-entities</code> properties of the new
        document node are set to empty.</p>

        <p>A <a title="temporary tree" href=
        "index.html#dt-temporary-tree">temporary tree</a> is available for
        processing in exactly the same way as any source document.
        For example, its nodes are accessible using path
        expressions, and they can be processed using instructions
        such as <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        and <a href=
        "index.html#element-for-each"><code>xsl:for-each</code></a>. Also,
        the <a href="index.html#function-key"><code>key</code></a> and
        <a href=
        "http://www.w3.org/TR/xpath-functions/#func-id"><code>id</code></a><sup>
        <small>FO</small></sup> functions can be used to find nodes
        within a temporary tree <span>rooted at a document
        node</span>, provided that at the time the function is
        called, the context item is a node within the temporary
        tree.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e12785" id="d5e12785"></a>Example: Two-Phase
            Transformation
          </div>

          <p>For example, the following stylesheet uses a temporary
          tree as the intermediate result of a two-phase
          transformation, using different <a title="mode" href=
          "index.html#dt-mode">modes</a> for the two phases (see <a href=
          "index.html#modes"><i>6.5 Modes</i></a>). <span>Typically, the
          template rules in module <code>phase1.xsl</code> will be
          declared with <code>mode="phase1"</code>, while those in
          module <code>phase2.xsl</code> will be declared with
          <code>mode="phase2"</code>:</span></p>

          <div class="exampleInner">
            <pre>
&lt;xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

&lt;xsl:import href="phase1.xsl"/&gt;
&lt;xsl:import href="phase2.xsl"/&gt;

&lt;xsl:variable name="intermediate"&gt;
  &lt;xsl:apply-templates select="/" mode="phase1"/&gt;
&lt;/xsl:variable&gt;

&lt;xsl:template match="/"&gt;
  &lt;xsl:apply-templates select="$intermediate" mode="phase2"/&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
          </div>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The algorithm for matching nodes against template
          rules is exactly the same regardless which tree the nodes
          come from. <span>If different template rules are to be
          used when processing different trees, then unless</span>
          nodes from different trees can be distinguished by means
          of <a title="pattern" href="index.html#dt-pattern">patterns</a>, it
          is a good idea to use <a title="mode" href=
          "index.html#dt-mode">modes</a> to ensure that each tree is
          processed using the appropriate set of template
          rules.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="global-variables" id=
        "global-variables"></a>9.5 Global Variables and
        Parameters</h3>

        <p>Both <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> and
        <a href="index.html#element-param"><code>xsl:param</code></a> are
        allowed as <a title="declaration" href=
        "index.html#dt-declaration">declaration</a> elements<span>: that is,
        they may appear as children of the <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element.</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-global-variable" id="dt-global-variable" title=
        "global variable"></a>A top-level <a title=
        "variable-binding element" href=
        "index.html#dt-variable-binding-element">variable-binding element</a>
        declares a <b>global variable</b> that is visible
        everywhere (except where it is <a title="shadows" href=
        "index.html#dt-shadows">shadowed</a> by another binding).<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-stylesheet-parameter" id="dt-stylesheet-parameter"
        title="stylesheet parameter"></a>A top-level <a href=
        "index.html#element-param"><code>xsl:param</code></a> element
        declares a <b>stylesheet parameter</b>. A stylesheet
        parameter is a global variable with the additional property
        that its value can be supplied by the caller when a
        transformation is initiated.<span class=
        "definition">]</span> <span>As described in <a href=
        "index.html#parameters"><i>9.2 Parameters</i></a>, a stylesheet
        parameter may be declared as being mandatory, or may have a
        default value specified for use when no value is supplied
        by the caller.</span> <span>The mechanism by which the
        caller supplies a value for a stylesheet parameter is
        <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>.</span>
        An XSLT <a title="processor" href=
        "index.html#dt-processor">processor</a> <span class=
        "verb">must</span> provide such a mechanism.</p>

        <p>It is an error if no value is supplied for a mandatory
        stylesheet parameter <span class="error">[see <a href=
        "index.html#err-XTDE0050">ERR XTDE0050</a>]</span>.</p>

        <p>If a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> contains more than one
        binding for a global variable of a particular name, then
        the binding with the highest <a title="import precedence"
        href="index.html#dt-import-precedence">import precedence</a> is
        used.</p>

        <p><a name="err-XTSE0630" id="err-XTSE0630"><span class=
        "error">[ERR XTSE0630]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> contains more than one
        binding of a global variable with the same name and same
        <a title="import precedence" href=
        "index.html#dt-import-precedence">import precedence</a><span>, unless
        it also contains another binding with the same name and
        higher import precedence</span>.</p>

        <p>For a global variable or the default value of a
        stylesheet parameter, the <a title="expression" href=
        "index.html#dt-expression">expression</a> or <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>
        specifying the variable value is evaluated with a <a title=
        "singleton focus" href="index.html#dt-singleton-focus">singleton
        focus</a> based on the <span>root</span> node of the
        <span>tree</span> containing the <a title=
        "initial context node" href=
        "index.html#dt-initial-context-node">initial context node</a>. An
        XPath error will be reported if the evaluation of a global
        variable or parameter references the context item, context
        position, or context size when no initial context node is
        supplied. <span>The values of other components of the
        dynamic context are the initial values as defined in
        <a href="index.html#xpath-dynamic-context"><i>5.4.3 Initializing the
        Dynamic Context</i></a> and <a href=
        "index.html#additional-dynamic-context"><i>5.4.4 Additional Dynamic
        Context Components used by XSLT</i></a></span>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e12936" id="d5e12936"></a>Example: A
            Stylesheet Parameter
          </div>

          <p>The following example declares a global parameter
          <code>para-font-size</code>, which is referenced in an
          <a title="attribute value template" href=
          "index.html#dt-attribute-value-template">attribute value
          template</a>.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:param name="para-font-size" as="xs:string"&gt;12pt&lt;/xsl:param&gt;

&lt;xsl:template match="para"&gt;
 &lt;fo:block font-size="{$para-font-size}"&gt;
   &lt;xsl:apply-templates/&gt;
 &lt;/fo:block&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>The implementation <span>must</span> provide a
          mechanism allowing the user to supply a value for the
          parameter <code>para-font-size</code> when invoking the
          stylesheet; the value <code>12pt</code> acts as a
          default.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="local-variables" id="local-variables"></a>9.6
        Local Variables and Parameters</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-local-variable" id="dt-local-variable" title=
        "local variable"></a>As well as being allowed as <a title=
        "declaration" href="index.html#dt-declaration">declaration</a>
        elements, the <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> element
        is also allowed in <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructors</a>. Such
        a variable is known as a <b>local variable</b>.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-template-parameter" id="dt-template-parameter" title=
        "template parameter"></a> An <a href=
        "index.html#element-param"><code>xsl:param</code></a> element may
        appear as a child of an <a href=
        "index.html#element-template"><code>xsl:template</code></a> element,
        before any non-<a href=
        "index.html#element-param"><code>xsl:param</code></a> children of
        that element. Such a parameter is known as a <b>template
        parameter</b>. A template parameter is a <a title=
        "local variable" href="index.html#dt-local-variable">local
        variable</a> with the additional property that its value
        can be set when the template is called, using any of the
        instructions <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>,
        <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
        <span>or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a></span>.<span class="definition">
        ]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-function-parameter" id="dt-function-parameter" title=
        "function parameter"></a> An <a href=
        "index.html#element-param"><code>xsl:param</code></a> element may
        appear as a child of an <a href=
        "index.html#element-function"><code>xsl:function</code></a> element,
        before any non-<a href=
        "index.html#element-param"><code>xsl:param</code></a> children of
        that element. Such a parameter is known as a <b>function
        parameter</b>. A function parameter is a <a title=
        "local variable" href="index.html#dt-local-variable">local
        variable</a> with the additional property that its value
        can be set when the function is called, using a function
        call in an XPath <a title="expression" href=
        "index.html#dt-expression">expression</a>.<span class=
        "definition">]</span></p>

        <p>The result of evaluating a local <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> or
        <a href="index.html#element-param"><code>xsl:param</code></a> element
        (that is, the contribution it makes to the result of the
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> it is
        part of) is an empty sequence.</p>
      </div>

      <div class="div2">
        <h3><a name="scope-of-variables" id=
        "scope-of-variables"></a>9.7 Scope of Variables</h3>

        <p>For any <a title="variable-binding element" href=
        "index.html#dt-variable-binding-element">variable-binding
        element</a>, there is a region <span>(more specifically, a
        set of element nodes)</span> of the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> within which the
        binding is visible. The set of variable bindings in scope
        for an XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> consists of those bindings
        that are visible at the point in the stylesheet where the
        expression occurs.</p>

        <p>A global <a title="variable-binding element" href=
        "index.html#dt-variable-binding-element">variable binding element</a>
        is visible everywhere in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> (including other <a title=
        "stylesheet module" href="index.html#dt-stylesheet-module">stylesheet
        modules</a>) except within the <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> or
        <a href="index.html#element-param"><code>xsl:param</code></a> element
        itself and any region where it is <a title="shadows" href=
        "index.html#dt-shadows">shadowed</a> by another variable binding.</p>

        <p>A local <a title="variable-binding element" href=
        "index.html#dt-variable-binding-element">variable binding element</a>
        is visible for all following siblings and their
        descendants<span>, with two exceptions: it is not visible
        in any region where it is <a title="shadows" href=
        "index.html#dt-shadows">shadowed</a> by another variable binding, and
        it is not visible within the subtree rooted at an <a href=
        "index.html#element-fallback"><code>xsl:fallback</code></a>
        instruction that is a sibling of the variable binding
        element.</span> The binding is not visible for the <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> or
        <a href="index.html#element-param"><code>xsl:param</code></a> element
        itself.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-shadows"
        id="dt-shadows" title="shadows"></a>A binding
        <b>shadows</b> another binding if the binding occurs at a
        point where the other binding is visible, and the bindings
        have the same name. <span class="definition">]</span> It is
        not an error if a binding established by a local <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> or
        <a href="index.html#element-param"><code>xsl:param</code></a>
        <a title="shadows" href="index.html#dt-shadows">shadows</a> a global
        binding. In this case, the global binding will not be
        visible in the region of the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> where it is shadowed by the
        other binding.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e13122" id="d5e13122"></a>Example: Local
            Variable Shadowing a Global Variable
          </div>

          <p>The following is allowed:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:param name="x" select="1"/&gt;
&lt;xsl:template name="foo"&gt;
  &lt;xsl:variable name="x" select="2"/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>It is also not an error if a binding established by a
        local <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> element
        <a title="shadows" href="index.html#dt-shadows">shadows</a> a binding
        established by another local <a href=
        "index.html#element-variable"><code>xsl:variable</code></a> or
        <a href="index.html#element-param"><code>xsl:param</code></a>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e13143" id="d5e13143"></a>Example: Misuse of
            Variable Shadowing
          </div>

          <p>The following is not an error, but the effect is
          probably not what was intended. The template outputs
          <code>&lt;x value="1"/&gt;</code>, because the
          declaration of the inner variable named <code>$x</code>
          has no effect on the value of the outer variable named
          <code>$x</code>.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="x" select="1"/&gt;
&lt;xsl:template name="foo"&gt;
  &lt;xsl:for-each select="1 to 5"&gt;
    &lt;xsl:variable name="x" select="$x+1"/&gt;
  &lt;/xsl:for-each&gt;
  &lt;x value="{$x}"/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Once a variable has been given a value, the value
          cannot subsequently be changed. XSLT does not provide an
          equivalent to the assignment operator available in many
          procedural programming languages.</p>

          <p>This is because an assignment operator would make it
          harder to create an implementation that processes a
          document other than in a batch-like way, starting at the
          beginning and continuing through to the end.</p>
        </div>

        <p>As well as global variables and local variables, an
        XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> may also declare range
        variables for use locally within an expression. For
        details, see <a href="index.html#xpath20">[XPath 2.0]</a>.</p>

        <p>Where a reference to a variable occurs in an XPath
        expression, it is resolved first by reference to range
        variables that are in scope, then by reference to local
        variables and parameters, and finally by reference to
        global variables and parameters. A range variable may
        shadow a local variable or a global variable. XPath also
        allows a range variable to shadow another range
        variable.</p>
      </div>

      <div class="div2">
        <h3><a name="circularity" id="circularity"></a>9.8 Circular
        Definitions</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-circularity" id="dt-circularity" title=
        "circularity"></a>A <b>circularity</b> is said to exist if
        a construct such as a <a title="global variable" href=
        "index.html#dt-global-variable">global variable</a>, an <a title=
        "attribute set" href="index.html#dt-attribute-set">attribute set</a>,
        or a <a title="key" href="index.html#dt-key">key</a> is defined in
        terms of itself. For example, if the <a title="expression"
        href="index.html#dt-expression">expression</a> or <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>
        specifying the value of a <a title="global variable" href=
        "index.html#dt-global-variable">global variable</a> <var>X</var>
        references a global variable <var>Y</var>, then the value
        for <var>Y</var> <span class="verb">must</span> be computed
        before the value of <var>X</var>. A circularity exists if
        it is impossible to do this for all global variable
        definitions.<span class="definition">]</span></p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e13219" id="d5e13219"></a>Example: Circular
            Variable Definitions
          </div>

          <p>The following two declarations create a
          circularity:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="x" select="$y+1"/&gt;
&lt;xsl:variable name="y" select="$x+1"/&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e13226" id="d5e13226"></a>Example:
            Circularity involving Variables and Functions
          </div>

          <p>The definition of a global variable can be circular
          even if no other variable is involved. For example the
          following two declarations (see <a href=
          "index.html#stylesheet-functions"><i>10.3 Stylesheet
          Functions</i></a> for an explanation of the <a href=
          "index.html#element-function"><code>xsl:function</code></a>
          element) also create a circularity:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="x" select="my:f()"/&gt;

&lt;xsl:function name="my:f"&gt;
  &lt;xsl:sequence select="$x"/&gt;
&lt;/xsl:function&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e13238" id="d5e13238"></a>Example:
            Circularity involving Variables and Templates
          </div>

          <p>The definition of a variable is also circular if the
          evaluation of the variable invokes an <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction and the variable is referenced in the pattern
          used in the <code>match</code> attribute of any template
          rule in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>. For example the
          following definition is circular:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="x"&gt;
  &lt;xsl:apply-templates select="//param[1]"/&gt;
&lt;/xsl:variable&gt;

&lt;xsl:template match="param[$x]"&gt;1&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e13254" id="d5e13254"></a>Example:
            Circularity involving Variables and Keys
          </div>

          <p>Similarly, a variable definition is circular if it
          causes a call on the <a href=
          "index.html#function-key"><code>key</code></a> function, and the
          definition of that <a title="" href="index.html#key">key</a> refers
          to that variable in its <code>match</code> or
          <code>use</code> attributes. So the following definition
          is circular:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="x" select="my:f(10)"/&gt;

&lt;xsl:function name="my:f"&gt;
  &lt;xsl:param name="arg1"/&gt;
  &lt;xsl:sequence select="key('k', $arg1)"/&gt;
&lt;/xsl:function&gt;

&lt;xsl:key name="k" match="item[@code=$x]" use="@desc"/&gt;
</pre>
          </div>
        </div>

        <p><a name="err-XTDE0640" id="err-XTDE0640"><span class=
        "error">[ERR XTDE0640]</span></a> In general, a <a title=
        "circularity" href="index.html#dt-circularity">circularity</a> in a
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        is a <a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a>. However, as with all other dynamic errors, an
        implementation will signal the error only if it actually
        executes the instructions and expressions that participate
        in the circularity. Because different implementations may
        optimize the execution of a stylesheet in different ways,
        it is <a title="implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>
        whether a particular circularity will actually be
        signaled.</p>

        <p>For example, in the following declarations, the function
        declares a <span>local variable <code>$b</code>, but it
        returns a result that does not require the variable to be
        evaluated. It is <a title="implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>
        whether the value is actually evaluated</span>, and it is
        therefore implementation-dependent whether the circularity
        is signaled as an error:</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:variable name="x" select="my:f(1)/&gt;

&lt;xsl:function name="my:f"&gt;
  &lt;xsl:param name="a"/&gt;
  &lt;xsl:variable name="b" select="$x"/&gt;  
  &lt;xsl:sequence select="$a + 2"/&gt;
&lt;/xsl:function&gt;
</pre>
        </div>

        <p>Circularities usually involve global variables or
        parameters, but they can also exist between <a title=""
        href="index.html#key">key</a> definitions (see <a href="index.html#key"><i>16.3
        Keys</i></a>), between named <a title="attribute set" href=
        "index.html#dt-attribute-set">attribute sets</a> (see <a href=
        "index.html#attribute-sets"><i>10.2 Named Attribute Sets</i></a>), or
        between any combination of these constructs. For example, a
        circularity exists if a key definition invokes a function
        that references an attribute set that calls the <a href=
        "index.html#function-key"><code>key</code></a> function, supplying
        the name of the original key definition as an argument.</p>

        <p>Circularity is not the same as recursion. Stylesheet
        functions (see <a href="index.html#stylesheet-functions"><i>10.3
        Stylesheet Functions</i></a>) and named templates (see
        <a href="index.html#named-templates"><i>10.1 Named Templates</i></a>)
        may call other functions and named templates without
        restriction. With careless coding, recursion may be
        non-terminating. Implementations are <span class=
        "verb">required</span> to signal circularity as a <a title=
        "dynamic error" href="index.html#dt-dynamic-error">dynamic error</a>,
        but they are not <span class="verb">required</span> to
        detect non-terminating recursion.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="callable-components" id=
      "callable-components"></a>10 Callable Components</h2>

      <p>This section describes three constructs that can be used
      to provide subroutine-like functionality that can be invoked
      from anywhere in the stylesheet: named templates (see
      <a href="index.html#named-templates"><i>10.1 Named Templates</i></a>),
      named attribute sets (see <a href="index.html#attribute-sets"><i>10.2
      Named Attribute Sets</i></a>) and <a title=
      "stylesheet function" href=
      "index.html#dt-stylesheet-function">stylesheet functions</a> (see
      <a href="index.html#stylesheet-functions"><i>10.3 Stylesheet
      Functions</i></a>).</p>

      <div class="div2">
        <h3><a name="named-templates" id="named-templates"></a>10.1
        Named Templates</h3>

        <p class="element-syntax"><a name="element-call-template"
        id="element-call-template"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:call-template<br />
        &#160;&#160;<b>name</b> = <var>qname</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: <a href=
        "index.html#element-with-param">xsl:with-param</a>* --&gt;<br />
        &lt;/xsl:call-template&gt;</code></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-named-template" id="dt-named-template" title=
        "named template"></a>Templates can be invoked by name. An
        <a href="index.html#element-template"><code>xsl:template</code></a>
        element with a <code>name</code> attribute defines a
        <b>named template</b>.<span class="definition">]</span> The
        value of the <code>name</code> attribute is a <a title=
        "QName" href="index.html#dt-qname">QName</a>, which is expanded as
        described in <a href="index.html#qname"><i>5.1 Qualified
        Names</i></a>. If an <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        has a <code>name</code> attribute, it may, but need not,
        also have a <code>match</code> attribute. An <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction invokes a template by name; it has a
        <span class="verb">required</span> <code>name</code>
        attribute that identifies the template to be invoked.
        Unlike <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        the <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction does not change the <a title="focus" href=
        "index.html#dt-focus">focus</a>.</p>

        <p>The <code>match</code>, <code>mode</code> and
        <code>priority</code> attributes on an <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        <span>have no effect when</span> the <a title="template"
        href="index.html#dt-template">template</a> is invoked by an <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction. Similarly, the <code>name</code> attribute on
        an <a href=
        "index.html#element-template"><code>xsl:template</code></a> element
        <span>has no effect when</span> the template is invoked by
        an <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
        instruction.</p>

        <p><a name="err-XTSE0650" id="err-XTSE0650"><span class=
        "error">[ERR XTSE0650]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> contains an <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction whose <code>name</code> attribute does not
        match the <code>name</code> attribute of any <a href=
        "index.html#element-template"><code>xsl:template</code></a> in the
        <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>.</p>

        <p><a name="err-XTSE0660" id="err-XTSE0660"><span class=
        "error">[ERR XTSE0660]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> contains more than one
        <a title="template" href="index.html#dt-template">template</a> with
        the same name and the same <a title="import precedence"
        href="index.html#dt-import-precedence">import precedence</a><span>,
        unless it also contains a <a title="template" href=
        "index.html#dt-template">template</a> with the same name and higher
        <a title="import precedence" href=
        "index.html#dt-import-precedence">import precedence</a></span>.</p>

        <p>The target <a title="template" href=
        "index.html#dt-template">template</a> for an <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction is the template whose <code>name</code>
        attribute matches the <code>name</code> attribute of the
        <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction and that has higher <a title=
        "import precedence" href="index.html#dt-import-precedence">import
        precedence</a> than any other template with this name. The
        result of evaluating an <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>
        instruction is the sequence produced by evaluating the
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>
        contained in its target <a title="template" href=
        "index.html#dt-template">template</a> (see <a href=
        "index.html#sequence-constructors"><i>5.7 Sequence
        Constructors</i></a>).</p>

        <div class="div3">
          <h4><a name="with-param" id="with-param"></a>10.1.1
          Passing Parameters to Templates</h4>

          <p class="element-syntax"><a name="element-with-param"
          id="element-with-param"></a><code>&lt;xsl:with-param<br />

          &#160;&#160;<b>name</b> = <var>qname</var><br />
          &#160;&#160;select? = <var>expression</var><br />
          &#160;&#160;as? = <var>sequence-type</var><br />
          &#160;&#160;tunnel? = "yes" | "no"&gt;<br />
          &#160;&#160;&lt;!-- Content:
          <var>sequence-constructor</var> --&gt;<br />
          &lt;/xsl:with-param&gt;</code></p>

          <p>Parameters are passed to templates using the <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          element. The <span class="verb">required</span>
          <code>name</code> attribute specifies the name of the
          <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a> (the
          variable the value of whose binding is to be replaced).
          The value of the <code>name</code> attribute is a
          <a title="QName" href="index.html#dt-qname">QName</a>, which is
          expanded as described in <a href="index.html#qname"><i>5.1
          Qualified Names</i></a>.</p>

          <p><a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a> is
          allowed within <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          <span>and <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>.</p>

          <p><a name="err-XTSE0670" id="err-XTSE0670"><span class=
          "error">[ERR XTSE0670]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if a single <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          <span>or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>
          element contains two or more <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          elements with <span>matching <code>name</code>
          attributes</span>.</p>

          <p>The value of the parameter is specified in the same
          way as for <a href=
          "index.html#element-variable"><code>xsl:variable</code></a> and
          <a href="index.html#element-param"><code>xsl:param</code></a> (see
          <a href="index.html#variable-values"><i>9.3 Values of Variables and
          Parameters</i></a>)<span>, taking account of the values
          of the <code>select</code> and <code>as</code> attributes
          and the content of the <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          element, if any.</span></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>It is possible to have an <code>as</code> attribute
            on the <a href=
            "index.html#element-with-param"><code>xsl:with-param</code></a>
            element that differs from the <code>as</code> attribute
            on the corresponding <a href=
            "index.html#element-param"><code>xsl:param</code></a> element
            describing the formal parameters of the called
            template.</p>

            <p>In this situation, the supplied value of the
            parameter will first be processed according to the
            rules of the <code>as</code> attribute on the <a href=
            "index.html#element-with-param"><code>xsl:with-param</code></a>
            element, and the resulting value will then be further
            processed according to the rules of the <code>as</code>
            attribute on the <a href=
            "index.html#element-param"><code>xsl:param</code></a>
            element.</p>

            <p>For example, suppose the supplied value is a node
            with <a title="type annotation" href=
            "index.html#dt-annotation">type annotation</a>
            <span><code>xs:untypedAtomic</code></span>, and the
            <a href=
            "index.html#element-with-param"><code>xsl:with-param</code></a>
            element specifies <code>as="xs:integer"</code>, while
            the <a href="index.html#element-param"><code>xsl:param</code></a>
            element specifies <code>as="xs:double"</code>. Then the
            node will first be atomized and the resulting untyped
            atomic value will be cast to <code>xs:integer</code>.
            If this succeeds, the <code>xs:integer</code> will then
            be promoted to an <code>xs:double</code>.</p>
          </div>

          <p>The <a title="focus" href="index.html#dt-focus">focus</a> used
          for computing the value specified by the <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          element is the same as that used for the <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a>, or
          <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          element within which it occurs.</p>

          <p><a name="err-XTSE0680" id="err-XTSE0680"><span class=
          "error">[ERR XTSE0680]</span></a> In the case of <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          it is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> to pass a
          <span>non-tunnel</span> parameter named <var>x</var> to a
          template that does not have a <a title=
          "template parameter" href=
          "index.html#dt-template-parameter">template parameter</a> named
          <var>x</var><span>, unless <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled for the <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          instruction</span>. This is not an error in the case of
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          <span>and <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>;
          in these cases the parameter is simply ignored.</p>

          <p>The optional <code>tunnel</code> attribute may be used
          to indicate that a parameter is a <a title=
          "tunnel parameter" href="index.html#dt-tunnel-parameter">tunnel
          parameter</a>. The default is <code>no</code>. Tunnel
          parameters are described in <a href=
          "index.html#tunnel-params"><i>10.1.2 Tunnel Parameters</i></a></p>

          <p><a name="err-XTSE0690" id="err-XTSE0690"><span class=
          "error">[ERR XTSE0690]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if a template that is invoked using <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          declares a <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a>
          specifying <code>required="yes"</code> <span>and not
          specifying <code>tunnel="yes"</code></span>, if no value
          for this parameter is supplied by the calling
          instruction.</p>

          <p><a name="err-XTDE0700" id="err-XTDE0700"><span class=
          "error">[ERR XTDE0700]</span></a> In other cases, it is a
          <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the template that is invoked declares a
          <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a> with
          <code>required="yes"</code> and no value for this
          parameter is supplied by the calling instruction.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e13826" id="d5e13826"></a>Example: A Named
              Template
            </div>

            <p>This example defines a named template for a
            <code>numbered-block</code> with an argument to control
            the format of the number.</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:template name="numbered-block"&gt;
  &lt;xsl:param name="format"&gt;1. &lt;/xsl:param&gt;
  &lt;fo:block&gt;
    &lt;xsl:number format="{$format}"/&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="ol//ol/li"&gt;
  &lt;xsl:call-template name="numbered-block"&gt;
    &lt;xsl:with-param name="format"&gt;a. &lt;/xsl:with-param&gt;
  &lt;/xsl:call-template&gt;
&lt;/xsl:template&gt;
</pre>
            </div>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Arguments to <a title="stylesheet function" href=
            "index.html#dt-stylesheet-function">stylesheet functions</a> are
            supplied as part of an XPath function call: see
            <a href="index.html#stylesheet-functions"><i>10.3 Stylesheet
            Functions</i></a></p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="tunnel-params" id="tunnel-params"></a>10.1.2
          Tunnel Parameters</h4>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-tunnel-parameter" id="dt-tunnel-parameter" title=
          "tunnel parameter"></a>A parameter passed to a template
          may be defined as a <b>tunnel parameter</b>. Tunnel
          parameters have the property that they are automatically
          passed on by the called template to any further templates
          that it calls, and so on recursively.<span class=
          "definition">]</span> Tunnel parameters thus allow values
          to be set that are accessible during an entire phase of
          stylesheet processing, without the need for each template
          that is used during that phase to be aware of the
          parameter.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Tunnel parameters are conceptually similar to
            dynamically-scoped variables in some functional
            programming languages.</p>
          </div>

          <p>A <a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">tunnel parameter</a> is created by
          using an <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          element that specifies <code>tunnel="yes"</code>. A
          template that requires access to the value of a tunnel
          parameter must declare it using an <a href=
          "index.html#element-param"><code>xsl:param</code></a> element that
          also specifies <code>tunnel="yes"</code>.</p>

          <p>On any template call using an <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
          or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a>
          instruction, a set of <a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">tunnel parameters</a> is passed
          from the calling template to the called template. This
          set consists of any parameters explicitly created using
          <code>&lt;xsl:with-param tunnel="yes"&gt;</code>,
          overlaid on a base set of tunnel parameters. If the
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
          or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a>
          instruction has an <a href=
          "index.html#element-template"><code>xsl:template</code></a>
          declaration as an ancestor element in the stylesheet,
          then the base set consists of the tunnel parameters that
          were passed to that template; otherwise (for example, if
          the instruction is within a global variable declaration,
          an <a title="attribute set" href=
          "index.html#dt-attribute-set">attribute set</a> declaration, or a
          <a title="stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a>), the
          base set is empty. If a parameter created using
          <code>&lt;xsl:with-param tunnel="yes"&gt;</code> has the
          same <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> as a parameter in
          the base set, then the parameter created using <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          overrides the parameter in the base set; otherwise, the
          parameter created using <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a> is
          added to the base set.</p>

          <p>When a template accesses the value of a <a title=
          "tunnel parameter" href="index.html#dt-tunnel-parameter">tunnel
          parameter</a> by declaring it with <code>xsl:param
          tunnel="yes"</code>, this does not remove the parameter
          from the base set of tunnel parameters that is passed on
          to any templates called by this template.</p>

          <p>Two sibling <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          elements must have distinct parameter names, even if one
          is a <a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">tunnel parameter</a> and the other
          is not. Equally, two sibling <a href=
          "index.html#element-param"><code>xsl:param</code></a> elements
          representing <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameters</a> must
          have distinct parameter names, even if one is a <a title=
          "tunnel parameter" href="index.html#dt-tunnel-parameter">tunnel
          parameter</a> and the other is not. However, the tunnel
          parameters that are implicitly passed in a template call
          may have names that duplicate the names of non-tunnel
          parameters that are explicitly passed on the same
          call.</p>

          <p><a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">Tunnel parameters</a> are not
          passed in calls to <a title="stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet functions</a>.</p>

          <p>All other options of <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a> and
          <a href="index.html#element-param"><code>xsl:param</code></a> are
          available with <a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">tunnel parameters</a> just as with
          non-tunnel parameters. For example, parameters may be
          declared as mandatory or optional, a default value may be
          specified, and a required type may be specified. If any
          conversion is required from the supplied value of a
          tunnel parameter to the required type specified in
          <a href="index.html#element-param"><code>xsl:param</code></a>, then
          the converted value is used within the receiving
          template, but the value that is passed on in any further
          template calls is the original supplied value before
          conversion. Equally, any default value is local to the
          template: specifying a default value for a tunnel
          parameter does not change the set of tunnel parameters
          that is passed on in further template calls.</p>

          <p>The set of <a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">tunnel parameters</a> that is
          passed to the <a title="initial template" href=
          "index.html#dt-initial-template">initial template</a> is empty.</p>

          <p><a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">Tunnel parameters</a> are passed
          unchanged through a built-in template rule (see <a href=
          "index.html#built-in-rule"><i>6.6 Built-in Template
          Rules</i></a>).</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e13990" id="d5e13990"></a>Example: Using
              Tunnel Parameters
            </div>

            <p>Suppose that the equations in a scientific paper are
            to be sequentially numbered, but that the format of the
            number depends on the context in which the equations
            appear. It is possible to reflect this using a rule of
            the form:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:template match="equation"&gt;
  &lt;xsl:param name="equation-format" select="'(1)'" tunnel="yes"/&gt;
  &lt;xsl:number level="any" format="{$equation-format}"/&gt;
&lt;/xsl:template&gt;
</pre>
            </div>

            <p>At any level of processing above this level, it is
            possible to determine how the equations will be
            numbered, for example:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:template match="appendix"&gt;
  ...
  &lt;xsl:apply-templates&gt;
    &lt;xsl:with-param name="equation-format" select="'[i]'" tunnel="yes"/&gt;
  &lt;/xsl:apply-templates&gt;
  ...
&lt;/xsl:template&gt;
</pre>
            </div>

            <p>The parameter value is passed transparently through
            all the intermediate layers of template rules until it
            reaches the rule with <code>match="equation"</code>.
            The effect is similar to using a global variable,
            except that the parameter can take different values
            during different phases of the transformation.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="attribute-sets" id="attribute-sets"></a>10.2
        Named Attribute Sets</h3>

        <p class="element-syntax"><a name="element-attribute-set"
        id="element-attribute-set"></a><code>&lt;!-- Category:
        declaration --&gt;<br />
        &lt;xsl:attribute-set<br />
        &#160;&#160;<b>name</b> = <var>qname</var><br />
        &#160;&#160;use-attribute-sets? =
        <var>qnames</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: <a href=
        "index.html#element-attribute">xsl:attribute</a>* --&gt;<br />
        &lt;/xsl:attribute-set&gt;</code></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-attribute-set" id="dt-attribute-set" title=
        "attribute set"></a>The <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        element defines a named <b>attribute set</b>: that is, a
        collection of attribute <span>definitions</span> that can
        be used repeatedly on different constructed
        elements.<span class="definition">]</span></p>

        <p>The <span class="verb">required</span> <code>name</code>
        attribute specifies the name of the attribute set. The
        value of the <code>name</code> attribute is a <a title=
        "QName" href="index.html#dt-qname">QName</a>, which is expanded as
        described in <a href="index.html#qname"><i>5.1 Qualified
        Names</i></a>. The content of the <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        element consists of zero or more <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instructions that are evaluated to produce the attributes
        in the set.</p>

        <p>The result of evaluating an attribute set is a sequence
        of attribute nodes. Evaluating the same attribute set more
        than once can produce different results, because although
        an attribute set does not have parameters, it may contain
        expressions or instructions whose value depends on the
        evaluation context.</p>

        <p><a title="attribute set" href=
        "index.html#dt-attribute-set">Attribute sets</a> are used by
        specifying a <code>use-attribute-sets</code> attribute on
        the <a href="index.html#element-element"><code>xsl:element</code></a>
        or <a href="index.html#element-copy"><code>xsl:copy</code></a>
        instruction, or by specifying an
        <code>xsl:use-attribute-sets</code> attribute on a literal
        result element. An attribute set may be defined in terms of
        other attribute sets by using the
        <code>use-attribute-sets</code> attribute on the <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        element itself. The value of the
        <code>[xsl:]use-attribute-sets</code> attribute is in each
        case a whitespace-separated list of names of attribute
        sets. Each name is specified as a <a title="QName" href=
        "index.html#dt-qname">QName</a>, which is expanded as described in
        <a href="index.html#qname"><i>5.1 Qualified Names</i></a>.</p>

        <p>Specifying a <code>use-attribute-sets</code> attribute
        is broadly equivalent to adding <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instructions for each of the attributes in each of the
        named attribute sets to the beginning of the content of the
        instruction with the <code>[xsl:]use-attribute-sets</code>
        attribute, in the same order in which the names of the
        attribute sets are specified in the
        <code>use-attribute-sets</code> attribute.</p>

        <p>More formally, an <code>xsl:use-attribute-sets</code>
        attribute is expanded using the following recursive
        algorithm, or any algorithm that produces the same
        results:</p>

        <ul>
          <li>
            <p>The value of the attribute is tokenized as a list of
            QNames.</p>
          </li>

          <li>
            <p>Each QName in the list is processed, in order, as
            follows:</p>

            <ul>
              <li>
                <p>The QName must match the <code>name</code>
                attribute of one or more <a href=
                "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
                declarations in the stylesheet.</p>
              </li>

              <li>
                <p>Each <a href=
                "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
                declaration whose name matches is processed as
                follows. Where two such declarations have different
                <a title="import precedence" href=
                "index.html#dt-import-precedence">import precedence</a>, the
                one with lower import precedence is processed
                first. Where two declarations have the same import
                precedence, they are processed in <a title=
                "declaration order" href=
                "index.html#dt-declaration-order">declaration order</a>.</p>

                <ul>
                  <li>
                    <p>If the <a href=
                    "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
                    declaration has a
                    <code>use-attribute-sets</code> attribute, the
                    attribute is expanded by applying this
                    algorithm recursively.</p>
                  </li>

                  <li>
                    <p>If the <a href=
                    "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
                    declaration contains one or more <a href=
                    "index.html#element-attribute"><code>xsl:attribute</code></a>
                    instructions, these instructions are evaluated
                    (following the rules for evaluating a <a title=
                    "sequence constructor" href=
                    "index.html#dt-sequence-constructor">sequence
                    constructor</a>: see <a href=
                    "index.html#sequence-constructors"><i>5.7 Sequence
                    Constructors</i></a>) to produce a sequence of
                    attribute nodes. These attribute nodes are
                    appended to the result sequence.</p>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>

        <p>The <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instructions are evaluated using the same <a title="focus"
        href="index.html#dt-focus">focus</a> as is used for evaluating the
        element that is the parent of the
        <code>[xsl:]use-attribute-sets</code> attribute forming the
        initial input to the algorithm. However, the static context
        for the evaluation depends on the position of the <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction in the stylesheet: thus, only local variables
        declared within an <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction, and global variables, are visible.</p>

        <p>The set of attribute nodes produced by expanding
        <code>xsl:use-attribute-sets</code> may include several
        attributes with the same name. When the attributes are
        added to an element node, only the last of the duplicates
        will take effect.</p>

        <p>The way in which each instruction uses the results of
        expanding the <code>[xsl:]use-attribute-sets</code>
        attribute is described in the specification for the
        relevant instruction: see <a href=
        "index.html#literal-result-element"><i>11.1 Literal Result
        Elements</i></a>, <a href="index.html#xsl-element"><i>11.2 Creating
        Element Nodes Using xsl:element</i></a> , and <a href=
        "index.html#copying"><i>11.9 Copying Nodes</i></a>.</p>

        <p><a name="err-XTSE0710" id="err-XTSE0710"><span class=
        "error">[ERR XTSE0710]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the value of the <code>use-attribute-sets</code> attribute
        of an <a href="index.html#element-copy"><code>xsl:copy</code></a>,
        <a href="index.html#element-element"><code>xsl:element</code></a>, or
        <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        element, or the <code>xsl:use-attribute-sets</code>
        attribute of a <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result element</a>, is
        not a <span>whitespace-separated</span> sequence of
        <a title="QName" href="index.html#dt-qname">QNames</a>, or if it
        contains a QName that does not match the <code>name</code>
        attribute of any <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        declaration in the stylesheet.</p>

        <p><a name="err-XTSE0720" id="err-XTSE0720"><span class=
        "error">[ERR XTSE0720]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        element directly or indirectly references itself via the
        names contained in the <code>use-attribute-sets</code>
        attribute.</p>

        <p>Each attribute node produced by expanding an attribute
        set has a <a title="type annotation" href=
        "index.html#dt-annotation">type annotation</a> determined by the
        rules for the <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction that created the attribute node: see <a href=
        "index.html#annotation-for-constructed-attribute"><i>11.3.1 Setting
        the Type Annotation for a Constructed Attribute
        Node</i></a>. These type annotations may be preserved,
        stripped, or replaced as determined by the rules for the
        instruction that creates the element in which the
        attributes are used.</p>

        <p>Attribute sets are used as follows:</p>

        <ul>
          <li>
            <p>The <a href=
            "index.html#element-copy"><code>xsl:copy</code></a> and <a href=
            "index.html#element-element"><code>xsl:element</code></a>
            instructions have an <code>use-attribute-sets</code>
            attribute. The sequence of attribute nodes produced by
            evaluating this attribute is prepended to the sequence
            produced by evaluating the <a title=
            "sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a>
            contained within the instruction.</p>
          </li>

          <li>
            <p><a title="literal result element" href=
            "index.html#dt-literal-result-element">Literal result
            elements</a> allow an
            <code>xsl:use-attribute-sets</code> attribute, which is
            evaluated in the same way as the
            <code>use-attribute-sets</code> attribute of <a href=
            "index.html#element-element"><code>xsl:element</code></a> and
            <a href="index.html#element-copy"><code>xsl:copy</code></a>. The
            sequence of attribute nodes produced by evaluating this
            attribute is prepended to the sequence of attribute
            nodes produced by evaluating the attributes of the
            literal result element, which in turn is prepended to
            the sequence produced by evaluating the <a title=
            "sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a>
            contained with the literal result element.</p>
          </li>
        </ul>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e14293" id="d5e14293"></a>Example: Using
            Attribute Sets
          </div>

          <p>The following example creates a named <a title=
          "attribute set" href="index.html#dt-attribute-set">attribute
          set</a> <code>title-style</code> and uses it in a
          <a title="template rule" href=
          "index.html#dt-template-rule">template rule</a>.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="chapter/heading"&gt;
  &lt;fo:block font-stretch="condensed" xsl:use-attribute-sets="title-style"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:attribute-set name="title-style"&gt;
  &lt;xsl:attribute name="font-size"&gt;12pt&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="font-weight"&gt;bold&lt;/xsl:attribute&gt;
&lt;/xsl:attribute-set&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e14309" id="d5e14309"></a>Example:
            Overriding Attributes in an Attribute Set
          </div>

          <p>The following example creates a named attribute set
          <code>base-style</code> and uses it in a template rule
          with multiple specifications of the attributes:</p>

          <dl>
            <dt class="label">font-family</dt>

            <dd>
              <p>is specified only in the attribute set</p>
            </dd>

            <dt class="label">font-size</dt>

            <dd>
              <p>is specified in the attribute set, is specified on
              the literal result element, and in an <a href=
              "index.html#element-attribute"><code>xsl:attribute</code></a>
              instruction</p>
            </dd>

            <dt class="label">font-style</dt>

            <dd>
              <p>is specified in the attribute set, and on the
              literal result element</p>
            </dd>

            <dt class="label">font-weight</dt>

            <dd>
              <p>is specified in the attribute set, and in an
              <a href=
              "index.html#element-attribute"><code>xsl:attribute</code></a>
              instruction</p>
            </dd>
          </dl>

          <p>Stylesheet fragment:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:attribute-set name="base-style"&gt;
  &lt;xsl:attribute name="font-family"&gt;Univers&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="font-size"&gt;10pt&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="font-style"&gt;normal&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="font-weight"&gt;normal&lt;/xsl:attribute&gt;
&lt;/xsl:attribute-set&gt;

&lt;xsl:template match="o"&gt;
  &lt;fo:block xsl:use-attribute-sets="base-style"
            font-size="12pt"
            font-style="italic"&gt;
    &lt;xsl:attribute name="font-size"&gt;14pt&lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="font-weight"&gt;bold&lt;/xsl:attribute&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>Result:</p>

          <div class="exampleInner">
            <pre>
&lt;fo:block font-family="Univers"
          font-size="14pt"
          font-style="italic"
          font-weight="bold"&gt;
...
&lt;/fo:block&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="stylesheet-functions" id=
        "stylesheet-functions"></a>10.3 Stylesheet Functions</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-stylesheet-function" id="dt-stylesheet-function" title=
        "stylesheet function"></a>An <a href=
        "index.html#element-function"><code>xsl:function</code></a>
        declaration declares the name, parameters, and
        implementation of a <b>stylesheet function</b> that can be
        called from any XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> within the <a title=
        "stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>.<span class=
        "definition">]</span></p>

        <p class="element-syntax"><a name="element-function" id=
        "element-function"></a><code>&lt;!-- Category: declaration
        --&gt;<br />
        &lt;xsl:function<br />
        &#160;&#160;<b>name</b> = <var>qname</var><br />
        &#160;&#160;as? = <var>sequence-type</var><br />
        &#160;&#160;override? = "yes" | "no"&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-param">xsl:param</a>*,
        <var>sequence-constructor</var>) --&gt;<br />
        &lt;/xsl:function&gt;</code></p>

        <p>The <a href=
        "index.html#element-function"><code>xsl:function</code></a>
        declaration defines a <a title="stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> that can
        be called from any XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> used in the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        (including an XPath expression used within a predicate in a
        <a title="pattern" href="index.html#dt-pattern">pattern</a>). The
        <code>name</code> attribute specifies the name of the
        function. The value of the <code>name</code> attribute is a
        <a title="QName" href="index.html#dt-qname">QName</a>, which is
        expanded as described in <a href="index.html#qname"><i>5.1 Qualified
        Names</i></a>.</p>

        <p>An <a href=
        "index.html#element-function"><code>xsl:function</code></a>
        declaration can only appear as a top-level element in a
        <span>stylesheet module</span>.</p>

        <p><a name="err-XTSE0740" id="err-XTSE0740"><span class=
        "error">[ERR XTSE0740]</span></a> A <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a>
        <span class="verb">must</span> have a prefixed name, to
        remove any risk of a clash with a function in the default
        function namespace. It is a <a title="static error" href=
        "index.html#dt-static-error">static error</a> if the name has no
        prefix..</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>To prevent the namespace declaration used for the
          function name appearing in the result document, use the
          <code>exclude-result-prefixes</code> attribute on the
          <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element: see <a href="index.html#lre-namespaces"><i>11.1.3
          Namespace Nodes for Literal Result Elements</i></a>.</p>

          <p>The prefix <span class="verb">must not</span> refer to
          a <a title="reserved namespace" href=
          "index.html#dt-reserved-namespace">reserved namespace</a>:
          <span class="error">[see <a href="index.html#err-XTSE0080">ERR
          XTSE0080</a>]</span></p>
        </div>

        <p>The content of the <a href=
        "index.html#element-function"><code>xsl:function</code></a> element
        consists of zero or more <a href=
        "index.html#element-param"><code>xsl:param</code></a> elements that
        specify the formal arguments of the function, followed by
        <span>a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> that
        defines the value to be returned by the
        function.</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-arity"
        id="dt-arity" title="arity"></a>The <b>arity</b> of a
        stylesheet function is the number of <a href=
        "index.html#element-param"><code>xsl:param</code></a> elements in the
        function definition.<span class="definition">]</span>
        Optional arguments are not allowed.</p>

        <p><a name="err-XTSE0760" id="err-XTSE0760"><span class=
        "error">[ERR XTSE0760]</span></a> Because arguments to a
        stylesheet function call <span class="verb">must</span> all
        be specified, the <a href=
        "index.html#element-param"><code>xsl:param</code></a> elements within
        an <a href=
        "index.html#element-function"><code>xsl:function</code></a> element
        <span class="verb">must not</span> specify a default value:
        this means they <span class="verb">must</span> be empty,
        and <span class="verb">must not</span> have a
        <code>select</code> attribute.</p>

        <p>A <a title="stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> is
        included in the <em>in-scope functions</em> of the static
        context for all XPath expressions used in the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>,
        unless</p>

        <ul>
          <li>
            <p>there is another <a title="stylesheet function"
            href="index.html#dt-stylesheet-function">stylesheet function</a>
            with the same name and <a title="arity" href=
            "index.html#dt-arity">arity</a>, and higher <a title=
            "import precedence" href="index.html#dt-import-precedence">import
            precedence</a>, or</p>
          </li>

          <li>
            <p>the <code>override</code> attribute has the value
            <code>no</code> and there is already a function with
            the same name and <a title="arity" href=
            "index.html#dt-arity">arity</a> in the in-scope functions.</p>
          </li>
        </ul>

        <p>The optional <code>override</code> attribute defines
        what happens if this function has the same name and
        <a title="arity" href="index.html#dt-arity">arity</a> as a function
        provided by the implementer or made available in the static
        context using an implementation-defined mechanism. If the
        <code>override</code> attribute has the value
        <code>yes</code>, then this function is used in preference;
        if it has the value <code>no</code>, then the other
        function is used in preference. The default value is
        <code>yes</code>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Specifying <code>override="yes"</code> ensures
          interoperable behavior: the same code will execute with
          all processors. Specifying <code>override="no"</code> is
          useful when writing a fallback implementation of a
          function that is available with some processors but not
          others: it allows the vendor's implementation of the
          function <span>(or a user's implementation written as an
          extension function)</span> to be used in preference to
          the stylesheet implementation, which is useful when the
          <span>extension function</span> is more efficient.</p>

          <p>The <code>override</code> attribute does <em>not</em>
          affect the rules for deciding which of several <a title=
          "stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet functions</a> with
          the same name and <a title="arity" href=
          "index.html#dt-arity">arity</a> takes precedence.</p>
        </div>

        <p><a name="err-XTSE0770" id="err-XTSE0770"><span class=
        "error">[ERR XTSE0770]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> for
        a <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> to contain two or more
        functions with the same <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a>, the same <a title=
        "arity" href="index.html#dt-arity">arity</a>, and the same <a title=
        "import precedence" href="index.html#dt-import-precedence">import
        precedence</a>, unless there is another function with the
        same <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> and arity, and a
        higher import precedence.</p>

        <p>As defined in XPath, the function that is executed as
        the result of a function call is identified by looking in
        the in-scope functions of the static context for a function
        whose name and <a title="arity" href="index.html#dt-arity">arity</a>
        matches the name and number of arguments in the function
        call.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Functions are not polymorphic. Although the XPath
          function call mechanism allows two functions to have the
          same name and different <a title="arity" href=
          "index.html#dt-arity">arity</a>, it does not allow them to be
          distinguished by the types of their arguments.</p>
        </div>

        <p>The optional <code>as</code> attribute indicates the
        <a title="required type" href="index.html#dt-required-type">required
        type</a> of the result of the function. The value of the
        <code>as</code> attribute is a <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-SequenceType">SequenceType</a><sup>
        <small>XP</small></sup>, as defined in <a href=
        "index.html#xpath20">[XPath 2.0]</a>.</p>

        <p><a name="err-XTTE0780" id="err-XTTE0780"><span class=
        "error">[ERR XTTE0780]</span></a> If the <code>as</code>
        attribute is specified, then the result evaluated by the
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> (see
        <a href="index.html#sequence-constructors"><i>5.7 Sequence
        Constructors</i></a>) is converted to the required type,
        using the <a title="function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a>. It is a <a title="type errors" href=
        "index.html#dt-type-error">type error</a> if this conversion fails.
        If the <code>as</code> attribute is omitted, the calculated
        result is used as supplied, and no conversion takes
        place.</p>

        <p>If a <a title="stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> has been
        defined with a particular <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a>, then a call on
        <a href=
        "index.html#function-function-available"><code>function-available</code></a>
        will return true when called with an argument that is a
        <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
        QName</a> that expands to this same <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a>.</p>

        <p>The <a href="index.html#element-param"><code>xsl:param</code></a>
        elements define the formal arguments to the function. These
        are interpreted positionally. When the function is called
        using a function-call in an XPath <a title="expression"
        href="index.html#dt-expression">expression</a>, the first argument
        supplied is assigned to the first <a href=
        "index.html#element-param"><code>xsl:param</code></a> element, the
        second argument supplied is assigned to the second <a href=
        "index.html#element-param"><code>xsl:param</code></a> element, and so
        on.</p>

        <p>The <code>as</code> attribute of the <a href=
        "index.html#element-param"><code>xsl:param</code></a> element defines
        the required type of the parameter. The rules for
        converting the values of the actual arguments supplied in
        the function call to the types required by each <a href=
        "index.html#element-param"><code>xsl:param</code></a> element are
        defined in <a href="index.html#xpath20">[XPath 2.0]</a>. The rules
        that apply are those for the case where <a title=
        "XPath 1.0 compatibility mode" href=
        "index.html#dt-compatibility-mode">XPath 1.0 compatibility mode</a>
        is set to <code>false</code>.</p>

        <p><a name="err-XTTE0790" id="err-XTTE0790"><span class=
        "error">[ERR XTTE0790]</span></a> If the value of a
        parameter to a <a title="stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> cannot be
        converted to the required type, a <a title="type errors"
        href="index.html#dt-type-error">type error</a> is signaled.</p>

        <p>If the <code>as</code> attribute is omitted, no
        conversion takes place and any value is accepted.</p>

        <p>Within the body of a stylesheet function, the <a title=
        "focus" href="index.html#dt-focus">focus</a> is initially undefined;
        this means that any attempt to reference the context item,
        context position, or context size is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a>. <span>[XPDY0002]</span></p>

        <p>It is not possible within the body of the <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> to access
        the values of local variables that were in scope in the
        place where the function call was written. Global
        variables, however, remain available.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e14761" id="d5e14761"></a>Example: A
            Stylesheet Function
          </div>

          <p>The following example creates a recursive <a title=
          "stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a> named
          <code>str:reverse</code> that reverses the words in a
          supplied sentence, and then invokes this function from
          within a <a title="template rule" href=
          "index.html#dt-template-rule">template rule</a>.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:transform 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:str="http://example.com/namespace"
  version="2.0"
  exclude-result-prefixes="str"&gt;

&lt;xsl:function name="str:reverse" as="xs:string"&gt;
  &lt;xsl:param name="sentence" as="xs:string"/&gt;
  &lt;xsl:sequence  
     select="if (contains($sentence, ' '))
             then concat(str:reverse(substring-after($sentence, ' ')),
                         ' ',
                         substring-before($sentence, ' '))
             else $sentence"/&gt;
&lt;/xsl:function&gt;

&lt;xsl:template match="/"&gt;
&lt;output&gt;
  &lt;xsl:value-of select="str:reverse('DOG BITES MAN')"/&gt;
&lt;/output&gt;
&lt;/xsl:template&gt;

&lt;/xsl:transform&gt;
</pre>
          </div>

          <p>An alternative way of writing the same function is to
          implement the conditional logic at the XSLT level,
          thus:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:function name="str:reverse" as="xs:string"&gt;
  &lt;xsl:param name="sentence" as="xs:string"/&gt;
  &lt;xsl:choose&gt;
    &lt;xsl:when test="contains($sentence, ' ')"&gt;  
      &lt;xsl:sequence select="concat(str:reverse(substring-after($sentence, ' ')),
                                ' ',
                                substring-before($sentence, ' '))"/&gt;
    &lt;/xsl:when&gt;
    &lt;xsl:otherwise&gt;
      &lt;xsl:sequence select="$sentence"/&gt;
    &lt;/xsl:otherwise&gt;
  &lt;/xsl:choose&gt;
&lt;/xsl:function&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e14781" id="d5e14781"></a>Example: Declaring
            the Return Type of a Function
          </div>

          <p>The following example illustrates the use of the
          <code>as</code> attribute in a function definition. It
          returns a string containing the representation of its
          integer argument, expressed as a roman numeral. For
          example, the function call <code>num:roman(7)</code> will
          return the string <code>"vii"</code>. This example uses
          the <a href="index.html#element-number"><code>xsl:number</code></a>
          instruction, described in <a href="index.html#number"><i>12
          Numbering</i></a>. The <a href=
          "index.html#element-number"><code>xsl:number</code></a> instruction
          returns a text node, and the <a title=
          "function conversion rules" href=
          "index.html#dt-function-conversion-rules">function conversion
          rules</a> are invoked to convert this text node to the
          type declared in the <a href=
          "index.html#element-function"><code>xsl:function</code></a>
          element, namely <code>xs:string</code>. So the text node
          is <a title="atomize" href="index.html#dt-atomization">atomized</a>
          to a string.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:function name="num:roman" as="xs:string"&gt;
  &lt;xsl:param name="value" as="xs:integer"/&gt;
  &lt;xsl:number value="$value" format="i"/&gt;
&lt;/xsl:function&gt;
</pre>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="creating-new-nodes" id=
      "creating-new-nodes"></a>11 Creating Nodes and Sequences</h2>

      <p>This section describes instructions that directly create
      new nodes, or sequences of nodes and atomic values.</p>

      <div class="div2">
        <h3><a name="literal-result-element" id=
        "literal-result-element"></a>11.1 Literal Result
        Elements</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-literal-result-element" id="dt-literal-result-element"
        title="literal result element"></a>In a <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, an
        element in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> that does not belong to the
        <a title="XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
        namespace</a> and that is not an <a title=
        "extension instruction" href=
        "index.html#dt-extension-instruction">extension instruction</a> (see
        <a href="index.html#extension-instruction"><i>18.2 Extension
        Instructions</i></a>) is classified as a <b>literal result
        element</b>.<span class="definition">]</span> A literal
        result element is evaluated to construct a new element node
        with the same <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> <span>(that is, the
        same namespace URI, local name, and namespace
        prefix)</span>. The result of evaluating a literal result
        element is a node sequence containing one element, the
        newly constructed element node.</p>

        <p>The content of the element is a <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> (see
        <a href="index.html#sequence-constructors"><i>5.7 Sequence
        Constructors</i></a>). The sequence obtained by evaluating
        this sequence constructor, after prepending any attribute
        nodes produced as described in <a href=
        "index.html#attributes-for-lres"><i>11.1.2 Attribute Nodes for
        Literal Result Elements</i></a> and namespace nodes
        produced as described in <a href=
        "index.html#lre-namespaces"><i>11.1.3 Namespace Nodes for Literal
        Result Elements</i></a>, is used to construct the content
        of the element, following the rules in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a></p>

        <p>The base URI of the new element is copied from the base
        URI of the literal result element in the stylesheet, unless
        the content of the new element includes an
        <code>xml:base</code> attribute, in which case the base URI
        of the new element is the value of that attribute, resolved
        (if it is a relative URI) against the base URI of the
        literal result element in the stylesheet. (Note, however,
        that this is only relevant when creating a parentless
        element. When the literal result element is copied to form
        a child of an element or document node, the base URI of the
        new copy is taken from that of its new parent.)</p>

        <div class="div3">
          <h4><a name="setting-annotation-for-lre" id=
          "setting-annotation-for-lre"></a>11.1.1 Setting the Type
          Annotation for Literal Result Elements</h4>

          <p>The attributes <code>xsl:type</code> and
          <code>xsl:validation</code> may be used on a literal
          result element to invoke validation of the contents of
          the element against a type definition or element
          declaration in a schema, and to determine the <a title=
          "type annotation" href="index.html#dt-annotation">type
          annotation</a> that the new element node will carry.
          These attributes also affect the type annotation carried
          by any elements and attributes that have the new element
          node as an ancestor. These two attributes are both
          optional, and if one is specified then the other
          <span class="verb">must</span> be omitted.</p>

          <p>The value of the <code>xsl:validation</code>
          attribute, if present, must be one of the values
          <code>strict</code>, <code>lax</code>,
          <code>preserve</code>, or <code>strip</code>. The value
          of the <code>xsl:type</code> attribute, if present, must
          be a <a title="QName" href="index.html#dt-qname">QName</a>
          identifying a type definition that is present in the
          <a title="in-scope schema component" href=
          "index.html#dt-in-scope-schema-component">in-scope schema
          components</a> for the stylesheet. Neither attribute may
          be specified as an <a title="attribute value template"
          href="index.html#dt-attribute-value-template">attribute value
          template.</a> The effect of these attributes is described
          in <a href="index.html#validation"><i>19.2 Validation</i></a>.</p>
        </div>

        <div class="div3">
          <h4><a name="attributes-for-lres" id=
          "attributes-for-lres"></a>11.1.2 Attribute Nodes for
          Literal Result Elements</h4>

          <p>Attribute nodes for a literal result element may be
          created by including <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instructions within the <a title="sequence constructor"
          href="index.html#dt-sequence-constructor">sequence constructor</a>.
          Additionally, attribute nodes are created corresponding
          to the attributes of the literal result element in the
          stylesheet, and as a result of expanding the
          <code>xsl:use-attribute-sets</code> attribute of the
          literal result element, if present.</p>

          <p>The sequence that is used to construct the content of
          the literal result element (as described in <a href=
          "index.html#constructing-complex-content"><i>5.7.1 Constructing
          Complex Content</i></a>) is the concatenation of the
          following four sequences, in order:</p>

          <ol class="enumar">
            <li>
              <p>The sequence of namespace nodes produced as
              described in <a href="index.html#lre-namespaces"><i>11.1.3
              Namespace Nodes for Literal Result
              Elements</i></a>.</p>
            </li>

            <li>
              <p>The sequence of attribute nodes produced by
              expanding the <code>xsl:use-attribute-sets</code>
              attribute (if present) following the rules given in
              <a href="index.html#attribute-sets"><i>10.2 Named Attribute
              Sets</i></a></p>
            </li>

            <li>
              <p>The attributes produced by processing the
              attributes of the literal result element itself,
              other than attributes in the <a title="" href=
              "index.html#xslt-namespace">XSLT namespace</a>. The way these
              are processed is described below.</p>
            </li>

            <li>
              <p>The sequence produced by evaluating the contained
              <a title="sequence constructor" href=
              "index.html#dt-sequence-constructor">sequence constructor</a>,
              if the element is not empty.</p>
            </li>
          </ol>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The significance of this order is that an attribute
            produced by an <code>xsl:attribute</code><span>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>, or
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a></span>
            instruction in the content of the literal result
            element takes precedence over an attribute produced by
            expanding an attribute of the literal result element
            itself, which in turn takes precedence over an
            attribute produced by expanding the
            <code>xsl:use-attribute-sets</code> attribute. This is
            because of the rules in <a href=
            "index.html#constructing-complex-content"><i>5.7.1 Constructing
            Complex Content</i></a>, which specify that when two or
            more attributes in the sequence have the same name, all
            but the last of the duplicates are discarded.</p>

            <p>Although the above rules place namespace nodes
            before attributes, this is not strictly necessary,
            because the rules in <a href=
            "index.html#constructing-complex-content"><i>5.7.1 Constructing
            Complex Content</i></a> allow the namespaces and
            attributes to appear in any order so long as both come
            before other kinds of node. The order of namespace
            nodes and attribute nodes in the sequence has no effect
            on the relative position of the nodes in document order
            once they are added to a tree.</p>
          </div>

          <p>Each attribute of the literal result element, other
          than an attribute in the <a title="XSLT namespace" href=
          "index.html#dt-xslt-namespace">XSLT namespace</a>, is processed to
          produce an attribute for the element in the <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a>.</p>

          <p>The value of such an attribute is interpreted as an
          <a title="attribute value template" href=
          "index.html#dt-attribute-value-template">attribute value
          template</a>: it can therefore contain <a title=
          "expression" href="index.html#dt-expression">expressions</a>
          contained in curly brackets (<code>{}</code>). The new
          attribute node will have the same <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> <span>(that is,
          the same namespace URI, local name, and namespace
          prefix)</span> as the attribute in the stylesheet tree,
          and its <a title="string value" href=
          "index.html#dt-string-value">string value</a> will be the same as
          the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          attribute in the stylesheet tree. The <a title=
          "type annotation" href="index.html#dt-annotation">type
          annotation</a> on the attribute will initially be
          <span><code>xs:untypedAtomic</code></span>, and the
          <a title="typed value" href="index.html#dt-typed-value">typed
          value</a> of the attribute node will be the same as its
          <a title="string value" href="index.html#dt-string-value">string
          value</a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The eventual <a title="type annotation" href=
            "index.html#dt-annotation">type annotation</a> of the attribute
            in the <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a> depends on the
            <code>xsl:validation</code> and <code>xsl:type</code>
            attributes of the parent literal result element, and on
            the instructions used to create its ancestor elements.
            If the <code>xsl:validation</code> attribute is set to
            <code>preserve</code> or <code>strip</code>, the type
            annotation will be
            <span><code>xs:untypedAtomic</code></span>, and the
            <a title="typed value" href="index.html#dt-typed-value">typed
            value</a> of the attribute node will be the same as its
            <a title="string value" href="index.html#dt-string-value">string
            value</a>. If the <code>xsl:validation</code> attribute
            is set to <code>strict</code> or <code>lax</code>, or
            if the <code>xsl:type</code> attribute is used, the
            type annotation on the attribute will be set as a
            result of the schema validation process applied to the
            parent element. If neither attribute is present, the
            type annotation on the attribute will be
            <span><code>xs:untypedAtomic</code></span>.</p>
          </div>

          <p>If the name of a constructed attribute is
          <code>xml:id</code>, the processor must perform attribute
          value normalization by effectively applying the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-normalize-space">
          <code>normalize-space</code></a><sup><small>FO</small></sup>
          function to the value of the attribute, and the resulting
          attribute node must be given the <code>is-id</code>
          property.</p>

          <p><a name="err-XTRE0795" id="err-XTRE0795"><span class=
          "error">[ERR XTRE0795]</span></a> It is a <a title=
          "recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          the name of a constructed attribute is
          <code>xml:space</code> and the value is not either
          <code>default</code> or <code>preserve</code>. The
          <a title="optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to construct the attribute with the value
          as requested.. This applies whether the attribute is
          constructed using a literal result element, or by using
          the <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>, or
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instructions.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The <code>xml:base</code>, <code>xml:lang</code>,
            <code>xml:space</code>, and <code>xml:id</code>
            attributes have two effects in XSLT. They behave as
            standard XSLT attributes, which means for example that
            if they appear on a literal result element, they will
            be copied to the <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a> in the same way as
            any other attribute. In addition, they have their
            standard meaning as defined in the core XML
            specifications. Thus, an <code>xml:base</code>
            attribute in the stylesheet affects the base URI of the
            element on which it appears, and an
            <code>xml:space</code> attribute affects the
            interpretation of <a title="whitespace text node" href=
            "index.html#dt-whitespace-text-node">whitespace text nodes</a>
            within that element. One consequence of this is that it
            is inadvisable to write these attributes as attribute
            value templates: although an XSLT processor will
            understand this notation, the XML parser will not. See
            also <a href="index.html#namespace-aliasing"><i>11.1.4 Namespace
            Aliasing</i></a> which describes how to use <a href=
            "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
            with these attributes.</p>

            <p>The same is true of the schema-defined attributes
            <code>xsi:type</code>, <code>xsi:nil</code>,
            <span><code>xsi:noNamespaceSchemaLocation</code></span>,
            and <code>xsi:schemaLocation</code>. If the stylesheet
            is processed by a schema processor, these attributes
            will be recognized and interpreted by the schema
            processor, but <span>in addition the XSLT processor
            treats them like any other attribute on a literal
            result element: that is, their <a title=
            "effective value" href="index.html#dt-effective-value">effective
            value</a> (after expanding <a title=
            "attribute value template" href=
            "index.html#dt-attribute-value-template">attribute value
            templates</a>) is copied to the result tree in the same
            way as any other attribute.</span> If the <a title=
            "result tree" href="index.html#dt-result-tree">result tree</a> is
            validated, the copied attributes will again be
            recognized and interpreted by the schema processor.</p>

            <p>None of these attributes will be generated in the
            <a title="result tree" href="index.html#dt-result-tree">result
            tree</a> unless the stylesheet writes them to the
            result tree explicitly, in the same way as any other
            attribute.</p>
          </div>

          <p><a name="err-XTSE0805" id="err-XTSE0805"><span class=
          "error">[ERR XTSE0805]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if an attribute on a literal result element is in the
          <a title="XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>, unless it is one of the attributes
          explicitly defined in this specification.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>If there is a need to create attributes in the XSLT
            namespace, this can be achieved using <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>, or
            by means of the <a href=
            "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
            declaration.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="lre-namespaces" id=
          "lre-namespaces"></a>11.1.3 Namespace Nodes for Literal
          Result Elements</h4>

          <p>The created element node will have a copy of the
          namespace nodes that were present on the element node in
          the stylesheet tree with the exception of any namespace
          node whose <a title="string value" href=
          "index.html#dt-string-value">string value</a> is designated as an
          <b>excluded namespace</b>. Special considerations apply
          to aliased namespaces: see <a href=
          "index.html#namespace-aliasing"><i>11.1.4 Namespace
          Aliasing</i></a></p>

          <p>The following namespaces are designated as excluded
          namespaces:</p>

          <ul>
            <li>
              <p>The <a title="XSLT namespace" href=
              "index.html#dt-xslt-namespace">XSLT namespace</a> URI
              (<code>http://www.w3.org/1999/XSL/Transform</code>)</p>
            </li>

            <li>
              <p>A namespace URI declared as an extension namespace
              (see <a href="index.html#extension-instruction"><i>18.2
              Extension Instructions</i></a>)</p>
            </li>

            <li>
              <p>A namespace URI designated by using an
              <code>[xsl:]exclude-result-prefixes</code> attribute
              either on the literal result element itself or on an
              ancestor element. The attribute <span class=
              "verb">must</span> be in the XSLT namespace only if
              its parent element is <em>not</em> in the XSLT
              namespace.</p>

              <p>The value of the attribute is either
              <code>#all</code>, or a whitespace-separated list of
              tokens, each of which is either a namespace prefix or
              <code>#default</code>. The namespace bound to each of
              the prefixes is designated as an excluded
              namespace.</p>

              <p><a name="err-XTSE0808" id=
              "err-XTSE0808"><span class="error">[ERR
              XTSE0808]</span></a> It is a <a title="static error"
              href="index.html#dt-static-error">static error</a> if a
              namespace prefix is used within the
              <code>[xsl:]exclude-result-prefixes</code> attribute
              and there is no namespace binding in scope for that
              prefix.</p>

              <p>The default namespace of the parent element of the
              <code>[xsl:]exclude-result-prefixes</code> attribute
              (see <a href=
              "http://www.w3.org/TR/xpath-datamodel/#ElementNode">Section
              6.2 Element Nodes</a><sup><small>DM</small></sup>)
              may be designated as an excluded namespace by
              including <code>#default</code> in the list of
              namespace prefixes.</p>

              <p><a name="err-XTSE0809" id=
              "err-XTSE0809"><span class="error">[ERR
              XTSE0809]</span></a> It is a <a title="static error"
              href="index.html#dt-static-error">static error</a> if the value
              <code>#default</code> is used within the
              <code>[xsl:]exclude-result-prefixes</code> attribute
              and the parent element of the
              <code>[xsl:]exclude-result-prefixes</code> attribute
              has no default namespace.</p>

              <p>The value <code>#all</code> indicates that all
              namespaces that are in scope for the stylesheet
              element that is the parent of the
              <code>[xsl:]exclude-result-prefixes</code> attribute
              are designated as excluded namespaces.</p>

              <p>The designation of a namespace as an excluded
              namespace is effective within the subtree of the
              stylesheet module rooted at the element bearing the
              <code>[xsl:]exclude-result-prefixes</code> attribute;
              a subtree rooted at an <a href=
              "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
              element does not include any stylesheet modules
              imported or included by children of that <a href=
              "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
              element.</p>
            </li>
          </ul>

          <p>The excluded namespaces, as described above,
          <em>only</em> affect namespace nodes copied from the
          stylesheet when processing a literal result element.
          There is no guarantee that an excluded namespace will not
          appear on the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a> for some other reason.
          Namespace nodes are also written to the result tree as
          part of the process of namespace fixup (see <a href=
          "index.html#namespace-fixup"><i>5.7.3 Namespace Fixup</i></a>), or
          as the result of instructions such as <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> and <a href=
          "index.html#element-element"><code>xsl:element</code></a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>When a stylesheet uses a namespace declaration only
            for the purposes of addressing a <a title="source tree"
            href="index.html#dt-source-tree">source tree</a>, specifying the
            prefix in the
            <code>[xsl:]exclude-result-prefixes</code> attribute
            will avoid superfluous namespace declarations in the
            serialized <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a>. The attribute is
            also useful to prevent namespaces used solely for the
            naming of stylesheet functions or extension functions
            from appearing in the serialized result tree.</p>
          </div>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e15344" id="d5e15344"></a>Example:
              Excluding Namespaces from the Result Tree
            </div>

            <p>For example, consider the following stylesheet:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:stylesheet xsl:version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:a="a.uri"
  xmlns:b="b.uri"&gt;
  exclude-result-prefixes="#all"&gt;
  
&lt;xsl:template match="/"&gt;
  &lt;foo xmlns:c="c.uri" xmlns:d="d.uri" xmlns:a2="a.uri" 
       xsl:exclude-result-prefixes="c"/&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
            </div>

            <p>The result of this stylesheet will be:</p>

            <div class="exampleInner">
              <pre>
&lt;foo xmlns:d="d.uri"/&gt;
</pre>
            </div>

            <p>The namespaces <code>a.uri</code> and
            <code>b.uri</code> are excluded by virtue of the
            <code>exclude-result-prefixes</code> attribute on the
            <a href=
            "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
            element, and the namespace <code>c.uri</code> is
            excluded by virtue of the
            <code>xsl:exclude-result-prefixes</code> attribute on
            the <code>foo</code> element. The setting
            <code>#all</code> does not affect the namespace
            <code>d.uri</code> because <code>d.uri</code> is not an
            in-scope namespace for the <a href=
            "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
            element. The element in the <a title="result tree"
            href="index.html#dt-result-tree">result tree</a> does not have a
            namespace node corresponding to
            <code>xmlns:a2="a.uri"</code> because the effect of
            <code>exclude-result-prefixes</code> is to designate
            the namespace URI <code>a.uri</code> as an excluded
            namespace, irrespective of how many prefixes are bound
            to this namespace URI.</p>

            <p>If the stylesheet is changed so that the literal
            result element has an attribute <code>b:bar="3"</code>,
            then the element in the <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a> will typically have a
            namespace declaration <code>xmlns:b="b.uri"</code>
            <span>(the processor may choose a different namespace
            prefix if this is necessary to avoid conflicts)</span>.
            The <code>exclude-result-prefixes</code> attribute
            makes <code>b.uri</code> an excluded namespace, so the
            namespace node is not automatically copied from the
            stylesheet, but the presence of an attribute whose name
            is in the namespace <code>b.uri</code> forces the
            namespace fixup process (see <a href=
            "index.html#namespace-fixup"><i>5.7.3 Namespace Fixup</i></a>) to
            introduce a namespace node for this namespace.</p>
          </div>

          <p>A literal result element may have an optional
          <code>xsl:inherit-namespaces</code> attribute, with the
          value <code>yes</code> or <code>no</code>. The default
          value is <code>yes</code>. If the value is set to
          <code>yes</code>, or is omitted, then the namespace nodes
          created for the newly constructed element are copied to
          the children and descendants of the newly constructed
          element, as described in <a href=
          "index.html#constructing-complex-content"><i>5.7.1 Constructing
          Complex Content</i></a>. If the value is set to
          <code>no</code>, then these namespace nodes are not
          automatically copied to the children. This may result in
          namespace undeclarations (such as <code>xmlns=""</code>
          or, in the case of XML 1.1, <code>xmlns:p=""</code>)
          appearing on the child elements when a <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a> is serialized.</p>
        </div>

        <div class="div3">
          <h4><a name="namespace-aliasing" id=
          "namespace-aliasing"></a>11.1.4 Namespace Aliasing</h4>

          <p>When a stylesheet is used to define a transformation
          whose output is itself a stylesheet module, or in certain
          other cases where the result document uses namespaces
          that it would be inconvenient to use in the stylesheet,
          namespace aliasing can be used to declare a mapping
          between a namespace URI used in the stylesheet and the
          corresponding namespace URI to be used in the result
          document.</p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-literal-namespace-uri" id="dt-literal-namespace-uri"
          title="literal namespace URI"></a>A namespace URI in the
          stylesheet tree that is being used to specify a namespace
          URI in the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a> is called a <b>literal
          namespace URI</b>.<span class="definition">]</span></p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-target-namespace-uri" id="dt-target-namespace-uri"
          title="target namespace URI"></a>The namespace URI that
          is to be used in the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a> as a substitute for a
          <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> is
          called the <b>target namespace URI</b>.<span class=
          "definition">]</span></p>

          <p>Either of the <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> or
          the <a title="target namespace URI" href=
          "index.html#dt-target-namespace-uri">target namespace URI</a> can
          be <em>null</em>: this is treated as a reference to the
          set of names that are in no namespace.</p>

          <p class="element-syntax"><a name=
          "element-namespace-alias" id=
          "element-namespace-alias"></a><code>&lt;!-- Category:
          declaration --&gt;<br />
          &lt;xsl:namespace-alias<br />
          &#160;&#160;<b>stylesheet-prefix</b> = <var>prefix</var>
          | "#default"<br />
          &#160;&#160;<b>result-prefix</b> = <var>prefix</var> |
          "#default"&#160;/&gt;</code></p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name="dt-alias"
          id="dt-alias" title="alias"></a>A stylesheet can use the
          <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          element to declare that a <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> is
          being used as an <b>alias</b> for a <a title=
          "target namespace URI" href=
          "index.html#dt-target-namespace-uri">target namespace
          URI</a>.<span class="definition">]</span></p>

          <p>The effect is that when names in the namespace
          identified by the <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> are
          copied to the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a>, the namespace URI in
          the result tree will be the <a title=
          "target namespace URI" href=
          "index.html#dt-target-namespace-uri">target namespace URI</a>,
          instead of the literal namespace URI. This applies
          to:</p>

          <ul>
            <li>
              <p>the namespace URI in the <a title="expanded-QName"
              href="index.html#dt-expanded-qname">expanded-QName</a> of a
              literal result element in the stylesheet</p>
            </li>

            <li>
              <p>the namespace URI in the <a title="expanded-QName"
              href="index.html#dt-expanded-qname">expanded-QName</a> of an
              attribute specified on a literal result element in
              the stylesheet</p>
            </li>
          </ul>

          <p>Where namespace aliasing changes the namespace URI
          part of the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> containing the
          name of an element or attribute node, the namespace
          prefix in that expanded-QName is replaced by the prefix
          indicated by the <code>result-prefix</code> attribute of
          the <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          declaration.</p>

          <p>The <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          element declares that the namespace URI bound to the
          prefix specified by the <code>stylesheet-prefix</code> is
          the <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a>,
          and the namespace URI bound to the prefix specified by
          the <code>result-prefix</code> attribute is the <a title=
          "target namespace URI" href=
          "index.html#dt-target-namespace-uri">target namespace URI</a>.
          Thus, the <code>stylesheet-prefix</code> attribute
          specifies the namespace URI that will appear in the
          stylesheet, and the <code>result-prefix</code> attribute
          specifies the corresponding namespace URI that will
          appear in the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a>.</p>

          <p>The default namespace (as declared by
          <code>xmlns</code>) may be specified by using
          <code>#default</code> instead of a prefix. <span>If no
          default namespace is in force, specifying
          <code>#default</code> denotes the null namespace URI.
          This allows elements that are in no namespace in the
          stylesheet to acquire a namespace in the result document,
          or vice versa.</span></p>

          <p>If a <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> is
          declared to be an alias for multiple different <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">target namespace URIs</a>,
          then the declaration with the highest <a title=
          "import precedence" href="index.html#dt-import-precedence">import
          precedence</a> is used.</p>

          <p><a name="err-XTSE0810" id="err-XTSE0810"><span class=
          "error">[ERR XTSE0810]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if there is more than one such declaration with the same
          <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> and
          the same <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a> and
          different values for the <a title="target namespace URI"
          href="index.html#dt-target-namespace-uri">target namespace URI</a>,
          unless there is also an <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          declaration with the same <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> and
          a higher import precedence.</p>

          <p><a name="err-XTSE0812" id="err-XTSE0812"><span class=
          "error">[ERR XTSE0812]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if a value other than <code>#default</code> is specified
          for either the <code>stylesheet-prefix</code> or the
          <code>result-prefix</code> attributes of the <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          element when there is no in-scope binding for that
          namespace prefix.</p>

          <p>When a literal result element is processed, its
          namespace nodes are handled as follows:</p>

          <ul>
            <li>
              <p>A namespace node whose string value is a <a title=
              "literal namespace URI" href=
              "index.html#dt-literal-namespace-uri">literal namespace URI</a>
              is not copied to the <a title="result tree" href=
              "index.html#dt-result-tree">result tree</a>.</p>
            </li>

            <li>
              <p>A namespace node whose string value is a <a title=
              "target namespace URI" href=
              "index.html#dt-target-namespace-uri">target namespace URI</a>
              is copied to the <a title="result tree" href=
              "index.html#dt-result-tree">result tree</a>, whether or not the
              URI identifies an excluded namespace.</p>
            </li>
          </ul>

          <p>In the event that the same URI is used as a <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> and
          a <a title="target namespace URI" href=
          "index.html#dt-target-namespace-uri">target namespace URI</a>, the
          second of these rules takes precedence.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>These rules achieve the effect that the element
            generated from the literal result element will have an
            in-scope namespace node that binds the
            <code>result-prefix</code> to the <a title=
            "target namespace URI" href=
            "index.html#dt-target-namespace-uri">target namespace URI</a>,
            provided that the namespace declaration associating
            this prefix with this URI is in scope for both the
            <a href=
            "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
            instruction and for the literal result element.
            Conversely, the <code>stylesheet-prefix</code> and the
            <a title="literal namespace URI" href=
            "index.html#dt-literal-namespace-uri">literal namespace URI</a>
            will not normally appear in the <a title="result tree"
            href="index.html#dt-result-tree">result tree</a>.</p>
          </div>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e15715" id="d5e15715"></a>Example: Using
              <code>xsl:namespace-alias</code> to Generate a
              Stylesheet
            </div>

            <p>When literal result elements are being used to
            create element, attribute, or namespace nodes that use
            the <a title="XSLT namespace" href=
            "index.html#dt-xslt-namespace">XSLT namespace</a> URI, the
            stylesheet may use an alias.</p>

            <p>For example, the stylesheet</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  xmlns:axsl="file://namespace.alias"&gt;

&lt;xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/&gt;

&lt;xsl:template match="/"&gt;
  &lt;axsl:stylesheet version="2.0"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/axsl:stylesheet&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="elements"&gt;
  &lt;axsl:template match="/"&gt;
     &lt;axsl:comment select="system-property('xsl:version')"/&gt;
     &lt;axsl:apply-templates/&gt;
  &lt;/axsl:template&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="block"&gt;
  &lt;axsl:template match="{.}"&gt;
     &lt;fo:block&gt;&lt;axsl:apply-templates/&gt;&lt;/fo:block&gt;
  &lt;/axsl:template&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
            </div>

            <p>will generate an XSLT stylesheet from a document of
            the form:</p>

            <div class="exampleInner">
              <pre>
&lt;elements&gt;
&lt;block&gt;p&lt;/block&gt;
&lt;block&gt;h1&lt;/block&gt;
&lt;block&gt;h2&lt;/block&gt;
&lt;block&gt;h3&lt;/block&gt;
&lt;block&gt;h4&lt;/block&gt;
&lt;/elements&gt;
</pre>
            </div>

            <p>The output of the transformation will be a
            stylesheet such as the following. Whitespace has been
            added for clarity. Note that an implementation may
            output different namespace prefixes from those
            appearing in this example; however, the rules guarantee
            that there will be a namespace node that binds the
            prefix <code>xsl</code> to the URI
            <code>http://www.w3.org/1999/XSL/Transform</code>,
            which makes it safe to use the QName
            <code>xsl:version</code> in the content of the
            generated stylesheet.</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;

&lt;xsl:template match="/"&gt;
  &lt;xsl:comment select="system-property('xsl:version')"/&gt;
  &lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
  
&lt;xsl:template match="p"&gt;
  &lt;fo:block&gt;&lt;xsl:apply-templates/&gt;&lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="h1"&gt;
  &lt;fo:block&gt;&lt;xsl:apply-templates/&gt;&lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="h2"&gt;
  &lt;fo:block&gt;&lt;xsl:apply-templates/&gt;&lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="h3"&gt;
  &lt;fo:block&gt;&lt;xsl:apply-templates/&gt;&lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="h4"&gt;
  &lt;fo:block&gt;&lt;xsl:apply-templates/&gt;&lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
            </div>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>It may be necessary also to use aliases for
            namespaces other than the XSLT namespace URI. For
            example, it can be useful to define an alias for the
            namespace
            <code>http://www.w3.org/2001/XMLSchema-instance</code>,
            so that the stylesheet can use the attributes
            <code>xsi:type</code>, <code>xsi:nil</code>, and
            <code>xsi:schemaLocation</code> on a literal result
            element, without running the risk that a schema
            processor will interpret these as applying to the
            stylesheet itself. Equally, literal result elements
            belonging to a namespace dealing with digital
            signatures might cause XSLT stylesheets to be
            mishandled by general-purpose security software; using
            an alias for the namespace would avoid the possibility
            of such mishandling.</p>
          </div>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e15762" id="d5e15762"></a>Example:
              Aliasing the XML Namespace
            </div>

            <p>It is possible to define an alias for the XML
            namespace.</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:stylesheet xmlns:axml="http://www.example.com/alias-xml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0"&gt;

&lt;xsl:namespace-alias stylesheet-prefix="axml" result-prefix="xml"/&gt;

&lt;xsl:template match="/"&gt;
  &lt;name axml:space="preserve"&gt;
    &lt;first&gt;James&lt;/first&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;last&gt;Clark&lt;/last&gt;
  &lt;/name&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
            </div>

            <p>produces the output:</p>

            <div class="exampleInner">
              <pre>
&lt;name xml:space="preserve"&gt;&lt;first&gt;James&lt;/first&gt; &lt;last&gt;Clark&lt;/last&gt;&lt;/name&gt;
</pre>
            </div>

            <p>This allows an <code>xml:space</code> attribute to
            be generated in the output without affecting the way
            the stylesheet is parsed. The same technique can be
            used for other attributes such as
            <code>xml:lang</code>, <code>xml:base</code>, and
            <code>xml:id</code>.</p>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Namespace aliasing is only necessary when literal
            result elements are used. The problem of reserved
            namespaces does not arise when using <a href=
            "index.html#element-element"><code>xsl:element</code></a> and
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a> to
            construct the <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a>. Therefore, as an
            alternative to using <a href=
            "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>,
            it is always possible to achieve the desired effect by
            replacing literal result elements with <a href=
            "index.html#element-element"><code>xsl:element</code></a> and
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>
            instructions.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="xsl-element" id="xsl-element"></a>11.2
        Creating Element Nodes Using <code>xsl:element</code></h3>

        <p class="element-syntax"><a name="element-element" id=
        "element-element"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:element<br />
        &#160;&#160;<b>name</b> = { <var>qname</var> }<br />
        &#160;&#160;namespace? = { <var>uri-reference</var> }<br />
        &#160;&#160;inherit-namespaces? = "yes" | "no"<br />
        &#160;&#160;use-attribute-sets? = <var>qnames</var><br />
        &#160;&#160;type? = <var>qname</var><br />
        &#160;&#160;validation? = "strict" | "lax" | "preserve" |
        "strip"&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:element&gt;</code></p>

        <p>The <a href=
        "index.html#element-element"><code>xsl:element</code></a> instruction
        allows an element to be created with a computed name. The
        <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of the element to
        be created is specified by a <span class=
        "verb">required</span> <code>name</code> attribute and an
        optional <code>namespace</code> attribute.</p>

        <p>The content of the <a href=
        "index.html#element-element"><code>xsl:element</code></a> instruction
        is a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> for the
        children, attributes, and namespaces of the created
        element. The sequence obtained by evaluating this sequence
        constructor (see <a href="index.html#sequence-constructors"><i>5.7
        Sequence Constructors</i></a>) is used to construct the
        content of the element, as described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>.</p>

        <p>The <a href=
        "index.html#element-element"><code>xsl:element</code></a> element may
        have a <code>use-attribute-sets</code> attribute, whose
        value is a whitespace-separated list of QNames that
        identify <a href=
        "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
        declarations. If this attribute is present, it is expanded
        as described in <a href="index.html#attribute-sets"><i>10.2 Named
        Attribute Sets</i></a> to produce a sequence of attribute
        nodes. This sequence is prepended to the sequence produced
        as a result of evaluating the <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, as
        described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>.</p>

        <p>The result of evaluating the <a href=
        "index.html#element-element"><code>xsl:element</code></a>
        instruction, except in error cases, is the newly
        constructed element node.</p>

        <p>The <code>name</code> attribute is interpreted as an
        <a title="attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>, whose <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> <span class=
        "verb">must</span> be a <a title="lexical QName" href=
        "index.html#dt-lexical-qname">lexical QName</a>.</p>

        <p><a name="err-XTDE0820" id="err-XTDE0820"><span class=
        "error">[ERR XTDE0820]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is not a <a title=
        "lexical QName" href="index.html#dt-lexical-qname">lexical
        QName</a>.</p>

        <p><a name="err-XTDE0830" id="err-XTDE0830"><span class=
        "error">[ERR XTDE0830]</span></a> In the case of an
        <a href="index.html#element-element"><code>xsl:element</code></a>
        instruction with no <code>namespace</code> attribute, it is
        a <a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is a <a title="QName" href=
        "index.html#dt-qname">QName</a> whose prefix is not declared in an
        in-scope namespace declaration for the <a href=
        "index.html#element-element"><code>xsl:element</code></a>
        instruction.</p>

        <p>If the <code>namespace</code> attribute is not present
        then the <a title="QName" href="index.html#dt-qname">QName</a> is
        expanded into an <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> using the namespace
        declarations in effect for the <a href=
        "index.html#element-element"><code>xsl:element</code></a> element,
        including any default namespace declaration.</p>

        <p>If the <code>namespace</code> attribute is present, then
        it too is interpreted as an <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>. The <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a>
        <span><span class="verb">must</span> be in the lexical
        space of the <code>xs:anyURI</code> type.</span> If the
        string is zero-length, then the <a title="expanded-QName"
        href="index.html#dt-expanded-qname">expanded-QName</a> of the element
        has a null namespace URI. Otherwise, the string is used as
        the namespace URI of the <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of the element to
        be created. The local part of the <a title="lexical QName"
        href="index.html#dt-lexical-qname">lexical QName</a> specified by the
        <code>name</code> attribute is used as the local part of
        the <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of the element to
        be created.</p>

        <p><a name="err-XTDE0835" id="err-XTDE0835"><span class=
        "error">[ERR XTDE0835]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>namespace</code> attribute is not in the lexical
        space of the <code>xs:anyURI</code> data type.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The <span>XDM</span> data model requires the name of a
          node to be an instance of <code>xs:QName</code>, and XML
          Schema defines the namespace part of an
          <code>xs:QName</code> to be an instance of
          <code>xs:anyURI</code>. However, the schema
          specification, and the specifications that it refers to,
          give implementations some flexibility in how strictly
          they enforce these constraints.</p>
        </div>

        <p>The prefix of the <a title="lexical QName" href=
        "index.html#dt-lexical-qname">lexical QName</a> specified in the
        <code>name</code> attribute (or the absence of a prefix) is
        copied to the prefix part of the <a title="expanded-QName"
        href="index.html#dt-expanded-qname">expanded-QName</a> representing
        the name of the new element node. In the event of a
        conflict <span>a prefix may subsequently be added, changed,
        or removed</span> during the namespace fixup process (see
        <a href="index.html#namespace-fixup"><i>5.7.3 Namespace
        Fixup</i></a>).</p>

        <p>The <a href=
        "index.html#element-element"><code>xsl:element</code></a> instruction
        has an optional <code>inherit-namespaces</code> attribute,
        with the value <code>yes</code> or <code>no</code>. The
        default value is <code>yes</code>. If the value is set to
        <code>yes</code>, or is omitted, then the namespace nodes
        created for the newly constructed element (whether these
        were copied from those of the source node, or generated as
        a result of namespace fixup) are copied to the children and
        descendants of the newly constructed element, as described
        in <a href="index.html#constructing-complex-content"><i>5.7.1
        Constructing Complex Content</i></a>. If the value is set
        to <code>no</code>, then these namespace nodes are not
        automatically copied to the children. This may result in
        namespace undeclarations (such as <code>xmlns=""</code> or,
        in the case of XML Namespaces 1.1, <code>xmlns:p=""</code>)
        appearing on the child elements when a <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a> is serialized.</p>

        <p>The base URI of the new element is copied from the base
        URI of the <a href=
        "index.html#element-element"><code>xsl:element</code></a> instruction
        in the stylesheet, unless the content of the new element
        includes an <code>xml:base</code> attribute, in which case
        the base URI of the new element is the value of that
        attribute, resolved (if it is a relative URI) against the
        base URI of the <a href=
        "index.html#element-element"><code>xsl:element</code></a> instruction
        in the stylesheet. (Note, however, that this is only
        relevant when creating parentless elements. When the new
        element is copied to form a child of an element or document
        node, the base URI of the new copy is taken from that of
        its new parent.)</p>

        <div class="div3">
          <h4><a name="annotation-for-constructed-element" id=
          "annotation-for-constructed-element"></a>11.2.1 Setting
          the Type Annotation for a Constructed Element Node</h4>

          <p>The optional attributes <code>type</code> and
          <code>validation</code> may be used on the <a href=
          "index.html#element-element"><code>xsl:element</code></a>
          instruction to invoke validation of the contents of the
          element against a type definition or element declaration
          in a schema, and to determine the <a title=
          "type annotation" href="index.html#dt-annotation">type
          annotation</a> that the new element node will carry.
          These attributes also affect the type annotation carried
          by any elements and attributes that have the new element
          node as an ancestor. These two attributes are both
          optional, and if one is specified then the other
          <span class="verb">must</span> be omitted. The permitted
          values of these attributes and their semantics are
          described in <a href="index.html#validation"><i>19.2
          Validation</i></a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The final type annotation of the element in the
            <a title="result tree" href="index.html#dt-result-tree">result
            tree</a> also depends on the <code>type</code> and
            <code>validation</code> attributes of the instructions
            used to create the ancestors of the element.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="creating-attributes" id=
        "creating-attributes"></a>11.3 Creating Attribute Nodes
        Using <code>xsl:attribute</code></h3>

        <p class="element-syntax"><a name="element-attribute" id=
        "element-attribute"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:attribute<br />
        &#160;&#160;<b>name</b> = { <var>qname</var> }<br />
        &#160;&#160;namespace? = { <var>uri-reference</var> }<br />
        &#160;&#160;select? = <var>expression</var><br />
        &#160;&#160;separator? = { <var>string</var> }<br />
        &#160;&#160;type? = <var>qname</var><br />
        &#160;&#160;validation? = "strict" | "lax" | "preserve" |
        "strip"&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:attribute&gt;</code></p>

        <p>The <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a> element
        can be used to add attributes to result elements whether
        created by literal result elements in the stylesheet or by
        instructions such as <a href=
        "index.html#element-element"><code>xsl:element</code></a> or <a href=
        "index.html#element-copy"><code>xsl:copy</code></a>. The <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of the attribute to
        be created is specified by a <span class=
        "verb">required</span> <code>name</code> attribute and an
        optional <code>namespace</code> attribute. <span>Except in
        error cases,</span> the result of evaluating an <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction is the newly constructed attribute node.</p>

        <p>The string value of the new attribute node may be
        defined either by using the <code>select</code> attribute,
        or by the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> that
        forms the content of the <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        element. These are mutually exclusive. If neither is
        present, the value of the new attribute node will be a
        zero-length string. The way in which the value is
        constructed is specified in <a href=
        "index.html#constructing-simple-content"><i>5.7.2 Constructing Simple
        Content</i></a>.</p>

        <p><a name="err-XTSE0840" id="err-XTSE0840"><span class=
        "error">[ERR XTSE0840]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <code>select</code> attribute of the <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a> element
        is present unless the element has empty content.</p>

        <p>If the <code>separator</code> attribute is present, then
        the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of this attribute
        is used to separate adjacent items in the result sequence,
        as described in <a href=
        "index.html#constructing-simple-content"><i>5.7.2 Constructing Simple
        Content</i></a>. In the absence of this attribute, the
        default separator is a single space (#x20) when the content
        is specified using the <code>select</code> attribute, or a
        zero-length string when the content is specified using a
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

        <p>The <code>name</code> attribute is interpreted as an
        <a title="attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a><span>, whose <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> <span class=
        "verb">must</span> be a <a title="lexical QName" href=
        "index.html#dt-lexical-qname">lexical QName</a>.</span></p>

        <p><a name="err-XTDE0850" id="err-XTDE0850"><span class=
        "error">[ERR XTDE0850]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is not a <a title=
        "lexical QName" href="index.html#dt-lexical-qname">lexical
        QName</a>.</p>

        <p><a name="err-XTDE0855" id="err-XTDE0855"><span class=
        "error">[ERR XTDE0855]</span></a> In the case of an
        <a href="index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction with no <code>namespace</code> attribute, it is
        a <a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is the string
        <code>xmlns</code>.</p>

        <p><a name="err-XTDE0860" id="err-XTDE0860"><span class=
        "error">[ERR XTDE0860]</span></a> In the case of an
        <a href="index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction with no <code>namespace</code> attribute, it is
        a <a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is a <a title="lexical QName"
        href="index.html#dt-lexical-qname">lexical QName</a> whose prefix is
        not declared in an in-scope namespace declaration for the
        <a href="index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction.</p>

        <p>If the <code>namespace</code> attribute is not present,
        then the <a title="lexical QName" href=
        "index.html#dt-lexical-qname">lexical QName</a> is expanded into an
        <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> using the namespace
        declarations in effect for the <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        element, <em>not</em> including any default namespace
        declaration.</p>

        <p>If the <code>namespace</code> attribute is present, then
        it too is interpreted as an <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>. The <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a>
        <span><span class="verb">must</span> be in the lexical
        space of the <code>xs:anyURI</code> type.</span> If the
        string is zero-length, then the <a title="expanded-QName"
        href="index.html#dt-expanded-qname">expanded-QName</a> of the
        attribute has a null namespace URI. Otherwise, the string
        is used as the namespace URI of the <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of the attribute to
        be created. The local part of the <a title="lexical QName"
        href="index.html#dt-lexical-qname">lexical QName</a> specified by the
        <code>name</code> attribute is used as the local part of
        the <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of the attribute to
        be created.</p>

        <p><a name="err-XTDE0865" id="err-XTDE0865"><span class=
        "error">[ERR XTDE0865]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>namespace</code> attribute is not in the lexical
        space of the <code>xs:anyURI</code> data type.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The same considerations apply as for elements:
          <span class="error">[see <a href="index.html#err-XTDE0835">ERR
          XTDE0835</a>]</span> in <a href="index.html#xsl-element"><i>11.2
          Creating Element Nodes Using xsl:element</i></a> .</p>
        </div>

        <p>The prefix of the <a title="lexical QName" href=
        "index.html#dt-lexical-qname">lexical QName</a> specified in the
        <code>name</code> attribute (or the absence of a prefix) is
        copied to the prefix part of the <a title="expanded-QName"
        href="index.html#dt-expanded-qname">expanded-QName</a> representing
        the name of the new attribute node. In the event of a
        conflict this prefix (or absence of a prefix) may
        subsequently be changed during the namespace fixup process
        (see <a href="index.html#namespace-fixup"><i>5.7.3 Namespace
        Fixup</i></a>). If the attribute is in a non-null namespace
        and no prefix is specified, then the namespace fixup
        process will invent a prefix.</p>

        <p>If the name of a constructed attribute is
        <code>xml:id</code>, <span>the processor must perform
        attribute value normalization by effectively applying the
        <a href=
        "http://www.w3.org/TR/xpath-functions/#func-normalize-space">
        <code>normalize-space</code></a><sup><small>FO</small></sup>
        function to the value of the attribute,</span> and the
        resulting attribute node must be given the
        <code>is-id</code> property. This applies whether the
        attribute is constructed using the <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>
        instruction or whether it is constructed using an attribute
        of a literal result element. This does not imply any
        constraints on the value of the attribute, or on its
        uniqueness, and it does not affect the <a title=
        "type annotation" href="index.html#dt-annotation">type annotation</a>
        of the attribute, unless the containing document is
        validated.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The effect of setting the <code>is-id</code> property
          is that the parent element can be located within the
          containing document by use of the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-id"><code>id</code></a><sup>
          <small>FO</small></sup> function. In effect, XSLT when
          constructing a document performs some of the functions of
          an <code>xml:id</code> processor, as defined in <a href=
          "index.html#xml-id">[xml:id]</a>; the other aspects of
          <code>xml:id</code> processing are performed during
          validation.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e16466" id="d5e16466"></a>Example: Creating
            a List-Valued Attribute
          </div>

          <p>The following instruction creates the attribute
          <code>colors="red green blue"</code>:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:attribute name="colors" select="'red', 'green', 'blue'"/&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e16476" id="d5e16476"></a>Example:
            Namespaces are not Attributes
          </div>

          <p>It is not an error to write:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:attribute name="xmlns:xsl" 
   namespace="file://some.namespace"&gt;http://www.w3.org/1999/XSL/Transform&lt;/xsl:attribute&gt;
</pre>
          </div>

          <p>However, this will not result in the namespace
          declaration
          <code>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"</code>
          being output. Instead, it will produce an attribute node
          with local name <code>xsl</code>, and with a
          system-allocated namespace prefix mapped to the namespace
          URI <code>file://some.namespace</code>. This is because
          the namespace fixup process is not allowed to use
          <code>xmlns</code> as the name of a namespace node.</p>
        </div>

        <p>As described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>, <span>in a sequence that is used
        to construct the content of an element,</span> any
        attribute nodes <span class="verb">must</span> appear in
        the sequence before any element, text, comment, or
        processing instruction nodes. Where the sequence contains
        two or more attribute nodes with the same <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a>, the one that comes
        last is the only one that takes effect.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>If a collection of attributes is generated repeatedly,
          this can be done conveniently by using named attribute
          sets: see <a href="index.html#attribute-sets"><i>10.2 Named
          Attribute Sets</i></a></p>
        </div>

        <div class="div3">
          <h4><a name="annotation-for-constructed-attribute" id=
          "annotation-for-constructed-attribute"></a>11.3.1 Setting
          the Type Annotation for a Constructed Attribute Node</h4>

          <p>The optional attributes <code>type</code> and
          <code>validation</code> may be used on the <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction to invoke validation of the contents of the
          attribute against a type definition or attribute
          declaration in a schema, and to determine the <a title=
          "type annotation" href="index.html#dt-annotation">type
          annotation</a> that the new attribute node will carry.
          These two attributes are both optional, and if one is
          specified then the other <span class="verb">must</span>
          be omitted. The permitted values of these attributes and
          their semantics are described in <a href=
          "index.html#validation"><i>19.2 Validation</i></a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The final <a title="type annotation" href=
            "index.html#dt-annotation">type annotation</a> of the attribute
            in the <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a> also depends on the
            <code>type</code> and <code>validation</code>
            attributes of the instructions used to create the
            ancestors of the attribute.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="creating-text-nodes" id=
        "creating-text-nodes"></a>11.4 Creating Text Nodes</h3>

        <p>This section describes three different ways of creating
        text nodes: by means of literal text nodes in the
        stylesheet, or by using the <a href=
        "index.html#element-text"><code>xsl:text</code></a> and <a href=
        "index.html#element-value-of"><code>xsl:value-of</code></a>
        instructions. It is also possible to create text nodes
        using the <a href=
        "index.html#element-number"><code>xsl:number</code></a> instruction
        described in <a href="index.html#number"><i>12 Numbering</i></a>.</p>

        <p>If and when the sequence that results from evaluating a
        <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> is used
        to form the content of a node, as described in <a href=
        "index.html#constructing-simple-content"><i>5.7.2 Constructing Simple
        Content</i></a> and <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>, adjacent text nodes in the
        sequence are merged. Within the sequence itself, however,
        they exist as distinct nodes.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e16577" id="d5e16577"></a>Example: A
            sequence of text nodes
          </div>

          <p>The following function returns a sequence of three
          text nodes:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:function name="f:wrap"&gt;
  &lt;xsl:param name="s"/&gt;
  &lt;xsl:text&gt;(&lt;/xsl:text&gt;
  &lt;xsl:value-of select="$s"/&gt;
  &lt;xsl:text&gt;)&lt;/xsl:text&gt;
&lt;/xsl:function&gt;
</pre>
          </div>

          <p>When this function is called as follows:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:value-of select="f:wrap('---')"/&gt;
</pre>
          </div>

          <p>the result is:</p>

          <div class="exampleInner">
            <pre>
(---)
</pre>
          </div>

          <p>No additional spaces are inserted, because the calling
          <a href="index.html#element-value-of"><code>xsl:value-of</code></a>
          instruction merges adjacent text nodes before atomizing
          the sequence. However, the result of the instruction:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:value-of select="data(f:wrap('---'))"/&gt;
</pre>
          </div>

          <p>is:</p>

          <div class="exampleInner">
            <pre>
( --- )
</pre>
          </div>

          <p>because in this case the three text nodes are atomized
          to form three strings, and spaces are inserted between
          adjacent strings.</p>
        </div>

        <p>It is possible to construct text nodes whose string
        value is zero-length. A zero-length text node, when
        atomized, produces a zero-length string. However,
        zero-length text nodes are ignored when they appear in a
        sequence that is used to form the content of a node, as
        described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a> and <a href=
        "index.html#constructing-simple-content"><i>5.7.2 Constructing Simple
        Content</i></a>.</p>

        <div class="div3">
          <h4><a name="literal-text-nodes" id=
          "literal-text-nodes"></a>11.4.1 Literal Text Nodes</h4>

          <p>A <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> can
          contain text nodes. Each text node in a sequence
          constructor remaining after <a title=
          "whitespace text node" href=
          "index.html#dt-whitespace-text-node">whitespace text nodes</a> have
          been stripped as specified in <a href=
          "index.html#stylesheet-stripping"><i>4.2 Stripping Whitespace from
          the Stylesheet</i></a> will construct a new text node
          with the same <a title="string value" href=
          "index.html#dt-string-value">string value</a>. The resulting text
          node is added to the result of the containing sequence
          constructor.</p>

          <p>Text is processed at the tree level. Thus, markup of
          <code>&amp;lt;</code> in a template will be represented
          in the stylesheet tree by a text node that includes the
          character <code>&lt;</code>. This will create a text node
          in the <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a> that contains a
          <code>&lt;</code> character, which will be represented by
          the markup <code>&amp;lt;</code> (or an equivalent
          character reference) when the result tree is serialized
          as an XML document, unless otherwise specified using
          <a title="character map" href=
          "index.html#dt-character-map">character maps</a> (see <a href=
          "index.html#character-maps"><i>20.1 Character Maps</i></a>) or
          <code>disable-output-escaping</code> (see <a href=
          "index.html#disable-output-escaping"><i>20.2 Disabling Output
          Escaping</i></a>).</p>
        </div>

        <div class="div3">
          <h4><a name="xsl-text" id="xsl-text"></a>11.4.2 Creating
          Text Nodes Using <code>xsl:text</code></h4>

          <p class="element-syntax"><a name="element-text" id=
          "element-text"></a><code>&lt;!-- Category: instruction
          --&gt;<br />
          &lt;xsl:text<br />
          &#160;&#160;<span class=
          "grayed">[disable-output-escaping]?</span> = "yes" |
          "no"&gt;<br />
          &#160;&#160;&lt;!-- Content: #PCDATA --&gt;<br />
          &lt;/xsl:text&gt;</code></p>

          <p>The <a href="index.html#element-text"><code>xsl:text</code></a>
          element is evaluated to contruct a new text node. The
          content of the <a href=
          "index.html#element-text"><code>xsl:text</code></a> element is a
          single text node whose value forms the <a title=
          "string value" href="index.html#dt-string-value">string value</a>
          of the <span>new</span> text node. An <a href=
          "index.html#element-text"><code>xsl:text</code></a> element may be
          empty, in which case the result of evaluating the
          instruction is <span>a text node whose string value is
          the zero-length string</span>.</p>

          <p>The result of evaluating an <a href=
          "index.html#element-text"><code>xsl:text</code></a> instruction is
          the newly constructed text node.</p>

          <p>A text node that is an immediate child of an <a href=
          "index.html#element-text"><code>xsl:text</code></a> instruction
          will not be stripped from the stylesheet tree, even if it
          consists entirely of whitespace (see <a href=
          "index.html#strip"><i>4.4 Stripping Whitespace from a Source
          Tree</i></a>).</p>

          <p>For the effect of the <a title="deprecated" href=
          "index.html#dt-deprecated">deprecated</a>
          <code>disable-output-escaping</code> attribute, see
          <a href="index.html#disable-output-escaping"><i>20.2 Disabling
          Output Escaping</i></a></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>It is not always necessary to use the <a href=
            "index.html#element-text"><code>xsl:text</code></a> instruction
            to write text nodes to the <a title="result tree" href=
            "index.html#dt-result-tree">result tree</a>. Literal text can be
            written to the result tree by including it anywhere in
            a <a title="sequence constructor" href=
            "index.html#dt-sequence-constructor">sequence constructor</a>,
            while computed text can be output using the <a href=
            "index.html#element-value-of"><code>xsl:value-of</code></a>
            instruction. The principal reason for using <a href=
            "index.html#element-text"><code>xsl:text</code></a> is that it
            offers improved control over whitespace handling.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="value-of" id="value-of"></a>11.4.3
          Generating Text with <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a></h4>

          <p>Within a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, the
          <a href="index.html#element-value-of"><code>xsl:value-of</code></a>
          instruction can be used to generate computed text nodes.
          The <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a>
          instruction computes the text using an <a title=
          "expression" href="index.html#dt-expression">expression</a> that is
          specified as the value of the <code>select</code>
          attribute, or by means of contained instructions. This
          might, for example, extract text from a <a title=
          "source tree" href="index.html#dt-source-tree">source tree</a> or
          insert the value of a variable.</p>

          <p class="element-syntax"><a name="element-value-of" id=
          "element-value-of"></a><code>&lt;!-- Category:
          instruction --&gt;<br />
          &lt;xsl:value-of<br />
          &#160;&#160;select? = <var>expression</var><br />
          &#160;&#160;separator? = { <var>string</var> }<br />
          &#160;&#160;<span class=
          "grayed">[disable-output-escaping]?</span> = "yes" |
          "no"&gt;<br />
          &#160;&#160;&lt;!-- Content:
          <var>sequence-constructor</var> --&gt;<br />
          &lt;/xsl:value-of&gt;</code></p>

          <p>The <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a>
          instruction is evaluated to construct a new text node;
          the result of the instruction is the newly constructed
          text node.</p>

          <p>The string value of the new text node may be defined
          either by using the <code>select</code> attribute, or by
          the <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> (see
          <a href="index.html#sequence-constructors"><i>5.7 Sequence
          Constructors</i></a>) that forms the content of the
          <a href="index.html#element-value-of"><code>xsl:value-of</code></a>
          element. These are mutually exclusive, and one of them
          must be present. The way in which the value is
          constructed is specified in <a href=
          "index.html#constructing-simple-content"><i>5.7.2 Constructing
          Simple Content</i></a>.</p>

          <p><a name="err-XTSE0870" id="err-XTSE0870"><span class=
          "error">[ERR XTSE0870]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the <code>select</code> attribute of the <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a> element
          is present when the content of the element is non-empty,
          or if the <code>select</code> attribute is absent when
          the content is empty.</p>

          <p>If the <code>separator</code> attribute is present,
          then the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of this
          attribute is used to separate adjacent items in the
          result sequence, as described in <a href=
          "index.html#constructing-simple-content"><i>5.7.2 Constructing
          Simple Content</i></a>. In the absence of this attribute,
          the default separator is a single space (#x20) when the
          content is specified using the <code>select</code>
          attribute, or a zero-length string when the content is
          specified using a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

          <p>Special rules apply when <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled for the instruction. If no
          <code>separator</code> attribute is present, and if the
          <code>select</code> attribute is present, then all items
          in the <a title="atomize" href=
          "index.html#dt-atomization">atomized</a> result sequence other than
          the first are ignored.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e16837" id="d5e16837"></a>Example:
              Generating a List with Separators
            </div>

            <p>The instruction:</p>

            <div class="exampleInner">
              <pre>
&lt;x&gt;&lt;xsl:value-of select="1 to 4" separator="|"/&gt;&lt;/x&gt;
</pre>
            </div>

            <p>produces the output:</p>

            <div class="exampleInner">
              <pre>
&lt;x&gt;1|2|3|4&lt;/x&gt;
</pre>
            </div>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a> element
            can be used to copy a sequence of nodes to the
            <a title="result tree" href="index.html#dt-result-tree">result
            tree</a> without <a title="atomize" href=
            "index.html#dt-atomization">atomization</a>. See <a href=
            "index.html#copy-of"><i>11.9.2 Deep Copy</i></a>.</p>
          </div>

          <p>For the effect of the <a title="deprecated" href=
          "index.html#dt-deprecated">deprecated</a>
          <code>disable-output-escaping</code> attribute, see
          <a href="index.html#disable-output-escaping"><i>20.2 Disabling
          Output Escaping</i></a></p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="creating-document-nodes" id=
        "creating-document-nodes"></a>11.5 Creating Document
        Nodes</h3>

        <p class="element-syntax"><a name="element-document" id=
        "element-document"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:document<br />
        &#160;&#160;validation? = "strict" | "lax" | "preserve" |
        "strip"<br />
        &#160;&#160;type? = <var>qname</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:document&gt;</code></p>

        <p>The <a href=
        "index.html#element-document"><code>xsl:document</code></a>
        instruction is used to create a new document node. The
        content of the <a href=
        "index.html#element-document"><code>xsl:document</code></a> element
        is a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> for the
        children of the new document node. A document node is
        created, and the sequence obtained by evaluating the
        sequence constructor is used to construct the content of
        the document, as described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>. The <a title="temporary tree"
        href="index.html#dt-temporary-tree">temporary tree</a> rooted at this
        document node forms the <a title="result tree" href=
        "index.html#dt-result-tree">result tree</a>.</p>

        <p>Except in error situations, the result of evaluating the
        <a href="index.html#element-document"><code>xsl:document</code></a>
        instruction is a single node, the newly constructed
        document node.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The new document is not serialized. To construct a
          document that is to form a final result rather than an
          intermediate result, use the <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction described in <a href=
          "index.html#creating-result-trees"><i>19.1 Creating Final Result
          Trees</i></a>.</p>
        </div>

        <p>The optional attributes <code>type</code> and
        <code>validation</code> may be used on the <a href=
        "index.html#element-document"><code>xsl:document</code></a>
        instruction to validate the contents of the new document,
        and to determine the <a title="type annotation" href=
        "index.html#dt-annotation">type annotation</a> that elements and
        attributes within the <a title="result tree" href=
        "index.html#dt-result-tree">result tree</a> will carry. The permitted
        values and their semantics are described in <a href=
        "index.html#validating-document-nodes"><i>19.2.2 Validating Document
        Nodes</i></a>.</p>

        <p>The base URI of the new document node is taken from the
        base URI of the <a href=
        "index.html#element-document"><code>xsl:document</code></a>
        instruction.</p>

        <p>The <code>document-uri</code> and
        <code>unparsed-entities</code> properties of the new
        document node are set to empty.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e16953" id="d5e16953"></a>Example: Checking
            Uniqueness Constraints in a Temporary Tree
          </div>

          <p>The following example creates a temporary tree held in
          a variable. The use of an enclosed <a href=
          "index.html#element-document"><code>xsl:document</code></a>
          instruction ensures that uniqueness constraints defined
          in the schema for the relevant elements are checked.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="tree" as="document-node()"&gt;
  &lt;xsl:document validation="strict"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:document&gt;
&lt;/xsl:variable&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="creating-processing-instructions" id=
        "creating-processing-instructions"></a>11.6 Creating
        Processing Instructions</h3>

        <p class="element-syntax"><a name=
        "element-processing-instruction" id=
        "element-processing-instruction"></a><code>&lt;!--
        Category: instruction --&gt;<br />
        &lt;xsl:processing-instruction<br />
        &#160;&#160;<b>name</b> = { <var>ncname</var> }<br />
        &#160;&#160;select? = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:processing-instruction&gt;</code></p>

        <p>The <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        element is evaluated to create a processing instruction
        node.</p>

        <p>The <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        element has a <span class="verb">required</span>
        <code>name</code> attribute that specifies the name of the
        processing instruction node. The value of the
        <code>name</code> attribute is interpreted as an <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>.</p>

        <p>The string value of the new processing-instruction node
        may be defined either by using the <code>select</code>
        attribute, or by the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> that
        forms the content of the <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        element. These are mutually exclusive. If neither is
        present, the string value of the new processing-instruction
        node will be a zero-length string. The way in which the
        value is constructed is specified in <a href=
        "index.html#constructing-simple-content"><i>5.7.2 Constructing Simple
        Content</i></a>.</p>

        <p><a name="err-XTSE0880" id="err-XTSE0880"><span class=
        "error">[ERR XTSE0880]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <code>select</code> attribute of the <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        element is present unless the element has empty
        content.</p>

        <p>Except in error situations, the result of evaluating the
        <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        instruction is a single node, the newly constructed
        processing instruction <span>node</span>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e17032" id="d5e17032"></a>Example: Creating
            a Processing Instruction
          </div>

          <p>This instruction:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:processing-instruction name="xml-stylesheet"
  select="('href=&amp;quot;book.css&amp;quot;', 'type=&amp;quot;text/css&amp;quot;)"/&gt;
</pre>
          </div>

          <p>creates the processing instruction</p>

          <div class="exampleInner">
            <pre>
&lt;?xml-stylesheet href="book.css" type="text/css"?&gt;
</pre>
          </div>

          <p>Note that the <code>xml-stylesheet</code> processing
          instruction contains <em>pseudo-attributes</em> in the
          form <code>name="value"</code>. Although these have the
          same textual form as attributes in an element start tag,
          they are not represented as <span>XDM</span> attribute
          nodes, and cannot therefore be constructed using <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instructions.</p>
        </div>

        <p><a name="err-XTDE0890" id="err-XTDE0890"><span class=
        "error">[ERR XTDE0890]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is not both an <a href=
        "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
        <small>Names</small></sup> and a <a href=
        "http://www.w3.org/TR/2000/REC-xml-20001006#NT-PITarget">PITarget</a><sup>
        <small>XML</small></sup>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p><span>Because these rules disallow the name
          <code>xml</code>,</span> the <a href=
          "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
          cannot be used to output an XML declaration. The <a href=
          "index.html#element-output"><code>xsl:output</code></a> declaration
          should be used to control this instead (see <a href=
          "index.html#serialization"><i>20 Serialization</i></a>).</p>
        </div>

        <p>If the result of evaluating the content of the <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        contains the string <code>?&gt;</code>, this string is
        modified by inserting a space between the <code>?</code>
        and <code>&gt;</code> characters.</p>

        <p>The base URI of the new processing-instruction is copied
        from the base URI of the <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
        element in the stylesheet. (Note, however, that this is
        only relevant when creating a parentless processing
        instruction. When the new processing instruction is copied
        to form a child of an element or document node, the base
        URI of the new copy is taken from that of its new
        parent.)</p>
      </div>

      <div class="div2">
        <h3><a name="creating-namespace-nodes" id=
        "creating-namespace-nodes"></a>11.7 Creating Namespace
        Nodes</h3>

        <p class="element-syntax"><a name="element-namespace" id=
        "element-namespace"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:namespace<br />
        &#160;&#160;<b>name</b> = { <var>ncname</var> }<br />
        &#160;&#160;select? = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:namespace&gt;</code></p>

        <p>The <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a> element
        is evaluated to create a namespace node. Except in error
        situations, the result of evaluating the <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a>
        instruction is a single node, the newly constructed
        namespace node.</p>

        <p>The <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a> element
        has a <span class="verb">required</span> <code>name</code>
        attribute that specifies the name of the namespace node
        (that is, the namespace prefix). The value of the
        <code>name</code> attribute is interpreted as an <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>. If the <span><a title="effective value" href=
        "index.html#dt-effective-value">effective value</a></span> of the
        <code>name</code> attribute is a zero-length string, a
        namespace node is added for the default namespace.</p>

        <p>The string value of the new namespace node (that is, the
        namespace URI) may be defined either by using the
        <code>select</code> attribute, or by the <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> that
        forms the content of the <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a>
        element. These are mutually exclusive. Since the string
        value of a namespace node cannot be a zero-length string,
        one of them must be present. The way in which the value is
        constructed is specified in <a href=
        "index.html#constructing-simple-content"><i>5.7.2 Constructing Simple
        Content</i></a>.</p>

        <p><a name="err-XTDE0905" id="err-XTDE0905"><span class=
        "error">[ERR XTDE0905]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the string value of the new namespace node is
        not valid in the lexical space of the data type
        <code>xs:anyURI</code>. <span class="error">[see <a href=
        "index.html#err-XTDE0835">ERR XTDE0835</a>]</span></p>

        <p><a name="err-XTSE0910" id="err-XTSE0910"><span class=
        "error">[ERR XTSE0910]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <code>select</code> attribute of the <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a> element
        is present when the element has content other than one or
        more <a href=
        "index.html#element-fallback"><code>xsl:fallback</code></a>
        instructions, or if the <code>select</code> attribute is
        absent when the element has empty content.</p>

        <p>Note the restrictions described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a> for the position of a namespace
        node relative to other nodes in the node sequence returned
        by a sequence constructor.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e17221" id="d5e17221"></a>Example:
            Constructing a QName-Valued Attribute
          </div>

          <p>This literal result element:</p>

          <div class="exampleInner">
            <pre>
&lt;data xsi:type="xs:integer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;xsl:namespace name="xs" select="'http://www.w3.org/2001/XMLSchema'"/&gt;
  &lt;xsl:text&gt;42&lt;/xsl:text&gt;
&lt;/data&gt;
</pre>
          </div>

          <p>would typically cause the output document to contain
          the element:</p>

          <div class="exampleInner">
            <pre>
&lt;data xsi:type="xs:integer"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;42&lt;/data&gt;
</pre>
          </div>

          <p>In this case, the element is constructed using a
          literal result element, and the namespace
          <code>xmlns:xs="http://www.w3.org/2001/XMLSchema"</code>
          could therefore have been added to the <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a>
          simply by declaring it as one of the in-scope namespaces
          in the stylesheet. In practice, the <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          instruction is more likely to be useful in situations
          where the element is constructed using an <a href=
          "index.html#element-element"><code>xsl:element</code></a>
          instruction, which does not copy all the in-scope
          namespaces from the stylesheet.</p>
        </div>

        <p><a name="err-XTDE0920" id="err-XTDE0920"><span class=
        "error">[ERR XTDE0920]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>name</code> attribute is neither a zero-length string
        nor an <a href=
        "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
        <small>Names</small></sup>, or if it is
        <code>xmlns</code>.</p>

        <p><a name="err-XTDE0925" id="err-XTDE0925"><span class=
        "error">[ERR XTDE0925]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a>
        instruction generates a namespace node whose name is
        <code>xml</code> and whose string value is not
        <code>http://www.w3.org/XML/1998/namespace</code>, or a
        namespace node whose string value is
        <code>http://www.w3.org/XML/1998/namespace</code> and whose
        name is not <code>xml</code>.</p>

        <p><a name="err-XTDE0930" id="err-XTDE0930"><span class=
        "error">[ERR XTDE0930]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if evaluating the <span><code>select</code>
        attribute or the contained <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a> of
        an <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a>
        instruction</span> results in a zero-length string.</p>

        <p>For details of other error conditions that may arise,
        see <a href="index.html#sequence-constructors"><i>5.7 Sequence
        Constructors</i></a>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>It is rarely necessary to use <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a> to
          create a namespace node in the <a title="result tree"
          href="index.html#dt-result-tree">result tree</a>; in most
          circumstances, the required namespace nodes will be
          created automatically, as a side-effect of writing
          elements or attributes that use the namespace. An example
          where <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a> is
          needed is a situation where the required namespace is
          used only within attribute values in the result document,
          not in element or attribute names; especially where the
          required namespace prefix or namespace URI is computed at
          run-time and is not present in either the source document
          or the stylesheet.</p>

          <p>Adding a namespace node to the <a title="result tree"
          href="index.html#dt-result-tree">result tree</a> will never change
          the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> of any element or
          attribute node in the result tree: that is, it will never
          change the namespace URI of an element or attribute. It
          <span>might</span>, however, constrain the choice of
          prefixes when namespace fixup is performed.</p>

          <p>Namespace prefixes for element and attribute names are
          effectively established by the namespace fixup process
          described in <a href="index.html#namespace-fixup"><i>5.7.3
          Namespace Fixup</i></a>. The fixup process ensures that
          an element has in-scope namespace nodes for the namespace
          URIs used in the element name and in its attribute names,
          and the serializer will typically use these namespace
          nodes to determine the prefix to use in the serialized
          output. The fixup process cannot generate namespace nodes
          that are inconsistent with those already present in the
          tree. This means that it is not possible for the
          processor to decide the prefix to use for an element or
          for any of its attributes until all the namespace nodes
          for the element have been added.</p>

          <p>If a namespace prefix is mapped to a particular
          namespace URI using the <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          instruction, or by using <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> or <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a> to copy a
          namespace node, this prevents the namespace fixup process
          (and hence the serializer) from using the same prefix for
          a different namespace URI on the same element.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e17356" id="d5e17356"></a>Example:
            Conflicting Namespace Prefixes
          </div>

          <p>Given the instruction:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:element name="p:item" xmlns:p="http://www.example.com/p"&gt;
  &lt;xsl:namespace name="p"&gt;http://www.example.com/q&lt;/xsl:namespace&gt;
&lt;/xsl:element&gt;
</pre>
          </div>

          <p>a possible serialization of the <a title="result tree"
          href="index.html#dt-result-tree">result tree</a> is:</p>

          <div class="exampleInner">
            <pre>
&lt;ns0:item xmlns:ns0="http://www.example.com/p" xmlns:p="http://www.example.com/q"/&gt;
</pre>
          </div>

          <p>The processor must invent a namespace prefix for the
          URI <code>p.uri</code>; it cannot use the prefix
          <code>p</code> because that prefix has been explicitly
          associated with a different URI.</p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          instruction cannot be used to generate a <b>namespace
          undeclaration</b> of the form <code>xmlns=""</code> (nor
          the new forms of namespace undeclaration permitted in
          <a href="index.html#xml-names11">[Namespaces in XML 1.1]</a>).
          Namespace undeclarations are generated automatically by
          the serializer if
          <span><code>undeclare-prefixes="yes"</code></span> is
          specified on <a href=
          "index.html#element-output"><code>xsl:output</code></a>, whenever a
          parent element has a namespace node for the default
          namespace prefix, and a child element has no namespace
          node for that prefix.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="creating-comments" id=
        "creating-comments"></a>11.8 Creating Comments</h3>

        <p class="element-syntax"><a name="element-comment" id=
        "element-comment"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:comment<br />
        &#160;&#160;select? = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:comment&gt;</code></p>

        <p>The <a href=
        "index.html#element-comment"><code>xsl:comment</code></a> element is
        evaluated to contruct a new comment node. Except in error
        cases, the result of evaluating the <a href=
        "index.html#element-comment"><code>xsl:comment</code></a> instruction
        is a single node, the newly constructed comment node.</p>

        <p>The string value of the new comment node may be defined
        either by using the <code>select</code> attribute, or by
        the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> that
        forms the content of the <a href=
        "index.html#element-comment"><code>xsl:comment</code></a> element.
        These are mutually exclusive. If neither is present, the
        value of the new comment node will be a zero-length string.
        The way in which the value is constructed is specified in
        <a href="index.html#constructing-simple-content"><i>5.7.2
        Constructing Simple Content</i></a>.</p>

        <p><a name="err-XTSE0940" id="err-XTSE0940"><span class=
        "error">[ERR XTSE0940]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <code>select</code> attribute of the <a href=
        "index.html#element-comment"><code>xsl:comment</code></a> element is
        present unless the element has empty content.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e17444" id="d5e17444"></a>Example:
            Generating a Comment Node
          </div>

          <p>For example, this</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:comment&gt;This file is automatically generated. Do not edit!&lt;/xsl:comment&gt;
</pre>
          </div>

          <p>would create the comment</p>

          <div class="exampleInner">
            <pre>
&lt;!--This file is automatically generated. Do not edit!--&gt;
</pre>
          </div>
        </div>

        <p>In the generated comment node, the processor
        <span class="verb">must</span> insert a space after any
        occurrence of <code>-</code> that is followed by another
        <code>-</code> or that ends the comment.</p>
      </div>

      <div class="div2">
        <h3><a name="copying" id="copying"></a>11.9 Copying
        Nodes</h3>

        <div class="div3">
          <h4><a name="shallow-copy" id="shallow-copy"></a>11.9.1
          Shallow Copy</h4>

          <p class="element-syntax"><a name="element-copy" id=
          "element-copy"></a><code>&lt;!-- Category: instruction
          --&gt;<br />
          &lt;xsl:copy<br />
          &#160;&#160;copy-namespaces? = "yes" | "no"<br />
          &#160;&#160;inherit-namespaces? = "yes" | "no"<br />
          &#160;&#160;use-attribute-sets? = <var>qnames</var><br />
          &#160;&#160;type? = <var>qname</var><br />
          &#160;&#160;validation? = "strict" | "lax" | "preserve" |
          "strip"&gt;<br />
          &#160;&#160;&lt;!-- Content:
          <var>sequence-constructor</var> --&gt;<br />
          &lt;/xsl:copy&gt;</code></p>

          <p>The <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction provides a way of copying the context item.
          If the <a title="context item" href=
          "index.html#dt-context-item">context item</a> is a node, evaluating
          the <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction constructs a copy of the context node, and
          the result of the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> instruction is
          this newly constructed node. <span>By default,</span> the
          namespace nodes of the context node are automatically
          copied as well, but the attributes and children of the
          node are not automatically copied.</p>

          <p>When the <a title="context item" href=
          "index.html#dt-context-item">context item</a> is an atomic value,
          the <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction returns this value. <span>The <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, if
          present, is not evaluated.</span></p>

          <p>When the <a title="context item" href=
          "index.html#dt-context-item">context item</a> is an attribute node,
          text node, comment node, processing instruction node, or
          namespace node, the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> instruction
          returns a new node that is a copy of the context node.
          The new node will have the same node kind, name, and
          string value as the context node. <span>In the case of an
          attribute node, it will also have the same values for the
          <code>is-id</code> and <code>is-idrefs</code>
          properties.</span> The <a title="sequence constructor"
          href="index.html#dt-sequence-constructor">sequence constructor</a>,
          if present, is not evaluated.</p>

          <p><span>When the context item is a document node or
          element node, the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> instruction
          returns a new node that has the same node kind and name
          as the context node. The content of the new node is
          formed by evaluating the <a title="sequence constructor"
          href="index.html#dt-sequence-constructor">sequence constructor</a>
          contained in the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a>
          instruction.</span> The sequence obtained by evaluating
          this sequence constructor is used (after prepending any
          attribute nodes or namespace nodes as described in the
          following paragraphs) to construct the content of the
          document or element node, as described in <a href=
          "index.html#constructing-complex-content"><i>5.7.1 Constructing
          Complex Content</i></a>.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e17557" id="d5e17557"></a>Example:
              Identity Transformation
            </div>

            <p>The identity transformation can be written using
            <a href="index.html#element-copy"><code>xsl:copy</code></a> as
            follows:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:template match="@*|node()"&gt;
  &lt;xsl:copy&gt;
    &lt;xsl:apply-templates select="@*|node()"/&gt;
  &lt;/xsl:copy&gt;
&lt;/xsl:template&gt;
</pre>
            </div>

            <p>This template rule can be used to copy any node in a
            tree by applying template rules to its attributes and
            children. It can be combined with additional template
            rules that modify selected nodes, for example if all
            nodes are to be copied except <code>note</code>
            elements and their contents, this can be achieved by
            using the identity template rule together with the
            template rule:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:template match="note"/&gt;
</pre>
            </div>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The <a href=
            "index.html#element-copy"><code>xsl:copy</code></a> instruction
            is most useful when copying element nodes. In other
            cases, the <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>
            instruction is more flexible, because it has a
            <code>select</code> attribute allowing selection of the
            nodes or values to be copied.</p>
          </div>

          <p>The <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction has an optional
          <code>use-attribute-sets</code> attribute, whose value is
          a <span>whitespace-separated</span> list of QNames that
          identify <a href=
          "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
          declarations. This attribute is used only when copying
          element nodes. This list is expanded as described in
          <a href="index.html#attribute-sets"><i>10.2 Named Attribute
          Sets</i></a> to produce a sequence of attribute nodes.
          This sequence is prepended to the sequence produced as a
          result of evaluating the <a title="sequence constructor"
          href="index.html#dt-sequence-constructor">sequence
          constructor</a>.</p>

          <p>The <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction has an optional <code>copy-namespaces</code>
          attribute, with the value <code>yes</code> or
          <code>no</code>. The default value is <code>yes</code>.
          The attribute is used only when copying element nodes. If
          the value is set to <code>yes</code>, or is omitted, then
          all the namespace nodes of the source element are copied
          as namespace nodes for the result element. These copied
          namespace nodes are prepended to the sequence produced as
          a result of evaluating the <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> (it
          is immaterial whether they come before or after any
          attribute nodes produced by expanding the
          <code>use-attribute-sets</code> attribute). If the value
          is set to <code>no</code>, then the namespace nodes are
          not copied. However, namespace nodes will still be added
          to the result element as <span class=
          "verb">required</span> by the namespace fixup process:
          see <a href="index.html#namespace-fixup"><i>5.7.3 Namespace
          Fixup</i></a>.</p>

          <p>The <a href="index.html#element-copy"><code>xsl:copy</code></a>
          instruction has an optional
          <code>inherit-namespaces</code> attribute, with the value
          <code>yes</code> or <code>no</code>. The default value is
          <code>yes</code>. The attribute is used only when copying
          element nodes. If the value is set to <code>yes</code>,
          or is omitted, then the namespace nodes created for the
          newly constructed element (whether these were copied from
          those of the source node, or generated as a result of
          namespace fixup) are copied to the children and
          descendants of the newly constructed element, as
          described in <a href=
          "index.html#constructing-complex-content"><i>5.7.1 Constructing
          Complex Content</i></a>. If the value is set to
          <code>no</code>, then these namespace nodes are not
          automatically copied to the children. This may result in
          namespace undeclarations (such as <code>xmlns=""</code>
          or, in the case of XML Namespaces 1.1,
          <code>xmlns:p=""</code>) appearing on the child elements
          when a <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a> is
          serialized.</p>

          <p><a name="err-XTTE0950" id="err-XTTE0950"><span class=
          "error">[ERR XTTE0950]</span></a> It is a <a title=
          "type errors" href="index.html#dt-type-error">type error</a> to use
          the <a href="index.html#element-copy"><code>xsl:copy</code></a> or
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instruction to copy a node that has namespace-sensitive
          content if the <code>copy-namespaces</code> attribute has
          the value <code>no</code> and its explicit or implicit
          <code>validation</code> attribute has the value
          <code>preserve</code>. It is also a type error if either
          of these instructions (with
          <code>validation="preserve"</code>) is used to copy an
          attribute having namespace-sensitive content, unless the
          parent element is also copied. A node has
          namespace-sensitive content if its typed value contains
          an item of type <code>xs:QName</code> or
          <code>xs:NOTATION</code> or a type derived therefrom. The
          reason this is an error is because the validity of the
          content depends on the namespace context being
          preserved.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>When attribute nodes are copied, whether with
            <a href="index.html#element-copy"><code>xsl:copy</code></a> or
            with <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>, the
            processor does not automatically copy any associated
            namespace information. The namespace used in the
            attribute name itself will be declared by virtue of the
            namespace fixup process (see <a href=
            "index.html#namespace-fixup"><i>5.7.3 Namespace Fixup</i></a>)
            when the attribute is added to an element in the
            <a title="result tree" href="index.html#dt-result-tree">result
            tree</a>, but if namespace <span>prefixes</span> are
            used in the content of the attribute (for example, if
            the value of the attribute is an XPath expression) then
            it is the responsibility of the stylesheet author to
            ensure that suitable namespace nodes are added to the
            <a title="result tree" href="index.html#dt-result-tree">result
            tree</a>. This can be achieved by copying the namespace
            nodes using <a href=
            "index.html#element-copy"><code>xsl:copy</code></a>, or by
            generating them using <a href=
            "index.html#element-namespace"><code>xsl:namespace</code></a>.</p>
          </div>

          <p>The optional attributes <code>type</code> and
          <code>validation</code> may be used on the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> instruction to
          validate the contents of an element, attribute or
          document node against a type definition, element
          declaration, or attribute declaration in a schema, and
          thus to determine the <a title="type annotation" href=
          "index.html#dt-annotation">type annotation</a> that the new copy of
          an element or attribute node will carry. These attributes
          are ignored when copying an item that is not an element,
          attribute or document node. When the node being copied is
          an element or document node, these attributes also affect
          the type annotation carried by any elements and
          attributes that have the copied element or document node
          as an ancestor. These two attributes are both optional,
          and if one is specified then the other <span class=
          "verb">must</span> be omitted. The permitted values of
          these attributes and their semantics are described in
          <a href="index.html#validation"><i>19.2 Validation</i></a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The final <a title="type annotation" href=
            "index.html#dt-annotation">type annotation</a> of the node in the
            <a title="result tree" href="index.html#dt-result-tree">result
            tree</a> also depends on the <code>type</code> and
            <code>validation</code> attributes of the instructions
            used to create the ancestors of the node.</p>
          </div>

          <p>The base URI of a node is copied<span>, except in the
          case of an element node having an <code>xml:base</code>
          attribute, in which case the base URI of the new node is
          taken as the value of the <code>xml:base</code>
          attribute, resolved if it is relative against the base
          URI of the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a>
          instruction</span>. If the copied node is subsequently
          attached as a child to a new element <span>or document
          node</span>, the final copy of the node inherits its base
          URI from its parent node, unless this is overridden using
          an <code>xml:base</code> attribute.</p>

          <p>When an <code>xml:id</code> attribute is copied, using
          either the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> or <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instruction, it is <a title="implementation-defined"
          href="index.html#dt-implementation-defined">implementation-defined</a>
          whether the value of the attribute is subjected to
          attribute value normalization (that is, effectively
          applying the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-normalize-space">
          <code>normalize-space</code></a><sup><small>FO</small></sup>
          function).</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>In most cases the value will already have been
            subjected to attribute value normalization on the
            source tree, but if this processing has not been
            performed on the source tree, it is not an error for it
            to be performed on the result tree.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="copy-of" id="copy-of"></a>11.9.2 Deep
          Copy</h4>

          <p class="element-syntax"><a name="element-copy-of" id=
          "element-copy-of"></a><code>&lt;!-- Category: instruction
          --&gt;<br />
          &lt;xsl:copy-of<br />
          &#160;&#160;<b>select</b> = <var>expression</var><br />
          &#160;&#160;copy-namespaces? = "yes" | "no"<br />
          &#160;&#160;type? = <var>qname</var><br />
          &#160;&#160;validation? = "strict" | "lax" | "preserve" |
          "strip"&#160;/&gt;</code></p>

          <p>The <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instruction can be used to construct a copy of a sequence
          of nodes <span>and/or atomic values</span>, with each new
          node containing copies of all the children, attributes,
          and (by default) namespaces of the original node,
          recursively. The result of evaluating the instruction is
          a sequence of <span>items</span> corresponding one-to-one
          with the supplied sequence, and retaining its order.</p>

          <p>The <span class="verb">required</span>
          <code>select</code> attribute contains an <a title=
          "expression" href="index.html#dt-expression">expression</a>,
          <span>whose value may be any sequence of nodes and atomic
          values</span>. The items in this sequence are processed
          as follows:</p>

          <ul>
            <li>
              <p>If the item is an element node, a new element is
              constructed and appended to the result sequence. The
              new element will have the same <a title=
              "expanded-QName" href=
              "index.html#dt-expanded-qname">expanded-QName</a> as the
              original, and it will have <span>deep</span> copies
              of the attribute nodes and children of the element
              node.</p>

              <p>The new element will also have namespace nodes
              copied from the original element node, unless they
              are excluded by <span>specifying
              <code>copy-namespaces="no"</code>. If this attribute
              is omitted, or takes the value <code>yes</code>, then
              all the namespace nodes of the original element are
              copied to the new element. If it takes the value
              <code>no</code>, then none of the namespace nodes are
              copied: however, namespace nodes will still be
              created in the <a title="result tree" href=
              "index.html#dt-result-tree">result tree</a> as <span class=
              "verb">required</span> by the namespace fixup
              process: see <a href="index.html#namespace-fixup"><i>5.7.3
              Namespace Fixup</i></a>. This attribute affects all
              elements copied by this instruction: both elements
              selected directly by the <code>select</code>
              <a title="expression" href=
              "index.html#dt-expression">expression</a>, and elements that
              are descendants of nodes selected by the
              <code>select</code> expression.</span></p>

              <p>The new element will have the same values of the
              <code>is-id</code>, <code>is-idrefs</code>, and
              <code>nilled</code> properties as the original
              element.</p>
            </li>

            <li>
              <p>If the item is a document node, the instruction
              adds a new document node to the result sequence; the
              children of this document node will be one-to-one
              copies of the children of the original document node
              (each copied according to the rules for its own node
              kind).</p>
            </li>

            <li>
              <p>If the item is an attribute or namespace node, or
              a text node, a comment, or a processing instruction,
              the same rules apply as with <a href=
              "index.html#element-copy"><code>xsl:copy</code></a> (see
              <a href="index.html#shallow-copy"><i>11.9.1 Shallow
              Copy</i></a>).</p>
            </li>

            <li>
              <p>If the item is an atomic value, the value is
              appended to the result sequence, as with <a href=
              "index.html#element-sequence"><code>xsl:sequence</code></a>.</p>
            </li>
          </ul>

          <p>The optional attributes <code>type</code> and
          <code>validation</code> may be used on the <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instruction to validate the contents of an element,
          attribute or document node against a type definition,
          element declaration, or attribute declaration in a schema
          and thus to determine the <a title="type annotation"
          href="index.html#dt-annotation">type annotation</a> that the new
          copy of an element or attribute node will carry. These
          attributes are applied individually to each element,
          attribute, and document node that is selected by the
          expression in the <code>select</code> attribute. These
          attributes are ignored when copying an item that is not
          an element, attribute or document node.</p>

          <p>The specified <code>type</code> and
          <code>validation</code> apply directly only to elements,
          attributes and document nodes created as copies of nodes
          actually selected by the <code>select</code> expression,
          they do not apply to nodes that are implicitly copied
          because they have selected nodes as an ancestor. However,
          these attributes do indirectly affect the <a title=
          "type annotation" href="index.html#dt-annotation">type
          annotation</a> carried by such implicitly copied nodes,
          as a consequence of the validation process.</p>

          <p>These two attributes are both optional, and if one is
          specified then the other <span class="verb">must</span>
          be omitted. The permitted values of these attributes and
          their semantics are described in <a href=
          "index.html#validation"><i>19.2 Validation</i></a>.</p>

          <p>Errors may occur when copying namespace-sensitive
          elements or attributes using
          <code>validation="preserve"</code>. <span class=
          "error">[see <a href="index.html#err-XTTE0950">ERR
          XTTE0950</a>]</span>.</p>

          <p>The base URI of a node is copied<span>, except in the
          case of an element node having an <code>xml:base</code>
          attribute, in which case the base URI of the new node is
          taken as the value of the <code>xml:base</code>
          attribute, resolved if it is relative against the base
          URI of the <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instruction</span>. If the copied node is subsequently
          attached as a child to a new element <span>or document
          node</span>, the final copy of the node inherits its base
          URI from its parent node, unless this is overridden using
          an <code>xml:base</code> attribute.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="constructing-sequences" id=
        "constructing-sequences"></a>11.10 Constructing
        Sequences</h3>

        <p class="element-syntax"><a name="element-sequence" id=
        "element-sequence"></a><code>&lt;!-- Category: instruction
        --&gt;<br />
        &lt;xsl:sequence<br />
        &#160;&#160;<b>select</b> = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: <a href=
        "index.html#element-fallback">xsl:fallback</a>* --&gt;<br />
        &lt;/xsl:sequence&gt;</code></p>

        <p>The <a href=
        "index.html#element-sequence"><code>xsl:sequence</code></a>
        instruction may be used within a <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> to
        construct a sequence of nodes and/or atomic values. This
        sequence is returned as the result of the instruction.
        Unlike most other instructions, <a href=
        "index.html#element-sequence"><code>xsl:sequence</code></a> can
        return a sequence containing existing nodes, rather than
        constructing new nodes. When <a href=
        "index.html#element-sequence"><code>xsl:sequence</code></a> is used
        to add atomic values to a sequence, the effect is very
        similar to the <a href=
        "index.html#element-copy-of"><code>xsl:copy-of</code></a>
        instruction.</p>

        <p>The items comprising the result sequence are selected
        using the <code>select</code> attribute.</p>

        <p>Any contained <a href=
        "index.html#element-fallback"><code>xsl:fallback</code></a>
        instructions are ignored by an XSLT 2.0 processor, but can
        be used to define fallback behavior for an XSLT 1.0
        processor running in forwards compatibility mode.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18039" id="d5e18039"></a>Example:
            Constructing a Sequence of Integers
          </div>

          <p>For example, the following code:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="values" as="xs:integer*"&gt;
    &lt;xsl:sequence select="(1,2,3,4)"/&gt;
    &lt;xsl:sequence select="(8,9,10)"/&gt;
&lt;/xsl:variable&gt;
&lt;xsl:value-of select="sum($values)"/&gt;
</pre>
          </div>

          <p>produces the output: <code>37</code></p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18050" id="d5e18050"></a>Example: Using
            <code>xsl:for-each</code> to Construct a Sequence
          </div>

          <p>The following code constructs a sequence containing
          the value of the <code>@price</code> attribute for
          selected elements (which we assume to be typed as
          <code>xs:decimal</code>), or a computed price for those
          elements that have no <code>@price</code> attribute. It
          then returns the average price:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="prices" as="xs:decimal*"&gt;
  &lt;xsl:for-each select="//product"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="@price"&gt;
        &lt;xsl:sequence select="@price"/&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:sequence select="@cost * 1.5"/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:for-each&gt;
&lt;/xsl:variable&gt;
&lt;xsl:value-of select="avg($prices)"/&gt;
</pre>
          </div>

          <p>Note that the existing <code>@price</code> attributes
          could equally have been added to the <code>$prices</code>
          sequence using <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a> or
          <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a>.
          However, <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a> would
          create a copy of the attribute node, which is not needed
          in this situation, while <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a> would
          create a new text node, which then has to be converted to
          an <code>xs:decimal</code>. Using <a href=
          "index.html#element-sequence"><code>xsl:sequence</code></a>, which
          in this case atomizes the existing attribute node and
          adds an <code>xs:decimal</code> atomic value to the
          result sequence, is a more direct way of achieving the
          same result.</p>

          <p>This example could alternatively be solved at the
          XPath level:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:value-of select="avg(//product/(+@price, @cost*1.5)[1])"/&gt;
</pre>
          </div>

          <p>(The apparently redundant <code>+</code> operator is
          there to atomize the attribute value: the expression on
          the right hand side of the <code>/</code> operator must
          not return a mixture of nodes and atomic values.)</p>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="number" id="number"></a>12 Numbering</h2>

      <p class="element-syntax"><a name="element-number" id=
      "element-number"></a><code>&lt;!-- Category: instruction
      --&gt;<br />
      &lt;xsl:number<br />
      &#160;&#160;value? = <var>expression</var><br />
      &#160;&#160;select? = <var>expression</var><br />
      &#160;&#160;level? = "single" | "multiple" | "any"<br />
      &#160;&#160;count? = <var>pattern</var><br />
      &#160;&#160;from? = <var>pattern</var><br />
      &#160;&#160;format? = { <var>string</var> }<br />
      &#160;&#160;lang? = { <var>nmtoken</var> }<br />
      &#160;&#160;letter-value? = { "alphabetic" | "traditional"
      }<br />
      &#160;&#160;ordinal? = { <var>string</var> }<br />
      &#160;&#160;grouping-separator? = { <var>char</var> }<br />
      &#160;&#160;grouping-size? = { <var>number</var>
      }&#160;/&gt;</code></p>

      <p>The <a href="index.html#element-number"><code>xsl:number</code></a>
      instruction is used to create a formatted number. The result
      of the instruction is a newly constructed text node
      containing the formatted number as its <a title=
      "string value" href="index.html#dt-string-value">string value</a>.</p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-place-marker" id="dt-place-marker" title=
      "place marker"></a>The <a href=
      "index.html#element-number"><code>xsl:number</code></a> instruction
      performs two tasks: firstly, determining a <b>place
      marker</b> (this is a sequence of integers, to allow for
      hierarchic numbering schemes such as <code>1.12.2</code> or
      <code>3(c)ii</code>), and secondly, formatting the place
      marker for output as a text node in the result
      sequence.<span class="definition">]</span> The place marker
      to be formatted can either be supplied directly, in the
      <code>value</code> attribute, or it can be computed based on
      the position of <span>a selected node</span> within the tree
      that contains it.</p>

      <p><a name="err-XTSE0975" id="err-XTSE0975"><span class=
      "error">[ERR XTSE0975]</span></a> It is a <a title=
      "static error" href="index.html#dt-static-error">static error</a> if
      the <code>value</code> attribute of <a href=
      "index.html#element-number"><code>xsl:number</code></a> is present
      unless the <code>select</code>, <code>level</code>,
      <code>count</code>, and <code>from</code> attributes are all
      absent.</p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>The facilities described in this section are
        specifically designed to enable the calculation and
        formatting of section numbers, paragraph numbers, and the
        like. For formatting of other numeric quantities, the
        <a href=
        "index.html#function-format-number"><code>format-number</code></a>
        function may be more suitable: see <a href=
        "index.html#format-number"><i>16.4 Number Formatting</i></a>.</p>
      </div>

      <div class="div2">
        <h3><a name="formatting-supplied-number" id=
        "formatting-supplied-number"></a>12.1 Formatting a Supplied
        Number</h3>

        <p>The <a title="place marker" href=
        "index.html#dt-place-marker">place marker</a> to be formatted may be
        specified by an expression. The <code>value</code>
        attribute contains the <a title="expression" href=
        "index.html#dt-expression">expression</a>. The value of this
        expression is <a title="atomize" href=
        "index.html#dt-atomization">atomized</a> using the procedure defined
        in <a href="index.html#xpath20">[XPath 2.0]</a>, and each value
        <span><var>$V</var> in the atomized sequence is then
        converted to the integer value returned by the XPath
        expression
        <code>xs:integer(round(number($V)))</code>.</span> The
        resulting sequence of integers is used as the place marker
        to be formatted.</p>

        <p>If <a title="backwards compatible behavior" href=
        "index.html#dt-backwards-compatible-behavior">backwards compatible
        behavior</a> is enabled for the instruction, then:</p>

        <ul>
          <li>
            <p>all items in the <a title="atomize" href=
            "index.html#dt-atomization">atomized</a> sequence after the first
            are discarded;</p>
          </li>

          <li>
            <p>If the atomized sequence is empty, it is replaced by
            a sequence containing the <code>xs:double</code> value
            <code>NaN</code> as its only item;</p>
          </li>

          <li>
            <p>If any value in the sequence cannot be converted to
            an integer (this includes the case where the sequence
            contains a <code>NaN</code> value) then the string
            <code>NaN</code> is inserted into the formatted result
            string in its proper position. The error described in
            the following paragraph does not apply in this
            case.</p>
          </li>
        </ul>

        <p><a name="err-XTDE0980" id="err-XTDE0980"><span class=
        "error">[ERR XTDE0980]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if any undiscarded item in the atomized sequence
        supplied as the value of the <code>value</code> attribute
        of <a href="index.html#element-number"><code>xsl:number</code></a>
        cannot be converted to an integer, or if the resulting
        integer is less than 0 (zero).</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The value zero does not arise when numbering nodes in
          a source document, but it can arise in other numbering
          sequences. It is permitted specifically because the rules
          of the <a href=
          "index.html#element-number"><code>xsl:number</code></a> instruction
          are also invoked by functions such as <a href=
          "index.html#function-format-time"><code>format-time</code></a>: the
          minutes and seconds component of a time value can
          legitimately be zero.</p>
        </div>

        <p>The resulting sequence is formatted as a string using
        the <a title="effective value" href=
        "index.html#dt-effective-value">effective values</a> of the
        attributes specified in <a href="index.html#convert"><i>12.3 Number
        to String Conversion Attributes</i></a>; each of these
        attributes is interpreted as an <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>. After conversion, the <a href=
        "index.html#element-number"><code>xsl:number</code></a> element
        constructs a new text node containing the resulting string,
        and returns this node.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18312" id="d5e18312"></a>Example: Numbering
            a Sorted List
          </div>

          <p>The following example numbers a sorted list:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="items"&gt;
  &lt;xsl:for-each select="item"&gt;
    &lt;xsl:sort select="."/&gt;
    &lt;p&gt;
      &lt;xsl:number value="position()" format="1. "/&gt;
      &lt;xsl:value-of select="."/&gt;
    &lt;/p&gt;
  &lt;/xsl:for-each&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="numbering-based-on-position" id=
        "numbering-based-on-position"></a>12.2 Numbering based on
        Position in a Document</h3>

        <p>If no <code>value</code> attribute is specified, then
        the <a href="index.html#element-number"><code>xsl:number</code></a>
        instruction returns a new text node containing a formatted
        <a title="place marker" href="index.html#dt-place-marker">place
        marker</a> that is based on the position of <span>a
        selected node within its containing document. If the
        <code>select</code> attribute is present, then the
        expression contained in the <code>select</code> attribute
        is evaluated to determine the selected node. If the
        <code>select</code> attribute is omitted, then the selected
        node is the <a title="context node" href=
        "index.html#dt-context-node">context node</a>.</span></p>

        <p><a name="err-XTTE0990" id="err-XTTE0990"><span class=
        "error">[ERR XTTE0990]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        <a href="index.html#element-number"><code>xsl:number</code></a>
        instruction is evaluated, with no <code>value</code> or
        <code>select</code> attribute, when the <a title=
        "context item" href="index.html#dt-context-item">context item</a> is
        not a node.</p>

        <p><a name="err-XTTE1000" id="err-XTTE1000"><span class=
        "error">[ERR XTTE1000]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        result of evaluating the <code>select</code> attribute of
        the <a href="index.html#element-number"><code>xsl:number</code></a>
        instruction is anything other than a single node.</p>

        <p>The following attributes control how the selected node
        is to be numbered:</p>

        <ul>
          <li>
            <p>The <code>level</code> attribute specifies rules for
            selecting the nodes that are taken into account in
            allocating a number; it has the values
            <code>single</code>, <code>multiple</code> or
            <code>any</code>. The default is
            <code>single</code>.</p>
          </li>

          <li>
            <p>The <code>count</code> attribute is a <a title=
            "pattern" href="index.html#dt-pattern">pattern</a> that specifies
            which nodes are to be counted at those levels. If
            <code>count</code> attribute is not specified, then it
            defaults to the pattern that matches any node with the
            same node <span>kind</span> as the
            <span>selected</span> node and, if the
            <span>selected</span> node has an <a title=
            "expanded-QName" href=
            "index.html#dt-expanded-qname">expanded-QName</a>, with the same
            <a title="expanded-QName" href=
            "index.html#dt-expanded-qname">expanded-QName</a> as the
            <span>selected</span> node.</p>
          </li>

          <li>
            <p>The <code>from</code> attribute is a <a title=
            "pattern" href="index.html#dt-pattern">pattern</a> that specifies
            where counting starts.</p>
          </li>
        </ul>

        <p>In addition, the attributes specified in <a href=
        "index.html#convert"><i>12.3 Number to String Conversion
        Attributes</i></a> are used for number to string
        conversion, as in the case when the <code>value</code>
        attribute is specified.</p>

        <p>The <a href=
        "index.html#element-number"><code>xsl:number</code></a> element first
        constructs a sequence of positive integers using the
        <code>level</code>, <code>count</code> and
        <code>from</code> attributes. Where <code>level</code> is
        <code>single</code> or <code>any</code>, this sequence will
        either be empty or contain a single number; where
        <code>level</code> is <code>multiple</code>, the sequence
        may be of any length. The sequence is constructed as
        follows:</p>

        <p>Let <code>matches-count($node)</code> be a function that
        returns true if and only if the given node
        <code>$node</code> matches the pattern given in the
        <code>count</code> attribute, or the implied pattern
        (according to the rules given above) if the
        <code>count</code> attribute is omitted.</p>

        <p>Let <code>matches-from($node)</code> be a function that
        returns true if and only if the given node
        <code>$node</code> matches the pattern given in the
        <code>from</code> attribute, <span>or if <code>$node</code>
        is the root node of a tree. If the <code>from</code>
        attribute is omitted, then the function returns true if and
        only if <code>$node</code> is the root node of a
        tree</span>.</p>

        <p>Let <code>$S</code> be the selected node.</p>

        <p>When <code>level="single"</code>:</p>

        <ul>
          <li>
            <p>Let <code>$A</code> be the node sequence selected by
            the following expression:</p>

            <p>
            <code>&#160;&#160;&#160;$S/ancestor-or-self::node()[matches-count(.)][1]</code></p>

            <p>(this selects the innermost ancestor-or-self node
            that matches the <code>count</code> pattern)</p>
          </li>

          <li>
            <p>Let <code>$F</code> be the node sequence selected by
            the expression</p>

            <p>
            <code>&#160;&#160;&#160;$S/ancestor-or-self::node()[matches-from(.)][1]</code></p>

            <p>(this selects the innermost ancestor-or-self node
            that matches the <code>from</code> pattern):</p>
          </li>

          <li>
            <p>Let <code>$AF</code> be the value of:</p>

            <p>
            <code>&#160;&#160;&#160;$A[ancestor-or-self::node()[.
            is $F]]</code></p>

            <p>(this selects $A if it is in the subtree rooted at
            $F, or the empty sequence otherwise)</p>
          </li>

          <li>
            <p>If <code>$AF</code> is empty, return the empty
            sequence, <code>()</code></p>
          </li>

          <li>
            <p>Otherwise return the value of:</p>

            <p><code>&#160;&#160;&#160;1 +
            count($AF/preceding-sibling::node()[matches-count(.)])</code></p>

            <p>(the number of preceding siblings of the counted
            node that match the <code>count</code> pattern, plus
            one).</p>
          </li>
        </ul>

        <p>When <code>level="multiple"</code>:</p>

        <ul>
          <li>
            <p>Let <code>$A</code> be the node sequence selected by
            the expression</p>

            <p>
            <code>&#160;&#160;&#160;$S/ancestor-or-self::node()[matches-count(.)]</code></p>

            <p>(the set of ancestor-or-self nodes that match the
            <code>count</code> pattern)</p>
          </li>

          <li>
            <p>Let <code>$F</code> be the node sequence selected by
            the expression</p>

            <p>
            <code>&#160;&#160;&#160;$S/ancestor-or-self::node()[matches-from(.)][1]</code></p>

            <p>(the innermost ancestor-or-self node that matches
            the <code>from</code> pattern)</p>
          </li>

          <li>
            <p>Let <code>$AF</code> be the value of</p>

            <p>
            <code>&#160;&#160;&#160;$A[ancestor-or-self::node()[.
            is $F]]</code></p>

            <p>(the nodes selected in the first step that are in
            the subtree rooted at the node selected in the second
            step)</p>
          </li>

          <li>
            <p>Return the result of the expression</p>

            <p><code>&#160;&#160;&#160;for $af in $AF return
            1+count($af/preceding-sibling::node()[matches-count(.)])</code></p>

            <p>(a sequence of integers containing, for each of
            these nodes, one plus the number of preceding siblings
            that match the <code>count</code> pattern)</p>
          </li>
        </ul>

        <p>When <code>level="any"</code>:</p>

        <ul>
          <li>
            <p>Let <code>$A</code> be the node sequence selected by
            the expression</p>

            <p>
            <code>&#160;&#160;&#160;$S/(preceding::node()|ancestor-or-self::node())[matches-count(.)]</code></p>

            <p>(the set of nodes consisting of the selected node
            together with all nodes, other than attributes and
            namespaces, that precede the selected node in document
            order, provided that they match the <code>count</code>
            pattern)</p>
          </li>

          <li>
            <p>Let <code>$F</code> be the node sequence selected by
            the expression</p>

            <p>
            <code>&#160;&#160;&#160;$S/(preceding::node()|ancestor::node())[matches-from(.)][last()]</code></p>

            <p>(the last node in document order that matches the
            <code>from</code> pattern and that precedes the
            selected node, using the same definition)</p>
          </li>

          <li>
            <p>Let <code>$AF</code> be the node sequence <code>$A[.
            is $F or . &gt;&gt; $F]</code>.</p>

            <p>(the nodes selected in the first step, excluding
            those that precede the node selected in the second
            step)</p>
          </li>

          <li>
            <p>If <code>$AF</code> is empty, return the empty
            sequence, <code>()</code></p>
          </li>

          <li>
            <p>Otherwise return the value of the expression
            <code>count($AF)</code></p>
          </li>
        </ul>

        <p>The sequence of numbers (the <a title="place marker"
        href="index.html#dt-place-marker">place marker</a>) is then converted
        into a string using the <a title="effective value" href=
        "index.html#dt-effective-value">effective values</a> of the
        attributes specified in <a href="index.html#convert"><i>12.3 Number
        to String Conversion Attributes</i></a>; each of these
        attributes is interpreted as an <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        template</a>. After conversion, the resulting string is
        <span>used to create a text node, which forms the result of
        the <a href="index.html#element-number"><code>xsl:number</code></a>
        instruction</span>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18740" id="d5e18740"></a>Example: Numbering
            the Items in an Ordered List
          </div>

          <p>The following will number the items in an ordered
          list:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="ol/item"&gt;
  &lt;fo:block&gt;
    &lt;xsl:number/&gt;
    &lt;xsl:text&gt;. &lt;/xsl:text&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18747" id="d5e18747"></a>Example:
            Multi-Level Numbering
          </div>

          <p>The following two rules will number <code>title</code>
          elements. This is intended for a document that contains a
          sequence of chapters followed by a sequence of
          appendices, where both chapters and appendices contain
          sections, which in turn contain subsections. Chapters are
          numbered 1, 2, 3; appendices are numbered A, B, C;
          sections in chapters are numbered 1.1, 1.2, 1.3; sections
          in appendices are numbered A.1, A.2, A.3.
          <span>Subsections within a chapter are numbered 1.1.1,
          1.1.2, 1.1.3; subsections within an appendix are numbered
          A.1.1, A.1.2, A.1.3.</span></p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="title"&gt;
  &lt;fo:block&gt;
     &lt;xsl:number level="multiple"
                 count="chapter|section|subsection"
                 format="1.1 "/&gt;
     &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="appendix//title" priority="1"&gt;
  &lt;fo:block&gt;
     &lt;xsl:number level="multiple"
                 count="appendix|section|subsection"
                 format="A.1 "/&gt;
     &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18759" id="d5e18759"></a>Example: Numbering
            Notes within a Chapter
          </div>

          <p>This example numbers notes sequentially within a
          chapter:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="note"&gt;
  &lt;fo:block&gt;
     &lt;xsl:number level="any" from="chapter" format="(1) "/&gt;
     &lt;xsl:apply-templates/&gt;
  &lt;/fo:block&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="convert" id="convert"></a>12.3 Number to
        String Conversion Attributes</h3>

        <p>The following attributes are used to control conversion
        of a sequence of numbers into a string. The numbers are
        integers greater than <span>or equal to</span> 0 (zero).
        The attributes are all optional.</p>

        <p>The main attribute is <code>format</code>. The default
        value for the <code>format</code> attribute is
        <code>1</code>. The <code>format</code> attribute is split
        into a sequence of tokens where each token is a maximal
        sequence of alphanumeric characters or a maximal sequence
        of non-alphanumeric characters. <em>Alphanumeric</em> means
        any character that has a Unicode category of Nd, Nl, No,
        Lu, Ll, Lt, Lm or Lo. The alphanumeric tokens (<em>format
        tokens</em>) indicate the format to be used for each number
        in the sequence; in most cases the format token is the same
        as the required representation of the number 1 (one).</p>

        <p>Each non-alphanumeric token is either a prefix, a
        separator, or a suffix. <span>If there is a
        non-alphanumeric token but no format token, then the single
        non-alphanumeric token is used as both the prefix and the
        suffix.</span> The prefix, if it exists, is the
        non-alphanumeric token that precedes the first format
        token: the prefix always appears exactly once in the
        constructed string, at the start. The suffix, if it exists,
        is the non-alphanumeric token that follows the last format
        token: the suffix always appears exactly once in the
        constructed string, at the end. All other non-alphanumeric
        tokens (those that occur between two format tokens) are
        <em>separator tokens</em> and are used to separate numbers
        in the sequence.</p>

        <p>The <var>n</var>th format token is used to format the
        <var>n</var>th number in the sequence. If there are more
        numbers than format tokens, then the last format token is
        used to format remaining numbers. If there are no format
        tokens, then a format token of <code>1</code> is used to
        format all numbers. Each number after the first is
        separated from the preceding number by the separator token
        preceding the format token used to format that number, or,
        if <span>that is the first format token</span>, then by
        <code>.</code> (dot).</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e18820" id="d5e18820"></a>Example:
            Formatting a List of Numbers
          </div>

          <p>Given the sequence of numbers <code>5, 13, 7</code>
          and the format token <code>A-001(i)</code>, the output
          will be the string <code>E-013(vii)</code></p>
        </div>

        <p>Format tokens are interpreted as follows:</p>

        <ul>
          <li>
            <p>Any token where the last character has a decimal
            digit value of 1 (as specified in the Unicode character
            property database), and the Unicode value of preceding
            characters is one less than the Unicode value of the
            last character generates a decimal representation of
            the number where each number is at least as long as the
            format token. <span>The digits used in the decimal
            representation are the set of digits containing the
            digit character used in the format token.</span> Thus,
            a format token <code>1</code> generates the sequence
            <code>0 1 2 ... 10 11 12 ...</code>, and a format token
            <code>01</code> generates the sequence <code>00 01 02
            ... 09 10 11 12 ... 99 100 101</code>. <span>A format
            token of <code>&amp;#x661;</code> (Arabic-Indic digit
            one) generates the sequence <code>١</code> then
            <code>٢</code> then <code>٣</code> ...</span></p>
          </li>

          <li>
            <p>A format token <code>A</code> generates the sequence
            <code>A B C ... Z AA AB AC...</code>.</p>
          </li>

          <li>
            <p>A format token <code>a</code> generates the sequence
            <code>a b c ... z aa ab ac...</code>.</p>
          </li>

          <li>
            <p>A format token <code>i</code> generates the sequence
            <code>i ii iii iv v vi vii viii ix x ...</code>.</p>
          </li>

          <li>
            <p>A format token <code>I</code> generates the sequence
            <code>I II III IV V VI VII VIII IX X ...</code>.</p>
          </li>

          <li>
            <p>A format token <code>w</code> generates numbers
            written as lower-case words, for example in English,
            <code>one two three four ...</code></p>
          </li>

          <li>
            <p>A format token <code>W</code> generates numbers
            written as upper-case words, for example in English,
            <code>ONE TWO THREE FOUR ...</code></p>
          </li>

          <li>
            <p>A format token <code>Ww</code> generates numbers
            written as title-case words, for example in English,
            <code>One Two Three Four ...</code></p>
          </li>

          <li>
            <p>Any other format token indicates a numbering
            sequence <span>in which that token represents the
            number 1 (one)</span> (but see the note below). It is
            <a title="implementation-defined" href=
            "index.html#dt-implementation-defined">implementation-defined</a>
            which numbering sequences, additional to those listed
            above, are supported. If an implementation does not
            support a numbering sequence represented by the given
            token, it <span class="verb">must</span> use a format
            token of <code>1</code>.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>In some traditional numbering sequences additional
              signs are added to denote that the letters should be
              interpreted as numbers; these are not included in the
              format token. An example, see also the example below,
              is classical Greek where a <em>dexia keraia</em> and
              sometimes an <em>aristeri keraia</em> is added.</p>
            </div>
          </li>
        </ul>

        <p>For all format tokens other than the first kind above
        (one that consists of decimal digits), there <span class=
        "verb">may</span> be <a title="implementation-defined"
        href="index.html#dt-implementation-defined">implementation-defined</a>
        <span>lower and</span> upper bounds on the range of numbers
        that can be formatted using this format token; indeed, for
        some numbering sequences there may be intrinsic limits.
        <span>For example, the formatting token
        <code>&amp;#x2460;</code> (circled digit one) has a range
        of 1 to 20 imposed by the Unicode character
        repertoire.</span> For the numbering sequences described
        above <span>any upper bound imposed by the implementation
        <span class="verb">must not</span> be less than 1000 (one
        thousand) and any lower bound must not be greater than 1.
        Numbers that fall outside this range <span class=
        "verb">must</span> be formatted using the format token
        <code>1</code>. The numbering sequence associated with the
        format token <code>1</code> has a lower bound of 0
        (zero)</span>.</p>

        <p>The above expansions of numbering sequences for format
        tokens such as <code>a</code> and <code>i</code> are
        indicative but not prescriptive. There are various
        conventions in use for how alphabetic sequences continue
        when the alphabet is exhausted, and differing conventions
        for how roman numerals are written (for example,
        <code>IV</code> versus <code>IIII</code> as the
        representation of the number 4). Sometimes alphabetic
        sequences are used that omit letters such as <code>i</code>
        and <code>o</code>. This specification does not prescribe
        the detail of any sequence other than those sequences
        consisting entirely of decimal digits.</p>

        <p>Many numbering sequences are language-sensitive. This
        applies especially to the sequence selected by the tokens
        <code>w</code>, <code>W</code> and <code>Ww</code>. It also
        applies to other sequences, for example different languages
        using the Cyrillic alphabet use different sequences of
        characters, each starting with the letter #x410 (Cyrillic
        capital letter A). In such cases, the <code>lang</code>
        attribute specifies which language's conventions are to be
        used; it has the same range of values as
        <code>xml:lang</code> (see <a href="index.html#REC-xml">[XML
        1.0]</a>). If no <code>lang</code> value is specified, the
        language that is used is <a title="implementation-defined"
        href=
        "index.html#dt-implementation-defined">implementation-defined</a>.
        The set of languages for which numbering is supported is
        <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>. If
        a language is requested that is not supported, the
        processor uses the language that it would use if the
        <code>lang</code> attribute were omitted.</p>

        <p>If the optional <code>ordinal</code> attribute is
        present, and if its value is not a zero-length string, this
        indicates a request to output ordinal numbers rather than
        cardinal numbers. For example, in English, the value
        <code>ordinal="yes"</code> when used with the format token
        <code>1</code> outputs the sequence <code>1st 2nd 3rd 4th
        ...</code>, and when used with the format token
        <code>w</code> outputs the sequence <code>first second
        third fourth ...</code>. In some languages, ordinal numbers
        vary depending on the grammatical context, for example they
        may have different genders and may decline with the noun
        that they qualify. In such cases the value of the
        <code>ordinal</code> attribute may be used to indicate the
        variation of the ordinal number required. The way in which
        the variation is indicated will depend on the conventions
        of the language. For inflected languages that vary the
        ending of the word, the preferred approach is to indicate
        the required ending, preceded by a hyphen: for example in
        German, appropriate values are <code>-e, -er, -es,
        -en</code>. <span>It is <a title="implementation-defined"
        href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        what combinations of values of the format token, the
        language, and the <code>ordinal</code> attribute are
        supported.</span> If ordinal numbering is not supported for
        the combination of the format token, the language, and the
        actual value of the <code>ordinal</code> attribute, the
        request is ignored and cardinal numbers are generated
        instead.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e19098" id="d5e19098"></a>Example: Ordinal
            Numbering in Italian
          </div>

          <p>The specification <code>format="1" ordinal="-º"
          lang="it"</code>, if supported, should produce the
          sequence:</p>

          <div class="exampleInner">
            <pre>
1º 2º 3º 4º ...
</pre>
          </div>

          <p>The specification <code>format="Ww" ordinal="-o"
          lang="it"</code>, if supported, should produce the
          sequence:</p>

          <div class="exampleInner">
            <pre>
Primo Secondo Terzo Quarto Quinto ...
</pre>
          </div>
        </div>

        <p>The <code>letter-value</code> attribute disambiguates
        between numbering sequences that use letters. In many
        languages there are two commonly used numbering sequences
        that use letters. One numbering sequence assigns numeric
        values to letters in alphabetic sequence, and the other
        assigns numeric values to each letter in some other manner
        traditional in that language. In English, these would
        correspond to the numbering sequences specified by the
        format tokens <code>a</code> and <code>i</code>. In some
        languages, the first member of each sequence is the same,
        and so the format token alone would be ambiguous. A value
        of <code>alphabetic</code> specifies the alphabetic
        sequence; a value of <code>traditional</code> specifies the
        other sequence. If the <code>letter-value</code> attribute
        is not specified, then it is <a title=
        "implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>
        how any ambiguity is resolved.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Implementations may use <span><a title=
          "extension attribute" href=
          "index.html#dt-extension-attribute">extension attributes</a></span>
          on <a href="index.html#element-number"><code>xsl:number</code></a>
          to provide additional control over the way in which
          numbers are formatted.</p>
        </div>

        <p>The <code>grouping-separator</code> attribute gives the
        separator used as a grouping (for example, thousands)
        separator in decimal numbering sequences, and the optional
        <code>grouping-size</code> specifies the size (normally 3)
        of the grouping. For example,
        <code>grouping-separator=","</code> and
        <code>grouping-size="3"</code> would produce numbers of the
        form <code>1,000,000</code> while
        <code>grouping-separator="."</code> and
        <code>grouping-size="2"</code> would produce numbers of the
        form <code>1.00.00.00</code>. If only one of the
        <code>grouping-separator</code> and
        <code>grouping-size</code> attributes is specified, then it
        is ignored.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e19182" id="d5e19182"></a>Example: Format
            Tokens and the Resulting Sequences
          </div>

          <p>These examples use non-Latin characters which might
          not display correctly in all browsers, depending on the
          system configuration.</p>

          <table border="1" cellpadding="5">
            <thead>
              <tr>
                <th align="left">Description</th>

                <th align="left">Format Token</th>

                <th align="left">Sequence</th>
              </tr>
            </thead>

            <tbody>
              <tr>
                <td>French cardinal words</td>

                <td><code>format="Ww" lang="fr"</code></td>

                <td>Un, Deux, Trois, Quatre</td>
              </tr>

              <tr>
                <td>German ordinal words</td>

                <td><code>format="w" ordinal="-e"
                lang="de"</code></td>

                <td>erste, zweite, dritte, vierte</td>
              </tr>

              <tr>
                <td>Katakana numbering</td>

                <td><code>format="&amp;#x30A2;"</code></td>

                <td>ア, イ, ウ, エ, オ, カ, キ, ク, ケ, コ, サ, シ, ス, セ, ソ, タ,
                チ, ツ, テ, ト, ナ, ニ, ヌ, ネ, ノ, ハ, ヒ, フ, ヘ, ホ, マ, ミ, ム,
                メ, モ, ヤ, ユ, ヨ, ラ, リ, ル, レ, ロ, ワ, ヰ, ヱ, ヲ, ン</td>
              </tr>

              <tr>
                <td>Katakana numbering in iroha order</td>

                <td><code>format="&amp;#x30A4;"</code></td>

                <td>イ, ロ, ハ, ニ, ホ, ヘ, ト, チ, リ, ヌ, ル, ヲ, ワ, カ, ヨ, タ,
                レ, ソ, ツ, ネ, ナ, ラ, ム, ウ, ヰ, ノ, オ, ク, ヤ, マ, ケ, フ, コ,
                エ, テ, ア, サ, キ, ユ, メ, ミ, シ, ヱ, ヒ, モ, セ, ス</td>
              </tr>

              <tr>
                <td>Thai numbering</td>

                <td><code>format="&amp;#x0E51;"</code></td>

                <td>๑, ๒, ๓, ๔, ๕, ๖, ๗, ๘, ๙, ๑๐, ๑๑, ๑๒, ๑๓, ๑๔,
                ๑๕, ๑๖, ๑๗, ๑๘, ๑๙, ๒๐</td>
              </tr>

              <tr>
                <td>Traditional Hebrew numbering</td>

                <td><code>format="&amp;#x05D0;"
                letter-value="traditional"</code></td>

                <td>א, ב, ג, ד, ה, ו, ז, ח, ט, י, יא, יב, יג, יד,
                טו, טז, יז, יח, יט, כ</td>
              </tr>

              <tr>
                <td>Traditional Georgian numbering</td>

                <td><code>format="&amp;#x10D0;"
                letter-value="traditional"</code></td>

                <td>ა, ბ, გ, დ, ე, ვ, ზ, ჱ, თ, ი, ია, იბ, იგ, იდ,
                იე, ივ, იზ, იჱ, ით, კ</td>
              </tr>

              <tr>
                <td>Classical Greek numbering (see note)</td>

                <td><code>format="&amp;#x03B1;"
                letter-value="traditional"</code></td>

                <td>αʹ, βʹ, γʹ, δʹ, εʹ, ϛʹ, ζʹ, ηʹ, θʹ, ιʹ, ιαʹ,
                ιβʹ, ιγʹ, ιδʹ, ιεʹ, ιϛʹ, ιζʹ, ιηʹ, ιθʹ, κʹ</td>
              </tr>

              <tr>
                <td>Old Slavic numbering</td>

                <td><code>format="&amp;#x0430;"
                letter-value="traditional"</code></td>

                <td>А, В, Г, Д, Е, Ѕ, З, И, Ѳ, Ӏ, АӀ, ВӀ, ГӀ, ДӀ,
                ЕӀ, ЅӀ, ЗӀ, ИӀ, ѲӀ, К</td>
              </tr>
            </tbody>
          </table>

          <p>Note that Glassical Greek is an example where the
          format token is not the same as the representation of the
          number 1.</p>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="sorting" id="sorting"></a>13 Sorting</h2>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-sort-key-specification" id="dt-sort-key-specification"
      title="sort key specification"></a>A <b>sort key
      specification</b> is a sequence of one or more adjacent
      <a href="index.html#element-sort"><code>xsl:sort</code></a> elements
      which together define rules for sorting the items in an input
      sequence to form a sorted sequence.<span class=
      "definition">]</span></p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-sort-key-component" id="dt-sort-key-component" title=
      "sort key component"></a>Within a <a title=
      "sort key specification" href=
      "index.html#dt-sort-key-specification">sort key specification</a>, each
      <a href="index.html#element-sort"><code>xsl:sort</code></a> element
      defines one <b>sort key component</b>.<span class=
      "definition">]</span> The first <a href=
      "index.html#element-sort"><code>xsl:sort</code></a> element specifies
      the primary component of the sort key specification, the
      second <a href="index.html#element-sort"><code>xsl:sort</code></a>
      element specifies the secondary component of the sort key
      specification and so on.</p>

      <p>A sort key specification may occur immediately within an
      <a href=
      "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
      <a href="index.html#element-for-each"><code>xsl:for-each</code></a>,
      <a href=
      "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>, or
      <a href=
      "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
      element.</p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>When used within <a href=
        "index.html#element-for-each"><code>xsl:for-each</code></a>, <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
        or <a href=
        "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>,
        <a href="index.html#element-sort"><code>xsl:sort</code></a> elements
        must occur before any other children.</p>
      </div>

      <div class="div2">
        <h3><a name="xsl-sort" id="xsl-sort"></a>13.1 The <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> Element</h3>

        <p class="element-syntax"><a name="element-sort" id=
        "element-sort"></a><code>&lt;xsl:sort<br />
        &#160;&#160;select? = <var>expression</var><br />
        &#160;&#160;lang? = { <var>nmtoken</var> }<br />
        &#160;&#160;order? = { "ascending" | "descending" }<br />
        &#160;&#160;collation? = { <var>uri</var> }<br />
        &#160;&#160;stable? = { "yes" | "no" }<br />
        &#160;&#160;case-order? = { "upper-first" | "lower-first"
        }<br />
        &#160;&#160;data-type? = { "text" | "number" |
        <var>qname-but-not-ncname</var> }&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:sort&gt;</code></p>

        <p>The <a href="index.html#element-sort"><code>xsl:sort</code></a>
        element defines a <a title="sort key component" href=
        "index.html#dt-sort-key-component">sort key component</a>. A sort key
        component specifies how a <a title="sort key value" href=
        "index.html#dt-sort-key-value">sort key value</a> is to be computed
        for each item in the sequence being sorted, and also how
        two sort key values are to be compared.</p>

        <p>The value of a <a title="sort key component" href=
        "index.html#dt-sort-key-component">sort key component</a> is
        determined either by its <code>select</code> attribute, or
        by the contained <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>. If
        neither is present, the default is <code>select="."</code>,
        which has the effect of sorting on the actual value of the
        item if it is an atomic value, or on the typed-value of the
        item if it is a node. If a <code>select</code> attribute is
        present, its value <span class="verb">must</span> be an
        XPath <a title="expression" href=
        "index.html#dt-expression">expression</a>.</p>

        <p><a name="err-XTSE1015" id="err-XTSE1015"><span class=
        "error">[ERR XTSE1015]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an <a href="index.html#element-sort"><code>xsl:sort</code></a>
        element with a <code>select</code> attribute has non-empty
        content.</p>

        <p>Those attributes of the <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> elements whose
        values are <a title="attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        templates</a> are evaluated using the same <a title="focus"
        href="index.html#dt-focus">focus</a> as is used to evaluate the
        <code>select</code> attribute of the containing instruction
        (specifically, <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        <a href="index.html#element-for-each"><code>xsl:for-each</code></a>,
        <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
        or <a href=
        "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>).</p>

        <p>The <code>stable</code> attribute is permitted only on
        the first <a href="index.html#element-sort"><code>xsl:sort</code></a>
        element within a <a title="sort key specification" href=
        "index.html#dt-sort-key-specification">sort key specification</a></p>

        <p><a name="err-XTSE1017" id="err-XTSE1017"><span class=
        "error">[ERR XTSE1017]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an <a href="index.html#element-sort"><code>xsl:sort</code></a>
        element other than the first in a sequence of sibling
        <a href="index.html#element-sort"><code>xsl:sort</code></a> elements
        has a <code>stable</code> attribute.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-stable"
        id="dt-stable" title="stable"></a>A <a title=
        "sort key specification" href=
        "index.html#dt-sort-key-specification">sort key specification</a> is
        said to be <b>stable</b> if its first <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> element has no
        <code>stable</code> attribute, or has a <code>stable</code>
        attribute whose <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> is
        <code>yes</code>.<span class="definition">]</span></p>

        <div class="div3">
          <h4><a name="sorting-process" id=
          "sorting-process"></a>13.1.1 The Sorting Process</h4>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-initial-sequence" id="dt-initial-sequence" title=
          "initial sequence"></a>The sequence to be sorted is
          referred to as the <b>initial sequence</b>.<span class=
          "definition">]</span></p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-sorted-sequence" id="dt-sorted-sequence" title=
          "sorted sequence"></a>The sequence after sorting as
          defined by the <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> elements is
          referred to as the <b>sorted sequence</b>.<span class=
          "definition">]</span></p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-sort-key-value" id="dt-sort-key-value" title=
          "sort key value"></a> For each item in the <a title=
          "initial sequence" href="index.html#dt-initial-sequence">initial
          sequence</a>, a value is computed for each <a title=
          "sort key component" href="index.html#dt-sort-key-component">sort
          key component</a> within the <a title=
          "sort key specification" href=
          "index.html#dt-sort-key-specification">sort key specification</a>.
          The value computed for an item by using the
          <var>N</var>th sort key component is referred to as the
          <var>N</var>th <b>sort key value</b> of that
          item.<span class="definition">]</span></p>

          <p>The items in the <a title="initial sequence" href=
          "index.html#dt-initial-sequence">initial sequence</a> are ordered
          into a <a title="sorted sequence" href=
          "index.html#dt-sorted-sequence">sorted sequence</a> by comparing
          their <a title="sort key value" href=
          "index.html#dt-sort-key-value">sort key values</a>. The relative
          position of two items <var>A</var> and <var>B</var> in
          the sorted sequence is determined as follows. The first
          sort key value of <var>A</var> is compared with the first
          sort key value of <var>B</var>, according to the rules of
          the first <a title="sort key component" href=
          "index.html#dt-sort-key-component">sort key component</a>. If,
          under these rules, <var>A</var> is less than
          <var>B</var>, then <var>A</var> will precede <var>B</var>
          in the sorted sequence, unless the <code>order</code>
          attribute of this <a title="sort key component" href=
          "index.html#dt-sort-key-component">sort key component</a> specifies
          <code>descending</code>, in which case <var>B</var> will
          precede <var>A</var> in the sorted sequence. If, however,
          the relevant sort key values compare equal, then the
          second sort key value of <var>A</var> is compared with
          the second sort key value of <var>B</var>, according to
          the rules of the second <a title="sort key component"
          href="index.html#dt-sort-key-component">sort key component</a>.
          This continues until two sort key values are found that
          compare unequal. If all the sort key values compare
          equal, <span>and the <a title="sort key specification"
          href="index.html#dt-sort-key-specification">sort key
          specification</a> is <a title="stable" href=
          "index.html#dt-stable">stable</a>,</span> then <var>A</var> will
          precede <var>B</var> in the <a title="sorted sequence"
          href="index.html#dt-sorted-sequence">sorted sequence</a> if and
          only if <var>A</var> preceded <var>B</var> in the
          <a title="initial sequence" href=
          "index.html#dt-initial-sequence">initial sequence</a>. <span>If all
          the sort key values compare equal, and the <a title=
          "sort key specification" href=
          "index.html#dt-sort-key-specification">sort key specification</a>
          is not <a title="stable" href="index.html#dt-stable">stable</a>,
          then the relative order of <var>A</var> and <var>B</var>
          in the <a title="sorted sequence" href=
          "index.html#dt-sorted-sequence">sorted sequence</a> is <a title=
          "implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>.</span></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>If two items have equal <a title="sort key value"
            href="index.html#dt-sort-key-value">sort key values</a>,
            <span>and the sort is <a title="stable" href=
            "index.html#dt-stable">stable</a>,</span> then their order in the
            <a title="sorted sequence" href=
            "index.html#dt-sorted-sequence">sorted sequence</a> will be the
            same as their order in the <a title="initial sequence"
            href="index.html#dt-initial-sequence">initial sequence</a>,
            regardless of whether <code>order="descending"</code>
            was specified on any or all of the <a title=
            "sort key component" href="index.html#dt-sort-key-component">sort
            key components</a>.</p>
          </div>

          <p>The <var>N</var>th sort key value is computed by
          evaluating either the <code>select</code> attribute or
          the contained <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> of
          the <var>N</var>th <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element, or the
          expression <code>.</code> (dot) if neither is present.
          This evaluation is done with the <a title="focus" href=
          "index.html#dt-focus">focus</a> set as follows:</p>

          <ul>
            <li>
              <p>The <a title="context item" href=
              "index.html#dt-context-item">context item</a> is the item in
              the <a title="initial sequence" href=
              "index.html#dt-initial-sequence">initial sequence</a> whose
              <a title="sort key value" href=
              "index.html#dt-sort-key-value">sort key value</a> is being
              computed.</p>
            </li>

            <li>
              <p>The <a title="context position" href=
              "index.html#dt-context-position">context position</a> is the
              position of that item in the initial sequence.</p>
            </li>

            <li>
              <p>The <a title="context size" href=
              "index.html#dt-context-size">context size</a> is the size of
              the initial sequence.</p>
            </li>
          </ul>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>As in any other XPath expression, the <a href=
            "index.html#function-current"><code>current</code></a> function
            may be used within the <code>select</code> expression
            of <a href="index.html#element-sort"><code>xsl:sort</code></a> to
            refer to the item that is the context item for the
            expression as a whole; that is, the item whose
            <a title="sort key value" href=
            "index.html#dt-sort-key-value">sort key value</a> is being
            computed.</p>
          </div>

          <p>The <a title="sort key value" href=
          "index.html#dt-sort-key-value">sort key values</a> are <a title=
          "atomize" href="index.html#dt-atomization">atomized</a>, and are
          then compared. The way they are compared depends on their
          data type, as described in the next section.</p>
        </div>

        <div class="div3">
          <h4><a name="comparing-sort-keys" id=
          "comparing-sort-keys"></a>13.1.2 Comparing Sort Key
          Values</h4>

          <p>It is possible to force the system to compare
          <a title="sort key value" href="index.html#dt-sort-key-value">sort
          key values</a> using the rules for a particular data type
          by including a cast as part of the <a title=
          "sort key component" href="index.html#dt-sort-key-component">sort
          key component</a>. For example, <code>&lt;xsl:sort
          select="xs:date(@dob)"/&gt;</code> will force the
          attributes to be compared as dates. In the absence of
          such a cast, the sort key values are compared using the
          rules appropriate to their data type. Any values of type
          <span><code>xs:untypedAtomic</code></span> are cast to
          <code>xs:string</code>.</p>

          <p>For backwards compatibility with XSLT 1.0, the
          <code>data-type</code> attribute <span>remains available.
          If this has the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a>
          <code>text</code>, the atomized <a title="sort key value"
          href="index.html#dt-sort-key-value">sort key values</a> are
          converted to strings before being compared. If it has the
          effective value <code>number</code>, the atomized sort
          key values are converted to doubles before being
          compared. The conversion is done by using the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-string"><code>
          string</code></a><sup><small>FO</small></sup> or <a href=
          "http://www.w3.org/TR/xpath-functions/#func-number"><code>
          number</code></a><sup><small>FO</small></sup> function as
          appropriate.</span> If the <code>data-type</code>
          attribute has any other <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a>, then the value
          <span class="verb">must</span> be a <span><a title=
          "lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a> with a non-empty prefix</span>, and the effect
          of the attribute is <a title="implementation-defined"
          href=
          "index.html#dt-implementation-defined">implementation-defined</a>.</p>

          <p><a name="err-XTTE1020" id="err-XTTE1020"><span class=
          "error">[ERR XTTE1020]</span></a> If any <a title=
          "sort key value" href="index.html#dt-sort-key-value">sort key
          value</a>, after <a title="atomize" href=
          "index.html#dt-atomization">atomization</a> and any type conversion
          <span class="verb">required</span> by the
          <code>data-type</code> attribute, is a sequence
          containing more than one item, then the effect depends on
          whether the <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element is
          evaluated with <a title="backwards compatible behavior"
          href="index.html#dt-backwards-compatible-behavior">backwards
          compatible behavior</a>. With backwards compatible
          behavior, the effective sort key value is the first item
          in the sequence. In other cases, this is a <a title=
          "type errors" href="index.html#dt-type-error">type error</a>.</p>

          <p>The set of <a title="sort key value" href=
          "index.html#dt-sort-key-value">sort key values</a> (after any
          conversion) is first divided into <span>two categories:
          empty values, and ordinary values.</span> The empty sort
          key values represent those items where the sort key value
          is an empty sequence. These values are considered for
          sorting purposes to be equal to each other, but less than
          any other value. The remaining values are classified as
          ordinary values.</p>

          <p><a name="err-XTDE1030" id="err-XTDE1030"><span class=
          "error">[ERR XTDE1030]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if, for any <a title="sort key component" href=
          "index.html#dt-sort-key-component">sort key component</a>, the set
          of <a title="sort key value" href=
          "index.html#dt-sort-key-value">sort key values</a> evaluated for
          all the items in the <a title="initial sequence" href=
          "index.html#dt-initial-sequence">initial sequence</a>, after any
          type conversion requested, contains a pair of ordinary
          values for which the result of the XPath <code>lt</code>
          operator is an error.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The above error condition may occur if the values to
            be sorted are of a type that does not support ordering
            (for example, <code>xs:QName</code>) or if the sequence
            is heterogeneous (for example, if it contains both
            strings and numbers). The error can generally be
            prevented by invoking a cast or constructor function
            within the sort key component.</p>

            <p>The error condition is subject to the usual caveat
            that a processor is not required to evaluate any
            expression solely in order to determine whether it
            raises an error. For example, if there are several sort
            key components, then a processor is not required to
            evaluate or compare minor sort key values unless the
            corresponding major sort key values are equal.</p>
          </div>

          <p>In general, comparison of two ordinary values is
          performed according to the rules of the XPath
          <code>lt</code> operator. <span>To ensure a total
          ordering, the same implementation of the <code>lt</code>
          operator <span class="verb">must</span> be used for all
          the comparisons: the one that is chosen is the one
          appropriate to the most specific type to which all the
          values can be converted by subtype substitution and/or
          type promotion. For example, if the sequence contains
          both <code>xs:decimal</code> and <code>xs:double</code>
          values, then the values are compared using
          <code>xs:double</code> comparison, even when comparing
          two <code>xs:decimal</code> values.</span> NaN values,
          for sorting purposes, are considered to be equal to each
          other, and less than any other numeric value. Special
          rules also apply to the <code>xs:string</code> <span>and
          <code>xs:anyURI</code> types, and types derived by
          restriction therefrom,</span>, as described in the next
          section.</p>
        </div>

        <div class="div3">
          <h4><a name="collating-sequences" id=
          "collating-sequences"></a>13.1.3 Sorting Using
          Collations</h4>

          <p>The rules given in this section apply when comparing
          values whose type is <code>xs:string</code> or a type
          derived by restriction from <code>xs:string</code><span>,
          or whose type is <code>xs:anyURI</code> or a type derived
          by restriction from <code>xs:anyURI</code></span>.</p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-collation" id="dt-collation" title=
          "collation"></a>Facilities in XSLT 2.0 and XPath 2.0 that
          require strings to be ordered rely on the concept of a
          named <b>collation</b>. A collation is a set of rules
          that determine whether two strings are equal, and if not,
          which of them is to be sorted before the
          other.<span class="definition">]</span> A collation is
          identified by a URI, but the manner in which this URI is
          associated with an actual rule or algorithm is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.</p>

          <p>The one collation URI that must be recognized by every
          implementation is
          <code>http://www.w3.org/2005/xpath-functions/collation/codepoint</code>,
          which provides the ability to compare strings based on
          the Unicode codepoint values of the characters in the
          string.</p>

          <p>For more information about collations, see <a href=
          "http://www.w3.org/TR/xpath-functions/#string-compare">Section
          7.3 Equality and Comparison of
          Strings</a><sup><small>FO</small></sup> in <a href=
          "index.html#xpath-functions">[Functions and Operators]</a>. Some
          specifications, for example <a href=
          "index.html#UNICODE-TR10">[UNICODE TR10]</a>, use the term
          "collation" to describe rules that can be tailored or
          parameterized for various purposes. In this
          specification, a collation URI refers to a collation in
          which all such parameters have already been fixed.
          Therefore, if a collation URI is specified, other
          attributes such as <code>case-order</code> and
          <code>lang</code> are ignored.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The reason XSLT does not provide detailed mechanisms
            for defining collating sequences is that many
            implementations will re-use collating mechanisms
            available from the underlying implementation platform
            (for example, from the operating system or from the
            run-time library of a chosen programming language).
            These will inevitably differ from one XSLT
            implementation to another.</p>
          </div>

          <p>If the <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element has a
          <code>collation</code> attribute, then the strings are
          compared according to the rules for the named <a title=
          "collation" href="index.html#dt-collation">collation</a>: that is,
          they are compared using the XPath function call
          <code>compare($a, $b, $collation)</code>.</p>

          <p>If the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>collation</code> attribute of <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> is a relative
          URI, then it is resolved against the base URI of the
          <a href="index.html#element-sort"><code>xsl:sort</code></a>
          element.</p>

          <p><a name="err-XTDE1035" id="err-XTDE1035"><span class=
          "error">[ERR XTDE1035]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <code>collation</code> attribute of
          <a href="index.html#element-sort"><code>xsl:sort</code></a> (after
          resolving against the base URI) is not a URI that is
          recognized by the implementation as referring to a
          collation.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>It is entirely for the implementation to determine
            whether it recognizes a particular collation URI. For
            example, if the implementation allows collation URIs to
            contain parameters in the query part of the URI, it is
            the implementation that determines whether a URI
            containing an unknown or invalid parameter is or is not
            a recognized collation URI. <span>The fact that this
            error is described as non-recoverable thus does not
            prevent an implementation applying a fallback collation
            if it chooses to do so.</span></p>
          </div>

          <p>The <code>lang</code> and <code>case-order</code>
          attributes are ignored if a <code>collation</code>
          attribute is present. But in the absence of a
          <code>collation</code> attribute, these attributes
          provide input to an <a title="implementation-defined"
          href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          algorithm to <span>locate</span> a suitable
          collation:</p>

          <ul>
            <li>
              <p>The <code>lang</code> attribute indicates that a
              collation suitable for a particular natural language
              <span class="verb">should</span> be used. The
              <a title="effective value" href=
              "index.html#dt-effective-value">effective value</a> of the
              attribute <span class="verb">must</span> be a value
              that would be valid for the <code>xml:lang</code>
              attribute (see <a href="index.html#REC-xml">[XML 1.0]</a>).</p>
            </li>

            <li>
              <p>The <code>case-order</code> attribute indicates
              whether the desired collation <span class=
              "verb">should</span> sort upper-case letters before
              lower-case or vice versa. The <a title=
              "effective value" href=
              "index.html#dt-effective-value">effective value</a> of the
              attribute <span class="verb">must</span> be either
              <code>lower-first</code> (indicating that lower-case
              letters precede upper-case letters in the collating
              sequence) or <code>upper-first</code> (indicating
              that upper-case letters precede lower-case).</p>
            </li>
          </ul>

          <p>If none of the <code>collation</code>,
          <code>lang</code> or <code>case-order</code> attributes
          is present, the collation is chosen in an <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          way. It is not <span class="verb">required</span> that
          the default collation for sorting should be the same as
          the <a title="default collation" href=
          "index.html#dt-default-collation">default collation</a> used when
          evaluating XPath expressions, as described in <a href=
          "index.html#static-context"><i>5.4.1 Initializing the Static
          Context</i></a> and <a href=
          "index.html#default-collation-attribute"><i>3.6.1 The
          default-collation attribute</i></a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>It is usually appropriate, when sorting, to use a
            strong collation, that is, one that takes account of
            secondary differences (accents) and tertiary
            differences (case) between strings that are otherwise
            equal. A weak collation, which ignores such
            differences, may be more suitable when comparing
            strings for equality.</p>

            <p>Useful background information on international
            sorting is provided in <a href="index.html#UNICODE-TR10">[UNICODE
            TR10]</a>. The <code>case-order</code> attribute may be
            interpreted as described in section 6.6 of <a href=
            "index.html#UNICODE-TR10">[UNICODE TR10]</a>.</p>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="creating-sorted-sequence" id=
        "creating-sorted-sequence"></a>13.2 Creating a Sorted
        Sequence</h3>

        <p class="element-syntax"><a name="element-perform-sort"
        id="element-perform-sort"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:perform-sort<br />
        &#160;&#160;select? = <var>expression</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-sort">xsl:sort</a>+,
        <var>sequence-constructor</var>) --&gt;<br />
        &lt;/xsl:perform-sort&gt;</code></p>

        <p>The <a href=
        "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>
        instruction is used to return a <a title="sorted sequence"
        href="index.html#dt-sorted-sequence">sorted sequence</a>.</p>

        <p>The <a title="initial sequence" href=
        "index.html#dt-initial-sequence">initial sequence</a> is obtained
        either by evaluating the <code>select</code> attribute or
        by evaluating the contained sequence constructor (but not
        both). If there is no <code>select</code> attribute and no
        sequence constructor then the <a title="initial sequence"
        href="index.html#dt-initial-sequence">initial sequence</a> (and
        therefore, the <a title="sorted sequence" href=
        "index.html#dt-sorted-sequence">sorted sequence</a>) is an empty
        sequence.</p>

        <p><a name="err-XTSE1040" id="err-XTSE1040"><span class=
        "error">[ERR XTSE1040]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        an <a href=
        "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>
        instruction with a <code>select</code> attribute has any
        content other than <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> and <a href=
        "index.html#element-fallback"><code>xsl:fallback</code></a>
        instructions.</p>

        <p>The result of the <a href=
        "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>
        instruction is the result of sorting its <a title=
        "initial sequence" href="index.html#dt-initial-sequence">initial
        sequence</a> using its contained <a title=
        "sort key specification" href=
        "index.html#dt-sort-key-specification">sort key
        specification</a>.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e20205" id="d5e20205"></a>Example: Sorting a
            Sequence of Atomic Values
          </div>

          <p>The following stylesheet function sorts a sequence of
          atomic values using the value itself as the sort key.</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:function name="local:sort" as="xs:anyAtomicType*"&gt;
  &lt;xsl:param name="in" as="xs:anyAtomicType*"/&gt;
  &lt;xsl:perform-sort select="$in"&gt;
    &lt;xsl:sort select="."/&gt;
  &lt;/xsl:perform-sort&gt;
&lt;/xsl:function&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e20212" id="d5e20212"></a>Example: Writing a
            Function to Perform a Sort
          </div>

          <p>The following example defines a function that sorts
          books by price, and uses this function to output the five
          books that have the lowest prices:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:function name="bib:books-by-price" as="schema-element(bib:book)*"&gt;
  &lt;xsl:param name="in" as="schema-element(bib:book)*"/&gt;
  &lt;xsl:perform-sort select="$in"&gt;
    &lt;xsl:sort select="xs:decimal(bib:price)"/&gt;
  &lt;/xsl:perform-sort&gt;
&lt;/xsl:function&gt;
   ...
   &lt;xsl:copy-of select="bib:books-by-price(//bib:book)[position() = 1 to 5]"/&gt;

 
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="sorted-iteration" id=
        "sorted-iteration"></a>13.3 Processing a Sequence in Sorted
        Order</h3>

        <p>When used within <a href=
        "index.html#element-for-each"><code>xsl:for-each</code></a> or
        <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        a <a title="sort key specification" href=
        "index.html#dt-sort-key-specification">sort key specification</a>
        indicates that the sequence of items selected by that
        instruction is to be processed in sorted order, not in the
        order of the supplied sequence.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e20233" id="d5e20233"></a>Example:
            Processing Elements in Sorted Order
          </div>

          <p>For example, suppose an employee database has the
          form</p>

          <div class="exampleInner">
            <pre>
&lt;employees&gt;
  &lt;employee&gt;
    &lt;name&gt;
      &lt;given&gt;James&lt;/given&gt;
      &lt;family&gt;Clark&lt;/family&gt;
    &lt;/name&gt;
    ...
  &lt;/employee&gt;
&lt;/employees&gt;
</pre>
          </div>

          <p>Then a list of employees sorted by name could be
          generated using:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="employees"&gt;
  &lt;ul&gt;
    &lt;xsl:apply-templates select="employee"&gt;
      &lt;xsl:sort select="name/family"/&gt;
      &lt;xsl:sort select="name/given"/&gt;
    &lt;/xsl:apply-templates&gt;
  &lt;/ul&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="employee"&gt;
  &lt;li&gt;
    &lt;xsl:value-of select="name/given"/&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:value-of select="name/family"/&gt;
  &lt;/li&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>When used within <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
        a <a title="sort key specification" href=
        "index.html#dt-sort-key-specification">sort key specification</a>
        indicates the order in which the groups are to be
        processed. For the effect of <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
        see <a href="index.html#grouping"><i>14 Grouping</i></a>.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="grouping" id="grouping"></a>14 Grouping</h2>

      <p>The facilities described in this section are designed to
      allow items in a sequence to be grouped based on common
      values; for example it allows grouping of elements having the
      same value for a particular attribute, or elements with the
      same name, or elements with common values for any other
      <a title="expression" href="index.html#dt-expression">expression</a>.
      Since grouping identifies items with duplicate values, the
      same facilities also allow selection of the distinct values
      in a sequence of items, that is, the elimination of
      duplicates.</p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>Simple elimination of duplicates can also be achieved
        using the function <a href=
        "http://www.w3.org/TR/xpath-functions/#func-distinct-values">
        <code>distinct-values</code></a><sup><small>FO</small></sup>
        in the <a title="core function" href=
        "index.html#dt-core-function">core function</a> library: see <a href=
        "index.html#xpath-functions">[Functions and Operators]</a>.</p>
      </div>

      <p>In addition these facilities allow grouping based on
      sequential position, for example selecting groups of adjacent
      <code>para</code> elements. The facilities also provide an
      easy way to do fixed-size grouping, for example identifying
      groups of three adjacent nodes, which is useful when
      arranging data in multiple columns.</p>

      <p>For each group of items identified, it is possible to
      evaluate a <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a> for the
      group. Grouping is nestable to multiple levels so that groups
      of distinct items can be identified, then from among the
      distinct groups selected, further sub-grouping of distinct
      items in the current group can be done.</p>

      <p>It is also possible for one item to participate in more
      than one group.</p>

      <div class="div2">
        <h3><a name="current-group" id="current-group"></a>14.1 The
        Current Group</h3><a name="function-current-group" id=
        "function-current-group"></a>

        <div class="proto">
          <code class="function">current-group</code>()<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">item()*</code>
        </div>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-current-group" id="dt-current-group" title=
        "current group"></a>The evaluation context for XPath
        <a title="expression" href="index.html#dt-expression">expressions</a>
        includes a <span>component</span> called the <b>current
        group</b>, which is a sequence. The current group is the
        collection of related items that are processed collectively
        in one iteration of the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        element.<span class="definition">]</span></p>

        <p>While an <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction is being evaluated, the <a title=
        "current group" href="index.html#dt-current-group">current group</a>
        will be non-empty. At other times, it will be an empty
        sequence.</p>

        <p>The function <a href=
        "index.html#function-current-group"><code>current-group</code></a>
        returns the current group.</p>

        <p>The function takes no arguments.</p>

        <p><a name="err-XTSE1060" id="err-XTSE1060"><span class=
        "error">[ERR XTSE1060]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <a href=
        "index.html#function-current-group"><code>current-group</code></a>
        function is used within a <a title="pattern" href=
        "index.html#dt-pattern">pattern</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="current-grouping-key" id=
        "current-grouping-key"></a>14.2 The Current Grouping
        Key</h3><a name="function-current-grouping-key" id=
        "function-current-grouping-key"></a>

        <div class="proto">
          <code class=
          "function">current-grouping-key</code>()<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:anyAtomicType?</code>
        </div>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-current-grouping-key" id="dt-current-grouping-key"
        title="current grouping key"></a>The evaluation context for
        XPath <a title="expression" href=
        "index.html#dt-expression">expressions</a> includes a component
        called the <b>current grouping key</b>, which is an atomic
        value. The current grouping key is <span>the <a title=
        "grouping key" href="index.html#dt-grouping-key">grouping
        key</a></span> shared in common by all the items within the
        <a title="current group" href="index.html#dt-current-group">current
        group</a>.<span class="definition">]</span></p>

        <p>While an <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction with a <code>group-by</code> or
        <code>group-adjacent</code> attribute is being evaluated,
        the <a title="current grouping key" href=
        "index.html#dt-current-grouping-key">current grouping key</a> will be
        <span>a single atomic value</span>. At other times, it will
        be the empty sequence.</p>

        <p>The function <a href=
        "index.html#function-current-grouping-key"><code>current-grouping-key</code></a>
        returns the <a title="current grouping key" href=
        "index.html#dt-current-grouping-key">current grouping key</a>.</p>

        <p>Although the <a title="grouping key" href=
        "index.html#dt-grouping-key">grouping keys</a> of all items in a
        group are by definition equal, they are not necessarily
        identical. For example, one might be an
        <code>xs:float</code> while another is an
        <code>xs:decimal</code>. The <a href=
        "index.html#function-current-grouping-key"><code>current-grouping-key</code></a>
        function is defined to return the grouping key of the
        <a title="initial item" href="index.html#dt-initial-item">initial
        item</a> in the group, after atomization and casting of
        <code>xs:untypedAtomic</code> to
        <code>xs:string</code>.</p>

        <p>The function takes no arguments.</p>

        <p><a name="err-XTSE1070" id="err-XTSE1070"><span class=
        "error">[ERR XTSE1070]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <a href=
        "index.html#function-current-grouping-key"><code>current-grouping-key</code></a>
        function is used within a <a title="pattern" href=
        "index.html#dt-pattern">pattern</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="xsl-for-each-group" id=
        "xsl-for-each-group"></a>14.3 The
        <code>xsl:for-each-group</code> Element</h3>

        <p class="element-syntax"><a name="element-for-each-group"
        id="element-for-each-group"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:for-each-group<br />
        &#160;&#160;<b>select</b> = <var>expression</var><br />
        &#160;&#160;group-by? = <var>expression</var><br />
        &#160;&#160;group-adjacent? = <var>expression</var><br />
        &#160;&#160;group-starting-with? = <var>pattern</var><br />
        &#160;&#160;group-ending-with? = <var>pattern</var><br />
        &#160;&#160;collation? = { <var>uri</var> }&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-sort">xsl:sort</a>*,
        <var>sequence-constructor</var>) --&gt;<br />
        &lt;/xsl:for-each-group&gt;</code></p>

        <p>This element is an <a title="instruction" href=
        "index.html#dt-instruction">instruction</a> that may be used anywhere
        within a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name="dt-group"
        id="dt-group" title="group"></a>The <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction <span>allocates the items in an input
        sequence</span> into <b>groups</b> of items (that is, it
        establishes a collection of sequences) based either on
        common values of a grouping key, or on a <a title="pattern"
        href="index.html#dt-pattern">pattern</a> that the initial or final
        node in a group must match.<span class=
        "definition">]</span> The <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a>
        that forms the content of the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction is evaluated once for each of these groups.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-population" id="dt-population" title=
        "population"></a>The sequence of items to be grouped, which
        is referred to as the <b>population</b>, is determined by
        evaluating the XPath <a title="expression" href=
        "index.html#dt-expression">expression</a> contained in the
        <code>select</code> attribute.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-population-order" id="dt-population-order" title=
        "population order"></a>The population is treated as a
        sequence; the order of items in this sequence is referred
        to as <b>population order</b><span class=
        "definition">]</span>.</p>

        <p>A group is never empty. If the population is empty, the
        number of groups will be zero. The assignment of items to
        groups depends on the <code>group-by</code>,
        <code>group-adjacent</code>,
        <code>group-starting-with</code>, and
        <code>group-ending-with</code> attributes.</p>

        <p><a name="err-XTSE1080" id="err-XTSE1080"><span class=
        "error">[ERR XTSE1080]</span></a> These four attributes are
        mutually exclusive: it is a <a title="static error" href=
        "index.html#dt-static-error">static error</a> if none of these four
        attributes is present, or if more than one of them is
        present.</p>

        <p><a name="err-XTSE1090" id="err-XTSE1090"><span class=
        "error">[ERR XTSE1090]</span></a> It is an error to specify
        the <code>collation</code> attribute if neither the
        <code>group-by</code> attribute nor
        <code>group-adjacent</code> attribute is specified.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-grouping-key" id="dt-grouping-key" title=
        "grouping key"></a>If either of the <code>group-by</code>
        attribute or <code>group-adjacent</code> attributes is
        present, then <b>grouping keys</b> are calculated for each
        item in the <a title="population" href=
        "index.html#dt-population">population</a>. <span>The grouping keys
        are the items in the sequence obtained by evaluating the
        expression contained in the <code>group-by</code> attribute
        or <code>group-adjacent</code> attribute, atomizing the
        result, and then casting an <code>xs:untypedAtomic</code>
        value to <code>xs:string</code>.</span><span class=
        "definition">]</span></p>

        <p><span>When calculating grouping keys for an item in the
        population,</span> the <a title="expression" href=
        "index.html#dt-expression">expression</a> contained in the
        <code>group-by</code> or <code>group-adjacent</code>
        attribute is evaluated with that item as the <a title=
        "context item" href="index.html#dt-context-item">context item</a>,
        with its position in <a title="population order" href=
        "index.html#dt-population-order">population order</a> as the
        <a title="context position" href=
        "index.html#dt-context-position">context position</a>, and with the
        size of the population as the <a title="context size" href=
        "index.html#dt-context-size">context size</a>. The resulting sequence
        is <a title="atomize" href="index.html#dt-atomization">atomized</a>,
        and each atomic value in the atomized sequence acts as a
        <a title="grouping key" href="index.html#dt-grouping-key">grouping
        key</a> for that item in the population.</p>

        <p>If the <code>group-by</code> attribute is present, then
        an item in the population may have multiple grouping keys:
        that is, the <code>group-by</code> expression evaluates to
        a sequence. The item is included in as many groups as there
        are distinct grouping keys (which may be zero). If the
        <code>group-adjacent</code> attribute is used, then each
        item in the population <span class="verb">must</span> have
        exactly one grouping key value.</p>

        <p><a name="err-XTTE1100" id="err-XTTE1100"><span class=
        "error">[ERR XTTE1100]</span></a> It is a <a title=
        "type errors" href="index.html#dt-type-error">type error</a> if the
        <span>grouping key evaluated using</span> the
        <code>group-adjacent</code> attribute is an empty sequence,
        or a sequence containing more than one item.</p>

        <p><a title="grouping key" href="index.html#dt-grouping-key">Grouping
        keys</a> are compared using the rules for the
        <code>eq</code> operator appropriate to their dynamic type.
        <span>Values of type</span> <code>xs:untypedAtomic</code>
        are cast to <code>xs:string</code> before the comparison.
        Two items that are not comparable using the <code>eq</code>
        operator are considered to be not equal, that is, they are
        allocated to different groups. If the values are strings,
        or untyped atomic values, <span>then if there is a
        <code>collation</code> attribute the values are compared
        using the collation specified as the <a title=
        "effective value" href="index.html#dt-effective-value">effective
        value</a> of the <code>collation</code> attribute, resolved
        if relative against the base URI of the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        element. If there is no <code>collation</code> attribute
        then the <a title="default collation" href=
        "index.html#dt-default-collation">default collation</a> is
        used.</span></p>

        <p>For the purposes of grouping, the value <code>NaN</code>
        is considered equal to itself.</p>

        <p><a name="err-XTDE1110" id="err-XTDE1110"><span class=
        "error">[ERR XTDE1110]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the collation URI specified to <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        <span>(after resolving against the base URI)</span> is a
        collation that is not recognized by the implementation.
        (For notes, <span class="error">[see <a href=
        "index.html#err-XTDE1035">ERR XTDE1035</a>]</span>.)</p>

        <p>For more information on collations, see <a href=
        "index.html#collating-sequences"><i>13.1.3 Sorting Using
        Collations</i></a>.</p>

        <p><a name="err-XTTE1120" id="err-XTTE1120"><span class=
        "error">[ERR XTTE1120]</span></a> When the
        <code>group-starting-with</code> or
        <code>group-ending-with</code> attribute is used, it is a
        <a title="type errors" href="index.html#dt-type-error">type error</a>
        if the result of evaluating the <code>select</code>
        expression contains an item that is not a node.</p>

        <ul>
          <li>
            <p>If the <code>group-by</code> attribute is present,
            the items in the <a title="population" href=
            "index.html#dt-population">population</a> are examined, in
            population order. For each item <var>J</var>, the
            expression in the <code>group-by</code> attribute is
            evaluated to produce a sequence of zero or more
            <a title="grouping key" href=
            "index.html#dt-grouping-key">grouping key</a> values. For each
            one of these <a title="grouping key" href=
            "index.html#dt-grouping-key">grouping keys</a>, if there is
            already a group created to hold items having that
            grouping key value, <var>J</var> is added to that
            group; otherwise a new group is created for items with
            that grouping key value, and <var>J</var> becomes its
            first member.</p>

            <p>An item in the population may thus be assigned to
            zero, one, or many groups. An item will never be
            assigned more than once to the same group; if two or
            more grouping keys for the same item are equal, then
            the duplicates are ignored. An <em>item</em> here means
            the item at a particular position within the
            population—if the population contains the same node at
            several different positions in the sequence then a
            group may indeed contain duplicate nodes.</p>

            <p>The number of groups will be the same as the number
            of distinct grouping key values present in the
            <a title="population" href=
            "index.html#dt-population">population</a>.</p>
          </li>

          <li>
            <p>If the <code>group-adjacent</code> attribute is
            present, the items in the <a title="population" href=
            "index.html#dt-population">population</a> are examined, in
            population order. If an item has the same value for the
            <a title="grouping key" href=
            "index.html#dt-grouping-key">grouping key</a> as its preceding
            item within the <a title="population" href=
            "index.html#dt-population">population</a> (in <a title=
            "population order" href=
            "index.html#dt-population-order">population order</a>), then it
            is assigned to the same group as its preceding item;
            otherwise a new group is created and the item becomes
            its first member.</p>
          </li>

          <li>
            <p>If the <code>group-starting-with</code> attribute is
            present, then its value <span class="verb">must</span>
            be a <a href="index.html#NT-Pattern">pattern</a>. In this case,
            the items in the population <span class=
            "verb">must</span> all be nodes.</p>

            <p>The nodes in the <a title="population" href=
            "index.html#dt-population">population</a> are examined in
            <a title="population order" href=
            "index.html#dt-population-order">population order</a>. If a node
            matches the pattern, or is the first node in the
            population, then a new group is created and the node
            becomes its first member. Otherwise, the node is
            assigned to the same group as its preceding node within
            the population.</p>
          </li>

          <li>
            <p>If the <code>group-ending-with</code> attribute is
            present, then its value <span class="verb">must</span>
            be a <a href="index.html#NT-Pattern">pattern</a>. In this case,
            the items in the population <span class=
            "verb">must</span> all be nodes.</p>

            <p>The nodes in the <a title="population" href=
            "index.html#dt-population">population</a> are examined in
            <a title="population order" href=
            "index.html#dt-population-order">population order</a>. If a node
            is the first node in the population, or if the previous
            node in the population matches the pattern, then a new
            group is created and the node becomes its first member.
            Otherwise, the node is assigned to the same group as
            its preceding node within the population.</p>
          </li>
        </ul>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-initial-item" id="dt-initial-item" title=
        "initial item"></a>For each <a title="group" href=
        "index.html#dt-group">group</a>, the item within the group that is
        first in <a title="population order" href=
        "index.html#dt-population-order">population order</a> is known as the
        <b>initial item</b> of the group.<span class=
        "definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-first-appearance" id="dt-first-appearance" title=
        "order of first appearance"></a>There is an ordering among
        <a title="group" href="index.html#dt-group">groups</a> referred to as
        the <b>order of first appearance</b>. A group <var>G</var>
        is defined to precede a group <var>H</var> in order of
        first appearance if the <a title="initial item" href=
        "index.html#dt-initial-item">initial item</a> of <var>G</var>
        precedes the initial item of <var>H</var> in population
        order. <span>If two groups <var>G</var> and <var>H</var>
        have the same initial item (because the item is in both
        groups) then <var>G</var> precedes <var>H</var> if the
        <a title="grouping key" href="index.html#dt-grouping-key">grouping
        key</a> of <var>G</var> precedes the grouping key of
        <var>H</var> in the sequence that results from evaluating
        the <code>group-by</code> expression of this initial
        item.</span><span class="definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-processing-order" id="dt-processing-order" title=
        "processing order"></a>There is another ordering among
        groups referred to as <b>processing order</b>. <span>If
        group <var>R</var> precedes group <var>S</var> in
        processing order, then in the result sequence returned by
        the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction the items generated by processing group
        <var>R</var> will precede the items generated by processing
        group <var>S</var>.</span><span class=
        "definition">]</span></p>

        <p>If there are no <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> elements
        immediately within the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        element, the <a title="processing order" href=
        "index.html#dt-processing-order">processing order</a> of the
        <a title="group" href="index.html#dt-group">groups</a> is the
        <a title="order of first appearance" href=
        "index.html#dt-first-appearance">order of first appearance</a>.</p>

        <p>Otherwise, the <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> elements
        immediately within the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        element define the processing order of the <a title="group"
        href="index.html#dt-group">groups</a> (see <a href="index.html#sorting"><i>13
        Sorting</i></a>). They do not affect the order of items
        within each group. Multiple <a title="sort key component"
        href="index.html#dt-sort-key-component">sort key components</a> are
        allowed, and are evaluated in major-to-minor order. If two
        groups have the same values for all their sort key
        components, they are processed in order of first
        appearance.</p>

        <p>The <code>select</code> <a title="expression" href=
        "index.html#dt-expression">expression</a> of an <a href=
        "index.html#element-sort"><code>xsl:sort</code></a> element is
        evaluated once for each <a title="group" href=
        "index.html#dt-group">group</a>. During this evaluation, the
        <a title="context item" href="index.html#dt-context-item">context
        item</a> is the <a title="initial item" href=
        "index.html#dt-initial-item">initial item</a> of the group, the
        <a title="context position" href=
        "index.html#dt-context-position">context position</a> is the position
        of this item within the set of initial items (that is, one
        item for each group in the <a title="population" href=
        "index.html#dt-population">population</a>) in <a title=
        "population order" href="index.html#dt-population-order">population
        order</a>, the <a title="context size" href=
        "index.html#dt-context-size">context size</a> is the number of
        groups, the <a title="current group" href=
        "index.html#dt-current-group">current group</a> is the group whose
        <a title="sort key value" href="index.html#dt-sort-key-value">sort
        key value</a> is being determined, <span>and the <a title=
        "current grouping key" href=
        "index.html#dt-current-grouping-key">current grouping key</a> is the
        grouping key for that group. If the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction uses the <code>group-starting-with</code> or
        <code>group-ending-with</code> attributes, then the current
        grouping key is the empty sequence.</span></p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21018" id="d5e21018"></a>Example: Sorting
            Groups
          </div>

          <p>For example, this means that if the <a title=
          "grouping key" href="index.html#dt-grouping-key">grouping key</a>
          is <code>@category</code>, you can sort the groups in
          order of their grouping key by writing <code>&lt;xsl:sort
          select="current-grouping-key()"/&gt;</code>; or you can
          sort the groups in order of size by writing
          <code>&lt;xsl:sort
          select="count(current-group())"/&gt;</code></p>
        </div>

        <p>The <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>
        contained in the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        element is evaluated once for each of the <a title="group"
        href="index.html#dt-group">groups</a>, in <a title="processing order"
        href="index.html#dt-processing-order">processing order</a>. The
        sequences that result are concatenated, in <a title=
        "processing order" href="index.html#dt-processing-order">processing
        order</a>, to form the result of the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        element. Within the <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a>, the
        <a title="context item" href="index.html#dt-context-item">context
        item</a> is the <a title="initial item" href=
        "index.html#dt-initial-item">initial item</a> of the relevant group,
        the <a title="context position" href=
        "index.html#dt-context-position">context position</a> is the position
        of this item among the sequence of initial items (one item
        for each group) arranged in <a title="processing order"
        href="index.html#dt-processing-order">processing order</a> of the
        groups, the <a title="context size" href=
        "index.html#dt-context-size">context size</a> is the number of
        groups, the <a title="current group" href=
        "index.html#dt-current-group">current group</a> is the <a title=
        "group" href="index.html#dt-group">group</a> being processed,
        <span>and the <a title="current grouping key" href=
        "index.html#dt-current-grouping-key">current grouping key</a> is the
        grouping key for that group. If the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction uses the <code>group-starting-with</code> or
        <code>group-ending-with</code> attributes, then the current
        grouping key is the empty sequence.</span> This has the
        effect that within the <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a>, a
        call on <code>position()</code> takes successive values
        <code>1, 2, ... last()</code>.</p>

        <p>During the evaluation of a <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a>, the
        <a title="current group" href="index.html#dt-current-group">current
        group</a> and <a title="current grouping key" href=
        "index.html#dt-current-grouping-key">current grouping key</a> are set
        to the empty sequence, and revert to their previous values
        on completion of evaluation of the stylesheet function.</p>

        <p>On completion of the evaluation of the <a href=
        "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
        instruction, the <a title="current group" href=
        "index.html#dt-current-group">current group</a> <span>and <a title=
        "current grouping key" href=
        "index.html#dt-current-grouping-key">current grouping key</a></span>
        revert to their previous value.</p>
      </div>

      <div class="div2">
        <h3><a name="grouping-examples" id=
        "grouping-examples"></a>14.4 Examples of Grouping</h3>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21133" id="d5e21133"></a>Example: Grouping
            Nodes based on Common Values
          </div>

          <p>The following example groups a list of nodes based on
          common values. The resulting groups are numbered but
          unsorted, and a total is calculated for each group.</p>

          <p>Source XML document:</p>

          <div class="exampleInner">
            <pre>
&lt;cities&gt;
  &lt;city name="Milano"  country="Italia"      pop="5"/&gt;
  &lt;city name="Paris"   country="France"      pop="7"/&gt;
  &lt;city name="München" country="Deutschland" pop="4"/&gt;
  &lt;city name="Lyon"    country="France"      pop="2"/&gt;
  &lt;city name="Venezia" country="Italia"      pop="1"/&gt;
&lt;/cities&gt;
</pre>
          </div>

          <p>More specifically, the aim is to produce a four-column
          table, containing one row for each distinct country. The
          four columns are to contain first, a sequence number
          giving the number of the row; second, the name of the
          country, third, a comma-separated alphabetical list of
          the city names within that country, and fourth, the sum
          of the <code>pop</code> attribute for the cities in that
          country.</p>

          <p>Desired output:</p>

          <div class="exampleInner">
            <pre>
&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;Position&lt;/th&gt;
    &lt;th&gt;Country&lt;/th&gt;
    &lt;th&gt;List of Cities&lt;/th&gt;
    &lt;th&gt;Population&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;Italia&lt;/td&gt;
    &lt;td&gt;Milano, Venezia&lt;/td&gt;
    &lt;td&gt;6&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;France&lt;/td&gt;
    &lt;td&gt;Lyon, Paris&lt;/td&gt;
    &lt;td&gt;9&lt;/td&gt;
  &lt;/tr&gt;  
  &lt;tr&gt;
    &lt;td&gt;3&lt;/td&gt;
    &lt;td&gt;Deutschland&lt;/td&gt;
    &lt;td&gt;München&lt;/td&gt;
    &lt;td&gt;4&lt;/td&gt;
  &lt;/tr&gt;  
&lt;/table&gt;
</pre>
          </div>

          <p>Solution:</p>

          <div class="exampleInner">
            <pre>
&lt;table xsl:version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;tr&gt;
    &lt;th&gt;Position&lt;/th&gt;
    &lt;th&gt;Country&lt;/th&gt;
    &lt;th&gt;City List&lt;/th&gt;
    &lt;th&gt;Population&lt;/th&gt;
  &lt;/tr&gt;
  &lt;xsl:for-each-group select="cities/city" group-by="@country"&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;xsl:value-of select="position()"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;xsl:value-of select="@country"/&gt;&lt;/td&gt;
      &lt;td&gt;
        &lt;xsl:value-of select="current-group()/@name" separator=", "/&gt;
      &lt;/td&gt;
      &lt;td&gt;&lt;xsl:value-of select="sum(current-group()/@pop)"/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/xsl:for-each-group&gt;
&lt;/table&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21156" id="d5e21156"></a>Example: A
            Composite Grouping Key
          </div>

          <p>Sometimes it is necessary to use a composite grouping
          key: for example, suppose the source document is similar
          to the one used in the previous examples, but allows
          multiple entries for the same country and city, such
          as:</p>

          <div class="exampleInner">
            <pre>
&lt;cities&gt;
  &lt;city name="Milano"  country="Italia"  year="1950"   pop="5.23"/&gt;
  &lt;city name="Milano"  country="Italia"  year="1960"   pop="5.29"/&gt;  
  &lt;city name="Padova"  country="Italia"  year="1950"   pop="0.69"/&gt;
  &lt;city name="Padova"  country="Italia"  year="1960"   pop="0.93"/&gt;    
  &lt;city name="Paris"   country="France"  year="1951"   pop="7.2"/&gt;
  &lt;city name="Paris"   country="France"  year="1961"   pop="7.6"/&gt;
&lt;/cities&gt;
</pre>
          </div>

          <p>Now suppose we want to list the average value of
          <code>@pop</code> for each (country, name) combination.
          One way to handle this is to concatenate the parts of the
          key, for example <code>&lt;xsl:for-each-group
          select="concat(@country, '/', @name)"&gt;</code>. A more
          flexible solution is to nest one <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          element directly inside another:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:for-each-group select="cities/city" group-by="@country"&gt;
  &lt;xsl:for-each-group select="current-group()" group-by="@name"&gt;
    &lt;p&gt;&lt;xsl:value-of select="@name"/&gt;, &lt;xsl:value-of select="@country"/&gt;:
        &lt;xsl:value-of select="avg(current-group()/@pop)"/&gt;&lt;/p&gt;
  &lt;/xsl:for-each-group&gt;
&lt;/xsl:for-each-group&gt;
</pre>
          </div>

          <p>The two approaches are not precisely equivalent. If
          the code were changed to output the value of
          <code>position()</code> alongside <code>@name</code> then
          the first approach (a single <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          element with a compound key) would number the groups (1,
          2, 3), while the second approach (two nested <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          elements) would number them (1, 2, 1).</p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21190" id="d5e21190"></a>Example:
            Identifying a Group by its Initial Element
          </div>

          <p>The next example identifies a group not by the
          presence of a common value, but rather by adjacency in
          document order. A group consists of an <code>h2</code>
          element, followed by all the <code>p</code> elements up
          to the next <code>h2</code> element.</p>

          <p>Source XML document:</p>

          <div class="exampleInner">
            <pre>
&lt;body&gt;
  &lt;h2&gt;Introduction&lt;/h2&gt;
  &lt;p&gt;XSLT is used to write stylesheets.&lt;/p&gt;
  &lt;p&gt;XQuery is used to query XML databases.&lt;/p&gt;
  &lt;h2&gt;What is a stylesheet?&lt;/h2&gt;
  &lt;p&gt;A stylesheet is an XML document used to define a transformation.&lt;/p&gt;
  &lt;p&gt;Stylesheets may be written in XSLT.&lt;/p&gt;
  &lt;p&gt;XSLT 2.0 introduces new grouping constructs.&lt;/p&gt;
&lt;/body&gt;
</pre>
          </div>

          <p>Desired output:</p>

          <div class="exampleInner">
            <pre>
&lt;chapter&gt;
  &lt;section title="Introduction"&gt;
    &lt;para&gt;XSLT is used to write stylesheets.&lt;/para&gt;
    &lt;para&gt;XQuery is used to query XML databases.&lt;/para&gt;
  &lt;/section&gt; 
  &lt;section title="What is a stylesheet?"&gt;
    &lt;para&gt;A stylesheet is an XML document used to define a transformation.&lt;/para&gt;
    &lt;para&gt;Stylesheets may be written in XSLT.&lt;/para&gt;
    &lt;para&gt;XSLT 2.0 introduces new grouping constructs.&lt;/para&gt;
  &lt;/section&gt;
&lt;/chapter&gt;
</pre>
          </div>

          <p>Solution:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="body"&gt;
  &lt;chapter&gt;
        &lt;xsl:for-each-group select="*" group-starting-with="h2"      &gt;
          &lt;section title="{self::h2}"&gt;
            &lt;xsl:for-each select="current-group()[self::p]"&gt;
              &lt;para&gt;&lt;xsl:value-of select="."/&gt;&lt;/para&gt;
            &lt;/xsl:for-each&gt; 
          &lt;/section&gt;
        &lt;/xsl:for-each-group&gt;
  &lt;/chapter&gt;
&lt;/xsl:template&gt;
</pre>
          </div>

          <p>The use of <code>title="{self::h2}"</code> rather than
          <code>title="{.}"</code> is to handle the case where the
          first element is not an <code>h2</code> element.</p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21227" id="d5e21227"></a>Example:
            Identifying a Group by its Final Element
          </div>

          <p>The next example illustrates how a group of related
          elements can be identified by the last element in the
          group, rather than the first. Here the absence of the
          attribute <code>continued="yes"</code> indicates the end
          of the group.</p>

          <p>Source XML document:</p>

          <div class="exampleInner">
            <pre>
&lt;doc&gt;
  &lt;page continued="yes"&gt;Some text&lt;/page&gt;
  &lt;page continued="yes"&gt;More text&lt;/page&gt;    
  &lt;page&gt;Yet more text&lt;/page&gt;
  &lt;page continued="yes"&gt;Some words&lt;/page&gt;
  &lt;page continued="yes"&gt;More words&lt;/page&gt;    
  &lt;page&gt;Yet more words&lt;/page&gt;        
&lt;/doc&gt;
</pre>
          </div>

          <p>Desired output:</p>

          <div class="exampleInner">
            <pre>
&lt;doc&gt;
  &lt;pageset&gt;
    &lt;page&gt;Some text&lt;/page&gt;
    &lt;page&gt;More text&lt;/page&gt;    
    &lt;page&gt;Yet more text&lt;/page&gt;
  &lt;/pageset&gt;
  &lt;pageset&gt;
    &lt;page&gt;Some words&lt;/page&gt;
    &lt;page&gt;More words&lt;/page&gt;    
    &lt;page&gt;Yet more words&lt;/page&gt;
  &lt;/pageset&gt;
&lt;/doc&gt;
</pre>
          </div>

          <p>Solution:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="doc"&gt;
&lt;doc&gt;
  &lt;xsl:for-each-group select="*" 
                      group-ending-with="page[not(@continued='yes')]"&gt;
    &lt;pageset&gt;
      &lt;xsl:for-each select="current-group()"&gt;
        &lt;page&gt;&lt;xsl:value-of select="."/&gt;&lt;/page&gt;
      &lt;/xsl:for-each&gt; 
    &lt;/pageset&gt;
  &lt;/xsl:for-each-group&gt;
&lt;/doc&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21247" id="d5e21247"></a>Example: Adding an
            Element to Several Groups
          </div>

          <p>The next example shows how an item can be added to
          multiple groups. Book titles will be added to one group
          for each indexing term marked up within the title.</p>

          <p>Source XML document:</p>

          <div class="exampleInner">
            <pre>
&lt;titles&gt;
    &lt;title&gt;A Beginner's Guide to &lt;ix&gt;Java&lt;/ix&gt;&lt;/title&gt;
    &lt;title&gt;Learning &lt;ix&gt;XML&lt;/ix&gt;&lt;/title&gt;
    &lt;title&gt;Using &lt;ix&gt;XML&lt;/ix&gt; with &lt;ix&gt;Java&lt;/ix&gt;&lt;/title&gt;
&lt;/titles&gt;
</pre>
          </div>

          <p>Desired output:</p>

          <div class="exampleInner">
            <pre>
&lt;h2&gt;Java&lt;/h2&gt;
    &lt;p&gt;A Beginner's Guide to Java&lt;/p&gt;
    &lt;p&gt;Using XML with Java&lt;/p&gt;
&lt;h2&gt;XML&lt;/h2&gt;
    &lt;p&gt;Learning XML&lt;/p&gt;
    &lt;p&gt;Using XML with Java&lt;/p&gt;
</pre>
          </div>

          <p>Solution:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="titles"&gt;
    &lt;xsl:for-each-group select="title" group-by="ix"&gt;
      &lt;h2&gt;&lt;xsl:value-of select="current-grouping-key()"/&gt;&lt;/h2&gt;
      &lt;xsl:for-each select="current-group()"&gt;
        &lt;p&gt;&lt;xsl:value-of select="."/&gt;&lt;/p&gt;
      &lt;/xsl:for-each&gt;
    &lt;/xsl:for-each-group&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21264" id="d5e21264"></a>Example: Grouping
            Alternating Sequences of Elements
          </div>

          <p>In the final example, the membership of a node within
          a group is based both on adjacency of the nodes in
          document order, and on common values. In this case, the
          grouping key is a boolean condition, true or false, so
          the effect is that a grouping establishes a maximal
          sequence of nodes for which the condition is true,
          followed by a maximal sequence for which it is false, and
          so on.</p>

          <p>Source XML document:</p>

          <div class="exampleInner">
            <pre>
&lt;p&gt;Do &lt;em&gt;not&lt;/em&gt;:
    &lt;ul&gt;
    &lt;li&gt;talk,&lt;/li&gt;
    &lt;li&gt;eat, or&lt;/li&gt;
    &lt;li&gt;use your mobile telephone&lt;/li&gt;
    &lt;/ul&gt;
    while you are in the cinema.&lt;/p&gt;
</pre>
          </div>

          <p>Desired output:</p>

          <div class="exampleInner">
            <pre>
&lt;p&gt;Do &lt;em&gt;not&lt;/em&gt;:&lt;/p&gt;
    &lt;ul&gt;
    &lt;li&gt;talk,&lt;/li&gt;
    &lt;li&gt;eat, or&lt;/li&gt;
    &lt;li&gt;use your mobile telephone&lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;while you are in the cinema.&lt;/p&gt;
</pre>
          </div>

          <p>Solution:</p>

          <p>This requires creating a <code>p</code> element around
          the maximal sequence of sibling nodes that does not
          include a <code>ul</code> or <code>ol</code> element.</p>

          <p>This can be done by using <code>group-adjacent</code>,
          with a grouping key that is true if the element is a
          <code>ul</code> or <code>ol</code> element, and false
          otherwise:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:template match="p"&gt;
    &lt;xsl:for-each-group select="node()" 
            group-adjacent="self::ul or self::ol"&gt;
        &lt;xsl:choose&gt;
            &lt;xsl:when test="current-grouping-key()"&gt;
                &lt;xsl:copy-of select="current-group()"/&gt;  
            &lt;/xsl:when&gt;
            &lt;xsl:otherwise&gt;
                &lt;p&gt;
                    &lt;xsl:copy-of select="current-group()"/&gt;
                &lt;/p&gt;
            &lt;/xsl:otherwise&gt;  
        &lt;/xsl:choose&gt;
    &lt;/xsl:for-each-group&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="regular-expressions" id=
      "regular-expressions"></a>15 Regular Expressions</h2>

      <p>The <a title="core function" href="index.html#dt-core-function">core
      function</a> library for XPath 2.0 defines three functions
      that make use of regular expressions:</p>

      <ul>
        <li>
          <p><a href=
          "http://www.w3.org/TR/xpath-functions/#func-matches"><code>
          matches</code></a><sup><small>FO</small></sup> returns a
          boolean result that indicates whether or not a string
          matches a given regular expression.</p>
        </li>

        <li>
          <p><a href=
          "http://www.w3.org/TR/xpath-functions/#func-replace"><code>
          replace</code></a><sup><small>FO</small></sup> takes a
          string as input and returns a string obtained by
          replacing all substrings that match a given regular
          expression with a replacement string.</p>
        </li>

        <li>
          <p><a href=
          "http://www.w3.org/TR/xpath-functions/#func-tokenize"><code>
          tokenize</code></a><sup><small>FO</small></sup> returns a
          sequence of strings formed by breaking a supplied input
          string at any separator that matches a given regular
          expression.</p>
        </li>
      </ul>

      <p>These functions are described in <a href=
      "index.html#xpath-functions">[Functions and Operators]</a>.</p>

      <p>For more complex string processing than is possible using
      these functions, XSLT provides an instruction <a href=
      "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>,
      which is defined in this section.</p>

      <p>The regular expressions used by this instruction, and the
      flags that control the interpretation of these regular
      expressions, <span class="verb">must</span> conform to the
      syntax defined in <a href="index.html#xpath-functions">[Functions and
      Operators]</a> (see <a href=
      "http://www.w3.org/TR/xpath-functions/#regex-syntax">Section
      7.6.1 Regular Expression
      Syntax</a><sup><small>FO</small></sup>), which is itself
      based on the syntax defined in <a href="index.html#xmlschema-2">[XML
      Schema Part 2]</a>.</p>

      <div class="div2">
        <h3><a name="analyze-string" id="analyze-string"></a>15.1
        The <code>xsl:analyze-string</code> instruction</h3>

        <p class="element-syntax"><a name="element-analyze-string"
        id="element-analyze-string"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:analyze-string<br />
        &#160;&#160;<b>select</b> = <var>expression</var><br />
        &#160;&#160;<b>regex</b> = { <var>string</var> }<br />
        &#160;&#160;flags? = { <var>string</var> }&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-matching-substring">xsl:matching-substring</a>?,
        <a href=
        "index.html#element-non-matching-substring">xsl:non-matching-substring</a>?,
        <a href="index.html#element-fallback">xsl:fallback</a>*) --&gt;<br />
        &lt;/xsl:analyze-string&gt;</code></p>

        <p class="element-syntax"><a name=
        "element-matching-substring" id=
        "element-matching-substring"></a><code>&lt;xsl:matching-substring&gt;<br />

        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:matching-substring&gt;</code></p>

        <p class="element-syntax"><a name=
        "element-non-matching-substring" id=
        "element-non-matching-substring"></a><code>&lt;xsl:non-matching-substring&gt;<br />

        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:non-matching-substring&gt;</code></p>

        <p>The <a href=
        "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
        instruction takes as input a string (the result of
        evaluating the expression in the <code>select</code>
        attribute) and a regular expression (the effective value of
        the <code>regex</code> attribute).</p>

        <p>If the result of evaluating the <code>select</code>
        expression is not a string, it is converted to a string by
        applying the <a title="function conversion rules" href=
        "index.html#dt-function-conversion-rules">function conversion
        rules</a>.</p>

        <p>The <code>flags</code> attribute may be used to control
        the interpretation of the regular expression. If the
        attribute is omitted, the effect is the same as supplying a
        zero-length string. This is interpreted in the same way as
        the <code>$flags</code> attribute of the functions <a href=
        "http://www.w3.org/TR/xpath-functions/#func-matches"><code>matches</code></a><sup>
        <small>FO</small></sup>, <a href=
        "http://www.w3.org/TR/xpath-functions/#func-replace"><code>replace</code></a><sup>
        <small>FO</small></sup>, and <a href=
        "http://www.w3.org/TR/xpath-functions/#func-tokenize"><code>
        tokenize</code></a><sup><small>FO</small></sup>.
        <span>Specifically, if it contains the letter
        <code>m</code>, the match operates in multiline mode. If it
        contains the letter <code>s</code>, it operates in dot-all
        mode. If it contains the letter <code>i</code>, it operates
        in case-insensitive mode. If it contains the letter
        <code>x</code>, then whitespace within the regular
        expression is ignored. For more detailed specifications of
        these modes, see <a href="index.html#xpath-functions">[Functions and
        Operators]</a> (<a href=
        "http://www.w3.org/TR/xpath-functions/#flags">Section
        7.6.1.1 Flags</a><sup><small>FO</small></sup>).</span></p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Because the <code>regex</code> attribute is an
          attribute value template, curly brackets within the
          regular expression must be doubled. For example, to match
          a sequence of one to five characters, write
          <code>regex=".{{1,5}}"</code>. <span>For regular
          expressions containing many curly brackets it may be more
          convenient to use a notation such as
          <code>regex="{'[0-9]{1,5}[a-z]{3}[0-9]{1,2}'}"</code>, or
          to use a variable.</span></p>
        </div>

        <p>The content of the <a href=
        "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
        instruction must take one of the following forms:</p>

        <ol class="enumar">
          <li>
            <p>A single <a href=
            "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
            instruction, followed by zero or more <a href=
            "index.html#element-fallback"><code>xsl:fallback</code></a>
            instructions</p>
          </li>

          <li>
            <p>A single <a href=
            "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
            instruction, followed by zero or more <a href=
            "index.html#element-fallback"><code>xsl:fallback</code></a>
            instructions</p>
          </li>

          <li>
            <p>A single <a href=
            "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
            instruction, followed by a single <a href=
            "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
            instruction, followed by zero or more <a href=
            "index.html#element-fallback"><code>xsl:fallback</code></a>
            instructions</p>
          </li>
        </ol>

        <p><a name="err-XTSE1130" id="err-XTSE1130"><span class=
        "error">[ERR XTSE1130]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <a href=
        "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
        instruction contains neither an <a href=
        "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
        nor an <a href=
        "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
        element.</p>

        <p><span>Any <a href=
        "index.html#element-fallback"><code>xsl:fallback</code></a> elements
        among the children of the <a href=
        "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
        instruction</span> are ignored by an XSLT 2.0 processor,
        but allow fallback behavior to be defined when the
        stylesheet is used with an XSLT 1.0 processor operating in
        forwards-compatible mode.</p>

        <p>This instruction is designed to process all the
        non-overlapping substrings of the input string that match
        the regular expression supplied.</p>

        <p><a name="err-XTDE1140" id="err-XTDE1140"><span class=
        "error">[ERR XTDE1140]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>regex</code> attribute does not conform to the
        <span class="verb">required</span> syntax for regular
        expressions, as specified in <a href=
        "index.html#xpath-functions">[Functions and Operators]</a>. If the
        regular expression is known statically (for example, if the
        attribute does not contain any <a title="expression" href=
        "index.html#dt-expression">expressions</a> enclosed in curly
        brackets) then the processor <span class="verb">may</span>
        signal the error as a <a title="static error" href=
        "index.html#dt-static-error">static error</a>.</p>

        <p><a name="err-XTDE1145" id="err-XTDE1145"><span class=
        "error">[ERR XTDE1145]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>flags</code> attribute has a value other than the
        values defined in <a href="index.html#xpath-functions">[Functions and
        Operators]</a>. If the value of the attribute is known
        statically (for example, if the attribute does not contain
        any <a title="expression" href=
        "index.html#dt-expression">expressions</a> enclosed in curly
        brackets) then the processor <span class="verb">may</span>
        signal the error as a <a title="static error" href=
        "index.html#dt-static-error">static error</a>.</p>

        <p><a name="err-XTDE1150" id="err-XTDE1150"><span class=
        "error">[ERR XTDE1150]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>regex</code> attribute is a regular expression that
        matches a zero-length string: or more specifically, if the
        regular expression <code>$r</code> and flags
        <code>$f</code> are such that <code>matches("", $r,
        $f)</code> returns true. If the regular expression is known
        statically (for example, if the attribute does not contain
        any <a title="expression" href=
        "index.html#dt-expression">expressions</a> enclosed in curly
        brackets) then the processor <span class="verb">may</span>
        signal the error as a <a title="static error" href=
        "index.html#dt-static-error">static error</a>.</p>

        <p>The <a href=
        "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
        instruction starts at the beginning of the input string and
        attempts to find the first substring that matches the
        regular expression. If there are several matches, the first
        match is defined to be the one whose starting position
        comes first in the string. If several alternatives within
        the regular expression both match at the same position in
        the input string, then the match that is chosen is the
        first alternative that matches. For example, if the input
        string is <code>The quick brown fox jumps</code> and the
        regular expression is <code>jump|jumps</code>, then the
        match that is chosen is <code>jump</code>.</p>

        <p>Having found the first match, the instruction proceeds
        to find the second and subsequent matches by repeating the
        search, starting at the first character that was not
        included in the previous match.</p>

        <p>The input string is thus partitioned into a sequence of
        substrings, some of which match the regular expression,
        others which do not match it. Each substring will contain
        at least one character. This sequence of substrings is
        processed using the <a href=
        "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
        and <a href=
        "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
        child instructions. A matching substring is processed using
        the <a href=
        "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
        element, a non-matching substring using the <a href=
        "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
        element. Each of these elements takes a sequence
        constructor as its content. If the element is absent, the
        effect is the same as if it were present with empty
        content. In processing each substring, the contents of the
        substring will be the <a title="context item" href=
        "index.html#dt-context-item">context item</a> (as a value of type
        <code>xs:string</code>); the position of the substring
        within the sequence of matching and non-matching substrings
        will be the <a title="context position" href=
        "index.html#dt-context-position">context position</a>; and the number
        of matching and non-matching substrings will be the
        <a title="context size" href="index.html#dt-context-size">context
        size</a>.</p>

        <p>If the input is a zero-length string, the number of
        substrings will be zero, so neither the <a href=
        "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
        nor <a href=
        "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
        elements will be evaluated.</p>
      </div>

      <div class="div2">
        <h3><a name="regex-group" id="regex-group"></a>15.2
        Captured Substrings</h3><a name="function-regex-group" id=
        "function-regex-group"></a>

        <div class="proto">
          <code class="function">regex-group</code>(<code class=
          "arg">$group-number</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:integer</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string</code>
        </div>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-current-captured-substrings" id=
        "dt-current-captured-substrings" title=
        "current captured substrings"></a>While the <a href=
        "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
        instruction is active, a set of <b>current captured
        substrings</b> is available, corresponding to the
        parenthesized sub-expressions of the regular
        expression.<span class="definition">]</span> These captured
        substrings are accessible using the function <a href=
        "index.html#function-regex-group"><code>regex-group</code></a>. This
        function takes an integer argument to identify the group,
        and returns a string representing the captured
        substring.</p>

        <p>The <var>N</var>th captured substring (where
        <var>N</var> &gt; 0) is the string matched by the
        subexpression contained by the <var>N</var>th left
        parenthesis in the regex. The zeroeth captured substring is
        the string that matches the entire regex. This means that
        the value of <code>regex-group(0)</code> is initially the
        same as the value of <code>.</code> (dot).</p>

        <p>The function returns the zero-length string if there is
        no captured substring with the relevant number. This can
        occur for a number of reasons:</p>

        <ol class="enumar">
          <li>
            <p>The number is negative.</p>
          </li>

          <li>
            <p>The regular expression does not contain a
            parenthesized sub-expression with the given number.</p>
          </li>

          <li>
            <p>The parenthesized sub-expression exists, and did not
            match any part of the input string.</p>
          </li>

          <li>
            <p>The parenthesized sub-expression exists, and matched
            a zero-length substring of the input string.</p>
          </li>
        </ol>

        <p>The set of captured substrings is a context variable
        with dynamic scope. It is initially an empty sequence.
        During the evaluation of an <a href=
        "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
        instruction it is set to the sequence of matched substrings
        for that regex match. During the evaluation of an <a href=
        "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
        instruction or a <a title="pattern" href=
        "index.html#dt-pattern">pattern</a> or a <a title=
        "stylesheet function" href=
        "index.html#dt-stylesheet-function">stylesheet function</a> it is set
        to an empty sequence. On completion of an instruction that
        changes the value, the variable reverts to its previous
        value.</p>

        <p>The value of the <a title="current captured substrings"
        href="index.html#dt-current-captured-substrings">current captured
        substrings</a> is unaffected through calls of <a href=
        "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
        <a href=
        "index.html#element-call-template"><code>xsl:call-template</code></a>,
        <a href=
        "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
        or <a href=
        "index.html#element-next-match"><code>xsl:next-match</code></a>, or
        by expansion of named <a title="attribute set" href=
        "index.html#dt-attribute-set">attribute sets</a>.</p>
      </div>

      <div class="div2">
        <h3><a name="regex-examples" id="regex-examples"></a>15.3
        Examples of Regular Expression Matching</h3>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21776" id="d5e21776"></a>Example: Replacing
            Characters by Elements
          </div>

          <p>Problem: replace all newline characters in the
          <code>abstract</code> element by empty <code>br</code>
          elements:</p>

          <p>Solution:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:analyze-string select="abstract" regex="\n"&gt;
  &lt;xsl:matching-substring&gt;
    &lt;br/&gt;
  &lt;/xsl:matching-substring&gt;
  &lt;xsl:non-matching-substring&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:non-matching-substring&gt;
&lt;/xsl:analyze-string&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21791" id="d5e21791"></a>Example:
            Recognizing non-XML Markup Structure
          </div>

          <p>Problem: replace all occurrences of <code>[...]</code>
          in the <code>body</code> by <code>cite</code> elements,
          retaining the content between the square brackets as the
          content of the new element.</p>

          <p>Solution:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:analyze-string select="body" regex="\[(.*?)\]"&gt;
  &lt;xsl:matching-substring&gt;
    &lt;cite&gt;&lt;xsl:value-of select="regex-group(1)"/&gt;&lt;/cite&gt;
  &lt;/xsl:matching-substring&gt;
  &lt;xsl:non-matching-substring&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:non-matching-substring&gt;
&lt;/xsl:analyze-string&gt;
</pre>
          </div>

          <p>Note that this simple approach fails if the
          <code>body</code> element contains markup that needs to
          be retained. In this case it is necessary to apply the
          regular expression processing to each text node
          individually. If the <code>[...]</code> constructs span
          multiple text nodes (for example, because there are
          elements within the square brackets) then it probably
          becomes necessary to make two or more passes over the
          data.</p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e21817" id="d5e21817"></a>Example: Parsing a
            Date
          </div>

          <p>Problem: the input string contains a date such as
          <code>23 March 2002</code>. Convert it to the form
          <code>2002-03-23</code>.</p>

          <p>Solution (with no error handling if the input format
          is incorrect):</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:variable name="months" select="'January', 'February', 'March', ..."/&gt;

&lt;xsl:analyze-string select="normalize-space($input)" 
    regex="([0-9]{{1,2}})\s([A-Z][a-z]+)\s([0-9]{{4}})"&gt;
    &lt;xsl:matching-substring&gt;
        &lt;xsl:number value="regex-group(3)" format="0001"/&gt;          
        &lt;xsl:text&gt;-&lt;/xsl:text&gt;
        &lt;xsl:number value="index-of($months, regex-group(2))" format="01"/&gt;
        &lt;xsl:text&gt;-&lt;/xsl:text&gt;
        &lt;xsl:number value="regex-group(1)" format="01"/&gt;
    &lt;/xsl:matching-substring&gt;
&lt;/xsl:analyze-string&gt;
</pre>
          </div>

          <p>Note the use of <code>normalize-space</code> to
          simplify the work done by the regular expression, and the
          use of doubled curly brackets because the
          <code>regex</code> attribute is an attribute value
          template.</p>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="add-func" id="add-func"></a>16 Additional
      Functions</h2>

      <p>This section describes XSLT-specific additions to the
      <a title="core function" href="index.html#dt-core-function">core
      function</a> library. Some of these additional functions also
      make use of information specified by <a title="declaration"
      href="index.html#dt-declaration">declarations</a> in the stylesheet;
      this section also describes these declarations.</p>

      <div class="div2">
        <h3><a name="document" id="document"></a>16.1 Multiple
        Source Documents</h3><a name="function-document" id=
        "function-document"></a>

        <div class="proto">
          <code class="function">document</code>(<code class=
          "arg">$uri-sequence</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">item()*</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">node()*</code>
        </div>

        <div class="proto">
          <code class="function">document</code>(<code class=
          "arg">$uri-sequence</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">item()*</code>, <code class=
          "arg">$base-node</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">node()</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">node()*</code>
        </div>

        <p>The <a href=
        "index.html#function-document"><code>document</code></a> function
        allows access to XML documents identified by a URI.</p>

        <p>The first argument contains a sequence of URI
        references. The second argument, if present, is a node
        whose base URI is used to resolve any relative URI
        references contained in the first argument.</p>

        <p>A sequence of absolute URI references is obtained as
        follows.</p>

        <ul>
          <li>
            <p>For an item in <code>$uri-sequence</code> that is an
            instance of <code>xs:string</code>,
            <code>xs:anyURI</code>, or
            <span><code>xs:untypedAtomic</code></span>, the value
            is cast to <code>xs:anyURI</code>. If the resulting URI
            reference is an absolute URI reference then it is used
            <em>as is</em>. If it is a relative URI reference, then
            it is resolved against the base URI of
            <code>$base-node</code> if supplied, or against the
            base URI from the static context otherwise (this will
            usually be the base URI of the stylesheet module). A
            relative URI is resolved against a base URI using the
            rules defined in <a href="index.html#RFC3986">[RFC3986]</a>.</p>
          </li>

          <li>
            <p>For an item in <code>$uri-sequence</code> that is a
            node, the node is <a title="atomize" href=
            "index.html#dt-atomization">atomized</a>. The result <span class=
            "verb">must</span> be a sequence whose items are all
            instances of <code>xs:string</code>,
            <code>xs:anyURI</code>, or
            <span><code>xs:untypedAtomic</code></span>. Each of
            these values is cast to <code>xs:anyURI</code>, and if
            the resulting URI reference is an absolute URI
            reference then it is used <em>as is</em>. If it is a
            relative URI reference, then it is resolved against the
            base URI of <code>$base-node</code> if supplied, or
            against the base URI of the node that contained it
            otherwise.</p>
          </li>
        </ul>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The XPath rules for function calling ensure that it is
          a type error if the supplied value of the second argument
          is anything other than a single node. If <a title=
          "XPath 1.0 compatibility mode" href=
          "index.html#dt-compatibility-mode">XPath 1.0 compatibility mode</a>
          is enabled, then a sequence of nodes may be supplied, and
          the first node in the sequence will be used.</p>
        </div>

        <p>Each of these absolute URI references is then processed
        as follows. Any fragment identifier that is present in the
        URI reference is removed, and the resulting absolute URI is
        cast to a string and then passed to the <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
        <small>FO</small></sup> function defined in <a href=
        "index.html#xpath-functions">[Functions and Operators]</a>. This
        returns a document node. If an error occurs during
        evaluation of the <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
        <small>FO</small></sup> function, the processor
        <span class="verb">may</span> either signal this error in
        the normal way, or <span class="verb">may</span> recover by
        ignoring the failure, in which case the failing URI will
        not contribute any nodes to the result of the <a href=
        "index.html#function-document"><code>document</code></a>
        function.</p>

        <p>If the URI reference contained no fragment identifier,
        then this document node is included in the sequence of
        nodes returned by the <a href=
        "index.html#function-document"><code>document</code></a>
        function.</p>

        <p>If the URI reference contained a fragment identifier,
        then the fragment identifier is interpreted according to
        the rules for the media type of the resource
        <span>representation</span> identified by the URI, and is
        used to select zero or more nodes that are
        descendant-or-self nodes of the returned document node. As
        described in <a href="index.html#initiating"><i>2.3 Initiating a
        Transformation</i></a>, the media type is available as part
        of the evaluation context for a transformation.</p>

        <p><a name="err-XTRE1160" id="err-XTRE1160"><span class=
        "error">[ERR XTRE1160]</span></a> When a URI reference
        contains a fragment identifier, it is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> if
        the media type is not one that is recognized by the
        processor, or if the fragment identifier does not conform
        to the rules for fragment identifiers for that media type,
        or if the fragment identifier selects something other than
        a sequence of nodes (for example, if it selects a range of
        characters within a text node). The <a title=
        "optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is to ignore the fragment identifier and return the
        document node. The set of media types recognized by a
        processor is <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The recovery action here is different from XSLT
          1.0</p>
        </div>

        <p>The sequence of nodes returned by the function is in
        document order, with no duplicates. This order has no
        necessary relationship to the order in which URIs were
        supplied in the <code>$uri-sequence</code> argument.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>One effect of these rules is that unless XML entities
          or <code>xml:base</code> are used, and provided that the
          base URI of the stylesheet module is known,
          <code>document("")</code> refers to the document node of
          the containing stylesheet module (the definitive rules
          are in <span><a href="index.html#RFC3986">[RFC3986]</a></span>).
          The XML resource containing the stylesheet module is
          processed exactly as if it were any other XML document,
          for example there is no special recognition of <a href=
          "index.html#element-text"><code>xsl:text</code></a> elements, and
          no special treatment of comments and processing
          instructions.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="unparsed-text" id="unparsed-text"></a>16.2
        Reading Text Files</h3><a name="function-unparsed-text" id=
        "function-unparsed-text"></a>

        <div class="proto">
          <code class="function">unparsed-text</code>(<code class=
          "arg">$href</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string?</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string?</code>
        </div>

        <div class="proto">
          <code class="function">unparsed-text</code>(<code class=
          "arg">$href</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string?</code>, <code class=
          "arg">$encoding</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string?</code>
        </div>

        <p>The <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        function reads an external resource (for example, a file)
        and returns its contents as a string.</p>

        <p>The <code>$href</code> argument <span class=
        "verb">must</span> be <span>a string in the form of a
        URI</span>. The URI <span class="verb">must</span> contain
        no fragment identifier, and <span class="verb">must</span>
        identify a resource that can be read as text. If the URI is
        a relative URI, then it is resolved relative to the base
        URI from the static context.</p>

        <p>If the value of the <code>$href</code> argument is an
        empty sequence, the function returns an empty sequence.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>If a different base URI is appropriate (for example,
          when resolving a relative URI read from a source
          document) then the relative URI should be resolved using
          the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-resolve-uri"><code>
          resolve-uri</code></a><sup><small>FO</small></sup>
          function before passing it to the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function.</p>
        </div>

        <p>The <code>$encoding</code> argument, if present, is the
        name of an encoding. The values for this attribute follow
        the same rules as for the <code>encoding</code> attribute
        in an XML declaration. The only values which every
        <a title="implementation" href=
        "index.html#dt-implementation">implementation</a> is <span class=
        "verb">required</span> to recognize are <code>utf-8</code>
        and <code>utf-16</code>.</p>

        <p>The encoding of the external resource is determined as
        follows:</p>

        <ol class="enumar">
          <li>
            <p>external encoding information is used if available,
            otherwise</p>
          </li>

          <li>
            <p>if the media type of the resource is
            <code>text/xml</code> or <code>application/xml</code>
            (see <a href="index.html#RFC2376">[RFC2376]</a>), or if it
            matches the conventions <code>text/*+xml</code> or
            <code>application/*+xml</code> (see <a href=
            "index.html#RFC3023">[RFC3023]</a> <span>and/or its
            successors</span>), then the encoding is recognized as
            specified in <a href="index.html#REC-xml">[XML 1.0]</a>,
            otherwise</p>
          </li>

          <li>
            <p>the value of the <code>$encoding</code> argument is
            used if present, otherwise</p>
          </li>

          <li>
            <p>the processor <span class="verb">may</span> use
            <a title="implementation-defined" href=
            "index.html#dt-implementation-defined">implementation-defined</a>
            heuristics to determine the likely encoding,
            otherwise</p>
          </li>

          <li>
            <p>UTF-8 is assumed.</p>
          </li>
        </ol>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The above rules are chosen for consistency with
          <a href="index.html#xinclude">[XInclude]</a>. Files with an XML
          media type are treated specially because there are use
          cases for this function where the retrieved text is to be
          included as unparsed XML within a CDATA section of a
          containing document, and because processors are likely to
          be able to reuse the code that performs encoding
          detection for XML external entities.</p>
        </div>

        <p><a name="err-XTDE1170" id="err-XTDE1170"><span class=
        "error">[ERR XTDE1170]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if a URI <span>contains a fragment
        identifier,</span> or if it cannot be used to retrieve a
        resource containing text.</p>

        <p><a name="err-XTDE1190" id="err-XTDE1190"><span class=
        "error">[ERR XTDE1190]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if a resource contains octets that cannot be
        decoded into Unicode characters using the specified
        encoding, or if the resulting characters are not permitted
        XML characters. This includes the case where the <a title=
        "processor" href="index.html#dt-processor">processor</a> does not
        support the requested encoding.</p>

        <p><a name="err-XTDE1200" id="err-XTDE1200"><span class=
        "error">[ERR XTDE1200]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the second argument of the <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        function is omitted and the <a title="processor" href=
        "index.html#dt-processor">processor</a> cannot infer the encoding
        using external information and the encoding is not
        UTF-8.</p>

        <p>The result is a string containing the text of the
        resource retrieved using the URI.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>If the text file contains characters such as
          <code>&lt;</code> and <code>&amp;</code>, these will
          typically be output as <code>&amp;lt;</code> and
          <code>&amp;amp;</code> when the string is written to a
          <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a> and
          serialized as XML or HTML. If these characters actually
          represent markup (for example, if the text file contains
          HTML), then the stylesheet can attempt to write them as
          markup to the output file using the
          <code>disable-output-escaping</code> attribute of the
          <a href="index.html#element-value-of"><code>xsl:value-of</code></a>
          instruction (see <a href=
          "index.html#disable-output-escaping"><i>20.2 Disabling Output
          Escaping</i></a>). Note, however, that implementations
          are not required to support this feature.</p>
        </div>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e22242" id="d5e22242"></a>Example: Copying
            Unparsed HTML Boilerplate
          </div>

          <p>This example attempts to read an HTML file and copy
          it, as HTML, to the serialized output file:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:output method="html"/&gt;

&lt;xsl:template match="/"&gt;
  &lt;xsl:value-of select="unparsed-text('header.html', 'iso-8859-1')"
                disable-output-escaping="yes"/&gt;
  &lt;xsl:apply-templates/&gt;
  &lt;xsl:value-of select="unparsed-text('footer.html', 'iso-8859-1')"
                disable-output-escaping="yes"/&gt;
&lt;/xsl:template&gt;
</pre>
          </div>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e22249" id="d5e22249"></a>Example: Splitting
            an Input File into a Sequence of Lines
          </div>

          <p>Often it is necessary to split a text file into a
          sequence of lines, representing each line as a string.
          This can be achieved by using the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function in conjunction with the XPath <a href=
          "http://www.w3.org/TR/xpath-functions/#func-tokenize"><code>
          tokenize</code></a><sup><small>FO</small></sup> function.
          For example:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:for-each select="tokenize(unparsed-text($in), '\r?\n')"&gt;
 ...
&lt;/xsl:for-each&gt;
</pre>
          </div>

          <p>Note that the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function does not normalize line endings. This example
          has therefore been written to recognize both Unix and
          Windows conventions for end-of-line, namely a single
          newline (#x0A) character or a carriage return / line feed
          pair (#x0D #x0A).</p>
        </div>

        <p>Because errors in evaluating the <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        function are non-recoverable, two functions are provided to
        allow a stylesheet to determine whether a call with
        particular arguments would succeed:</p><a name=
        "function-unparsed-text-available" id=
        "function-unparsed-text-available"></a>

        <div class="proto">
          <code class=
          "function">unparsed-text-available</code>(<code class=
          "arg">$href</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string?</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:boolean</code>
        </div>

        <div class="proto">
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="baseline" rowspan="2"><code class=
              "function">unparsed-text-available</code>(</td>

              <td valign="baseline"><code class=
              "arg">$href</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$encoding</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>)<code class=
              "as">&#160;as&#160;</code><code class=
              "return-type">xs:boolean</code></td>
            </tr>
          </table>
        </div>

        <p>The <a href=
        "index.html#function-unparsed-text-available"><code>unparsed-text-available</code></a>
        function determines whether a call on the <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        function with identical arguments would <span>return a
        string</span>.</p>

        <p>If the first argument is an empty sequence, the function
        returns false. If the second argument is an empty sequence,
        the function behaves as if the second argument were
        omitted.</p>

        <p>In other cases, the function returns true if a call on
        <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        with the same arguments would succeed, and false if a call
        on <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        with the same arguments would fail with a non-recoverable
        dynamic error.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>This requires that the <a href=
          "index.html#function-unparsed-text-available"><code>unparsed-text-available</code></a>
          function should actually attempt to read the resource
          identified by the URI, and check that it is correctly
          encoded and contains no characters that are invalid in
          XML. Implementations may avoid the cost of repeating
          these checks for example by caching the validated
          contents of the resource, to anticipate a subsequent call
          on the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function. Alternatively, implementations may be able to
          rewrite an expression such as <code>if
          (unparsed-text-available(A)) then unparsed-text(A) else
          ...</code> to generate a single call internally.</p>
        </div>

        <p>The functions <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        and <a href=
        "index.html#function-unparsed-text-available"><code>unparsed-text-available</code></a>
        have the same requirement for stability as the functions
        <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
        <small>FO</small></sup> and <a href=
        "http://www.w3.org/TR/xpath-functions/#func-doc-available"><code>
        doc-available</code></a><sup><small>FO</small></sup>
        defined in <a href="index.html#xpath-functions">[Functions and
        Operators]</a>. This means that unless the user has
        explicitly stated a requirement for a reduced level of
        stability, either of these functions if called twice with
        the same arguments during the course of a transformation
        <span class="verb">must</span> return the same results each
        time; moreover, the results of a call on <a href=
        "index.html#function-unparsed-text-available"><code>unparsed-text-available</code></a>
        <span class="verb">must</span> be consistent with the
        results of a subsequent call on <a href=
        "index.html#function-unparsed-text"><code>unparsed-text</code></a>
        with the same arguments.</p>
      </div>

      <div class="div2">
        <h3><a name="key" id="key"></a>16.3 Keys</h3>

        <p>Keys provide a way to work with documents that contain
        an implicit cross-reference structure. They make it easier
        to locate the nodes within a document that have a given
        value for a given attribute or child element, and they
        provide a hint to the implementation that certain access
        paths in the document need to be efficient.</p>

        <div class="div3">
          <h4><a name="xsl-key" id="xsl-key"></a>16.3.1 The
          <a href="index.html#element-key"><code>xsl:key</code></a>
          Declaration</h4>

          <p class="element-syntax"><a name="element-key" id=
          "element-key"></a><code>&lt;!-- Category: declaration
          --&gt;<br />
          &lt;xsl:key<br />
          &#160;&#160;<b>name</b> = <var>qname</var><br />
          &#160;&#160;<b>match</b> = <var>pattern</var><br />
          &#160;&#160;use? = <var>expression</var><br />
          &#160;&#160;collation? = <var>uri</var>&gt;<br />
          &#160;&#160;&lt;!-- Content:
          <var>sequence-constructor</var> --&gt;<br />
          &lt;/xsl:key&gt;</code></p>

          <p>The <a href="index.html#element-key"><code>xsl:key</code></a>
          <a title="declaration" href=
          "index.html#dt-declaration">declaration</a> is used to declare
          <a title="key" href="index.html#dt-key">keys</a>. The
          <code>name</code> attribute specifies the name of the
          key. The value of the <code>name</code> attribute is a
          <a title="QName" href="index.html#dt-qname">QName</a>, which is
          expanded as described in <a href="index.html#qname"><i>5.1
          Qualified Names</i></a>. The <code>match</code> attribute
          is a <a href="index.html#NT-Pattern">Pattern</a>; an <a href=
          "index.html#element-key"><code>xsl:key</code></a> element applies
          to all nodes that match the pattern specified in the
          <code>match</code> attribute.</p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name="dt-key"
          id="dt-key" title="key"></a>A <b>key</b> is defined as a
          set of <a href="index.html#element-key"><code>xsl:key</code></a>
          declarations in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> that share the same
          name.<span class="definition">]</span></p>

          <p>The value of the key may be specified either using the
          <code>use</code> attribute or by means of the contained
          <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

          <p><a name="err-XTSE1205" id="err-XTSE1205"><span class=
          "error">[ERR XTSE1205]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if an <a href="index.html#element-key"><code>xsl:key</code></a>
          declaration has a <code>use</code> attribute and has
          non-empty content, or if it has empty content and no
          <code>use</code> attribute.</p>

          <p>If the <code>use</code> attribute is present, its
          value is an <a title="expression" href=
          "index.html#dt-expression">expression</a> specifying the values of
          the key. The expression will be evaluated with the node
          that matches the pattern as the context node. The result
          of evaluating the expression is <a title="atomize" href=
          "index.html#dt-atomization">atomized</a>.</p>

          <p>Similarly, if a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> is
          present, it is used to determine the values of the key.
          The sequence constructor will be evaluated with the node
          that matches the pattern as the context node. <span>The
          result of evaluating the sequence constructor is
          <a title="atomize" href=
          "index.html#dt-atomization">atomized</a>.</span></p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-key-specifier" id="dt-key-specifier" title=
          "key specifier"></a>The expression in the
          <code>use</code> attribute and the <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>
          within an <a href="index.html#element-key"><code>xsl:key</code></a>
          declaration are referred to collectively as the <b>key
          specifier</b>. The key specifier determines the values
          that may be used to find a node using this <a title="key"
          href="index.html#dt-key">key</a>.<span class=
          "definition">]</span></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>There is no requirement that all the values of a key
            should have the same type.</p>
          </div>

          <p>The presence of an <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration makes
          it easy to find a node that matches the
          <code>match</code> pattern if any of the values of the
          <span><a title="key specifier" href=
          "index.html#dt-key-specifier">key specifier</a></span> (when
          applied to that node) are known. It also provides a hint
          to the implementation that access to the nodes by means
          of these values needs to be efficient (many
          implementations are likely to construct an index or hash
          table to achieve this). Note that the <span><a title=
          "key specifier" href="index.html#dt-key-specifier">key
          specifier</a></span> in general returns a sequence of
          values, and any one of these may be used to locate the
          node.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>An <a href="index.html#element-key"><code>xsl:key</code></a>
            declaration is not bound to a specific source document.
            The source document to which it applies is determined
            only when the <a href=
            "index.html#function-key"><code>key</code></a> function is used
            to locate nodes using the key. Keys can be used to
            locate nodes within any source document (including
            temporary trees), but each use of the <a href=
            "index.html#function-key"><code>key</code></a> function searches
            one document only.</p>
          </div>

          <p>The optional <code>collation</code> attribute is used
          only when deciding whether two strings are equal for the
          purposes of key matching. Specifically, two values
          <code>$a</code> and <code>$b</code> are considered equal
          if the result of the function call <code>compare($a, $b,
          $collation)</code> is zero. The effective collation for
          an <a href="index.html#element-key"><code>xsl:key</code></a>
          declaration is the collation specified in its
          <code>collation</code> attribute if present,
          <span>resolved against the base URI of the <a href=
          "index.html#element-key"><code>xsl:key</code></a> element</span>,
          or the <a title="default collation" href=
          "index.html#dt-default-collation">default collation</a> that is in
          scope for the <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration
          otherwise; the effective collation must be the same for
          all the <a href="index.html#element-key"><code>xsl:key</code></a>
          declarations making up a <a title="key" href=
          "index.html#dt-key">key</a>.</p>

          <p><a name="err-XTSE1210" id="err-XTSE1210"><span class=
          "error">[ERR XTSE1210]</span></a> It is a static error if
          the <a href="index.html#element-key"><code>xsl:key</code></a>
          declaration has a <code>collation</code> attribute whose
          value <span>(after resolving against the base URI)</span>
          is not a URI recognized by the implementation as
          referring to a collation.</p>

          <p><a name="err-XTSE1220" id="err-XTSE1220"><span class=
          "error">[ERR XTSE1220]</span></a> It is a static error if
          there are several <a href=
          "index.html#element-key"><code>xsl:key</code></a> declarations in
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> with the same key name
          and different effective collations. Two collations are
          the same if their URIs are equal under the rules for
          comparing <code>xs:anyURI</code> values, or if the
          implementation can determine that they are different URIs
          referring to the same collation.</p>

          <p>It is possible to have:</p>

          <ul>
            <li>
              <p>multiple <a href=
              "index.html#element-key"><code>xsl:key</code></a> declarations
              with the same name;</p>
            </li>

            <li>
              <p>a node that matches the <code>match</code>
              patterns of several different <a href=
              "index.html#element-key"><code>xsl:key</code></a>
              declarations<span>, whether these have the same key
              name or different key names;</span></p>
            </li>

            <li>
              <p>a node that returns more than one value from its
              <span><a title="key specifier" href=
              "index.html#dt-key-specifier">key specifier</a></span>;</p>
            </li>

            <li>
              <p>a key value that identifies more than one node
              (the key values for different nodes do not need to be
              unique).</p>
            </li>
          </ul>

          <p>An <a href="index.html#element-key"><code>xsl:key</code></a>
          declaration with higher <a title="import precedence"
          href="index.html#dt-import-precedence">import precedence</a> does
          not override another of lower import precedence; all the
          <a href="index.html#element-key"><code>xsl:key</code></a>
          declarations in the stylesheet are effective regardless
          of their import precedence.</p>
        </div>

        <div class="div3">
          <h4><a name="keys" id="keys"></a>16.3.2 The <a href=
          "index.html#function-key"><code>key</code></a>
          Function</h4><a name="function-key" id=
          "function-key"></a>

          <div class="proto">
            <code class="function">key</code>(<code class=
            "arg">$key-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>, <code class=
            "arg">$key-value</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:anyAtomicType*</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">node()*</code>
          </div>

          <div class="proto">
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td valign="baseline" rowspan="3"><code class=
                "function">key</code>(</td>

                <td valign="baseline"><code class=
                "arg">$key-name</code></td>

                <td valign="baseline"><code class=
                "as">&#160;as&#160;</code><code class=
                "type">xs:string</code>,</td>
              </tr>

              <tr>
                <td valign="baseline"><code class=
                "arg">$key-value</code></td>

                <td valign="baseline"><code class=
                "as">&#160;as&#160;</code><code class=
                "type">xs:anyAtomicType*</code>,</td>
              </tr>

              <tr>
                <td valign="baseline"><code class=
                "arg">$top</code></td>

                <td valign="baseline"><code class=
                "as">&#160;as&#160;</code><code class=
                "type">node()</code>)<code class=
                "as">&#160;as&#160;</code><code class=
                "return-type">node()*</code></td>
              </tr>
            </table>
          </div>

          <p>The <a href="index.html#function-key"><code>key</code></a>
          function does for keys what the <a href=
          "http://www.w3.org/TR/xpath-functions/#func-id"><code>id</code></a><sup>
          <small>FO</small></sup> function does for IDs.</p>

          <p>The <code>$key-name</code> argument specifies the name
          of the <a title="key" href="index.html#dt-key">key</a>. The value
          of the argument <span class="verb">must</span> be a
          <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a>, which is expanded as described in <a href=
          "index.html#qname"><i>5.1 Qualified Names</i></a>.</p>

          <p><a name="err-XTDE1260" id="err-XTDE1260"><span class=
          "error">[ERR XTDE1260]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the value is not a valid QName, or if there
          is no namespace declaration in scope for the prefix of
          the QName, or if the name obtained by expanding the QName
          is not the same as the expanded name of any <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration in
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>. If the processor is able
          to detect the error statically (for example, when the
          argument is supplied as a string literal), then the
          processor <span class="verb">may</span> optionally signal
          this as a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>

          <p>The <code>$key-value</code> argument to the <a href=
          "index.html#function-key"><code>key</code></a> function is
          considered as a sequence. The set of requested key values
          is formed by atomizing the supplied value of the
          argument, using the standard <a title=
          "function conversion rules" href=
          "index.html#dt-function-conversion-rules">function conversion
          rules</a>. Each of the resulting atomic values is
          considered as a requested key value. The result of the
          function is a sequence of nodes, in document order and
          with duplicates removed, comprising those nodes in the
          selected <span>subtree</span> (see below) that are
          matched by an <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration whose
          name is the same as the supplied key name, where the
          result of evaluating the <a title="key specifier" href=
          "index.html#dt-key-specifier">key specifier</a> contains a value
          that is equal to one of these requested key values, under
          the rules appropriate to the XPath <code>eq</code>
          operator for the two values in question, using the
          <code>collation</code> attributes of the <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration when
          comparing strings. No error is reported if two values are
          encountered that are not comparable; they are regarded
          for the purposes of this function as being not equal.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Under the rules for the <code>eq</code> operator,
            untyped atomic values are converted to strings, not to
            the type of the other operand. This means, for example,
            that if the expression in the <code>use</code>
            attribute returns a date, supplying an untyped atomic
            value in the call to the <a href=
            "index.html#function-key"><code>key</code></a> function will
            return an empty sequence.</p>
          </div>

          <p>If the second argument is an empty sequence, the
          result of the function will be an empty sequence.</p>

          <p>Different rules apply when <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards
          compatible</a> behavior is enabled. Specifically, if any
          of the <a href="index.html#element-key"><code>xsl:key</code></a>
          elements in the definition of the <a title="key" href=
          "index.html#dt-key">key</a> enables backwards compatible behavior,
          then the value of the <a title="key specifier" href=
          "index.html#dt-key-specifier">key specifier</a> and the value of
          the second argument of the <a href=
          "index.html#function-key"><code>key</code></a> function are both
          converted after atomization to a sequence of strings, by
          applying a cast to each item in the sequence, before
          performing the comparison.</p>

          <p>The third argument is used to identify the selected
          subtree. If the argument is present, the selected subtree
          is the set of nodes that have <var>$top</var> as an
          ancestor-or-self node. If the argument is omitted, the
          selected subtree is the document containing the context
          node. This means that the third argument effectively
          defaults to <code>/</code>.</p>

          <p><a name="err-XTDE1270" id="err-XTDE1270"><span class=
          "error">[ERR XTDE1270]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> to call the <a href=
          "index.html#function-key"><code>key</code></a> function with two
          arguments if there is no <a title="context node" href=
          "index.html#dt-context-node">context node</a>, <span>or if the root
          of the tree containing the context node is not a document
          node</span>; or to call the function with three arguments
          if the root of the tree containing the node supplied in
          the third argument is not a document node.</p>

          <p>The result of the <a href=
          "index.html#function-key"><code>key</code></a> function can be
          described more specifically as follows. The result is a
          sequence containing every node <var>$N</var> that
          satisfies the following conditions:</p>

          <ul>
            <li>
              <p><code>$N/ancestor-or-self::node() intersect
              $top</code> is non-empty. (If the third argument is
              omitted, <code>$top</code> defaults to
              <code>/</code>)</p>
            </li>

            <li>
              <p><var>$N</var> matches the pattern specified in the
              <code>match</code> attribute of an <a href=
              "index.html#element-key"><code>xsl:key</code></a> declaration
              whose <code>name</code> attribute matches the name
              specified in the <code>$key-name</code> argument.</p>
            </li>

            <li>
              <p>When the <a title="key specifier" href=
              "index.html#dt-key-specifier">key specifier</a> of that
              <a href="index.html#element-key"><code>xsl:key</code></a>
              declaration is evaluated with a <a title=
              "singleton focus" href=
              "index.html#dt-singleton-focus">singleton focus</a> based on
              <var>$N</var>, the <a title="atomize" href=
              "index.html#dt-atomization">atomized</a> value of the resulting
              sequence includes a value that compares equal to at
              least one item in the atomized value of the sequence
              supplied as <code>$key-value</code>, under the rules
              of the <code>eq</code> operator with the collation
              selected as described above.</p>
            </li>
          </ul>

          <p>The sequence returned by the <a href=
          "index.html#function-key"><code>key</code></a> function will be in
          document order, with duplicates (that is, nodes having
          the same identity) removed.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e22835" id="d5e22835"></a>Example: Using a
              Key to Follow Cross-References
            </div>

            <p>For example, given a declaration</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:key name="idkey" match="div" use="@id"/&gt;
</pre>
            </div>

            <p>an expression <code>key("idkey",@ref)</code> will
            return the same nodes as <code>id(@ref)</code>,
            assuming that the only ID attribute declared in the XML
            source document is:</p>

            <div class="exampleInner">
              <pre>
&lt;!ATTLIST div id ID #IMPLIED&gt;
</pre>
            </div>

            <p>and that the <code>ref</code> attribute of the
            context node contains no whitespace.</p>

            <p>Suppose a document describing a function library
            uses a <code>prototype</code> element to define
            functions</p>

            <div class="exampleInner">
              <pre>
&lt;prototype name="sqrt" return-type="xs:double"&gt;
  &lt;arg type="xs:double"/&gt;
&lt;/prototype&gt;
</pre>
            </div>

            <p>and a <code>function</code> element to refer to
            function names</p>

            <div class="exampleInner">
              <pre>
&lt;function&gt;sqrt&lt;/function&gt;
</pre>
            </div>

            <p>Then the stylesheet could generate hyperlinks
            between the references and definitions as follows:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:key name="func" match="prototype" use="@name"/&gt;

&lt;xsl:template match="function"&gt;
&lt;b&gt;
  &lt;a href="#{generate-id(key('func',.))}"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/a&gt;
&lt;/b&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="prototype"&gt;
  &lt;p&gt;
    &lt;a name="{generate-id()}"&gt;
      &lt;b&gt;Function: &lt;/b&gt;
      ...
    &lt;/a&gt;
  &lt;/p&gt;
&lt;/xsl:template&gt;
</pre>
            </div>
          </div>

          <p>When called with two arguments, the <a href=
          "index.html#function-key"><code>key</code></a> function always
          returns nodes that are in the same document as the
          context node. To retrieve a node from any other document,
          it is necessary either to change the context node, or to
          supply a third argument.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e22881" id="d5e22881"></a>Example: Using
              Keys to Reference other Documents
            </div>

            <p>For example, suppose a document contains
            bibliographic references in the form
            <code>&lt;bibref&gt;XSLT&lt;/bibref&gt;</code>, and
            there is a separate XML document <code>bib.xml</code>
            containing a bibliographic database with entries in the
            form:</p>

            <div class="exampleInner">
              <pre>
&lt;entry name="XSLT"&gt;...&lt;/entry&gt;
</pre>
            </div>

            <p>Then the stylesheet could use the following to
            transform the <code>bibref</code> elements:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:key name="bib" match="entry" use="@name"/&gt;

&lt;xsl:template match="bibref"&gt;
  &lt;xsl:variable name="name" select="."/&gt;
  &lt;xsl:apply-templates select="document('bib.xml')/key('bib',$name)"/&gt;
&lt;/xsl:template&gt;
</pre>
            </div>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>This relies on the ability in XPath 2.0 to have a
              function call on the right-hand side of the
              <code>/</code> operator in a path expression.</p>
            </div>

            <p>The following code would also work:</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:key name="bib" match="entry" use="@name"/&gt;

&lt;xsl:template match="bibref"&gt;
  &lt;xsl:apply-templates select="key('bib', ., document('bib.xml'))"/&gt;
&lt;/xsl:template&gt;
</pre>
            </div>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="format-number" id="format-number"></a>16.4
        Number Formatting</h3><a name="function-format-number" id=
        "function-format-number"></a>

        <div class="proto">
          <code class="function">format-number</code>(<code class=
          "arg">$value</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">numeric?</code>, <code class=
          "arg">$picture</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string</code>
        </div>

        <div class="proto">
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="baseline" rowspan="3"><code class=
              "function">format-number</code>(</td>

              <td valign="baseline"><code class=
              "arg">$value</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">numeric?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$picture</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$decimal-format-name</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string</code>)<code class=
              "as">&#160;as&#160;</code><code class=
              "return-type">xs:string</code></td>
            </tr>
          </table>
        </div>

        <p>The <a href=
        "index.html#function-format-number"><code>format-number</code></a>
        function formats <code>$value</code> as a string using the
        <a title="picture string" href="index.html#dt-picture-string">picture
        string</a> specified by the <code>$picture</code> argument
        and the decimal-format named by the
        <code>$decimal-format-name</code> argument, or the default
        decimal-format, if there is no
        <code>$decimal-format-name</code> argument. <span>The
        syntax of the picture string is described in <a href=
        "index.html#processing-picture-string"><i>16.4.2 Processing the
        Picture String</i></a>.</span></p>

        <p>The <code>$value</code> argument may be of any numeric
        data type (<code>xs:double</code>, <code>xs:float</code>,
        <code>xs:decimal</code>, or their subtypes including
        <code>xs:integer</code>). Note that if an
        <code>xs:decimal</code> is supplied, it is not
        automatically promoted to an <code>xs:double</code>, as
        such promotion can involve a loss of precision.</p>

        <p>If the supplied value of the <code>$value</code>
        argument is an empty sequence, the function behaves as if
        the supplied value were the <code>xs:double</code> value
        <code>NaN</code>.</p>

        <p>The value of <code>$decimal-format-name</code>
        <span class="verb">must</span> be a <a title=
        "lexical QName" href="index.html#dt-lexical-qname">lexical QName</a>,
        which is expanded as described in <a href="index.html#qname"><i>5.1
        Qualified Names</i></a>. The result of the function is the
        formatted string representation of the supplied number.</p>

        <p><a name="err-XTDE1280" id="err-XTDE1280"><span class=
        "error">[ERR XTDE1280]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the name specified as the
        <code>$decimal-format-name</code> argument <span>is not a
        valid <a title="QName" href="index.html#dt-qname">QName</a>, or if
        its prefix has not been declared in an in-scope namespace
        declaration</span>, or if the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> does not contain a
        declaration of a decimal-format with a matching <a title=
        "expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a>. If the processor
        is able to detect the error statically (for example, when
        the argument is supplied as a string literal), then the
        processor <span class="verb">may</span> optionally signal
        this as a <a title="static error" href=
        "index.html#dt-static-error">static error</a>.</p>

        <div class="div3">
          <h4><a name="defining-decimal-format" id=
          "defining-decimal-format"></a>16.4.1 Defining a Decimal
          Format</h4>

          <p class="element-syntax"><a name=
          "element-decimal-format" id=
          "element-decimal-format"></a><code>&lt;!-- Category:
          declaration --&gt;<br />
          &lt;xsl:decimal-format<br />
          &#160;&#160;name? = <var>qname</var><br />
          &#160;&#160;decimal-separator? = <var>char</var><br />
          &#160;&#160;grouping-separator? = <var>char</var><br />
          &#160;&#160;infinity? = <var>string</var><br />
          &#160;&#160;minus-sign? = <var>char</var><br />
          &#160;&#160;NaN? = <var>string</var><br />
          &#160;&#160;percent? = <var>char</var><br />
          &#160;&#160;per-mille? = <var>char</var><br />
          &#160;&#160;zero-digit? = <var>char</var><br />
          &#160;&#160;digit? = <var>char</var><br />
          &#160;&#160;pattern-separator? =
          <var>char</var>&#160;/&gt;</code></p>

          <p>The <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          element controls the interpretation of a <a title=
          "picture string" href="index.html#dt-picture-string">picture
          string</a> used by the <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function.</p>

          <p>A <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> may contain multiple
          <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declarations and may include or import <a title=
          "stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a> that also
          contain <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declarations. The name of an <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration is the value of its <code>name</code>
          attribute, if any.</p>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-decimal-format" id="dt-decimal-format" title=
          "decimal format"></a>All the <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declarations in a stylesheet that share the same name are
          grouped into a named <b>decimal format</b>; those that
          have no name are grouped into a single unnamed decimal
          format.<span class="definition">]</span></p>

          <p>If a <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> does not contain a
          declaration of the unnamed decimal format, a declaration
          equivalent to an <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          element with no attributes is implied.</p>

          <p>The attributes of the <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration establish values for a number of variables
          used as input to the algorithm followed by the <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function. An outline of the purpose of each attribute is
          given below; however, the definitive explanations are
          given later, as part of the description of this
          algorithm.</p>

          <p>For any named <a title="decimal format" href=
          "index.html#dt-decimal-format">decimal format</a>, the effective
          value of each attribute is taken from an <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration that has that name, and that specifies an
          explicit value for the required attribute. If there is no
          such declaration, the default value of the attribute is
          used. If there is more than one such declaration, the one
          with highest <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a> is
          used.</p>

          <p>For any unnamed <a title="decimal format" href=
          "index.html#dt-decimal-format">decimal format</a>, the effective
          value of each attribute is taken from an <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration that is unnamed, and that specifies an
          explicit value for the required attribute. If there is no
          such declaration, the default value of the attribute is
          used. If there is more than one such declaration, the one
          with highest <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a> is
          used.</p>

          <p><a name="err-XTSE1290" id="err-XTSE1290"><span class=
          "error">[ERR XTSE1290]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if a named or unnamed <a title="decimal format" href=
          "index.html#dt-decimal-format">decimal format</a> contains two
          conflicting values for the same attribute in different
          <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declarations having the same <a title="import precedence"
          href="index.html#dt-import-precedence">import precedence</a>,
          unless there is another definition of the same attribute
          with higher import precedence.</p>

          <p>The following attributes control the interpretation of
          characters in the <a title="picture string" href=
          "index.html#dt-picture-string">picture string</a> supplied to the
          <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function, and also specify characters that may appear in
          the result of formatting the number. In each case the
          value <span class="verb">must</span> be a single
          character <span><span class="error">[see <a href=
          "index.html#err-XTSE0020">ERR XTSE0020</a>]</span></span>.</p>

          <ul>
            <li>
              <p><code>decimal-separator</code> specifies the
              character used for the
              <var>decimal-separator-sign</var>; the default value
              is the period character (<code>.</code>)</p>
            </li>

            <li>
              <p><code>grouping-separator</code> specifies the
              character used for the <var>grouping-sign</var>,
              which is typically used as a thousands separator; the
              default value is the comma character
              (<code>,</code>)</p>
            </li>

            <li>
              <p><code>percent</code> specifies the character used
              for the <var>percent-sign</var>; the default value is
              the percent character (<code>%</code>)</p>
            </li>

            <li>
              <p><code>per-mille</code> specifies the character
              used for the <var>per-mille-sign</var>; the default
              value is the Unicode per-mille character (#x2030)</p>
            </li>

            <li>
              <p><code>zero-digit</code> specifies the character
              used for the <var>digit-zero-sign</var>; the default
              value is the digit zero (<code>0</code>). This
              character <span class="verb">must</span> be a digit
              (category Nd in the Unicode property database), and
              it <span class="verb">must</span> have the numeric
              value zero. <span>This attribute implicitly defines
              the Unicode character that is used to represent each
              of the values 0 to 9 in the final result string:
              Unicode is organized so that each set of decimal
              digits forms a contiguous block of characters in
              numerical sequence.</span></p>
            </li>
          </ul>

          <p><a name="err-XTSE1295" id="err-XTSE1295"><span class=
          "error">[ERR XTSE1295]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the character specified in the <code>zero-digit</code>
          attribute is not a digit or is a digit that does not have
          the numeric value zero.</p>

          <p>The following attributes control the interpretation of
          characters in the <a title="picture string" href=
          "index.html#dt-picture-string">picture string</a> supplied to the
          <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function. In each case the value <span class=
          "verb">must</span> be a single character
          <span><span class="error">[see <a href=
          "index.html#err-XTSE0020">ERR XTSE0020</a>]</span></span>.</p>

          <ul>
            <li>
              <p><code>digit</code> specifies the character used
              for the <var>digit-sign</var> in the <a title=
              "picture string" href="index.html#dt-picture-string">picture
              string</a>; the default value is the number sign
              character (<code>#</code>)</p>
            </li>

            <li>
              <p><code>pattern-separator</code> specifies the
              character used for the
              <var>pattern-separator-sign</var>, which separates
              positive and negative sub-pictures in a <a title=
              "picture string" href="index.html#dt-picture-string">picture
              string</a>; the default value is the semi-colon
              character (<code>;</code>)</p>
            </li>
          </ul>

          <p>The following attributes specify characters or strings
          that may appear in the result of formatting the
          number:</p>

          <ul>
            <li>
              <p><code>infinity</code> specifies the string used
              for the <var>infinity-symbol</var>; the default value
              is the string <code>Infinity</code></p>
            </li>

            <li>
              <p><code>NaN</code> specifies the string used for the
              <var>NaN-symbol</var>, which is used to represent the
              value NaN (not-a-number); the default value is the
              string <code>NaN</code></p>
            </li>

            <li>
              <p><code>minus-sign</code> specifies the character
              used for the <var>minus-symbol</var>; the default
              value is the hyphen-minus character (<code>-</code>,
              #x2D). The value <span class="verb">must</span> be a
              single character.</p>
            </li>
          </ul>

          <p><a name="err-XTSE1300" id="err-XTSE1300"><span class=
          "error">[ERR XTSE1300]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if, for any named or unnamed decimal format, the
          variables representing characters used in a <a title=
          "picture string" href="index.html#dt-picture-string">picture
          string</a> do not each have distinct values. These
          variables are <var>decimal-separator-sign</var>,
          <var>grouping-sign</var>, <var>percent-sign</var>,
          <var>per-mille-sign</var>, <var>digit-zero-sign</var>,
          <var>digit-sign</var>, and
          <var>pattern-separator-sign</var>.</p>
        </div>

        <div class="div3">
          <h4><a name="processing-picture-string" id=
          "processing-picture-string"></a>16.4.2 Processing the
          Picture String</h4>

          <p><span class=
          "definition">[Definition:&#160;</span><a name=
          "dt-picture-string" id="dt-picture-string" title=
          "picture string"></a>The formatting of a number is
          controlled by a <b>picture string</b>. The picture string
          is a sequence of characters, in which the characters
          assigned to the variables
          <var>decimal-separator-sign</var>,
          <var>grouping-sign</var>, <var>zero-digit-sign</var>,
          <var>digit-sign</var> and
          <var>pattern-separator-sign</var> are classified as
          active characters, and all other characters (including
          the <var>percent-sign</var> and
          <var>per-mille-sign</var>) are classified as passive
          characters.<span class="definition">]</span></p>

          <p>The <var>integer part</var> of the sub-picture is
          defined as the part that appears to the left of the
          <var>decimal-separator-sign</var> if there is one, or the
          entire sub-picture otherwise. The <var>fractional
          part</var> of the sub-picture is defined as the part that
          appears to the right of the
          <var>decimal-separator-sign</var> if there is one; it is
          a zero-length string otherwise.</p>

          <p><a name="err-XTDE1310" id="err-XTDE1310"><span class=
          "error">[ERR XTDE1310]</span></a> The <a title=
          "picture string" href="index.html#dt-picture-string">picture
          string</a> <span class="verb">must</span> conform to the
          following rules. It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the picture string does not satisfy these
          rules.</p>

          <p>Note that in these rules the words "preceded" and
          "followed" refer to characters anywhere in the string,
          they are not to be read as "immediately preceded" and
          "immediately followed".</p>

          <ul>
            <li>
              <p>A picture-string consists either of a sub-picture,
              or of two sub-pictures separated by a
              <var>pattern-separator-sign</var>. A picture-string
              <span class="verb">must not</span> contain more than
              one <var>pattern-separator-sign</var>. If the
              picture-string contains two sub-pictures, the first
              is used for positive values and the second for
              negative values.</p>
            </li>

            <li>
              <p>A sub-picture <span class="verb">must not</span>
              contain more than one
              <var>decimal-separator-sign</var>.</p>
            </li>

            <li>
              <p>A sub-picture <span class="verb">must not</span>
              contain more than one <var>percent-sign</var> or
              <var>per-mille-sign</var>, and it <span class=
              "verb">must not</span> contain one of each.</p>
            </li>

            <li>
              <p>A sub-picture <span class="verb">must</span>
              contain at least one <var>digit-sign</var> or
              <var>zero-digit-sign</var>.</p>
            </li>

            <li>
              <p>A sub-picture <span class="verb">must not</span>
              contain a passive character that is preceded by an
              active character and that is followed by another
              active character.</p>
            </li>

            <li>
              <p>A sub-picture <span class="verb">must not</span>
              contain a <var>grouping-separator-sign</var> adjacent
              to a <var>decimal-separator-sign</var>.</p>
            </li>

            <li>
              <p>The integer part of a sub-picture <span class=
              "verb">must not</span> contain a
              <var>zero-digit-sign</var> that is followed by a
              <var>digit-sign</var>. The fractional part of a
              sub-picture <span class="verb">must not</span>
              contain a <var>digit-sign</var> that is followed by a
              <var>zero-digit-sign</var>.</p>
            </li>
          </ul>

          <p>The evaluation of the <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function is described below in two phases, an analysis
          phase and a formatting phase. The analysis phase takes as
          its inputs the <a title="picture string" href=
          "index.html#dt-picture-string">picture string</a> and the variables
          derived from the relevant <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration, and produces as its output a number of
          variables with defined values. The formatting phase takes
          as its inputs the number to be formatted and the
          variables produced by the analysis phase, and produces as
          its output a string containing a formatted representation
          of the number.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Numbers will always be formatted with the most
            significant digit on the left.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="analysing-picture-string" id=
          "analysing-picture-string"></a>16.4.3 Analysing the
          Picture String</h4>

          <p>This phase of the algorithm analyses the <a title=
          "picture string" href="index.html#dt-picture-string">picture
          string</a> and the attribute settings of the <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration, and has the effect of setting the values of
          various variables, which are used in the subsequent
          formatting phase. These variables are listed below. Each
          is shown with its initial setting and its data type.</p>

          <p>Several variables are associated with each
          sub-picture. If there are two sub-pictures, then these
          rules are applied to one sub-picture to obtain the values
          that apply to positive numbers, and to the other to
          obtain the values that apply to negative numbers. If
          there is only one sub-picture, then the values for both
          cases are derived from this sub-picture.</p>

          <p>The variables are as follows:</p>

          <ul>
            <li>
              <p>The <var>integer-part-grouping-positions</var> is
              a sequence of integers representing the positions of
              grouping separators within the integer part of the
              sub-picture. For each
              <var>grouping-separator-sign</var> that appears
              within the integer part of the sub-picture, this
              sequence contains an integer that is equal to the
              total number of <var>digit-sign</var> and
              <var>zero-digit-sign</var> characters that appear
              within the integer part of the sub-picture and to the
              right of the <var>grouping-separator-sign</var>. In
              addition, if these
              <var>integer-part-grouping-positions</var> are at
              regular intervals (that is, if they <span>form a
              sequence <var>N</var>, <var>2N</var>, <var>3N</var>,
              ... for some integer value <var>N</var>,</span>
              including the case where there is only one number in
              the list), then the sequence contains all integer
              multiples of <var>N</var> as far as necessary to
              accommodate the largest possible number.</p>
            </li>

            <li>
              <p>The <var>minimum-integer-part-size</var> is an
              integer indicating the minimum number of digits that
              will appear to the left of the
              <var>decimal-separator-sign</var>. It is normally set
              to the number of <var>zero-digit-sign</var>
              characters found in the integer part of the
              sub-picture. But if the sub-picture contains no
              <var>zero-digit-sign</var> and no
              <var>decimal-separator-sign</var>, it is set to
              one.</p>

              <div class="note">
                <p class="prefix"><b>Note:</b></p>

                <p>There is no maximum integer part size. All
                significant digits in the integer part of the
                number will be displayed, even if this exceeds the
                number of <var>digit-sign</var> and
                <var>zero-digit-sign</var> characters in the
                subpicture.</p>
              </div>
            </li>

            <li>
              <p>The <var>prefix</var> is set to contain all
              passive characters in the sub-picture to the left of
              the leftmost active character. <span>If the picture
              string contains only one sub-picture</span>, the
              <var>prefix</var> for the negative sub-picture is set
              by concatenating the <var>minus-sign</var> character
              and the <var>prefix</var> for the positive
              sub-picture (if any), in that order.</p>
            </li>

            <li>
              <p>The <var>fractional-part-grouping-positions</var>
              is a sequence of integers representing the positions
              of grouping separators within the fractional part of
              the sub-picture. For each
              <var>grouping-separator-sign</var> that appears
              within the fractional part of the sub-picture, this
              sequence contains an integer that is equal to the
              total number of <var>digit-sign</var> and
              <var>zero-digit-sign</var> characters that appear
              within the fractional part of the sub-picture and to
              the left of the
              <var>grouping-separator-sign</var>.</p>
            </li>

            <li>
              <p>The <var>minimum-fractional-part-size</var> is set
              to the number of <var>zero-digit-sign</var>
              characters found in the fractional part of the
              sub-picture.</p>
            </li>

            <li>
              <p>The <var>maximum-fractional-part-size</var> is set
              to the total number of <var>digit-sign</var> and
              <var>zero-digit-sign</var> characters found in the
              fractional part of the sub-picture.</p>
            </li>

            <li>
              <p>The <var>suffix</var> is set to contain all
              passive characters to the right of the rightmost
              active character in the fractional part of the
              sub-picture.</p>
            </li>
          </ul>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>If there is only one sub-picture, then all variables
            for positive numbers and negative numbers will be the
            same, except for <var>prefix</var>: the prefix for
            negative numbers will <span>be preceded by the
            <var>minus-sign</var> character</span>.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="formatting-the-number" id=
          "formatting-the-number"></a>16.4.4 Formatting the
          Number</h4>

          <p>This section describes the second phase of processing
          of the <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function. This phase takes as input a number to be
          formatted (referred to as the <em>input number</em>), and
          the variables set up by analysing the <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declaration and the <a title="picture string" href=
          "index.html#dt-picture-string">picture string</a>, as described
          above. The result of this phase is a string, which forms
          the return value of the <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function.</p>

          <p>The algorithm for this second stage of processing is
          as follows:</p>

          <ol class="enumar">
            <li>
              <p>If the input number is NaN (not a number), the
              result is the specified <var>NaN-symbol</var> (with
              no <var>prefix</var> or <var>suffix</var>).</p>
            </li>

            <li>
              <p>In the rules below, the positive sub-picture and
              its associated variables are used if the input number
              is positive, and the negative sub-picture and its
              associated variables are used otherwise. Negative
              zero is taken as negative, positive zero as
              positive.</p>
            </li>

            <li>
              <p>If the input number is positive or negative
              infinity, the result is the concatenation of the
              appropriate <var>prefix</var>, the
              <var>infinity-symbol</var>, and the appropriate
              <var>suffix</var>.</p>
            </li>

            <li>
              <p>If the sub-picture contains a
              <var>percent-sign</var>, the number is multiplied by
              100. If the sub-picture contains a
              <var>per-mille-sign</var>, the number is multiplied
              by 1000. The resulting number is referred to below as
              the <var>adjusted number</var>.</p>
            </li>

            <li>
              <p>The <var>adjusted number</var> is converted (if
              necessary) to an <code>xs:decimal</code> value, using
              an implementation of <code>xs:decimal</code> that
              imposes no limits on the <code>totalDigits</code> or
              <code>fractionDigits</code> facets. If there are
              several such values that are numerically equal to the
              <var>adjusted number</var> (bearing in mind that if
              the <var>adjusted number</var> is an
              <code>xs:double</code> or <code>xs:float</code>, the
              comparison will be done by converting the decimal
              value back to an <code>xs:double</code> or
              <code>xs:float</code>), the one that is chosen
              <span class="verb">should</span> be one with the
              smallest possible number of digits not counting
              leading or trailing zeroes <span>(whether significant
              or insignificant)</span>. For example, 1.0 is
              preferred to 0.9999999999, and 100000000 is preferred
              to 100000001. This value is then rounded so that it
              uses no more than
              <code>maximum-fractional-part-size</code> digits in
              its fractional part. The <var>rounded number</var> is
              defined to be the result of converting the
              <var>adjusted number</var> to an
              <code>xs:decimal</code> value, as described above,
              and then calling the function <a href=
              "http://www.w3.org/TR/xpath-functions/#func-round-half-to-even">
              <code>round-half-to-even</code></a><sup><small>FO</small></sup>
              with this converted number as the first argument and
              the <code>maximum-fractional-part-size</code> as the
              second argument, again with no limits on the
              <code>totalDigits</code> or
              <code>fractionDigits</code> in the result.</p>
            </li>

            <li>
              <p>The absolute value of the <var>rounded
              number</var> is converted to a string in decimal
              notation, with no insignificant leading or trailing
              zeroes, using the characters implied by the choice of
              <var>zero-digit-sign</var> to represent the ten
              decimal digits, and the
              <var>decimal-separator-sign</var> to separate the
              integer part and the fractional part. (The value zero
              will at this stage be represented by a
              <var>decimal-separator-sign</var> on its own.)</p>
            </li>

            <li>
              <p>If the number of digits to the left of the
              <var>decimal-separator-sign</var> is less than
              <var>minimum-integer-part-size</var>, leading
              <var>zero-digit-sign</var> characters are added to
              pad out to that size.</p>
            </li>

            <li>
              <p>If the number of digits to the right of the
              <var>decimal-separator-sign</var> is less than
              <var>minimum-fractional-part-size</var>, trailing
              <var>zero-digit-sign</var> characters are added to
              pad out to that size.</p>
            </li>

            <li>
              <p>For each integer <var>N</var> in the
              <var>integer-part-grouping-positions</var> list, a
              <var>grouping-separator-sign</var> character is
              inserted into the string immediately after that digit
              that appears in the integer part of the number and
              has <var>N</var> digits between it and the
              <var>decimal-separator-sign</var>, if there is such a
              digit.</p>
            </li>

            <li>
              <p>For each integer <var>N</var> in the
              <var>fractional-part-grouping-positions</var> list, a
              <var>grouping-separator-sign</var> character is
              inserted into the string immediately before that
              digit that appears in the fractional part of the
              number and has <var>N</var> digits between it and the
              <var>decimal-separator-sign</var>, if there is such a
              digit.</p>
            </li>

            <li>
              <p>If there is no <var>decimal-separator-sign</var>
              in the sub-picture, <span>or if there are no digits
              to the right of the <var>decimal-separator-sign</var>
              character in the string, then</span> the
              <var>decimal-separator-sign</var> character is
              removed from the string (it will be the rightmost
              character in the string).</p>
            </li>

            <li>
              <p>The result of the function is the concatenation of
              the appropriate <var>prefix</var>, the string
              conversion of the number as obtained above, and the
              appropriate <var>suffix</var>.</p>
            </li>
          </ol>
        </div>
      </div>

      <div class="div2">
        <h3><a name="format-date" id="format-date"></a>16.5
        Formatting Dates and Times</h3>

        <p>Three functions are provided to represent dates and
        times as a string, using the conventions of a selected
        calendar, language, and country. Each has two
        variants.</p><a name="function-format-dateTime" id=
        "function-format-dateTime"></a>

        <div class="proto">
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="baseline" rowspan="5"><code class=
              "function">format-dateTime</code>(</td>

              <td valign="baseline"><code class=
              "arg">$value</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:dateTime?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$picture</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$language</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$calendar</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$country</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>)<code class=
              "as">&#160;as&#160;</code><code class=
              "return-type">xs:string?</code></td>
            </tr>
          </table>
        </div>

        <div class="proto">
          <code class=
          "function">format-dateTime</code>(<code class="arg">$value</code><code class="as">
          &#160;as&#160;</code><code class=
          "type">xs:dateTime?</code>, <code class=
          "arg">$picture</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string?</code>
        </div><a name="function-format-date" id=
        "function-format-date"></a>

        <div class="proto">
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="baseline" rowspan="5"><code class=
              "function">format-date</code>(</td>

              <td valign="baseline"><code class=
              "arg">$value</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:date?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$picture</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$language</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$calendar</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$country</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>)<code class=
              "as">&#160;as&#160;</code><code class=
              "return-type">xs:string?</code></td>
            </tr>
          </table>
        </div>

        <div class="proto">
          <code class="function">format-date</code>(<code class=
          "arg">$value</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:date?</code>, <code class=
          "arg">$picture</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string?</code>
        </div><a name="function-format-time" id=
        "function-format-time"></a>

        <div class="proto">
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="baseline" rowspan="5"><code class=
              "function">format-time</code>(</td>

              <td valign="baseline"><code class=
              "arg">$value</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:time?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$picture</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$language</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$calendar</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>,</td>
            </tr>

            <tr>
              <td valign="baseline"><code class=
              "arg">$country</code></td>

              <td valign="baseline"><code class=
              "as">&#160;as&#160;</code><code class=
              "type">xs:string?</code>)<code class=
              "as">&#160;as&#160;</code><code class=
              "return-type">xs:string?</code></td>
            </tr>
          </table>
        </div>

        <div class="proto">
          <code class="function">format-time</code>(<code class=
          "arg">$value</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:time?</code>, <code class=
          "arg">$picture</code><code class=
          "as">&#160;as&#160;</code><code class=
          "type">xs:string</code>)<code class=
          "as">&#160;as&#160;</code><code class=
          "return-type">xs:string?</code>
        </div>

        <p>The <a href=
        "index.html#function-format-dateTime"><code>format-dateTime</code></a>,
        <a href=
        "index.html#function-format-date"><code>format-date</code></a>, and
        <a href=
        "index.html#function-format-time"><code>format-time</code></a>
        functions format <code>$value</code> as a string using the
        picture string specified by the <code>$picture</code>
        argument, the calendar specified by the
        <code>$calendar</code> argument, the language specified by
        the <code>$language</code> argument, and the country
        specified by the <code>$country</code> argument. The result
        of the function is the formatted string representation of
        the supplied <code>dateTime</code>, <code>date</code>, or
        <code>time</code> value.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-date-formatting-function" id=
        "dt-date-formatting-function" title=
        "date formatting function"></a>The three functions <a href=
        "index.html#function-format-date"><code>format-date</code></a>,
        <a href=
        "index.html#function-format-time"><code>format-time</code></a>, and
        <a href=
        "index.html#function-format-dateTime"><code>format-dateTime</code></a>
        are referred to collectively as the <b>date formatting
        functions</b>.<span class="definition">]</span></p>

        <p>If <code>$value</code> is the empty sequence, the empty
        sequence is returned.</p>

        <p>Calling the two-argument form of each of the three
        functions is equivalent to calling the five-argument form
        with each of the last three arguments set to an empty
        sequence.</p>

        <p>For details of the <code>language</code>,
        <code>calendar</code>, and <code>country</code> arguments,
        see <a href="index.html#lang-cal-country"><i>16.5.2 The Language,
        Calendar, and Country Arguments</i></a>.</p>

        <p>In general, the use of an invalid <code>picture</code>,
        <code>language</code>, <code>calendar</code>, or
        <code>country</code> argument is classified as a
        <span><a title="non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a>. By contrast,</span> use of an option in any of
        these arguments that is valid but not supported by the
        implementation is not an error, and in these cases the
        implementation is required to output the value in a
        fallback representation.</p>

        <div class="div3">
          <h4><a name="date-picture-string" id=
          "date-picture-string"></a>16.5.1 The Picture String</h4>

          <p>The picture consists of a sequence of variable markers
          and literal substrings. A substring enclosed in square
          brackets is interpreted as a variable marker; substrings
          not enclosed in square brackets are taken as literal
          substrings. The literal substrings are optional and if
          present are rendered unchanged, including any whitespace.
          If an opening or closing square bracket is required
          within a literal substring, it <span class=
          "verb">must</span> be doubled. The variable markers are
          replaced in the result by strings representing aspects of
          the date and/or time to be formatted. These are described
          in detail below.</p>

          <p>A variable marker consists of a component specifier
          followed optionally by one or two presentation modifiers
          and/or optionally by a width modifier. Whitespace within
          a variable marker is ignored.</p>

          <p>The <em>component specifier</em> indicates the
          component of the date or time that is required, and takes
          the following values:</p>

          <table border="1" cellpadding="5">
            <thead>
              <tr>
                <th align="left">Specifier</th>

                <th align="left">Meaning</th>

                <th align="left">Default Presentation Modifier</th>
              </tr>
            </thead>

            <tbody>
              <tr>
                <td valign="top">Y</td>

                <td>year <span>(absolute value)</span></td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">M</td>

                <td>month in year</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">D</td>

                <td>day in month</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">d</td>

                <td>day in year</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">F</td>

                <td>day of week</td>

                <td valign="top">n</td>
              </tr>

              <tr>
                <td valign="top">W</td>

                <td>week in year</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">w</td>

                <td>week in month</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">H</td>

                <td>hour in day (24 hours)</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">h</td>

                <td>hour in half-day (12 hours)</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">P</td>

                <td>am/pm marker</td>

                <td valign="top">n</td>
              </tr>

              <tr>
                <td valign="top">m</td>

                <td>minute in hour</td>

                <td valign="top"><span>01</span></td>
              </tr>

              <tr>
                <td valign="top">s</td>

                <td>second in minute</td>

                <td valign="top"><span>01</span></td>
              </tr>

              <tr>
                <td valign="top">f</td>

                <td>fractional seconds</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">Z</td>

                <td>timezone as a time offset from UTC, or if an
                alphabetic modifier is present the conventional
                name of a timezone (such as PST)</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">z</td>

                <td>timezone as a time offset using GMT, for
                example GMT+1</td>

                <td valign="top">1</td>
              </tr>

              <tr>
                <td valign="top">C</td>

                <td>calendar: the name or abbreviation of a
                calendar name</td>

                <td valign="top">n</td>
              </tr>

              <tr>
                <td valign="top">E</td>

                <td>era: the name of a baseline for the numbering
                of years, for example the reign of a monarch</td>

                <td valign="top">n</td>
              </tr>
            </tbody>
          </table>

          <p><a name="err-XTDE1340" id="err-XTDE1340"><span class=
          "error">[ERR XTDE1340]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the syntax of the picture is incorrect.</p>

          <p><a name="err-XTDE1350" id="err-XTDE1350"><span class=
          "error">[ERR XTDE1350]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if a component specifier within the picture
          refers to components that are not available in the given
          type of <code>$value</code>, for example if the picture
          supplied to the <a href=
          "index.html#function-format-time"><code>format-time</code></a>
          refers to the year, month, or day component.</p>

          <p>It is not an error to include a timezone component
          when the supplied value has no timezone. In these
          circumstances the timezone component will be ignored.</p>

          <p>The first <em>presentation modifier</em> indicates the
          style in which the value of a component is to be
          represented. Its value may be either:</p>

          <ul>
            <li>
              <p>any format token permitted in the
              <code>format</code> string of the <a href=
              "index.html#element-number"><code>xsl:number</code></a>
              instruction (see <a href="index.html#number"><i>12
              Numbering</i></a>), indicating that the value of the
              component is to be output numerically using the
              specified number format (for example, <code>1</code>,
              <code>01</code>, <code>i</code>, <code>I</code>,
              <code>w</code>, <code>W</code>, or <code>Ww</code>)
              or</p>
            </li>

            <li>
              <p>the format token <code>n</code>, <code>N</code>,
              or <code>Nn</code>, indicating that the value of the
              component is to be output by name, in lower-case,
              upper-case, or title-case respectively. Components
              that can be output by name include (but are not
              limited to) months, days of the week, timezones, and
              eras. If the processor cannot output these components
              by name for the chosen calendar and language then it
              must use an implementation-defined fallback
              representation.</p>
            </li>
          </ul>

          <p>If the implementation does not support the use of the
          requested format token, it <span class="verb">must</span>
          use the default presentation modifier for that
          component.</p>

          <p>If the first presentation modifier is present, then it
          may optionally be followed by a second presentation
          modifier as follows:</p>

          <table border="1" cellpadding="5">
            <thead>
              <tr>
                <th align="left">Modifier</th>

                <th align="left">Meaning</th>
              </tr>
            </thead>

            <tbody>
              <tr>
                <td valign="top">t</td>

                <td valign="top">traditional numbering. This has
                the same meaning as
                <code>letter-value="traditional"</code> in <a href=
                "index.html#element-number"><code>xsl:number</code></a>.</td>
              </tr>

              <tr>
                <td valign="top">o</td>

                <td valign="top">ordinal form of a number, for
                example <code>8th</code> or <code>8º</code>. The
                actual representation of the ordinal form of a
                number may depend not only on the language, but
                also on the grammatical context (for example, in
                some languages it must agree in gender).</td>
              </tr>
            </tbody>
          </table>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Although the formatting rules are expressed in terms
            of the rules for format tokens in <a href=
            "index.html#element-number"><code>xsl:number</code></a>, the
            formats actually used may be specialized to the
            numbering of date components where appropriate. For
            example, in Italian, it is conventional to use an
            ordinal number (<code>primo</code>) for the first day
            of the month, and cardinal numbers (<code>due, tre,
            quattro ...</code>) for the remaining days. A processor
            may therefore use this convention to number days of the
            month, ignoring the presence or absence of the ordinal
            presentation modifier.</p>
          </div>

          <p>Whether or not a presentation modifier is included, a
          width modifier may be supplied. This indicates the number
          of characters or digits to be included in the
          representation of the value.</p>

          <p>The width modifier, if present, is introduced by a
          comma. It takes the form:</p>

          <p><code>&#160;&#160;&#160;,&#160;&#160;min-width ("-"
          max-width)?</code></p>

          <p>where <code>min-width</code> is either an unsigned
          integer indicating the minimum number of characters to be
          output, or <code>*</code> indicating that there is no
          explicit minimum, and <code>max-width</code> is either an
          unsigned integer indicating the maximum number of
          characters to be output, or <code>*</code> indicating
          that there is no explicit maximum; if
          <code>max-width</code> is omitted then <code>*</code> is
          assumed. Both integers, if present, <span class=
          "verb">must</span> be greater than zero.</p>

          <p>A format token containing leading zeroes, such as
          <code>001</code>, sets the minimum and maximum width to
          the number of digits appearing in the format token; if a
          width modifier is also present, then the width modifier
          takes precedence.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>A format token consisting of a one-digit on its own,
            such as <code>1</code>, does not constrain the number
            of digits in the output. In the case of fractional
            seconds in particular, <code>[f001]</code> requests
            three decimal digits, <code>[f01]</code> requests two
            digits, but <code>[f1]</code> will produce an
            implementation-defined number of digits. If exactly one
            digit is required, this can be achieved using the
            component specifier <code>[f1,1-1]</code>.</p>
          </div>

          <p>If the minumum and maximum width are unspecified, then
          the output uses as many characters as are required to
          represent the value of the component without truncation
          and without padding: this is referred to below as the
          <em>full representation</em> of the value.</p>

          <p>If the full representation of the value exceeds the
          specified maximum width, then the processor <span class=
          "verb">should</span> attempt to use an alternative
          shorter representation that fits within the maximum
          width. Where the presentation modifier is <code>N</code>,
          <code>n</code>, or <code>Nn</code>, this is done by
          abbreviating the name, using either conventional
          abbreviations if available, or crude right-truncation if
          not. For example, setting <code>max-width</code> to
          <code>4</code> indicates that four-letter abbreviations
          <span class="verb">should</span> be used, though it would
          be acceptable to use a three-letter abbreviation if this
          is in conventional use. (For example, "Tuesday" might be
          abbreviated to "Tues", and "Friday" to "Fri".) In the
          case of the year component, setting
          <code>max-width</code> requests omission of high-order
          digits from the year, for example, if
          <code>max-width</code> is set to <code>2</code> then the
          year 2003 will be output as <code>03</code>. <span>In the
          case of the fractional seconds component, the value is
          rounded to the specified size as if by applying the
          function <code>round-half-to-even(fractional-seconds,
          max-width)</code>.</span> If no mechanism is available
          for fitting the value within the specified maximum width
          (for example, when roman numerals are used), then the
          value <span class="verb">should</span> be output in its
          full representation.</p>

          <p>If the full representation of the value is shorter
          than the specified minimum width, then the processor
          <span class="verb">should</span> pad the value to the
          specified width. For decimal representations of numbers,
          this <span class="verb">should</span> be done by
          prepending zero digits from the appropriate set of digit
          characters, or appending zero digits in the case of the
          fractional seconds component. In other cases, it
          <span class="verb">should</span> be done by appending
          spaces.</p>
        </div>

        <div class="div3">
          <h4><a name="lang-cal-country" id=
          "lang-cal-country"></a>16.5.2 The Language, Calendar, and
          Country Arguments</h4>

          <p>The set of languages, calendars, and countries that
          are supported in the <a title="date formatting function"
          href="index.html#dt-date-formatting-function">date formatting
          functions</a> is <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          When any of these arguments is omitted or is an empty
          sequence, an <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          default value is used.</p>

          <p>If the fallback representation uses a different
          calendar from that requested, the output string
          <span class="verb">must</span> be prefixed with
          <code>[Calendar: X]</code> where <code>X</code>
          identifies the calendar actually used. The string
          <code>Calendar</code> <span class="verb">should</span> be
          localized using the requested language if available. If
          the fallback representation uses a different language
          from that requested, the output string should be prefixed
          with <code>[Language: Y]</code> where <code>Y</code>
          identifies the language actually used. The string
          <code>Language</code> <span class="verb">may</span> be
          localized in an <a title="implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>
          way. If a particular component of the value cannot be
          output in the requested format, it <span class=
          "verb">should</span> be output in the default format for
          that component.</p>

          <p>The <code>language</code> argument specifies the
          language to be used for the result string of the
          function. The value of the argument <span class=
          "verb">must</span> be either the empty sequence or a
          value that would be valid for the <code>xml:lang</code>
          attribute (see [XML]). Note that this permits the
          identification of sublanguages based on country codes
          (from <a href="index.html#ISO3166">[ISO 3166-1]</a>) as well as
          identification of dialects and of regions within a
          country.</p>

          <p>If the <code>language</code> argument is omitted or is
          set to an empty sequence, or if it is set to an invalid
          value or a value that the implementation does not
          recognize, then the processor uses an <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          language.</p>

          <p>The language is used to select the appropriate
          language-dependent forms of:</p>

          <blockquote>
            <p>names (for example, of months)<br />
            numbers expressed as words or as ordinals
            (<code>twenty, 20th, twentieth</code>)<br />
            hour convention (0-23 vs 1-24, 0-11 vs 1-12)<br />
            first day of week, first week of year</p>
          </blockquote>

          <p>Where appropriate this choice may also take into
          account the value of the <code>country</code> argument,
          though this <span class="verb">should</span> not be used
          to override the language or any sublanguage that is
          specified as part of the <code>language</code>
          argument.</p>

          <p>The choice of the names and abbreviations used in any
          given language is <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          For example, one implementation might abbreviate July as
          <code>Jul</code> while another uses <code>Jly</code>. In
          German, one implementation might represent Saturday as
          <code>Samstag</code> while another uses
          <code>Sonnabend</code>. Implementations <span class=
          "verb">may</span> provide mechanisms allowing users to
          control such choices.</p>

          <p>Where ordinal numbers are used, the selection of the
          correct representation of the ordinal (for example, the
          linguistic gender) <span class="verb">may</span> depend
          on the component being formatted and on its textual
          context in the picture string.</p>

          <p>The <code>calendar</code> attribute specifies that the
          <code>dateTime</code>, <code>date</code>, or
          <code>time</code> supplied in the <code>$value</code>
          argument <span class="verb">must</span> be converted to a
          value in the specified calendar and then converted to a
          string using the conventions of that calendar.</p>

          <p>A calendar value <span class="verb">must</span> be a
          valid <a title="QName" href="index.html#dt-qname">QName</a>. If the
          QName does not have a prefix, then it identifies a
          calendar with the designator specified below. If the
          QName has a prefix, then the QName is expanded into an
          expanded-QName as described in <a href="index.html#qname"><i>5.1
          Qualified Names</i></a>; the expanded-QName identifies
          the calendar; the behavior in this case is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.</p>

          <p>If the calendar attribute is omitted an <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          value is used.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The calendars listed below were known to be in use
            during the last hundred years. Many other calendars
            have been used in the past.</p>

            <p>This specification does not define any of these
            calendars, nor the way that they map to the value space
            of the <code>xs:date</code> data type in <a href=
            "index.html#xmlschema-2">[XML Schema Part 2]</a>. There may be
            ambiguities when dates are recorded using different
            calendars. For example, the start of a new day is not
            simultaneous in different calendars, and may also vary
            geographically (for example, based on the time of
            sunrise or sunset). Translation of dates is therefore
            more reliable when the time of day is also known, and
            when the geographic location is known. When translating
            dates between one calendar and another, the processor
            may take account of the values of the
            <code>country</code> and/or <code>language</code>
            arguments, with the <code>country</code> argument
            taking precedence.</p>

            <p>Information about some of these calendars, and
            algorithms for converting between them, may be found in
            <a href="index.html#CALCALC">[Calendrical Calculations]</a>.</p>
          </div>

          <table border="1" cellpadding="5">
            <thead>
              <tr>
                <th valign="top" align="left">Designator</th>

                <th valign="top" align="left">Calendar</th>
              </tr>
            </thead>

            <tbody>
              <tr>
                <td>AD</td>

                <td>Anno Domini (Christian Era)</td>
              </tr>

              <tr>
                <td>AH</td>

                <td>Anno Hegirae (Muhammedan Era)</td>
              </tr>

              <tr>
                <td>AME</td>

                <td>Mauludi Era (solar years since Mohammed's
                birth)</td>
              </tr>

              <tr>
                <td>AM</td>

                <td>Anno Mundi (Jewish Calendar)</td>
              </tr>

              <tr>
                <td>AP</td>

                <td>Anno Persici</td>
              </tr>

              <tr>
                <td>AS</td>

                <td>Aji Saka Era (Java)</td>
              </tr>

              <tr>
                <td>BE</td>

                <td>Buddhist Era</td>
              </tr>

              <tr>
                <td>CB</td>

                <td>Cooch Behar Era</td>
              </tr>

              <tr>
                <td>CE</td>

                <td>Common Era</td>
              </tr>

              <tr>
                <td>CL</td>

                <td>Chinese Lunar Era</td>
              </tr>

              <tr>
                <td>CS</td>

                <td>Chula Sakarat Era</td>
              </tr>

              <tr>
                <td>EE</td>

                <td>Ethiopian Era</td>
              </tr>

              <tr>
                <td>FE</td>

                <td>Fasli Era</td>
              </tr>

              <tr>
                <td>ISO</td>

                <td>ISO 8601 calendar</td>
              </tr>

              <tr>
                <td>JE</td>

                <td>Japanese Calendar</td>
              </tr>

              <tr>
                <td>KE</td>

                <td>Khalsa Era (Sikh calendar)</td>
              </tr>

              <tr>
                <td>KY</td>

                <td>Kali Yuga</td>
              </tr>

              <tr>
                <td>ME</td>

                <td>Malabar Era</td>
              </tr>

              <tr>
                <td>MS</td>

                <td>Monarchic Solar Era</td>
              </tr>

              <tr>
                <td>NS</td>

                <td>Nepal Samwat Era</td>
              </tr>

              <tr>
                <td>OS</td>

                <td>Old Style (Julian Calendar)</td>
              </tr>

              <tr>
                <td>RS</td>

                <td>Rattanakosin (Bangkok) Era</td>
              </tr>

              <tr>
                <td>SE</td>

                <td>Saka Era</td>
              </tr>

              <tr>
                <td>SH</td>

                <td>Mohammedan Solar Era (Iran)</td>
              </tr>

              <tr>
                <td>SS</td>

                <td>Saka Samvat</td>
              </tr>

              <tr>
                <td>TE</td>

                <td>Tripurabda Era</td>
              </tr>

              <tr>
                <td>VE</td>

                <td>Vikrama Era</td>
              </tr>

              <tr>
                <td>VS</td>

                <td>Vikrama Samvat Era</td>
              </tr>
            </tbody>
          </table>

          <p>At least one of the above calendars <span class=
          "verb">must</span> be supported. It is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          which calendars are supported.</p>

          <p>The ISO 8601 calendar (<a href="index.html#ISO8601">[ISO
          8601]</a>), which is included in the above list and
          designated <code>ISO</code>, is very similar to the
          Gregorian calendar designated <code>AD</code>, but it
          differs in several ways. The ISO calendar is intended to
          ensure that date and time formats can be read easily by
          other software, as well as being legible for human users.
          The ISO calendar prescribes the use of particular
          numbering conventions as defined in ISO 8601, rather than
          allowing these to be localized on a per-language basis.
          In particular it provides a numeric 'week date' format
          which identifies dates by year, week of the year, and day
          in the week; in the ISO calendar the days of the week are
          numbered from 1 (Monday) to 7 (Sunday), and week 1 in any
          calendar year is the week (from Monday to Sunday) that
          includes the first Thursday of that year. The numeric
          values of the components year, month, day, hour, minute,
          and second are the same in the ISO calendar as the values
          used in the lexical representation of the date and time
          as defined in <a href="index.html#xmlschema-2">[XML Schema Part
          2]</a>. The era ("E" component) with this calendar is
          either a minus sign (for negative years) or a zero-length
          string (for positive years). For dates before 1 January,
          AD 1, year numbers in the ISO and AD calendars are off by
          one from each other: ISO year 0000 is 1 BC, -0001 is 2
          BC, etc.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The value space of the date and time data types, as
            defined in XML Schema, is based on absolute points in
            time. The lexical space of these data types defines a
            representation of these absolute points in time using
            the proleptic Gregorian calendar, that is, the modern
            Western calendar extrapolated into the past and the
            future; but the value space is calendar-neutral. The
            <a title="date formatting function" href=
            "index.html#dt-date-formatting-function">date formatting
            functions</a> produce a representation of this absolute
            point in time, but denoted in a possibly different
            calendar. So, for example, the date whose lexical
            representation in XML Schema is <code>1502-01-11</code>
            (the day on which Pope Gregory XIII was born) might be
            formatted using the Old Style (Julian) calendar as
            <code>1 January 1502</code>. This reflects the fact
            that there was at that time a ten-day difference
            between the two calendars. It would be incorrect, and
            would produce incorrect results, to represent this date
            in an element or attribute of type <code>xs:date</code>
            as <code>1502-01-01</code>, even though this might
            reflect the way the date was recorded in contemporary
            documents.</p>

            <p>When referring to years occurring in antiquity,
            modern historians generally use a numbering system in
            which there is no year zero (the year before 1 CE is
            thus 1 BCE). This is the convention that <span class=
            "verb">should</span> be used when the requested
            calendar is OS (Julian) or AD (Gregorian). When the
            requested calendar is ISO, however, the conventions of
            ISO 8601 <span class="verb">should</span> be followed:
            here the year before +0001 is numbered zero. In
            <a href="index.html#xmlschema-2">[XML Schema Part 2]</a> (version
            1.0), the value space for <code>xs:date</code> and
            <code>xs:dateTime</code> does not include a year zero:
            however, a future edition is expected to endorse the
            ISO 8601 convention. This means that the date on which
            Julius Caesar was assassinated has the ISO 8601 lexical
            representation -0043-03-13, but will be formatted as 15
            March 44 BCE in the Julian calendar or 13 March 44 BCE
            in the Gregorian calendar (dependant on the chosen
            localization of the names of months and eras).</p>
          </div>

          <p>The intended use of the <code>country</code> argument
          is to identify the place where an event represented by
          the <code>dateTime</code>, <code>date</code>, or
          <code>time</code> supplied in the <code>$value</code>
          argument took place or will take place. If the value is
          supplied, and is not the empty sequence, then it
          <span class="verb">should</span> be a country code
          defined in <a href="index.html#ISO3166">[ISO 3166-1]</a>.
          Implementations <span class="verb">may</span> also allow
          the use of codes representing subdivisions of a country
          from ISO 3166-2, or codes representing formerly used
          names of countries from ISO 3166-3. This argument is not
          intended to identify the location of the user for whom
          the date or time is being formatted; that should be done
          by means of the <code>language</code> attribute. This
          information <span class="verb">may</span> be used to
          provide additional information when converting dates
          between calendars or when deciding how individual
          components of the date and time are to be formatted. For
          example, different countries using the Old Style (Julian)
          calendar started the new year on different days, and some
          countries used variants of the calendar that were out of
          synchronization as a result of differences in calculating
          leap years. <span>The geographical area identified by a
          country code is defined by the boundaries as they existed
          at the time of the date to be formatted, or the
          present-day boundaries for dates in the
          future.</span></p>
        </div>

        <div class="div3">
          <h4><a name="date-time-examples" id=
          "date-time-examples"></a>16.5.3 Examples of Date and Time
          Formatting</h4>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e24888" id="d5e24888"></a>Example:
              Gregorian Calendar
            </div>

            <p>The following examples show a selection of dates and
            times and the way they might be formatted. These
            examples assume the use of the Gregorian calendar as
            the default calendar.</p>

            <table border="1" cellpadding="5">
              <thead>
                <tr>
                  <th align="left">Required Output</th>

                  <th align="left">Expression</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td><code>2002-12-31</code></td>

                  <td><code>format-date($d,
                  "[Y0001]-[M01]-[D01]")</code></td>
                </tr>

                <tr>
                  <td><code>12-31-2002</code></td>

                  <td><code>format-date($d,
                  "[M]-[D]-[Y]")</code></td>
                </tr>

                <tr>
                  <td><code>31-12-2002</code></td>

                  <td><code>format-date($d,
                  "[D]-[M]-[Y]")</code></td>
                </tr>

                <tr>
                  <td><code>31 XII 2002</code></td>

                  <td><code>format-date($d, "[D1] [MI]
                  [Y]")</code></td>
                </tr>

                <tr>
                  <td><code>31st December, 2002</code></td>

                  <td><code>format-date($d, "[D1o] [MNn], [Y]",
                  "en", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>31 DEC 2002</code></td>

                  <td><code>format-date($d, "[D01] [MN,*-3]
                  [Y0001]", "en", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>December 31, 2002</code></td>

                  <td><code>format-date($d, "[MNn] [D], [Y]", "en",
                  (), ())</code></td>
                </tr>

                <tr>
                  <td><code>31 Dezember, 2002</code></td>

                  <td><code>format-date($d, "[D] [MNn], [Y]", "de",
                  (), ())</code></td>
                </tr>

                <tr>
                  <td><code>Tisdag 31 December 2002</code></td>

                  <td><code>format-date($d, "[FNn] [D] [MNn] [Y]",
                  "sv", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>[2002-12-31]</code></td>

                  <td><code>format-date($d,
                  "[[[Y0001]-[M01]-[D01]]]")</code></td>
                </tr>

                <tr>
                  <td><code>Two Thousand and Three</code></td>

                  <td><code>format-date($d, "[YWw]", "en", (),
                  ())</code></td>
                </tr>

                <tr>
                  <td><code>einunddreißigste Dezember</code></td>

                  <td><code>format-date($d, "[Dwo] [MNn]", "de",
                  (), ())</code></td>
                </tr>

                <tr>
                  <td><code>3:58 PM</code></td>

                  <td><code>format-time($t, "[h]:[m01] [PN]", "en",
                  (), ())</code></td>
                </tr>

                <tr>
                  <td><code>3:58:45 pm</code></td>

                  <td><code>format-time($t, "[h]:[m01]:[s01] [Pn]",
                  "en", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>3:58:45 PM PDT</code></td>

                  <td><code>format-time($t, "[h]:[m01]:[s01] [PN]
                  [ZN,*-3]", "en", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>3:58:45 o'clock PM PDT</code></td>

                  <td><code>format-time($t, "[h]:[m01]:[s01]
                  o'clock [PN] [ZN,*-3]", "en")</code></td>
                </tr>

                <tr>
                  <td><code>15:58</code></td>

                  <td>
                  <code>format-time($t,"[H01]:[m01]")</code></td>
                </tr>

                <tr>
                  <td><code>15:58:45.762</code></td>

                  <td>
                  <code>format-time($t,"[H01]:[m01]:[s01].[f001]")</code></td>
                </tr>

                <tr>
                  <td><code>15:58:45 GMT+02:00</code></td>

                  <td><code>format-time($t,"[H01]:[m01]:[s01] [z]",
                  "en", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>15.58 Uhr GMT+02:00</code></td>

                  <td><code>format-time($t,"[H01]:[m01] Uhr [z]",
                  "de", (), ())</code></td>
                </tr>

                <tr>
                  <td><code>3.58pm on Tuesday, 31st
                  December</code></td>

                  <td><code>format-dateTime($dt, "[h].[m01][Pn] on
                  [FNn], [D1o] [MNn]")</code></td>
                </tr>

                <tr>
                  <td><span><code>12/31/2002 at
                  15:58:45</code></span></td>

                  <td><code>format-dateTime($dt,
                  "[M01]/[D01]/[Y0001] at
                  [H01]:[m01]:[s01]")</code></td>
                </tr>
              </tbody>
            </table>
          </div>

          <p>&#160;</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e25057" id="d5e25057"></a>Example:
              Non-Gregorian Calendars
            </div>

            <p>The following examples use calendars other than the
            Gregorian calendar.</p>

            <p>These examples use non-Latin characters which might
            not display correctly in all browsers, depending on the
            system configuration.</p>

            <table border="1" cellpadding="5">
              <thead>
                <tr>
                  <th align="left">Description</th>

                  <th align="left">Request</th>

                  <th align="left">Result</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td valign="top">Islamic</td>

                  <td valign="top"><code>format-date($d,
                  "[D&amp;#x0661;] [Mn] [Y&amp;#x0661;]",
                  "Islamic", "ar", "AH", ())</code></td>

                  <td valign="top">٢٦ ﺸﻭّﺍﻝ ١٤٢٣</td>
                </tr>

                <tr>
                  <td valign="top">Jewish (with Western
                  numbering)</td>

                  <td valign="top"><code>format-date($d, "[D] [Mn]
                  [Y]", "he", "AM", ())</code></td>

                  <td valign="top">‏26 טבת 5763</td>
                </tr>

                <tr>
                  <td valign="top">Jewish (with traditional
                  numbering)</td>

                  <td valign="top"><code>format-date($d,
                  "[D&amp;#x05D0;t] [Mn] [Y&amp;#x05D0;t]", "he",
                  "AM", ())</code></td>

                  <td valign="top">כ״ו טבת תשס״ג</td>
                </tr>

                <tr>
                  <td valign="top">Julian (Old Style)</td>

                  <td valign="top"><code>format-date($d, "[D] [MNn]
                  [Y]", "en", "OS", ())</code></td>

                  <td valign="top">18 December 2002</td>
                </tr>

                <tr>
                  <td valign="top">Thai</td>

                  <td valign="top"><code>format-date($d,
                  "[D&amp;#x0E51;] [Mn] [Y&amp;#x0E51;]", "th",
                  "BE", ())</code></td>

                  <td valign="top">๓๑ ธันวาคม ๒๕๔๕</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="misc-func" id="misc-func"></a>16.6
        Miscellaneous Additional Functions</h3>

        <div class="div3">
          <h4><a name="current-function" id=
          "current-function"></a>16.6.1 current</h4><a name=
          "function-current" id="function-current"></a>

          <div class="proto">
            <code class="function">current</code>()<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">item()</code>
          </div>

          <p>The <a href=
          "index.html#function-current"><code>current</code></a> function,
          used within an XPath <a title="expression" href=
          "index.html#dt-expression">expression</a>, returns the item that
          was the <a title="context item" href=
          "index.html#dt-context-item">context item</a> at the point where
          the expression was invoked from the XSLT <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>. This
          is referred to as the current item. For an outermost
          expression (an expression not occurring within another
          expression), the current item is always the same as the
          context item. Thus,</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:value-of select="current()"/&gt;
</pre>
          </div>

          <p>means the same as</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:value-of select="."/&gt;
</pre>
          </div>

          <p>However, within square brackets, or on the right-hand
          side of the <code>/</code> operator, the current item is
          generally different from the context item.</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e25146" id="d5e25146"></a>Example: Using
              the <code>current</code> Function
            </div>

            <p>For example,</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:apply-templates select="//glossary/entry[@name=current()/@ref]"/&gt;
</pre>
            </div>

            <p>will process all <code>entry</code> elements that
            have a <code>glossary</code> parent element and that
            have a <code>name</code> attribute with value equal to
            the value of the current item's <code>ref</code>
            attribute. This is different from</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:apply-templates select="//glossary/entry[@name=./@ref]"/&gt;
</pre>
            </div>

            <p>which means the same as</p>

            <div class="exampleInner">
              <pre>
&lt;xsl:apply-templates select="//glossary/entry[@name=@ref]"/&gt;
</pre>
            </div>

            <p>and so would process all <code>entry</code> elements
            that have a <code>glossary</code> parent element and
            that have a <code>name</code> attribute and a
            <code>ref</code> attribute with the same value.</p>
          </div>

          <p>If the <a href=
          "index.html#function-current"><code>current</code></a> function is
          used within a <a title="pattern" href=
          "index.html#dt-pattern">pattern</a>, its value is the node that is
          being matched against the pattern.</p>

          <p><a name="err-XTDE1360" id="err-XTDE1360"><span class=
          "error">[ERR XTDE1360]</span></a> If the <a href=
          "index.html#function-current"><code>current</code></a> function is
          evaluated within an expression that is evaluated when the
          context item is undefined, a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> occurs.</p>
        </div>

        <div class="div3">
          <h4><a name="unparsed-entity-uri" id=
          "unparsed-entity-uri"></a>16.6.2
          unparsed-entity-uri</h4><a name=
          "function-unparsed-entity-uri" id=
          "function-unparsed-entity-uri"></a>

          <div class="proto">
            <code class=
            "function">unparsed-entity-uri</code>(<code class=
            "arg">$entity-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:anyURI</code>
          </div>

          <p>The <a href=
          "index.html#function-unparsed-entity-uri"><code>unparsed-entity-uri</code></a>
          function returns the URI of the unparsed entity whose
          name is given by the value of the
          <code>$entity-name</code> argument, in the document
          containing the <a title="context node" href=
          "index.html#dt-context-node">context node</a>. It returns the
          zero-length <span><code>xs:anyURI</code></span> if there
          is no such entity. <span>This function maps to the
          <code>dm:unparsed-entity-system-id</code> accessor
          defined in <a href="index.html#xpath-datamodel">[Data
          Model]</a>.</span></p>

          <p><a name="err-XTDE1370" id="err-XTDE1370"><span class=
          "error">[ERR XTDE1370]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a href=
          "index.html#function-unparsed-entity-uri"><code>unparsed-entity-uri</code></a>
          function is called when there is no <a title=
          "context node" href="index.html#dt-context-node">context node</a>,
          or when the root of the tree containing the context node
          is not a document node.</p>
        </div>

        <div class="div3">
          <h4><a name="unparsed-entity-public-id" id=
          "unparsed-entity-public-id"></a>16.6.3
          unparsed-entity-public-id</h4><a name=
          "function-unparsed-entity-public-id" id=
          "function-unparsed-entity-public-id"></a>

          <div class="proto">
            <code class=
            "function">unparsed-entity-public-id</code>(<code class="arg">
            $entity-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:string</code>
          </div>

          <p>The <a href=
          "index.html#function-unparsed-entity-public-id"><code>unparsed-entity-public-id</code></a>
          function returns the public identifier of the unparsed
          entity whose name is given by the value of the
          <code>$entity-name</code> argument, in the document
          containing the <a title="context node" href=
          "index.html#dt-context-node">context node</a>. It returns the
          zero-length string if there is no such entity<span>, or
          if the entity has no public identifier</span>. <span>This
          function maps to the
          <code>dm:unparsed-entity-public-id</code> accessor
          defined in <a href="index.html#xpath-datamodel">[Data
          Model]</a>.</span></p>

          <p><a name="err-XTDE1380" id="err-XTDE1380"><span class=
          "error">[ERR XTDE1380]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a href=
          "index.html#function-unparsed-entity-public-id"><code>unparsed-entity-public-id</code></a>
          function is called when there is no <a title=
          "context node" href="index.html#dt-context-node">context node</a>,
          or when the root of the tree containing the context node
          is not a document node.</p>
        </div>

        <div class="div3">
          <h4><a name="generate-id" id="generate-id"></a>16.6.4
          generate-id</h4><a name="function-generate-id" id=
          "function-generate-id"></a>

          <div class="proto">
            <code class="function">generate-id</code>()<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:string</code>
          </div>

          <div class="proto">
            <code class="function">generate-id</code>(<code class=
            "arg">$node</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">node()?</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:string</code>
          </div>

          <p>The <a href=
          "index.html#function-generate-id"><code>generate-id</code></a>
          function returns a string that uniquely identifies a
          given node. The unique identifier <span class=
          "verb">must</span> consist of ASCII alphanumeric
          characters and <span class="verb">must</span> start with
          an alphabetic character. Thus, the string is
          syntactically an XML name. An implementation is free to
          generate an identifier in any convenient way provided
          that it always generates the same identifier for the same
          node and that different identifiers are always generated
          from different nodes. An implementation is under no
          obligation to generate the same identifiers each time a
          document is transformed. There is no guarantee that a
          generated unique identifier will be distinct from any
          unique IDs specified in the source document. If the
          argument is the empty sequence, the result is the
          <span>zero-length string</span>. If the argument is
          omitted, it defaults to the <a title="context node" href=
          "index.html#dt-context-node">context node</a>.</p>
        </div>

        <div class="div3">
          <h4><a name="system-property" id=
          "system-property"></a>16.6.5 system-property</h4><a name=
          "function-system-property" id=
          "function-system-property"></a>

          <div class="proto">
            <code class=
            "function">system-property</code>(<code class=
            "arg">$property-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:string</code>
          </div>

          <p>The <code>$property-name</code> argument <span class=
          "verb">must</span> evaluate to a <a title="lexical QName"
          href="index.html#dt-lexical-qname">lexical QName</a>. The <a title=
          "lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a> is expanded as described in <a href=
          "index.html#qname"><i>5.1 Qualified Names</i></a>.</p>

          <p><a name="err-XTDE1390" id="err-XTDE1390"><span class=
          "error">[ERR XTDE1390]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the value is not a valid QName, or if there
          is no namespace declaration in scope for the prefix of
          the QName. If the processor is able to detect the error
          statically (for example, when the argument is supplied as
          a string literal), then the processor <span class=
          "verb">may</span> optionally signal this as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>

          <p>The <a href=
          "index.html#function-system-property"><code>system-property</code></a>
          function returns a string representing the value of the
          system property identified by the name. If there is no
          such system property, the zero-length string
          <span>is</span> returned.</p>

          <p>Implementations <span class="verb">must</span> provide
          the following system properties, which are all in the
          <a title="XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>:</p>

          <ul>
            <li>
              <p><code>xsl:version</code>, a number giving the
              version of XSLT implemented by the <a title=
              "processor" href="index.html#dt-processor">processor</a>; for
              implementations conforming to the version of XSLT
              specified by this document, this is the string
              <code>"2.0"</code>. The value will always be a string
              in the lexical space of the decimal data type defined
              in XML Schema (see <a href="index.html#xmlschema-2">[XML Schema
              Part 2]</a>). This allows the value to be converted
              to a number for the purpose of magnitude
              comparisons.</p>
            </li>

            <li>
              <p><code>xsl:vendor</code>, a string identifying the
              implementer of the <a title="processor" href=
              "index.html#dt-processor">processor</a></p>
            </li>

            <li>
              <p><code>xsl:vendor-url</code>, a string containing a
              URL identifying the implementer of the <a title=
              "processor" href="index.html#dt-processor">processor</a>;
              typically this is the host page (home page) of the
              implementer's Web site.</p>
            </li>

            <li>
              <p><code>xsl:product-name</code>, a string containing
              the name of the implementation, as defined by the
              implementer. This <span class="verb">should</span>
              normally remain constant from one release of the
              product to the next. It <span class=
              "verb">should</span> also be constant across
              platforms in cases where the same source code is used
              to produce compatible products for multiple execution
              platforms.</p>
            </li>

            <li>
              <p><code>xsl:product-version</code>, a string
              identifying the version of the implementation, as
              defined by the implementer. This <span class=
              "verb">should</span> normally vary from one release
              of the product to the next, and at the discretion of
              the implementer it <span class="verb">may</span> also
              vary across different execution platforms.</p>
            </li>

            <li>
              <p><code>xsl:is-schema-aware</code>, returns the
              string <code>"yes"</code> in the case of a processor
              that claims conformance as a <a title=
              "schema-aware XSLT processor" href=
              "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
              processor</a>, or <code>"no"</code> in the case of a
              <a title="basic XSLT processor" href=
              "index.html#dt-basic-xslt-processor">basic XSLT
              processor</a>.</p>
            </li>

            <li>
              <p><code>xsl:supports-serialization</code>, returns
              the string <code>"yes"</code> in the case of a
              processor that offers the <a title=
              "serialization feature" href=
              "index.html#dt-serialization-feature">serialization
              feature</a>, or <code>"no"</code> otherwise.</p>
            </li>

            <li>
              <p><code>xsl:supports-backwards-compatibility</code>,
              returns the string <code>"yes"</code> in the case of
              a processor that offers the <a title=
              "backwards compatibility feature" href=
              "index.html#dt-backwards-compatibility-feature">backwards
              compatibility feature</a>, or <code>"no"</code>
              otherwise.</p>
            </li>
          </ul>

          <p>Some of these properties relate to the conformance
          levels and features offered by the <a title="processor"
          href="index.html#dt-processor">processor</a>: these options are
          described in <a href="index.html#conformance"><i>21
          Conformance</i></a>.</p>

          <p>The actual values returned for the above properties
          are <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.</p>

          <p>The set of system properties that are supported, in
          addition to those listed above, is also <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          Implementations <span class="verb">must not</span> define
          additional system properties in the XSLT namespace.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>An implementation must not return the value
            <code>2.0</code> as the value of the
            <code>xsl:version</code> system property unless it is
            conformant to XSLT 2.0.</p>

            <p>It is recognized that vendors who are enhancing XSLT
            1.0 processors may wish to release interim
            implementations before all the mandatory features of
            this specification are implemented. Since such products
            are not conformant to XSLT 2.0, this specification
            cannot define their behavior. However, implementers of
            such products are encouraged to return a value for the
            <code>xsl:version</code> system property that is
            intermediate between 1.0 and 2.0, and to provide the
            <a href=
            "index.html#function-element-available"><code>element-available</code></a>
            and <a href=
            "index.html#function-function-available"><code>function-available</code></a>
            functions to allow users to test which features have
            been fully implemented.</p>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="message" id="message"></a>17 Messages</h2>

      <p class="element-syntax"><a name="element-message" id=
      "element-message"></a><code>&lt;!-- Category: instruction
      --&gt;<br />
      &lt;xsl:message<br />
      &#160;&#160;select? = <var>expression</var><br />
      &#160;&#160;terminate? = { "yes" | "no" }&gt;<br />
      &#160;&#160;&lt;!-- Content: <var>sequence-constructor</var>
      --&gt;<br />
      &lt;/xsl:message&gt;</code></p>

      <p>The <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      sends a message in an <a title="implementation-defined" href=
      "index.html#dt-implementation-defined">implementation-defined</a> way.
      The <a href="index.html#element-message"><code>xsl:message</code></a>
      instruction causes the creation of a new document, which is
      typically serialized and output to an <a title=
      "implementation-defined" href=
      "index.html#dt-implementation-defined">implementation-defined</a>
      destination. The result of the <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      is an empty sequence.</p>

      <p>The content of the message may be specified by using
      either or both of the optional <code>select</code> attribute
      and the <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a> that
      forms the content of the <a href=
      "index.html#element-message"><code>xsl:message</code></a>
      instruction.</p>

      <p>If the <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      contains a <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a>, then the
      sequence obtained by evaluating this sequence constructor is
      used to construct the content of the new document node, as
      described in <a href="index.html#constructing-complex-content"><i>5.7.1
      Constructing Complex Content</i></a>.</p>

      <p>If the <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      has a <code>select</code> attribute, then the value of the
      attribute <span class="verb">must</span> be an XPath
      expression. The effect of the <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      is then the same as if a single <a href=
      "index.html#element-copy-of"><code>xsl:copy-of</code></a> instruction
      with this <code>select</code> attribute were added to the
      start of the <a title="sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a>.</p>

      <p>If the <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      has no content and no <code>select</code> attribute, then an
      empty message is produced.</p>

      <p>The tree produced by the <a href=
      "index.html#element-message"><code>xsl:message</code></a> instruction
      is not technically a <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result tree</a>. The tree has
      no URI and processors are not <span class=
      "verb">required</span> to make the tree accessible to
      applications.</p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>In many cases, the XML document produced using <a href=
        "index.html#element-message"><code>xsl:message</code></a> will
        consist of a document node owning a single text node.
        However, it may contain a more complex structure.</p>
      </div>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>An implementation might implement <a href=
        "index.html#element-message"><code>xsl:message</code></a> by popping
        up an alert box or by writing to a log file. <span>Because
        the order of execution of instructions is
        implementation-defined, the order in which such messages
        appear is not predictable.</span></p>
      </div>

      <p>The <code>terminate</code> attribute is interpreted as an
      <a title="attribute value template" href=
      "index.html#dt-attribute-value-template">attribute value
      template</a>.</p>

      <p>If the <a title="effective value" href=
      "index.html#dt-effective-value">effective value</a> of the
      <code>terminate</code> attribute is <code>yes</code>, then
      the <a title="processor" href="index.html#dt-processor">processor</a>
      <span class="verb">must</span> terminate processing after
      sending the message. The default value is <code>no</code>.
      Note that because the order of evaluation of instructions is
      <a title="implementation-dependent" href=
      "index.html#dt-implementation-dependent">implementation-dependent</a>,
      this gives no guarantee that any particular instruction will
      or will not be evaluated before processing terminates.</p>

      <p><a name="err-XTMM9000" id="err-XTMM9000"><span class=
      "error">[ERR XTMM9000]</span></a> When a transformation is
      terminated by use of <code>xsl:message
      terminate="yes"</code>, the effect is the same as when a
      <a title="non-recoverable dynamic error" href=
      "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic error</a>
      occurs during the transformation.</p>

      <div class="example">
        <div class="exampleHeader">
          <a name="d5e25672" id="d5e25672"></a>Example: Localizing
          Messages
        </div>

        <p>One convenient way to do localization is to put the
        localized information (message text, etc.) in an XML
        document, which becomes an additional input file to the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>.
        For example, suppose messages for a language
        <code><var>L</var></code> are stored in an XML file
        <code>resources/<var>L</var>.xml</code> in the form:</p>

        <div class="exampleInner">
          <pre>
&lt;messages&gt;
  &lt;message name="problem"&gt;A problem was detected.&lt;/message&gt;
  &lt;message name="error"&gt;An error was detected.&lt;/message&gt;
&lt;/messages&gt;
</pre>
        </div>

        <p>Then a stylesheet could use the following approach to
        localize messages:</p>

        <div class="exampleInner">
          <pre>
&lt;xsl:param name="lang" select="'en'"/&gt;
&lt;xsl:variable name="messages"
  select="document(concat('resources/', $lang, '.xml'))/messages"/&gt;

&lt;xsl:template name="localized-message"&gt;
  &lt;xsl:param name="name"/&gt;
  &lt;xsl:message select="string($messages/message[@name=$name])"/&gt;
&lt;/xsl:template&gt;

&lt;xsl:template name="problem"&gt;
  &lt;xsl:call-template name="localized-message"&gt;
    &lt;xsl:with-param name="name"&gt;problem&lt;/xsl:with-param&gt;
  &lt;/xsl:call-template&gt;
&lt;/xsl:template&gt;
</pre>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="extension" id="extension"></a>18 Extensibility
      and Fallback</h2>

      <p>XSLT allows two kinds of extension, extension instructions
      and extension functions.</p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-extension-instruction" id="dt-extension-instruction"
      title="extension instruction"></a>An <b>extension
      instruction</b> is an element within a <a title=
      "sequence constructor" href=
      "index.html#dt-sequence-constructor">sequence constructor</a> that is
      in a namespace (not the <a title="XSLT namespace" href=
      "index.html#dt-xslt-namespace">XSLT namespace</a>) designated as an
      extension namespace.<span class="definition">]</span></p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-extension-function" id="dt-extension-function" title=
      "extension function"></a>An <b>extension function</b> is a
      function that is available for use within an XPath <a title=
      "expression" href="index.html#dt-expression">expression</a>, other than
      a <a title="core function" href="index.html#dt-core-function">core
      function</a> defined in <a href="index.html#xpath-functions">[Functions
      and Operators]</a>, an additional function defined in this
      XSLT specification, <span>a constructor function named after
      an atomic type,</span> or a <a title="stylesheet function"
      href="index.html#dt-stylesheet-function">stylesheet function</a>
      defined using an <a href=
      "index.html#element-function"><code>xsl:function</code></a>
      declaration.<span class="definition">]</span>.</p>

      <p>This specification does not define any mechanism for
      creating or binding implementations of <a title=
      "extension instruction" href=
      "index.html#dt-extension-instruction">extension instructions</a> or
      <a title="extension function" href=
      "index.html#dt-extension-function">extension functions</a>, and it is
      not <span class="verb">required</span> that implementations
      support any such mechanism. Such mechanisms, if they exist,
      are <a title="implementation-defined" href=
      "index.html#dt-implementation-defined">implementation-defined</a>.
      Therefore, an XSLT stylesheet that <span class=
      "verb">must</span> be portable between XSLT implementations
      cannot rely on particular extensions being available. XSLT
      provides mechanisms that allow an XSLT stylesheet to
      determine whether the implementation makes particular
      extensions available, and to specify what happens if those
      extensions are not available. If an XSLT stylesheet is
      careful to make use of these mechanisms, it is possible for
      it to take advantage of extensions and still retain
      portability.</p>

      <div class="div2">
        <h3><a name="extension-functions" id=
        "extension-functions"></a>18.1 Extension Functions</h3>

        <p>The set of functions that can be called from a <a href=
        "http://www.w3.org/TR/xpath20/#doc-xpath-FunctionCall">FunctionCall</a><sup>
        <small>XP</small></sup> within an XPath <a title=
        "expression" href="index.html#dt-expression">expression</a> may
        include one or more <a title="extension function" href=
        "index.html#dt-extension-function">extension functions</a>. The
        <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of an extension
        function always has a non-null namespace URI.</p>

        <div class="div3">
          <h4><a name="testing-function-availability" id=
          "testing-function-availability"></a>18.1.1 Testing
          Availability of Functions</h4>

          <p>The <a href=
          "index.html#function-function-available"><code>function-available</code></a>
          function can be used with the <code>[xsl:]use-when</code>
          attribute (see <a href="index.html#conditional-inclusion"><i>3.12
          Conditional Element Inclusion</i></a>) to explicitly
          control how a stylesheet behaves if a particular
          extension function is not available.</p><a name=
          "function-function-available" id=
          "function-function-available"></a>

          <div class="proto">
            <code class=
            "function">function-available</code>(<code class=
            "arg">$function-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:boolean</code>
          </div>

          <div class="proto">
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td valign="baseline" rowspan="2"><code class=
                "function">function-available</code>(</td>

                <td valign="baseline"><code class=
                "arg">$function-name</code></td>

                <td valign="baseline"><code class=
                "as">&#160;as&#160;</code><code class=
                "type">xs:string</code>,</td>
              </tr>

              <tr>
                <td valign="baseline"><code class=
                "arg">$arity</code></td>

                <td valign="baseline"><code class=
                "as">&#160;as&#160;</code><code class=
                "type">xs:integer</code>)<code class=
                "as">&#160;as&#160;</code><code class=
                "return-type">xs:boolean</code></td>
              </tr>
            </table>
          </div>

          <p>A function is said to be available within an XPath
          expression if it is present in the <a href=
          "http://www.w3.org/TR/xpath20/#dt-function-signature">in-scope
          functions</a><sup><small>XP</small></sup> for that
          expression (see <a href="index.html#static-context"><i>5.4.1
          Initializing the Static Context</i></a>). Functions in
          the static context are uniquely identified by the name of
          the function (a QName) in combination with its <a title=
          "arity" href="index.html#dt-arity">arity</a>.</p>

          <p>The value of the <code>$function-name</code> argument
          <span class="verb">must</span> be a string containing a
          <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a>. The lexical QName is expanded into an
          <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> using the
          namespace declarations in scope for the <a title=
          "expression" href="index.html#dt-expression">expression</a>. If the
          lexical QName is unprefixed, then the <a title=
          "standard function namespace" href=
          "index.html#dt-standard-function-namespace">standard function
          namespace</a> is used in the expanded QName.</p>

          <p>The two-argument version of the <a href=
          "index.html#function-function-available"><code>function-available</code></a>
          function returns true if and only if there is an
          available function whose name matches the value of the
          <code>$function-name</code> argument and whose <a title=
          "arity" href="index.html#dt-arity">arity</a> matches the value of
          the <code>$arity</code> argument.</p>

          <p>The single-argument version of the <a href=
          "index.html#function-function-available"><code>function-available</code></a>
          function returns true if and only if there is at least
          one available function (with some arity) whose name
          matches the value of the <code>$function-name</code>
          argument.</p>

          <p><a name="err-XTDE1400" id="err-XTDE1400"><span class=
          "error">[ERR XTDE1400]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the argument does not evaluate to a string
          that is a valid <a title="QName" href=
          "index.html#dt-qname">QName</a>, or if there is no namespace
          declaration in scope for the prefix of the <a title=
          "QName" href="index.html#dt-qname">QName</a>. If the processor is
          able to detect the error statically (for example, when
          the argument is supplied as a string literal), then the
          processor <span class="verb">may</span> optionally signal
          this as a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>

          <p>When <a title="backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled, the <a href=
          "index.html#function-function-available"><code>function-available</code></a>
          function returns false in respect of a function name and
          arity for which no implementation is available (other
          than the fallback error function that raises a dynamic
          error whenever it is called). This means that it is
          possible (as in XSLT 1.0) to use logic such as the
          following to test whether a function is available before
          calling it:</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e25880" id="d5e25880"></a>Example: Calling
              an extension function with backwards-compatibility
              enabled
            </div>

            <div class="exampleInner">
              <pre>
&lt;summary xsl:version="1.0"&gt;
  &lt;xsl:choose&gt;
    &lt;xsl:when test="function-available('my:summary')"&gt;
      &lt;xsl:value-of select="my:summary()"/&gt;
    &lt;/xsl:when&gt;
    &lt;xsl:otherwise&gt;
      &lt;xsl:text&gt;Summary not available&lt;/xsl:text&gt;
    &lt;/xsl:otherwise&gt;
  &lt;/xsl:choose&gt;
&lt;/summary&gt;
</pre>
            </div>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The fact that a function with a given name is
            available gives no guarantee that any particular call
            on the function will be successful. For example, it is
            not possible to determine the types of the arguments
            expected.</p>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>In XSLT 2.0 <span>(without backwards compatibility
            enabled)</span> a static error occurs when an XPath
            expression references a function that is not available.
            This is true even in a part of the stylesheet that uses
            <a title="forwards-compatible behavior" href=
            "index.html#dt-forwards-compatible-behavior">forwards-compatible
            behavior</a>. Therefore, the conditional logic to test
            whether a function is available before calling it
            should normally be written in a <code>use-when</code>
            attribute (see <a href="index.html#conditional-inclusion"><i>3.12
            Conditional Element Inclusion</i></a>).</p>
          </div>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e25903" id="d5e25903"></a>Example:
              Stylesheet portable between XSLT 1.0 and XSLT 2.0
            </div>

            <p>A stylesheet that is designed to use XSLT 2.0
            facilities when they are available, but to fall back to
            XSLT 1.0 capabilities when not, might be written using
            the code:</p>

            <div class="exampleInner">
              <pre>
&lt;out xsl:version="2.0"&gt;
  &lt;xsl:choose&gt;
    &lt;xsl:when test="function-available('matches')"&gt;
      &lt;xsl:value-of select="matches($input, '[a-z]*')"/&gt;
    &lt;/xsl:when&gt;
    &lt;xsl:otherwise&gt;
      &lt;xsl:value-of select="string-length(
                          translate($in, 'abcdefghijklmnopqrstuvwxyz', '')) = 0"/&gt;
    &lt;/xsl:otherwise&gt;
  &lt;/xsl:choose&gt;
&lt;/out&gt;
</pre>
            </div>

            <p>Here an XSLT 2.0 processor will always take the
            <a href="index.html#element-when"><code>xsl:when</code></a>
            branch, while a 1.0 processor will follow the <a href=
            "index.html#element-otherwise"><code>xsl:otherwise</code></a>
            branch. The single-argument version of the <a href=
            "index.html#function-function-available"><code>function-available</code></a>
            function is used here, because that is the only version
            available in XSLT 1.0. Under the rules of XSLT 1.0, the
            call on the <code>matches</code> function is not an
            error, because it is never evaluated.</p>
          </div>

          <p>&#160;</p>

          <div class="example">
            <div class="exampleHeader">
              <a name="d5e25924" id="d5e25924"></a>Example:
              Stylesheet portable between XSLT 2.0 and a future
              version of XSLT
            </div>

            <p>A stylesheet that is designed to use facilities in
            some future XSLT version when they are available, but
            to fall back to XSLT 2.0 capabilities when not, might
            be written using code such as the following. This
            hypothesizes the availability in some future version of
            a function <code>pad</code> which pads a string to a
            fixed length with spaces:</p>

            <div class="exampleInner">
              <pre>
 &lt;xsl:value-of select="pad($input, 10)" 
               use-when="function-available('pad', 2)"/&gt;
 &lt;xsl:value-of select="concat($input, string-join(
                          for $i in 1 to 10 - string-length($input) 
                                                  return ' ', ''))"
               use-when="not(function-available('pad', 2))"/&gt;
 
</pre>
            </div>

            <p>In this case the two-argument version of <a href=
            "index.html#function-function-available"><code>function-available</code></a>
            is used, because there is no requirement for this code
            to run under XSLT 1.0.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="calling-extension-functions" id=
          "calling-extension-functions"></a>18.1.2 Calling
          Extension Functions</h4>

          <p>If the function name used in a <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-FunctionCall">FunctionCall</a><sup>
          <small>XP</small></sup> within an XPath <a title=
          "expression" href="index.html#dt-expression">expression</a>
          identifies an extension function, then to evaluate the
          <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-FunctionCall">FunctionCall</a><sup>
          <small>XP</small></sup>, the processor will first
          evaluate each of the arguments in the <a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-FunctionCall">FunctionCall</a><sup>
          <small>XP</small></sup>. If the processor has information
          about the data types expected by the extension function,
          then it <span class="verb">may</span> perform any
          necessary type conversions between the XPath data types
          and those defined by the implementation language. If
          multiple extension functions are available with the same
          name, the processor <span class="verb">may</span> decide
          which one to invoke based on the number of arguments, the
          types of the arguments, or any other criteria. The result
          returned by the implementation is returned as the result
          of the function call, again after any necessary
          conversions between the data types of the implementation
          language and those of XPath. The details of such type
          conversions are outside the scope of this
          specification.</p>

          <p><a name="err-XTDE1420" id="err-XTDE1420"><span class=
          "error">[ERR XTDE1420]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the arguments supplied to a call on an
          extension function do not satisfy the rules defined for
          that particular extension function, or if the extension
          function reports an error, or if the result of the
          extension function cannot be converted to an XPath
          value.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Implementations may also provide mechanisms allowing
            extension functions to report recoverable dynamic
            errors, or to execute within an environment that treats
            some or all of the errors listed above as
            recoverable.</p>
          </div>

          <p><a name="err-XTDE1425" id="err-XTDE1425"><span class=
          "error">[ERR XTDE1425]</span></a> When <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled, it is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> to evaluate an extension function call if no
          implementation of the extension function is
          available.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>When backwards-compatible behavior is not enabled,
            this is a static error [XPST0017].</p>
          </div>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>There is no prohibition on calling extension
            functions that have side-effects (for example, an
            extension function that writes data to a file).
            However, the order of execution of XSLT instructions is
            not defined in this specification, so the effects of
            such functions are unpredictable.</p>
          </div>

          <p>Implementations are not <span class=
          "verb">required</span> to perform full validation of
          values returned by extension functions. It is an error
          for an extension function to return a string containing
          characters that are not permitted in XML, but the
          consequences of this error are <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          The implementation <span class="verb">may</span> raise an
          error, <span class="verb">may</span> convert the string
          to a string containing valid characters only, or
          <span class="verb">may</span> treat the invalid
          characters as if they were permitted characters.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>The ability to execute extension functions
            represents a potential security weakness, since
            untrusted stylesheets may invoke code that has
            privileged access to resources on the machine where the
            <a title="processor" href="index.html#dt-processor">processor</a>
            executes. Implementations may therefore provide
            mechanisms that restrict the use of extension functions
            by untrusted stylesheets.</p>
          </div>

          <p>All observations in this section regarding the errors
          that can occur when invoking extension functions apply
          equally when invoking <a title="extension instruction"
          href="index.html#dt-extension-instruction">extension
          instructions</a>.</p>
        </div>

        <div class="div3">
          <h4><a name="external-objects" id=
          "external-objects"></a>18.1.3 External Objects</h4>

          <p>An implementation <span class="verb">may</span> allow
          an extension function to return an object that does not
          have any natural representation in the <span>XDM</span>
          data model, either as an atomic value or as a node. For
          example, an extension function <code>sql:connect</code>
          might return an object that represents a connection to a
          relational database; the resulting connection object
          might be passed as an argument to calls on other
          extension functions such as <code>sql:insert</code> and
          <code>sql:select</code>.</p>

          <p>The way in which such objects are represented in the
          type system is <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          They might be represented by a completely new data type,
          or they might be mapped to existing data types such as
          <code>integer</code>, <code>string</code>, or
          <code>anyURI</code>.</p>
        </div>

        <div class="div3">
          <h4><a name="testing-type-availability" id=
          "testing-type-availability"></a>18.1.4 Testing
          Availability of Types</h4>

          <p>The <a href=
          "index.html#function-type-available"><code>type-available</code></a>
          function can be used, for example with the
          <code>[xsl:]use-when</code> attribute (see <a href=
          "index.html#conditional-inclusion"><i>3.12 Conditional Element
          Inclusion</i></a>), to explicitly control how a
          stylesheet behaves if a particular schema type is not
          available in the static context.</p><a name=
          "function-type-available" id=
          "function-type-available"></a>

          <div class="proto">
            <code class=
            "function">type-available</code>(<code class=
            "arg">$type-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:boolean</code>
          </div>

          <p>A schema type (that is, a simple type or a complex
          type) is said to be available within an XPath expression
          if it is a type definition that is present in the
          <a href="http://www.w3.org/TR/xpath20/#dt-is-types">in-scope
          schema types</a><sup><small>XP</small></sup> for that
          expression (see <a href="index.html#static-context"><i>5.4.1
          Initializing the Static Context</i></a>). This includes
          built-in types, types imported using <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>,
          and extension types defined by the implementation.</p>

          <p>The value of the <code>$type-name</code> argument
          <span class="verb">must</span> be a string containing a
          <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a>. The lexical QName is expanded into an
          <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> using the
          namespace declarations in scope for the <a title=
          "expression" href="index.html#dt-expression">expression</a>. If the
          lexical QName is unprefixed, then the default namespace
          is used in the expanded QName.</p>

          <p>The function returns true if and only if there is an
          available type whose name matches the value of the
          <code>$type-name</code> argument.</p>

          <p><a name="err-XTDE1428" id="err-XTDE1428"><span class=
          "error">[ERR XTDE1428]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the argument does not evaluate to a string
          that is a valid <a title="QName" href=
          "index.html#dt-qname">QName</a>, or if there is no namespace
          declaration in scope for the prefix of the <a title=
          "QName" href="index.html#dt-qname">QName</a>. If the processor is
          able to detect the error statically (for example, when
          the argument is supplied as a string literal), then the
          processor <span class="verb">may</span> optionally signal
          this as a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="extension-instruction" id=
        "extension-instruction"></a>18.2 Extension
        Instructions</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-extension-namespace" id="dt-extension-namespace" title=
        "extension namespace"></a>The <a title=
        "extension instruction" href=
        "index.html#dt-extension-instruction">extension instruction</a>
        mechanism allows namespaces to be designated as
        <b>extension namespaces</b>. When a namespace is designated
        as an extension namespace and an element with a name from
        that namespace occurs in a <a title="sequence constructor"
        href="index.html#dt-sequence-constructor">sequence constructor</a>,
        then the element is treated as an <a title="instruction"
        href="index.html#dt-instruction">instruction</a> rather than as a
        <a title="literal result element" href=
        "index.html#dt-literal-result-element">literal result
        element</a>.<span class="definition">]</span> The namespace
        determines the semantics of the instruction.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Since an element that is a child of an <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element is not occurring <em>in a <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a></em>,
          <a title="user-defined data element" href=
          "index.html#dt-data-element">user-defined data elements</a> (see
          <a href="index.html#user-defined-top-level"><i>3.6.2 User-defined
          Data Elements</i></a>) are not extension elements as
          defined here, and nothing in this section applies to
          them.</p>
        </div>

        <div class="div3">
          <h4><a name="designating-extension-namespace" id=
          "designating-extension-namespace"></a>18.2.1 Designating
          an Extension Namespace</h4>

          <p>A namespace is designated as an extension namespace by
          using an <code>[xsl:]extension-element-prefixes</code>
          attribute on an element in the stylesheet (see <a href=
          "index.html#standard-attributes"><i>3.5 Standard
          Attributes</i></a>). The attribute <span class=
          "verb">must</span> be in the XSLT namespace only if its
          parent element is <em>not</em> in the XSLT namespace. The
          value of the attribute is a whitespace-separated list of
          namespace prefixes. The namespace bound to each of the
          prefixes is designated as an extension namespace.</p>

          <p>The default namespace (as declared by
          <code>xmlns</code>) may be designated as an extension
          namespace by including <code>#default</code> in the list
          of namespace prefixes.</p>

          <p><a name="err-XTSE1430" id="err-XTSE1430"><span class=
          "error">[ERR XTSE1430]</span></a> It is a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if there is no namespace bound to the prefix on the
          element bearing the
          <code>[xsl:]extension-element-prefixes</code> attribute
          <span>or, when <code>#default</code> is specified, if
          there is no default namespace</span>.</p>

          <p>The designation of a namespace as an extension
          namespace is effective for the element bearing the
          <code>[xsl:]extension-element-prefixes</code> attribute
          and for all descendants of that element within the same
          stylesheet module.</p>
        </div>

        <div class="div3">
          <h4><a name="testing-instruction-available" id=
          "testing-instruction-available"></a>18.2.2 Testing
          Availability of Instructions</h4>

          <p>The <a href=
          "index.html#function-element-available"><code>element-available</code></a>
          function can be used with the <a href=
          "index.html#element-choose"><code>xsl:choose</code></a> and
          <a href="index.html#element-if"><code>xsl:if</code></a>
          instructions<span>, or with the
          <code>[xsl:]use-when</code> attribute (see <a href=
          "index.html#conditional-inclusion"><i>3.12 Conditional Element
          Inclusion</i></a>) to explicitly control how a stylesheet
          behaves when a particular XSLT instruction or extension
          instruction is (or is not) available.</span></p><a name=
          "function-element-available" id=
          "function-element-available"></a>

          <div class="proto">
            <code class=
            "function">element-available</code>(<code class=
            "arg">$element-name</code><code class=
            "as">&#160;as&#160;</code><code class=
            "type">xs:string</code>)<code class=
            "as">&#160;as&#160;</code><code class=
            "return-type">xs:boolean</code>
          </div>

          <p>The value of the <code>$element-name</code> argument
          <span class="verb">must</span> be a string containing a
          <a title="QName" href="index.html#dt-qname">QName</a>. The
          <a title="QName" href="index.html#dt-qname">QName</a> is expanded
          into an <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> using the
          namespace declarations in scope for the <a title=
          "expression" href="index.html#dt-expression">expression</a>. If
          there is a default namespace in scope, then it is used to
          expand an unprefixed <a title="QName" href=
          "index.html#dt-qname">QName</a>. The <a href=
          "index.html#function-element-available"><code>element-available</code></a>
          function returns true if and only if the <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> is the name of an
          <a title="instruction" href=
          "index.html#dt-instruction">instruction</a>. If the <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> has a namespace
          URI equal to the <a title="XSLT namespace" href=
          "index.html#dt-xslt-namespace">XSLT namespace</a> URI, then it
          refers to an element defined by XSLT. Otherwise, it
          refers to an <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instruction</a>. If
          the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> has a null
          namespace URI, the <a href=
          "index.html#function-element-available"><code>element-available</code></a>
          function will return false.</p>

          <p><a name="err-XTDE1440" id="err-XTDE1440"><span class=
          "error">[ERR XTDE1440]</span></a> It is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the argument does not evaluate to a string
          that is a valid <a title="QName" href=
          "index.html#dt-qname">QName</a>, or if there is no namespace
          declaration in scope for the prefix of the <a title=
          "QName" href="index.html#dt-qname">QName</a>. If the processor is
          able to detect the error statically (for example, when
          the argument is supplied as a string literal), then the
          processor <span class="verb">may</span> optionally signal
          this as a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>

          <p>If the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> is in the
          <a title="XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>, the function returns true if and only if
          the expanded QName is the name of an <a title=
          "XSLT instruction" href="index.html#dt-xslt-instruction">XSLT
          instruction</a>, that is, an <a title="XSLT element"
          href="index.html#dt-xslt-element">XSLT element</a> whose syntax
          summary in this specification classifies it as an
          <a title="instruction" href=
          "index.html#dt-instruction">instruction</a>.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Although the result of applying this function to a
            name in the XSLT namespace when using a conformant XSLT
            2.0 processor is entirely predictable, the function is
            useful in cases where the stylesheet might be executing
            under a processor that implements some other version of
            XSLT with different rules.</p>
          </div>

          <p>If the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> is not in the
          <a title="XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>, the function returns true if and only if
          the processor has an implementation available of an
          <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instruction</a>
          with the given expanded QName. This applies whether or
          not the namespace has been designated as an <a title=
          "extension namespace" href=
          "index.html#dt-extension-namespace">extension namespace</a>.</p>

          <p>If the processor does not have an implementation of a
          particular extension instruction available, and such an
          extension instruction is evaluated, then the processor
          <span class="verb">must</span> perform fallback for the
          element as specified in <a href="index.html#fallback"><i>18.2.3
          Fallback</i></a>. An implementation <span class=
          "verb">must not</span> signal an error merely because the
          stylesheet contains an extension instruction for which no
          implementation is available.</p>
        </div>

        <div class="div3">
          <h4><a name="fallback" id="fallback"></a>18.2.3
          Fallback</h4>

          <p class="element-syntax"><a name="element-fallback" id=
          "element-fallback"></a><code>&lt;!-- Category:
          instruction --&gt;<br />
          &lt;xsl:fallback&gt;<br />
          &#160;&#160;&lt;!-- Content:
          <var>sequence-constructor</var> --&gt;<br />
          &lt;/xsl:fallback&gt;</code></p>

          <p>The content of an <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a> element
          is a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, and
          when performing fallback, the value returned by the
          <a href="index.html#element-fallback"><code>xsl:fallback</code></a>
          element is the result of evaluating this sequence
          constructor.</p>

          <p>When not performing fallback, evaluating an <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a> element
          returns an empty sequence: the content of the <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a> element
          is ignored.</p>

          <p>There are two situations where a <a title="processor"
          href="index.html#dt-processor">processor</a> performs fallback:
          when an extension instruction that is not available is
          evaluated, and when an instruction in the XSLT namespace,
          that is not defined in XSLT 2.0, is evaluated within a
          region of the stylesheet for which <a title=
          "forwards-compatible behavior" href=
          "index.html#dt-forwards-compatible-behavior">forwards compatible
          behavior</a> is enabled.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>Fallback processing is not invoked in other
            situations, for example it is not invoked when an XPath
            expression uses unrecognized syntax or contains a call
            to an unknown function. To handle such situations
            dynamically, the stylesheet should call functions such
            as <a href=
            "index.html#function-system-property"><code>system-property</code></a>
            and <a href=
            "index.html#function-function-available"><code>function-available</code></a>
            to decide what capabilities are available.</p>
          </div>

          <p><a name="err-XTDE1450" id="err-XTDE1450"><span class=
          "error">[ERR XTDE1450]</span></a> When a <a title=
          "processor" href="index.html#dt-processor">processor</a> performs
          fallback for an <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instruction</a>
          that is not recognized, if the instruction element has
          one or more <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          children, then the content of each of the <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          children <span class="verb">must</span> be evaluated; it
          is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if it has no <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          children.</p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>This is different from the situation with
            unrecognized <a title="XSLT element" href=
            "index.html#dt-xslt-element">XSLT elements</a>. As explained in
            <a href="index.html#forwards"><i>3.9 Forwards-Compatible
            Processing</i></a>, an unrecognized XSLT element
            appearing within a <a title="sequence constructor"
            href="index.html#dt-sequence-constructor">sequence
            constructor</a> is a static error unless (a) <a title=
            "forwards-compatible behavior" href=
            "index.html#dt-forwards-compatible-behavior">forwards-compatible
            behavior</a> is enabled, and (b) the instruction has an
            <a href=
            "index.html#element-fallback"><code>xsl:fallback</code></a>
            child.</p>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="result-trees" id="result-trees"></a>19 Final
      Result Trees</h2>

      <p>The output of a transformation is a set of
      <span>one</span> or more <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result trees</a>.</p>

      <p>A <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result tree</a> can be created
      explicitly, by evaluating an <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>
      instruction. <span>As explained in <a href=
      "index.html#executing-a-transformation"><i>2.4 Executing a
      Transformation</i></a>,</span> a final result tree is also
      created implicitly if no <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>
      instruction is evaluated, or if the result of evaluating the
      <a title="initial template" href=
      "index.html#dt-initial-template">initial template</a> is a non-empty
      sequence.</p>

      <p>The way in which a <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result tree</a> is delivered to
      an application is <a title="implementation-defined" href=
      "index.html#dt-implementation-defined">implementation-defined</a>.</p>

      <p>Serialization of <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result trees</a> is described
      further in <a href="index.html#serialization"><i>20
      Serialization</i></a></p>

      <div class="div2">
        <h3><a name="creating-result-trees" id=
        "creating-result-trees"></a>19.1 Creating Final Result
        Trees</h3>

        <p class="element-syntax"><a name="element-result-document"
        id="element-result-document"></a><code>&lt;!-- Category:
        instruction --&gt;<br />
        &lt;xsl:result-document<br />
        &#160;&#160;format? = { <var>qname</var> }<br />
        &#160;&#160;href? = { <var>uri-reference</var> }<br />
        &#160;&#160;validation? = "strict" | "lax" | "preserve" |
        "strip"<br />
        &#160;&#160;type? = <var>qname</var><br />
        &#160;&#160;method? = { "xml" | "html" | "xhtml" | "text" |
        <var>qname-but-not-ncname</var> }<br />
        &#160;&#160;byte-order-mark? = { "yes" | "no" }<br />
        &#160;&#160;cdata-section-elements? = { <var>qnames</var>
        }<br />
        &#160;&#160;doctype-public? = { <var>string</var> }<br />
        &#160;&#160;doctype-system? = { <var>string</var> }<br />
        &#160;&#160;encoding? = { <var>string</var> }<br />
        &#160;&#160;escape-uri-attributes? = { "yes" | "no" }<br />
        &#160;&#160;include-content-type? = { "yes" | "no" }<br />
        &#160;&#160;indent? = { "yes" | "no" }<br />
        &#160;&#160;media-type? = { <var>string</var> }<br />
        &#160;&#160;normalization-form? = { "NFC" | "NFD" | "NFKC"
        | "NFKD" | "fully-normalized" | "none" | <var>nmtoken</var>
        }<br />
        &#160;&#160;omit-xml-declaration? = { "yes" | "no" }<br />
        &#160;&#160;standalone? = { "yes" | "no" | "omit" }<br />
        &#160;&#160;undeclare-prefixes? = { "yes" | "no" }<br />
        &#160;&#160;use-character-maps? = <var>qnames</var><br />
        &#160;&#160;output-version? = { <var>nmtoken</var>
        }&gt;<br />
        &#160;&#160;&lt;!-- Content:
        <var>sequence-constructor</var> --&gt;<br />
        &lt;/xsl:result-document&gt;</code></p>

        <p>The <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction is used to create a <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a>. The content of the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        element is a <a title="sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> for the
        children of the document node of the tree. A document node
        is created, and the sequence obtained by evaluating the
        sequence constructor is used to construct the content of
        the document, as described in <a href=
        "index.html#constructing-complex-content"><i>5.7.1 Constructing
        Complex Content</i></a>. The tree rooted at this document
        node forms the final result tree.</p>

        <p>The <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction defines the URI of the result tree, and may
        optionally specify the output format to be used for
        serializing this tree.</p>

        <p>The <span><a title="effective value" href=
        "index.html#dt-effective-value">effective value</a></span> of the
        <code>format</code> attribute, if specified, <span class=
        "verb">must</span> be a <a title="lexical QName" href=
        "index.html#dt-lexical-qname">lexical QName</a>. The QName is
        expanded using the namespace declarations in scope for the
        <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        element. The <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> <span class=
        "verb">must</span> match the expanded QName of a named
        <a title="output definition" href=
        "index.html#dt-output-definition">output definition</a> in the
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>.
        This identifies the <a href=
        "index.html#element-output"><code>xsl:output</code></a> declaration
        that will control the serialization of the <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a> (see <a href="index.html#serialization"><i>20
        Serialization</i></a>), if the result tree is serialized.
        If the <code>format</code> attribute is omitted, the
        unnamed <a title="output definition" href=
        "index.html#dt-output-definition">output definition</a> is used to
        control serialization of the result tree.</p>

        <p><a name="err-XTDE1460" id="err-XTDE1460"><span class=
        "error">[ERR XTDE1460]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>format</code> attribute is not a valid <a title=
        "lexical QName" href="index.html#dt-lexical-qname">lexical QName</a>,
        or if it does not match the <a title="expanded-QName" href=
        "index.html#dt-expanded-qname">expanded-QName</a> of an <a title=
        "output definition" href="index.html#dt-output-definition">output
        definition</a> in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>. If the processor is able
        to detect the error statically (for example, when the
        <code>format</code> attribute contains no curly brackets),
        then the processor <span class="verb">may</span> optionally
        signal this as a <a title="static error" href=
        "index.html#dt-static-error">static error</a>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The only way to select the unnamed <a title=
          "output definition" href="index.html#dt-output-definition">output
          definition</a> is to omit the <code>format</code>
          attribute.</p>
        </div>

        <p>The attributes <code>method</code>,
        <code>byte-order-mark</code>
        <code>cdata-section-elements</code>,
        <code>doctype-public</code>, <code>doctype-system</code>,
        <code>encoding</code>, <code>escape-uri-attributes</code>,
        <code>indent</code>, <code>media-type</code>,
        <code>normalization-form</code>,
        <code>omit-xml-declaration</code>, <code>standalone</code>,
        <code>undeclare-prefixes</code>,
        <code>use-character-maps</code>, and
        <code>output-version</code> may be used to override
        attributes defined in the selected <a title=
        "output definition" href="index.html#dt-output-definition">output
        definition</a>.</p>

        <p>With the exception of <code>use-character-maps</code>,
        these attributes are all defined as <a title=
        "attribute value template" href=
        "index.html#dt-attribute-value-template">attribute value
        templates</a>, so their values may be set dynamically. For
        any of these attributes that is present on the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction, the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the attribute
        overrides or supplements the corresponding value from the
        output definition. This works in the same way as when one
        <a href="index.html#element-output"><code>xsl:output</code></a>
        declaration overrides another:</p>

        <ul>
          <li>
            <p>In the case of <code>cdata-section-elements</code>,
            the value of the serialization parameter is the union
            of the expanded names of the elements named in this
            instruction and the elements named in the selected
            output definition;</p>
          </li>

          <li>
            <p>In the case of <code>use-character-maps</code>, the
            character maps referenced in this instruction
            supplement and take precedence over those defined in
            the selected output definition;</p>
          </li>

          <li>
            <p>In all other cases, the effective value of an
            attribute actually present on this instruction takes
            precedence over the value defined in the selected
            output definition.</p>
          </li>
        </ul>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>In the case of the attributes <code>method</code>,
          <code>cdata-section-elements</code>, <span>and
          <code>use-character-maps</code>,</span> the <a title=
          "effective value" href="index.html#dt-effective-value">effective
          value</a> of the attribute contains one or more lexical
          QNames. The prefix in such a QName is expanded using the
          in-scope namespaces for the
          <code>xsl:result-document</code> element. In the case of
          <code>cdata-section-elements</code>, an unprefixed
          element name is expanded using the default namespace.</p>
        </div>

        <p>The <code>output-version</code> attribute on the
        <a href="index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction overrides the <code>version</code> attribute on
        <a href="index.html#element-output"><code>xsl:output</code></a> (it
        has been renamed because <code>version</code> is available
        with a different meaning as a standard attribute: see
        <a href="index.html#standard-attributes"><i>3.5 Standard
        Attributes</i></a>). In all other cases, attributes
        correspond if they have the same name.</p>

        <p>There are some serialization parameters that apply to
        some output methods but not to others. For example, the
        <code>indent</code> attribute has no effect on the
        <code>text</code> output method. If a value is supplied for
        an attribute that is inapplicable to the output method, its
        value is <span>not passed to the serializer</span>. The
        processor <span class="verb">may</span> validate the value
        of such an attribute, but is not <span class=
        "verb">required</span> to do so.</p>

        <p>The <code>href</code> attribute is optional. The default
        value is the zero-length string. The <a title=
        "effective value" href="index.html#dt-effective-value">effective
        value</a> of the attribute <span class="verb">must</span>
        be a <a title="URI Reference" href="index.html#dt-uri-reference">URI
        Reference</a>, which may be absolute or relative. There
        <span class="verb">may</span> be <a title=
        "implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        restrictions on the form of absolute URI that may be used,
        but the implementation is not <span class=
        "verb">required</span> to enforce any restrictions. Any
        legal relative URI <span class="verb">must</span> be
        accepted. Note that the zero-length string is a legal
        relative URI.</p>

        <p>The base URI of the document node at the root of the
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> is based on
        the <a title="effective value" href=
        "index.html#dt-effective-value">effective value</a> of the
        <code>href</code> attribute. If the <a title=
        "effective value" href="index.html#dt-effective-value">effective
        value</a> is a relative URI, then it is resolved relative
        to the <a title="base output URI" href=
        "index.html#dt-base-output-uri">base output URI</a>. If the
        implementation provides an API to access final result
        trees, then it <span class="verb">must</span> allow a final
        result tree to be identified by means of this base URI.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The base URI of the <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a> is not
          <span>necessarily</span> the same thing as the URI of its
          serialized representation on disk, if any. For example, a
          server (or browser client) might store final result trees
          only in memory, or in an internal disk cache. As long as
          <span>the processor</span> satisfies requests for those
          URIs, it is irrelevant where they are actually written on
          disk, if at all.</p>
        </div>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>It will often be the case that one <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a> contains links to another final result
          tree produced during the same transformation, in the form
          of a relative URI. The mechanism of associating a URI
          with a final result tree has been chosen to allow the
          integrity of such links to be preserved when the trees
          are serialized.</p>

          <p>As well as being potentially significant in any API
          that provides access to final result trees, the base URI
          of the new document node is relevant if the final result
          tree, rather than being serialized, is supplied as input
          to a further transformation.</p>
        </div>

        <p>The optional attributes <code>type</code> and
        <code>validation</code> may be used on the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction to validate the contents of the new document,
        and to determine the <a title="type annotation" href=
        "index.html#dt-annotation">type annotation</a> that elements and
        attributes within the <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> will carry.
        The permitted values and their semantics are described in
        <a href="index.html#validating-document-nodes"><i>19.2.2 Validating
        Document Nodes</i></a>.</p>

        <p>A <a title="processor" href=
        "index.html#dt-processor">processor</a> <span class="verb">may</span>
        allow a <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> to be
        serialized. Serialization is described in <a href=
        "index.html#serialization"><i>20 Serialization</i></a>. However, an
        implementation (for example, a <a title="processor" href=
        "index.html#dt-processor">processor</a> running in an environment
        with no access to writable filestore) is not <span class=
        "verb">required</span> to support the serialization of
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result trees</a>. An
        implementation that does not support the serialization of
        final result trees <span class="verb">may</span> ignore the
        <code>format</code> attribute <span>and the serialization
        attributes</span>. Such an implementation <span class=
        "verb">must</span> provide the application with some means
        of access to the (un-serialized) result tree, using its URI
        to identify it.</p>

        <p>Implementations may provide additional mechanisms,
        outside the scope of this specification, for defining the
        way in which <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result trees</a> are
        processed. Such mechanisms <span class="verb">may</span>
        make use of the XSLT-defined attributes on the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        and/or <a href=
        "index.html#element-output"><code>xsl:output</code></a> elements, or
        they <span class="verb">may</span> use additional elements
        or attributes in an <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        namespace.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e27003" id="d5e27003"></a>Example: Multiple
            Result Documents
          </div>

          <p>The following example takes an XHTML document as
          input, and breaks it up so that the text following each
          &lt;h1&gt; element is included in a separate document. A
          new document <code>toc.html</code> is constructed to act
          as an index:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:stylesheet
        version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"&gt;
        
&lt;xsl:output name="toc-format" method="xhtml" indent="yes"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
            doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/&gt;
            
&lt;xsl:output name="section-format" method="xhtml" indent="no"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
            doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/&gt;        
         
&lt;xsl:template match="/"&gt;
  &lt;xsl:result-document href="toc.html" format="toc-format" validation="strict"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;&lt;title&gt;Table of Contents&lt;/title&gt;&lt;/head&gt;
      &lt;body&gt;
        &lt;h1&gt;Table of Contents&lt;/h1&gt;
        &lt;xsl:for-each select="/*/xhtml:body/(*[1] | xhtml:h1)"&gt;
          &lt;p&gt;&lt;a href="section{position()}.html"&gt;&lt;xsl:value-of select="."/&gt;&lt;/a&gt;&lt;/p&gt;
        &lt;/xsl:for-each&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:result-document&gt;
  &lt;xsl:for-each-group select="/*/xhtml:body/*" group-starting-with="xhtml:h1"&gt;
    &lt;xsl:result-document href="section{position()}.html" 
                         format="section-format" validation="strip"&gt;         
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
        &lt;head&gt;&lt;title&gt;&lt;xsl:value-of select="."/&gt;&lt;/title&gt;&lt;/head&gt;
        &lt;body&gt;
          &lt;xsl:copy-of select="current-group()"/&gt;
        &lt;/body&gt;
      &lt;/html&gt;
    &lt;/xsl:result-document&gt;
  &lt;/xsl:for-each-group&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
          </div>
        </div>

        <p>There are restrictions on the use of the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction, designed to ensure that the results are fully
        interoperable even when processors optimize the sequence in
        which instructions are evaluated. Informally, the
        restriction is that the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction can only be used while writing a final result
        tree, not while writing to a temporary tree or a sequence.
        This restriction is defined formally as follows.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-output-state" id="dt-output-state" title=
        "output state"></a>Each instruction in the <a title=
        "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> is
        evaluated in one of two possible <b>output states</b>:
        <a title="final output state" href=
        "index.html#dt-final-output-state">final output state</a> or
        <a title="temporary output state" href=
        "index.html#dt-temporary-output-state">temporary output
        state</a><span class="definition">]</span>.</p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-final-output-state" id="dt-final-output-state" title=
        "final output state"></a>The first of the two <a title=
        "output state" href="index.html#dt-output-state">output states</a> is
        called <b>final output</b> state. This state applies when
        instructions are writing to a <a title="final result tree"
        href="index.html#dt-final-result-tree">final result
        tree</a>.<span class="definition">]</span></p>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-temporary-output-state" id="dt-temporary-output-state"
        title="temporary output state"></a>The second of the two
        <a title="output state" href="index.html#dt-output-state">output
        states</a> is called <b>temporary output</b> state. This
        state applies when instructions are writing to a <a title=
        "temporary tree" href="index.html#dt-temporary-tree">temporary
        tree</a> or any other non-final destination.<span class=
        "definition">]</span></p>

        <p>The instructions in the <a title="initial template"
        href="index.html#dt-initial-template">initial template</a> are
        evaluated in <a title="final output state" href=
        "index.html#dt-final-output-state">final output state</a>. An
        instruction is evaluated in the same <a title=
        "output state" href="index.html#dt-output-state">output state</a> as
        its calling instruction, except that <a href=
        "index.html#element-variable"><code>xsl:variable</code></a>, <a href=
        "index.html#element-param"><code>xsl:param</code></a>, <a href=
        "index.html#element-with-param"><code>xsl:with-param</code></a>,
        <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>,
        <a href="index.html#element-comment"><code>xsl:comment</code></a>,
        <a href=
        "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>,
        <a href=
        "index.html#element-namespace"><code>xsl:namespace</code></a>,
        <a href="index.html#element-value-of"><code>xsl:value-of</code></a>,
        <a href="index.html#element-function"><code>xsl:function</code></a>,
        <a href="index.html#element-key"><code>xsl:key</code></a>, <a href=
        "index.html#element-sort"><code>xsl:sort</code></a>, and <a href=
        "index.html#element-message"><code>xsl:message</code></a> always
        evaluate the instructions in their contained <a title=
        "sequence constructor" href=
        "index.html#dt-sequence-constructor">sequence constructor</a> in
        <a title="temporary output state" href=
        "index.html#dt-temporary-output-state">temporary output
        state</a>.</p>

        <p><a name="err-XTDE1480" id="err-XTDE1480"><span class=
        "error">[ERR XTDE1480]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> to evaluate the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction in <a title="temporary output state" href=
        "index.html#dt-temporary-output-state">temporary output
        state</a>.</p>

        <p><a name="err-XTDE1490" id="err-XTDE1490"><span class=
        "error">[ERR XTDE1490]</span></a> It is a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> for a transformation to generate two or more
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result trees</a> with the
        same URI.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Note, this means that it is an error to evaluate more
          than one <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction that omits the <code>href</code> attribute,
          or to evaluate any <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction that omits the <code>href</code> attribute if
          an initial <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a> is created
          implicitly.</p>
        </div>

        <p>Technically, the result of evaluating the <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction is an empty sequence. This means it does not
        contribute any nodes to the result of the
        <span>sequence</span> constructor it is part of.</p>

        <p><a name="err-XTRE1495" id="err-XTRE1495"><span class=
        "error">[ERR XTRE1495]</span></a> It is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> for a
        transformation to generate two or more <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result trees</a> with URIs that identify the same physical
        resource. The <a title="optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is <a title="implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>,
        since it may be impossible for the processor to detect the
        error.</p>

        <p><a name="err-XTRE1500" id="err-XTRE1500"><span class=
        "error">[ERR XTRE1500]</span></a> It is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> for a
        <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
        to write to an external resource and read from the same
        resource during a single transformation, whether or not the
        same URI is used to access the resource in both cases. The
        <a title="optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is <a title="implementation-dependent" href=
        "index.html#dt-implementation-dependent">implementation-dependent</a>:
        implementations are not <span class="verb">required</span>
        to detect the error condition. <span>Note that if the error
        is not detected, it is undefined whether the document that
        is read from the resource reflects its state before or
        after the result tree is written.</span></p>
      </div>

      <div class="div2">
        <h3><a name="validation" id="validation"></a>19.2
        Validation</h3>

        <p>It is possible to control the <a title="type annotation"
        href="index.html#dt-annotation">type annotation</a> applied to
        individual element and attribute nodes as they are
        constructed. This is done using the <code>type</code> and
        <code>validation</code> attributes of the <a href=
        "index.html#element-element"><code>xsl:element</code></a>, <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>,
        <a href="index.html#element-copy"><code>xsl:copy</code></a>, <a href=
        "index.html#element-copy-of"><code>xsl:copy-of</code></a>,
        <span><a href=
        "index.html#element-document"><code>xsl:document</code></a></span>,
        and <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instructions, or the <code>xsl:type</code> and
        <code>xsl:validation</code> attributes of a <a title=
        "literal result element" href=
        "index.html#dt-literal-result-element">literal result
        element</a>.</p>

        <p>The <code>[xsl:]type</code> attribute is used to request
        validation of an element or attribute against a specific
        simple or complex type defined in a schema. The
        <code>[xsl:]validation</code> attribute is used to request
        validation against the global element or attribute
        declaration whose name matches the name of the element or
        attribute being validated.</p>

        <p>The <code>[xsl:]type</code> and
        <code>[xsl:]validation</code> attributes are mutually
        exclusive. Both are optional, but if one is present then
        the other <span class="verb">must</span> be omitted. If
        both attributes are omitted, the effect is the same as
        specifying the <code>validation</code> attribute with the
        value specified in the <code>default-validation</code>
        attribute of the containing <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element; if this is not specified, the effect is the same
        as specifying <code>validation="strip"</code>.</p>

        <p><a name="err-XTSE1505" id="err-XTSE1505"><span class=
        "error">[ERR XTSE1505]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        both the <code>[xsl:]type</code> and
        <code>[xsl:]validation</code> attributes are present on the
        <a href="index.html#element-element"><code>xsl:element</code></a>,
        <a href=
        "index.html#element-attribute"><code>xsl:attribute</code></a>,
        <a href="index.html#element-copy"><code>xsl:copy</code></a>, <a href=
        "index.html#element-copy-of"><code>xsl:copy-of</code></a>,
        <span><a href=
        "index.html#element-document"><code>xsl:document</code></a></span>,
        or <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instructions, or on a <a title="literal result element"
        href="index.html#dt-literal-result-element">literal result
        element</a>.</p>

        <p>The detailed rules for validation vary depending on the
        kind of node being validated. The rules for element and
        attribute nodes are given in <a href=
        "index.html#validating-constructed-nodes"><i>19.2.1 Validating
        Constructed Elements and Attributes</i></a>, while those
        for document nodes are given in <a href=
        "index.html#validating-document-nodes"><i>19.2.2 Validating Document
        Nodes</i></a>.</p>

        <div class="div3">
          <h4><a name="validating-constructed-nodes" id=
          "validating-constructed-nodes"></a>19.2.1 Validating
          Constructed Elements and Attributes</h4>

          <div class="div4">
            <h5><a name="validating-using-validation-attribute" id=
            "validating-using-validation-attribute"></a>19.2.1.1
            Validation using the <code>[xsl:]validation</code>
            Attribute</h5>

            <p>The <code>[xsl:]validation</code> attribute defines
            the validation action to be taken. It determines not
            only the <a title="type annotation" href=
            "index.html#dt-annotation">type annotation</a> of the node that
            is constructed by the relevant instruction itself, but
            also the type annotations of all element and attribute
            nodes that have the constructed node as an ancestor.
            Conceptually, the validation requested for a child
            element or attribute node is applied before the
            validation requested for its parent element. For
            example, if the instruction that constructs a child
            element specifies <code>validation="strict"</code>,
            this will cause the child element to be checked against
            an element declaration, but if the instruction that
            constructs its parent element specifies
            <code>validation="strip"</code>, then the final effect
            will be that the child node is annotated as
            <span><code>xs:untyped</code></span>.</p>

            <p>In the paragraphs below, the term <em>contained
            nodes</em> means the elements and attributes that have
            the newly constructed node as an ancestor.</p>

            <ul>
              <li>
                <p>The value <code>strip</code> indicates that the
                new node and each of the contained nodes will have
                the <a title="type annotation" href=
                "index.html#dt-annotation">type annotation</a>
                <span><code>xs:untyped</code></span> if it is an
                element, or
                <span><code>xs:untypedAtomic</code></span> if it is
                an attribute. Any previous type annotation present
                on a contained element or attribute node (for
                example, a type annotation that is present on an
                element copied from a source document) is also
                replaced by <span><code>xs:untyped</code></span> or
                <span><code>xs:untypedAtomic</code></span> as
                appropriate. <span>The typed value of the node is
                changed to be the same as its string value, as an
                instance of <code>xs:untypedAtomic</code>. In the
                case of elements the <code>nilled</code> property
                is set to <code>false</code>. The values of the
                <code>is-id</code> and <code>is-idrefs</code>
                properties are unchanged.</span> Schema validation
                is not invoked.</p>
              </li>

              <li>
                <p>The value <code>preserve</code> indicates that
                nodes that are copied will retain their <a title=
                "type annotation" href="index.html#dt-annotation">type
                annotations</a>, but nodes whose content is newly
                constructed will be annotated as
                <code>xs:anyType</code> in the case of elements, or
                <span><code>xs:untypedAtomic</code></span> in the
                case of attributes. Schema validation is not
                invoked. The detailed effect depends on the
                instruction:</p>

                <ul>
                  <li>
                    <p>In the case of <a href=
                    "index.html#element-element"><code>xsl:element</code></a>
                    and literal result elements, the new element
                    has a <a title="type annotation" href=
                    "index.html#dt-annotation">type annotation</a> of
                    <code>xs:anyType</code>, and the type
                    annotations of contained nodes are retained
                    unchanged.</p>
                  </li>

                  <li>
                    <p>In the case of <a href=
                    "index.html#element-attribute"><code>xsl:attribute</code></a>,
                    the effect is exactly the same as specifying
                    <code>validation="strip"</code>: that is, the
                    new attribute will have the type annotation
                    <span><code>xs:untypedAtomic</code></span>.</p>
                  </li>

                  <li>
                    <p>In the case of <a href=
                    "index.html#element-copy-of"><code>xsl:copy-of</code></a>,
                    all the nodes that are copied will retain their
                    type annotations unchanged.</p>
                  </li>

                  <li>
                    <p>In the case of <a href=
                    "index.html#element-copy"><code>xsl:copy</code></a>, the
                    effect depends on the kind of node being
                    copied.</p>

                    <ol class="enumar">
                      <li>
                        <p>Where the node being copied is an
                        attribute, the copied attribute will retain
                        its <a title="type annotation" href=
                        "index.html#dt-annotation">type annotation</a>.</p>
                      </li>

                      <li>
                        <p>Where the node being copied is an
                        element, the copied element will have a
                        <a title="type annotation" href=
                        "index.html#dt-annotation">type annotation</a> of
                        <span><code>xs:anyType</code></span>
                        (because this instruction does not copy the
                        content of the element, it would be wrong
                        to assume that the type is unchanged); but
                        any contained nodes will have their type
                        annotations retained in the same way as
                        with <a href=
                        "index.html#element-element"><code>xsl:element</code></a>.</p>
                      </li>
                    </ol>
                  </li>
                </ul>
              </li>

              <li>
                <p>The value <code>strict</code> indicates that
                <a title="type annotation" href=
                "index.html#dt-annotation">type annotations</a> are
                established by performing strict schema validity
                assessment on the element or attribute node created
                by this instruction as follows:</p>

                <ul>
                  <li>
                    <p>In the case of an element, <span>a
                    top-level</span> element declaration is
                    identified whose local name and namespace (if
                    any) match the name of the element, and
                    schema-validity assessment is carried out
                    according to the rules defined in <a href=
                    "index.html#xmlschema-1">[XML Schema Part 1]</a> (section
                    3.3.4 "Element Declaration Validation Rules",
                    validation rule "Schema-Validity Assessment
                    (Element)", clauses 1.1 and 2<span>, using the
                    top-level element declaration as the
                    "declaration stipulated by the processor",
                    which is mentioned in clause 1.1.1.1</span>).
                    The element is considered valid if the result
                    of the schema validity assessment is a PSVI in
                    which the relevant element node has a
                    <code>validity</code> property whose value is
                    <code>valid</code>. If <span>there is no
                    matching element declaration, or if</span> the
                    element is not considered valid, the
                    transformation fails <span class="error">[see
                    <a href="index.html#err-XTTE1510">ERR
                    XTTE1510</a>]</span>, <span class="error">[see
                    <a href="index.html#err-XTTE1512">ERR
                    XTTE1512</a>]</span>. In effect this means that
                    the element being validated <span class=
                    "verb">must</span> be declared using a
                    top-level declaration in the schema, and
                    <span class="verb">must</span> conform to its
                    declaration. The process of validation applies
                    recursively to contained elements and
                    attributes to the extent required by the schema
                    definition.</p>

                    <div class="note">
                      <p class="prefix"><b>Note:</b></p>

                      <p>It is not an error if the identified type
                      definition is a simple type, although
                      <a href="index.html#xmlschema-1">[XML Schema Part
                      1]</a> does not define explicitly that this
                      case is permitted.</p>
                    </div>
                  </li>

                  <li>
                    <p>In the case of an attribute, <span>a
                    top-level</span> attribute declaration is
                    identified whose local name and namespace (if
                    any) match the name of the attribute, and
                    schema-validity assessment is carried out
                    according to the rules defined in <a href=
                    "index.html#xmlschema-1">[XML Schema Part 1]</a> (section
                    3.2.4 "Attribute Declaration Validation Rules",
                    validation rule "Schema-Validity Assessment
                    (Attribute)"). The attribute is considered
                    valid if the result of the schema validity
                    assessment is a PSVI in which the relevant
                    attribute node has a <code>validity</code>
                    property whose value is <code>valid</code>. If
                    the attribute is not considered valid, the
                    transformation fails <span><span class=
                    "error">[see <a href="index.html#err-XTTE1510">ERR
                    XTTE1510</a>]</span></span>. In effect this
                    means that the attribute being validated
                    <span class="verb">must</span> be declared
                    using a top-level declaration in the schema,
                    and <span class="verb">must</span> conform to
                    its declaration.</p>
                  </li>

                  <li>
                    <p>The schema components used to validate an
                    element or attribute may be located in any way
                    <span>described</span> by <a href=
                    "index.html#xmlschema-1">[XML Schema Part 1]</a> (see
                    section 4.3.2, <em>How schema documents are
                    located on the Web</em>). The components in the
                    schema constructed from the synthetic schema
                    document (see <a href="index.html#import-schema"><i>3.14
                    Importing Schema Components</i></a>) will
                    always be available for validating constructed
                    nodes; if additional schema components are
                    needed, they <span class="verb">may</span>
                    <span>be located in other ways, for example
                    implicitly from knowledge of the namespace in
                    which the elements and attributes appear, or
                    using the <code>xsi:schemaLocation</code>
                    attribute of elements within the tree being
                    validated.</span></p>
                  </li>

                  <li>
                    <p>If no validation is performed for a node,
                    which can happen when the schema specifies
                    <code>lax</code> or <code>skip</code>
                    validation for that node or for a subtree, then
                    the node is annotated as
                    <span><code>xs:anyType</code></span> in the
                    case of an element, and
                    <span><code>xs:untypedAtomic</code></span> in
                    the case of an attribute.</p>
                  </li>
                </ul>
              </li>

              <li>
                <p>The value <code>lax</code> has the same effect
                as the value <code>strict</code>, except that
                whereas <code>strict</code> validation fails
                <span>if there is no matching top-level element
                declaration or</span> if the outcome of validity
                assessment is a <code>validity</code> property of
                <code>invalid</code> or <code>notKnown</code>,
                <code>lax</code> validation fails only if the
                outcome of validity assessment is a
                <code>validity</code> property of
                <code>invalid</code>. That is, <code>lax</code>
                validation does not cause a type error when the
                outcome is <code>notKnown</code>.</p>

                <p>In practice this means that the element or
                attribute being validated <span class=
                "verb">must</span> conform to its declaration if a
                top-level declaration is available. If no such
                declaration is available, then the element or
                attribute is not validated, but its attributes and
                children are validated, again with lax validation.
                Any nodes whose validation outcome is a
                <code>validity</code> property of
                <code>notKnown</code> are annotated as
                <span><code>xs:anyType</code></span> in the case of
                an element, and
                <span><code>xs:untypedAtomic</code></span> in the
                case of an attribute.</p>

                <div class="note">
                  <p class="prefix"><b>Note:</b></p>

                  <p>When the parent element lacks a declaration,
                  the XML Schema specification defines the
                  recursive checking of children and attributes as
                  optional. For this specification, this recursive
                  checking is required.</p>
                </div>

                <div class="note">
                  <p class="prefix"><b>Note:</b></p>

                  <p>If an element that is being validated has an
                  <code>xsi:type</code> attribute, then the value
                  of the <code>xsi:type</code> attribute will be
                  taken into account when performing the
                  validation. However, the presence of an
                  <code>xsi:type</code> attribute will not of
                  itself cause an element to be validated: if
                  validation against a named type is required, as
                  distinct from validation against a top-level
                  element declaration, then it must be requested
                  using the XSLT <code>[xsl:]type</code> attribute
                  on the instruction that invokes the validation,
                  as described in section <a href=
                  "index.html#validation-xsl-type"><i>19.2.1.2 Validation
                  using the [xsl:]type Attribute</i></a></p>
                </div>
              </li>
            </ul>

            <p><a name="err-XTTE1510" id=
            "err-XTTE1510"><span class="error">[ERR
            XTTE1510]</span></a> If the <code>validation</code>
            attribute of an <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>,
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>, or
            <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>
            instruction, or the <code>xsl:validation</code>
            attribute of a literal result element, has the
            effective value <code>strict</code>, and schema
            validity assessment concludes that the validity of the
            element or attribute is invalid or unknown, a type
            error occurs. As with other type errors, the error
            <span class="verb">may</span> be signaled statically if
            it can be detected statically.</p>

            <p><a name="err-XTTE1512" id=
            "err-XTTE1512"><span class="error">[ERR
            XTTE1512]</span></a> If the <code>validation</code>
            attribute of an <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>,
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>, or
            <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>
            instruction, or the <code>xsl:validation</code>
            attribute of a literal result element, has the
            effective value <code>strict</code>, and there is no
            matching top-level declaration in the schema, then a
            type error occurs. As with other type errors, the error
            <span class="verb">may</span> be signaled statically if
            it can be detected statically.</p>

            <p><a name="err-XTTE1515" id=
            "err-XTTE1515"><span class="error">[ERR
            XTTE1515]</span></a> If the <code>validation</code>
            attribute of an <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>,
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>, or
            <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>
            instruction, or the <code>xsl:validation</code>
            attribute of a literal result element, has the
            effective value <code>lax</code>, and schema validity
            assessment concludes that the element or attribute is
            invalid, a type error occurs. As with other type
            errors, the error <span class="verb">may</span> be
            signaled statically if it can be detected
            statically.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>No mechanism is provided to validate an element or
              attribute against a local declaration in a schema.
              Such validation can usually be achieved by applying
              validation to a containing element for which a
              top-level element declaration exists.</p>
            </div>
          </div>

          <div class="div4">
            <h5><a name="validation-xsl-type" id=
            "validation-xsl-type"></a>19.2.1.2 Validation using the
            <code>[xsl:]type</code> Attribute</h5>

            <p>The <code>[xsl:]type</code> attribute takes as its
            value a <code>QName</code>. This <span class=
            "verb">must</span> <span>be the name of a type
            definition included in the <a title=
            "in-scope schema component" href=
            "index.html#dt-in-scope-schema-component">in-scope schema
            components</a> for the stylesheet.</span> If the QName
            has no prefix, it is expanded using the default
            namespace established using the effective
            <code>[xsl:]xpath-default-namespace</code> attribute if
            there is one; otherwise, it is taken as being a name in
            no namespace.</p>

            <p>If the <code>[xsl:]type</code> attribute is present,
            then the newly constructed element or attribute is
            validated against the type definition identified by
            this attribute.</p>

            <ul>
              <li>
                <p>In the case of an element, schema-validity
                assessment is carried out according to the rules
                defined in <a href="index.html#xmlschema-1">[XML Schema Part
                1]</a> (section 3.3.4 "Element Declaration
                Validation Rules", validation rule "Schema-Validity
                Assessment (Element)", clauses 1.2 and 2), using
                this type definition as the "processor-stipulated
                type definition". The element is considered valid
                if the result of the schema validity assessment is
                a PSVI in which the relevant element node has a
                <code>validity</code> property whose value is
                <code>valid</code>.</p>
              </li>

              <li>
                <p>In the case of an attribute, the attribute is
                considered valid if (in the terminology of XML
                Schema) the attribute's normalized value is locally
                valid with respect to that type definition
                according to the rules for "String Valid" (<a href=
                "index.html#xmlschema-1">[XML Schema Part 1]</a>, section
                3.14.4). (Normalization here refers to the process
                of normalizing whitespace according to the rules of
                the <code>whiteSpace</code> facet for the data
                type).</p>
              </li>

              <li>
                <p>If the element or attribute is not considered
                valid, <span>as defined above</span>, the
                transformation fails <span><span class="error">[see
                <a href="index.html#err-XTTE1540">ERR
                XTTE1540</a>]</span></span>.</p>
              </li>
            </ul>

            <p><a name="err-XTSE1520" id=
            "err-XTSE1520"><span class="error">[ERR
            XTSE1520]</span></a> It is a <a title="static error"
            href="index.html#dt-static-error">static error</a> if the value
            of the <code>type</code> attribute of an <a href=
            "index.html#element-element"><code>xsl:element</code></a>,
            <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>,
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>,
            <span><a href=
            "index.html#element-document"><code>xsl:document</code></a>,</span>
            or <a href=
            "index.html#element-result-document"><code>xsl:result-document</code></a>
            instruction, or the <code>xsl:type</code> attribute of
            a literal result element, is not a valid
            <code>QName</code>, or if it uses a prefix that is not
            defined in an in-scope namespace declaration, or if the
            QName is not the name of a type definition included in
            the <a title="in-scope schema component" href=
            "index.html#dt-in-scope-schema-component">in-scope schema
            components</a> for the stylesheet.</p>

            <p><a name="err-XTSE1530" id=
            "err-XTSE1530"><span class="error">[ERR
            XTSE1530]</span></a> It is a <a title="static error"
            href="index.html#dt-static-error">static error</a> if the value
            of the <code>type</code> attribute of an <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>
            instruction refers to a complex type definition.</p>

            <p><a name="err-XTTE1540" id=
            "err-XTTE1540"><span class="error">[ERR
            XTTE1540]</span></a> It is a <a title="type errors"
            href="index.html#dt-type-error">type error</a> if an
            <code>[xsl:]type</code> attribute is defined for a
            constructed element or attribute, and the outcome of
            schema validity assessment against that type is that
            the <code>validity</code> property of that element or
            attribute information item is other than
            <code>valid</code>.</p>

            <div class="note">
              <p class="prefix"><b>Note:</b></p>

              <p>Like other type errors, this error may be signaled
              statically if it can be detected statically. For
              example, the instruction <code>&lt;xsl:attribute
              name="dob"
              type="xs:date"&gt;1999-02-29&lt;/xsl:attribute&gt;</code>
              may result in a static error being signaled. If the
              error is not signaled statically, it will be signaled
              when the instruction is evaluated.</p>
            </div>
          </div>

          <div class="div4">
            <h5><a name="validation-process" id=
            "validation-process"></a>19.2.1.3 The Validation
            Process</h5>

            <p>As well as checking for validity against the schema,
            the validity assessment process causes <a title=
            "type annotation" href="index.html#dt-annotation">type
            annotations</a> to be associated with element and
            attribute nodes. If default values for elements or
            attributes are defined in the schema, the validation
            process will where necessary create new nodes
            containing these default values.</p>

            <p>Validation of an element or attribute node only
            takes into account constraints on the content of the
            element or attribute. Validation rules affecting the
            document as a whole are not applied. Specifically, this
            means:</p>

            <ul>
              <li>
                <p>The validation rule "Validation Root Valid
                (ID/IDREF)" is not applied. This means that
                validation will not fail if there are non-unique ID
                values or dangling IDREF values in the subtree
                being validated.</p>
              </li>

              <li>
                <p>The validation rule "Validation Rule:
                Identity-constraint Satisfied" is not applied.</p>
              </li>

              <li>
                <p>There is no check that the document contains
                unparsed entities whose names match the values of
                nodes of type <code>xs:ENTITY</code> or
                <code>xs:ENTITIES</code>. (XSLT 2.0 provides no
                facility to construct unparsed entities within a
                tree.)</p>
              </li>

              <li>
                <p>There is no check that the document contains
                notations whose names match the values of nodes of
                type <code>xs:NOTATION</code>. (The
                <span>XDM</span> data model makes no provision for
                notations to be represented in the tree.)</p>
              </li>
            </ul>

            <p>With these caveats, validating a newly constructed
            element, using strict or lax validation, is equivalent
            to the following steps:</p>

            <ol class="enumar">
              <li>
                <p>The element is serialized to textual XML form,
                according to the rules defined in <a href=
                "index.html#xslt-xquery-serialization">[XSLT and XQuery
                Serialization]</a> using the XML output method,
                with all parameters defaulted. Note that this
                process discards any existing <a title=
                "type annotation" href="index.html#dt-annotation">type
                annotations</a>.</p>
              </li>

              <li>
                <p>The resulting XML document is parsed to create
                an XML Information Set (see <a href=
                "index.html#xml-infoset">[XML Information Set]</a>.)</p>
              </li>

              <li>
                <p>The Information Set produced in the previous
                step is validated according to the rules in
                <a href="index.html#xmlschema-1">[XML Schema Part 1]</a>. The
                result of this step is a Post-Schema Validation
                Infoset (PSVI). If the validation process is not
                successful (as defined above), a type error is
                raised.</p>
              </li>

              <li>
                <p>The PSVI produced in the previous step is
                converted back into the <span>XDM</span> data model
                by the mapping described in <a href=
                "index.html#xpath-datamodel">[Data Model]</a> (<a href=
                "http://www.w3.org/TR/xpath-datamodel/#PSVI2Types">Section
                3.3.1 Mapping PSVI Additions to Node
                Properties</a><sup><small>DM</small></sup>). This
                process creates nodes with simple or complex
                <a title="type annotation" href=
                "index.html#dt-annotation">type annotations</a> based on the
                types established during schema validation.</p>
              </li>
            </ol>

            <p>Validating an attribute using strict or lax
            validation requires a modified version of this
            procedure. A copy of the attribute is first added to an
            element node that is created for the purpose, and
            namespace fixup (see <a href=
            "index.html#namespace-fixup"><i>5.7.3 Namespace Fixup</i></a>) is
            performed on this element node. The name of this
            element is of no consequence, but it must be the same
            as the name of a synthesized element declaration of the
            form:</p>

            <div class="exampleInner">
              <pre>
&lt;xs:element name="E"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence/&gt;
    &lt;xs:attribute ref="A"/&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;
</pre>
            </div>

            <p>where A is the name of the attribute being
            validated.</p>

            <p>This synthetic element is then validated using the
            procedure given above for validating elements, and if
            it is found to be valid, a copy of the validated
            attribute is made, retaining its <a title=
            "type annotation" href="index.html#dt-annotation">type
            annotation</a>, but detaching it from the containing
            element (and thus, from any namespace nodes).</p>

            <p>The <span>XDM</span> data model does not permit an
            attribute node with no parent to have a typed value
            that includes a namespace-qualified name, that is, a
            value whose type is derived from <code>xs:QName</code>
            or <code>xs:NOTATION</code>. This restriction is
            imposed because these types rely on the namespace nodes
            of a containing element to resolve namespace prefixes.
            Therefore, it is an error to validate a parentless
            attribute against such a type. This affects the
            instructions <a href=
            "index.html#element-attribute"><code>xsl:attribute</code></a>,
            <a href="index.html#element-copy"><code>xsl:copy</code></a>, and
            <a href=
            "index.html#element-copy-of"><code>xsl:copy-of</code></a>.</p>

            <p><a name="err-XTTE1545" id=
            "err-XTTE1545"><span class="error">[ERR
            XTTE1545]</span></a> A <a title="type errors" href=
            "index.html#dt-type-error">type error</a> occurs if a
            <code>type</code> or <code>validation</code> attribute
            is defined (explicitly or implicitly) for an
            instruction that constructs a new attribute node, if
            the effect of this is to cause the attribute value to
            be validated against a type that is derived from, or
            constructed by list or union from, the primitive types
            <code>xs:QName</code> or <code>xs:NOTATION</code>.</p>
          </div>
        </div>

        <div class="div3">
          <h4><a name="validating-document-nodes" id=
          "validating-document-nodes"></a>19.2.2 Validating
          Document Nodes</h4>

          <p>It is possible to apply validation to a document node.
          <span>This happens when a new document node is
          constructed by one of the instructions <a href=
          "index.html#element-document"><code>xsl:document</code></a>,
          <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>, or
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>,
          and this instruction has a <code>type</code> attribute,
          or a <code>validation</code> attribute with the value
          <code>strict</code> or <code>lax</code></span>.</p>

          <p>Document-level validation is not applied to the
          document node that is created implicitly when a
          variable-binding element has no <code>select</code>
          attribute and no <code>as</code> attribute (see <a href=
          "index.html#temporary-trees"><i>9.4 Creating implicit document
          nodes</i></a>). This is equivalent to using
          <code>validation="preserve"</code> on <a href=
          "index.html#element-document"><code>xsl:document</code></a>: nodes
          within such trees retain their <a title="type annotation"
          href="index.html#dt-annotation">type annotation</a>. Similarly,
          validation is not applied to document nodes created using
          <a href=
          "index.html#element-message"><code>xsl:message</code></a>.</p>

          <p>The values <code>validation="preserve"</code> and
          <code>validation="strip"</code> do not request
          validation. In the first case, all element and attribute
          nodes within the tree rooted at the new document node
          retain their <a title="type annotation" href=
          "index.html#dt-annotation">type annotations</a>. In the second
          case, elements within the tree have their type annotation
          set to <span><code>xs:untyped</code></span>, while
          attributes have their type annotation set to
          <span><code>xs:untypedAtomic</code></span>.</p>

          <p>When validation is requested for a document node (that
          is, when <code>validation</code> is set to
          <code>strict</code> or <code>lax</code>, or when a
          <code>type</code> attribute is present), the following
          processing takes place:</p>

          <ul>
            <li>
              <p><a name="err-XTTE1550" id=
              "err-XTTE1550"><span class="error">[ERR
              XTTE1550]</span></a> A <a title="type errors" href=
              "index.html#dt-type-error">type error</a> occurs unless the
              children of the document node comprise exactly one
              element node, no text nodes, and zero or more comment
              and processing instruction nodes, in any order.</p>
            </li>

            <li>
              <p>The single element node child is validated, using
              the supplied values of the <code>validation</code>
              and <code>type</code> attributes, as described in
              <a href="index.html#validating-constructed-nodes"><i>19.2.1
              Validating Constructed Elements and
              Attributes</i></a>.</p>

              <div class="note">
                <p class="prefix"><b>Note:</b></p>

                <p>The <code>type</code> attribute on
                <span><a href="index.html#element-document"><code>xsl:document</code></a>
                and</span> <a href=
                "index.html#element-result-document"><code>xsl:result-document</code></a>,
                and on <a href=
                "index.html#element-copy"><code>xsl:copy</code></a> and
                <a href=
                "index.html#element-copy-of"><code>xsl:copy-of</code></a>
                when copying a document node, thus refers to the
                required type of the element node that is the only
                element child of the document node. It does not
                refer to the type of the document node itself.</p>
              </div>
            </li>

            <li>
              <p>The validation rule "Validation Root Valid
              (ID/IDREF)" is applied to the single element node
              child of the document node. This means that
              validation will fail if there are non-unique ID
              values or dangling IDREF values in the document
              tree.</p>
            </li>

            <li>
              <p>Identity constraints, as defined in section 3.11
              of <a href="index.html#xmlschema-1">[XML Schema Part 1]</a>,
              are checked. (This refers to constraints defined
              using <code>xs:unique</code>, <code>xs:key</code>,
              and <code>xs:keyref</code>.)</p>
            </li>

            <li>
              <p>There is no check that the tree contains unparsed
              entities whose names match the values of nodes of
              type <code>xs:ENTITY</code> or
              <code>xs:ENTITIES</code>. This is because there is no
              facility in XSLT 2.0 to create unparsed entities in a
              <a title="result tree" href="index.html#dt-result-tree">result
              tree</a>. It is possible to add unparsed entity
              declarations to the result document by referencing a
              suitable DOCTYPE during serialization.</p>
            </li>

            <li>
              <p>There is no check that the document contains
              notations whose names match the values of nodes of
              type <code>xs:NOTATION</code>. This is because
              notations are not part of the <span>XDM</span> data
              model. It is possible to add notations to the result
              document by referencing a suitable DOCTYPE during
              serialization.</p>
            </li>

            <li>
              <p>All other children of the document node (comments
              and processing instructions) are copied
              unchanged.</p>
            </li>
          </ul>

          <p><a name="err-XTTE1555" id="err-XTTE1555"><span class=
          "error">[ERR XTTE1555]</span></a> It is a <a title=
          "type errors" href="index.html#dt-type-error">type error</a> if,
          when validating a document node, document-level
          constraints are not satisfied. These constraints include
          identity constraints (<code>xs:unique</code>,
          <code>xs:key</code>, and <code>xs:keyref</code>) and
          ID/IDREF constraints.</p>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="serialization" id="serialization"></a>20
      Serialization</h2>

      <p>A <a title="processor" href="index.html#dt-processor">processor</a>
      <span class="verb">may</span> output a <a title=
      "final result tree" href="index.html#dt-final-result-tree">final result
      tree</a> as a sequence of octets, although it is not
      <span class="verb">required</span> to be able to do so (see
      <a href="index.html#conformance"><i>21 Conformance</i></a>).
      <span>Stylesheet authors can use <a href=
      "index.html#element-output"><code>xsl:output</code></a> declarations to
      specify how they wish result trees to be serialized. If a
      processor serializes a final result tree, it <span class=
      "verb">must</span> do so as specified by these
      declarations.</span></p>

      <p>The rules governing the output of the serializer are
      defined in <a href="index.html#xslt-xquery-serialization">[XSLT and
      XQuery Serialization]</a>. The serialization is controlled
      using a number of serialization parameters. The values of
      these serialization parameters may be set within the
      <a title="stylesheet" href="index.html#dt-stylesheet">stylesheet</a>,
      using the <a href=
      "index.html#element-output"><code>xsl:output</code></a>, <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>,
      and <a href=
      "index.html#element-character-map"><code>xsl:character-map</code></a>
      declarations.</p>

      <p class="element-syntax"><a name="element-output" id=
      "element-output"></a><code>&lt;!-- Category: declaration
      --&gt;<br />
      &lt;xsl:output<br />
      &#160;&#160;name? = <var>qname</var><br />
      &#160;&#160;method? = "xml" | "html" | "xhtml" | "text" |
      <var>qname-but-not-ncname</var><br />
      &#160;&#160;byte-order-mark? = "yes" | "no"<br />
      &#160;&#160;cdata-section-elements? = <var>qnames</var><br />
      &#160;&#160;doctype-public? = <var>string</var><br />
      &#160;&#160;doctype-system? = <var>string</var><br />
      &#160;&#160;encoding? = <var>string</var><br />
      &#160;&#160;escape-uri-attributes? = "yes" | "no"<br />
      &#160;&#160;include-content-type? = "yes" | "no"<br />
      &#160;&#160;indent? = "yes" | "no"<br />
      &#160;&#160;media-type? = <var>string</var><br />
      &#160;&#160;normalization-form? = "NFC" | "NFD" | "NFKC" |
      "NFKD" | "fully-normalized" | "none" |
      <var>nmtoken</var><br />
      &#160;&#160;omit-xml-declaration? = "yes" | "no"<br />
      &#160;&#160;standalone? = "yes" | "no" | "omit"<br />
      &#160;&#160;undeclare-prefixes? = "yes" | "no"<br />
      &#160;&#160;use-character-maps? = <var>qnames</var><br />
      &#160;&#160;version? =
      <var>nmtoken</var>&#160;/&gt;</code></p>

      <p>The <a href="index.html#element-output"><code>xsl:output</code></a>
      declaration is optional; if used, it <span class=
      "verb">must</span> always appear as a <a title="top-level"
      href="index.html#dt-top-level">top-level</a> element within a
      <span>stylesheet module</span>.</p>

      <p>A <a title="stylesheet" href=
      "index.html#dt-stylesheet">stylesheet</a> may contain multiple <a href=
      "index.html#element-output"><code>xsl:output</code></a> declarations
      and may include or import stylesheet modules that also
      contain <a href="index.html#element-output"><code>xsl:output</code></a>
      declarations. The name of an <a href=
      "index.html#element-output"><code>xsl:output</code></a> declaration is
      the value of its <code>name</code> attribute, if any.</p>

      <p><span class="definition">[Definition:&#160;</span><a name=
      "dt-output-definition" id="dt-output-definition" title=
      "output definition"></a>All the <a href=
      "index.html#element-output"><code>xsl:output</code></a> declarations in
      a stylesheet that share the same name are grouped into a
      named <b>output definition</b>; those that have no name are
      grouped into a single unnamed output definition.<span class=
      "definition">]</span></p>

      <p>A stylesheet always includes an unnamed <a title=
      "output definition" href="index.html#dt-output-definition">output
      definition</a>; in the absence of an unnamed <a href=
      "index.html#element-output"><code>xsl:output</code></a> declaration,
      the unnamed output definition is equivalent to the one that
      would be used if the stylesheet contained an <a href=
      "index.html#element-output"><code>xsl:output</code></a> declaration
      having no attributes.</p>

      <p>A named <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> is used when
      its name matches the <code>format</code> attribute used in an
      <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>
      element. The unnamed output definition is used when an
      <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>
      element omits the <code>format</code> attribute. It is also
      used when serializing the <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result tree</a> that is created
      implicitly in the absence of an <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>
      element.</p>

      <p>All the <a href=
      "index.html#element-output"><code>xsl:output</code></a> elements making
      up an <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> are effectively
      merged. <span>For those attributes whose values are
      namespace-sensitive, the merging is done after <a title=
      "lexical QName" href="index.html#dt-lexical-qname">lexical QNames</a>
      have been converted into <a title="expanded-QName" href=
      "index.html#dt-expanded-qname">expanded QNames</a>.</span> For the
      <code>cdata-section-elements</code> attribute, the output
      definition uses the union of the values from all the
      constituent <a href=
      "index.html#element-output"><code>xsl:output</code></a> declarations.
      <span>For the <code>use-character-maps</code> attribute, the
      output definition uses the concatenation of the sequences of
      <a title="expanded-QName" href="index.html#dt-expanded-qname">expanded
      QNames</a> values from all the constituent <a href=
      "index.html#element-output"><code>xsl:output</code></a> declarations,
      taking them in order of increasing <a title=
      "import precedence" href="index.html#dt-import-precedence">import
      precedence</a>, or where several have the same import
      precedence, in <a title="declaration order" href=
      "index.html#dt-declaration-order">declaration order</a>.</span> For
      other attributes, the <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> uses the value
      of that attribute from the <a href=
      "index.html#element-output"><code>xsl:output</code></a> declaration
      with the highest <a title="import precedence" href=
      "index.html#dt-import-precedence">import precedence</a>.</p>

      <p><a name="err-XTSE1560" id="err-XTSE1560"><span class=
      "error">[ERR XTSE1560]</span></a> It is a <a title=
      "static error" href="index.html#dt-static-error">static error</a> if
      two <a href="index.html#element-output"><code>xsl:output</code></a>
      declarations within an <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> specify
      explicit values for the same attribute (other than
      <code>cdata-section-elements</code> and
      <code>use-character-maps</code>), with the values of the
      attributes being not equal, unless there is another <a href=
      "index.html#element-output"><code>xsl:output</code></a> declaration
      within the same <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> that has higher
      import precedence and that specifies an explicit value for
      the same attribute.</p>

      <p>If none of the <a href=
      "index.html#element-output"><code>xsl:output</code></a> declarations
      within an <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> specifies a
      value for a particular attribute, then the corresponding
      serialization parameter takes a default value. The default
      value depends on the chosen output method.</p>

      <p>There are some serialization parameters that apply to some
      output methods but not to others. For example, the
      <code>indent</code> attribute has no effect on the
      <code>text</code> output method. If a value is supplied for
      an attribute that is inapplicable to the output method, its
      value is <span>not passed to the serializer</span>. The
      processor <span class="verb">may</span> validate the value of
      such an attribute, but is not <span class=
      "verb">required</span> to do so.</p>

      <p>An implementation <span class="verb">may</span> allow the
      attributes of the <a href=
      "index.html#element-output"><code>xsl:output</code></a> declaration to
      be overridden, or the default values to be changed, using the
      API that controls the transformation.</p>

      <p>The location to which <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result trees</a> are serialized
      (whether in filestore or elsewhere) is <a title=
      "implementation-defined" href=
      "index.html#dt-implementation-defined">implementation-defined</a>
      (which in practice <span class="verb">may</span> mean that it
      is controlled using an implementation-defined API). However,
      these locations <span class="verb">must</span> satisfy the
      constraint that when two <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result trees</a> are both
      created (implicitly or explicitly) using relative URIs in the
      <code>href</code> attribute of the <a href=
      "index.html#element-result-document"><code>xsl:result-document</code></a>
      instruction, then these relative URIs may be used to
      construct references from one tree to the other, and such
      references <span class="verb">must</span> remain valid when
      both result trees are serialized.</p>

      <p>The <code>method</code> attribute on the <a href=
      "index.html#element-output"><code>xsl:output</code></a> element
      identifies the overall method that is to be used for
      outputting the <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result tree</a>.</p>

      <p><a name="err-XTSE1570" id="err-XTSE1570"><span class=
      "error">[ERR XTSE1570]</span></a> The value <span class=
      "verb">must</span> <span>(if present)</span> be a valid
      <a title="QName" href="index.html#dt-qname">QName</a>. If the <a title=
      "QName" href="index.html#dt-qname">QName</a> does not have a prefix,
      then it identifies a method specified in <a href=
      "index.html#xslt-xquery-serialization">[XSLT and XQuery
      Serialization]</a> and <span class="verb">must</span> be one
      of <code>xml</code>, <code>html</code>, <code>xhtml</code>,
      or <code>text</code>. If the <a title="QName" href=
      "index.html#dt-qname">QName</a> has a prefix, then the <a title="QName"
      href="index.html#dt-qname">QName</a> is expanded into an <a title=
      "expanded-QName" href="index.html#dt-expanded-qname">expanded-QName</a>
      as described in <a href="index.html#qname"><i>5.1 Qualified
      Names</i></a>; the <a title="expanded-QName" href=
      "index.html#dt-expanded-qname">expanded-QName</a> identifies the output
      method; the behavior in this case is not specified by this
      document.</p>

      <p>The default for the <code>method</code> attribute
      <span>depends on the contents of the tree being serialized,
      and</span> is chosen as follows. If the document node of the
      <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result tree</a> has an element
      child, and any text nodes preceding the first element child
      of the document node of the result tree contain only
      whitespace characters, then:</p>

      <ul>
        <li>
          <p>If the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> of this first
          element child has local part <code>html</code> (in lower
          case), and namespace URI
          <code>http://www.w3.org/1999/xhtml</code>, then the
          default output method is <span>normally</span>
          <code>xhtml</code>. <span>However, if the
          <code>version</code> attribute of the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element of the <a title="principal stylesheet module"
          href="index.html#dt-principal-stylesheet-module">principal
          stylesheet module</a> has the value <code>1.0</code>, and
          if the result tree is generated implicitly (rather than
          by an explicit <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction), then the default output method in this
          situation is <code>xml</code>.</span></p>
        </li>

        <li>
          <p>If the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> of this first
          element child has local part <code>html</code> (in any
          combination of upper and lower case) and a null namespace
          URI, then the default output method is
          <code>html</code>.</p>
        </li>
      </ul>

      <p>In all other cases, the default output method is
      <code>xml</code>.</p>

      <p>The default output method is used if the selected
      <a title="output definition" href=
      "index.html#dt-output-definition">output definition</a> does not
      include a <code>method</code> attribute.</p>

      <p>The other attributes on <a href=
      "index.html#element-output"><code>xsl:output</code></a> provide
      parameters for the output method. The following attributes
      are allowed:</p>

      <ul>
        <li>
          <p>The value of the <code>encoding</code> attribute
          provides the value of the <code>encoding</code> parameter
          to the serialization method. The default value is
          <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>,
          but in the case of the <code>xml</code> and
          <code>xhtml</code> methods it <span class=
          "verb">must</span> be either <code>UTF-8</code> or
          <code>UTF-16</code>.</p>
        </li>

        <li>
          <p>The <code>byte-order-mark</code> attribute defines
          whether a byte order mark is written at the start of the
          file. If the value <code>yes</code> is specified, a byte
          order mark is written; if <code>no</code> is specified,
          no byte order mark is written. The default value depends
          on the encoding used. If the encoding is
          <code>UTF-16</code>, the default is <code>yes</code>; for
          <code>UTF-8</code> it is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>,
          and for all other encodings it is <code>no</code>. The
          value of the byte order mark indicates whether high order
          bytes are written before or after low order bytes; the
          actual byte order used is <a title=
          "implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a><span>
          , unless it is defined by the selected
          encoding</span>.</p>
        </li>

        <li>
          <p>The <code>cdata-section-elements</code> attribute is a
          whitespace-separated list of QNames. The default value is
          an empty list. After expansion of these names using the
          in-scope namespace declarations for the <a href=
          "index.html#element-output"><code>xsl:output</code></a> declaration
          in which they appear, this list of names provides the
          value of the <code>cdata-section-elements</code>
          parameter to the serialization method. <span>In the case
          of an unprefixed name, the default namespace (that is,
          the namespace declared using <code>xmlns="uri"</code>) is
          used.</span></p>

          <div class="note">
            <p class="prefix"><b>Note:</b></p>

            <p>This differs from the rule for most other QNames
            used in a stylesheet. The reason is that these names
            refer to elements in the result document, and therefore
            follow the same convention as the name of a literal
            result element or the <code>name</code> attribute of
            <a href=
            "index.html#element-element"><code>xsl:element</code></a>.</p>
          </div>
        </li>

        <li>
          <p>The value of the <code>doctype-system</code> attribute
          provides the value of the <code>doctype-system</code>
          parameter to the serialization method. By default, the
          parameter is not supplied.</p>
        </li>

        <li>
          <p>The value of the <code>doctype-public</code> attribute
          provides the value of the <code>doctype-public</code>
          parameter to the serialization method. By default, the
          parameter is not supplied.</p>
        </li>

        <li>
          <p>The value of the <code>escape-uri-attributes</code>
          attribute provides the value of the
          <code>escape-uri-attributes</code> parameter to the
          serialization method. The default value is
          <code>yes</code>.</p>
        </li>

        <li>
          <p>The value of the <code>include-content-type</code>
          attribute provides the value of the
          <code>include-content-type</code> parameter to the
          serialization method. The default value is
          <code>yes</code>.</p>
        </li>

        <li>
          <p>The value of the <code>indent</code> attribute
          provides the value of the <code>indent</code> parameter
          to the serialization method. The default value is
          <code>yes</code> in the case of the <code>html</code> and
          <code>xhtml</code> output methods, <code>no</code> in the
          case of the <code>xml</code> output method.</p>
        </li>

        <li>
          <p>The value of the <code>media-type</code> attribute
          provides the value of the <code>media-type</code>
          parameter to the serialization method. The default value
          is <code>text/xml</code> in the case of the
          <code>xml</code> output method, <code>text/html</code> in
          the case of the <code>html</code> and <code>xhtml</code>
          output methods, and <code>text/plain</code> in the case
          of the <code>text</code> output method.</p>
        </li>

        <li>
          <p>The value of the <code>normalization-form</code>
          attribute provides the value of the
          <code>normalization-form</code> parameter to the
          serialization method. A value that is an
          <code>NMTOKEN</code> other than one of those enumerated
          for the <code>normalization-form</code> attribute
          specifes an implementation-defined normalization form;
          the behavior in this case is not specified by this
          document. The default value is <code>none</code>.</p>
        </li>

        <li>
          <p>The value of the <code>omit-xml-declaration</code>
          attribute provides the value of the
          <code>omit-xml-declaration</code> parameter to the
          serialization method. The default value is
          <code>no</code>.</p>
        </li>

        <li>
          <p>The value of the <code>standalone</code> attribute
          provides the value of the <code>standalone</code>
          parameter to the serialization method. <span>The default
          value is <code>omit</code>; this means that no
          <code>standalone</code> attribute is to be included in
          the XML declaration.</span></p>
        </li>

        <li>
          <p>The <code>undeclare-prefixes</code> attribute is
          relevant only when producing output with
          <code>method="xml"</code> and <code>version="1.1"</code>
          <span>(or later)</span>. It defines whether namespace
          undeclarations (of the form <code>xmlns:foo=""</code>)
          <span class="verb">should</span> be output when a child
          element has no namespace node with the same name (that
          is, namespace prefix) as a namespace node of its parent
          element. The default value is <code>no</code>: this means
          that namespace undeclarations are not output, which has
          the effect that when the resulting XML is reparsed, the
          new tree may contain namespace nodes on the child element
          that were not there in the original tree before
          serialization.</p>
        </li>

        <li>
          <p>The <code>use-character-maps</code> attribute provides
          a list of named character maps that are used in
          conjunction with this <a title="output definition" href=
          "index.html#dt-output-definition">output definition</a>. The way
          this attribute is used is described in <a href=
          "index.html#character-maps"><i>20.1 Character Maps</i></a>.
          <span>The default value is an empty list.</span></p>
        </li>

        <li>
          <p>The value of the <code>version</code> attribute
          provides the value of the <code>version</code> parameter
          to the serialization method. <span>The set of permitted
          values, and the default value, are <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          A <a title="serialization error" href=
          "index.html#dt-serialization-error">serialization error</a> will be
          reported if the requested version is not supported by the
          implementation.</span></p>
        </li>
      </ul>

      <p>If the processor performs serialization, then it must
      signal any non-recoverable serialization errors that occur.
      These have the same effect as <a title=
      "non-recoverable dynamic error" href=
      "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
      errors</a>: that is, the processor must signal the error and
      must not finish as if the transformation had been
      successful.</p>

      <div class="div2">
        <h3><a name="character-maps" id="character-maps"></a>20.1
        Character Maps</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-character-map" id="dt-character-map" title=
        "character map"></a>A <b>character map</b> allows a
        specific character appearing in a text or attribute node in
        the <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> to be
        substituted by a specified string of characters during
        serialization.<span class="definition">]</span> The effect
        of character maps is defined in <a href=
        "index.html#xslt-xquery-serialization">[XSLT and XQuery
        Serialization]</a>.</p>

        <p>The character map that is supplied as a parameter to the
        serializer is determined from the <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        elements referenced from the <a href=
        "index.html#element-output"><code>xsl:output</code></a> declaration
        for the selected <a title="output definition" href=
        "index.html#dt-output-definition">output definition</a>.</p>

        <p>The <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        element is a declaration that may appear as a child of the
        <a href=
        "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
        element.</p>

        <p class="element-syntax"><a name="element-character-map"
        id="element-character-map"></a><code>&lt;!-- Category:
        declaration --&gt;<br />
        &lt;xsl:character-map<br />
        &#160;&#160;<b>name</b> = <var>qname</var><br />
        &#160;&#160;use-character-maps? =
        <var>qnames</var>&gt;<br />
        &#160;&#160;&lt;!-- Content: (<a href=
        "index.html#element-output-character">xsl:output-character</a>*)
        --&gt;<br />
        &lt;/xsl:character-map&gt;</code></p>

        <p>The <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        declaration declares a character map with a name and a set
        of character mappings. The character mappings are specified
        by means of <a href=
        "index.html#element-output-character"><code>xsl:output-character</code></a>
        elements contained either directly within the <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        element, or in further character maps referenced in the
        <code>use-character-maps</code> attribute.</p>

        <p>The <span class="verb">required</span> <code>name</code>
        attribute provides a name for the character map. When a
        character map is used by an <a title="output definition"
        href="index.html#dt-output-definition">output definition</a> or
        another character map, the character map with the highest
        <a title="import precedence" href=
        "index.html#dt-import-precedence">import precedence</a> is used.</p>

        <p><a name="err-XTSE1580" id="err-XTSE1580"><span class=
        "error">[ERR XTSE1580]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> contains two or more
        character maps with the same name and the same <a title=
        "import precedence" href="index.html#dt-import-precedence">import
        precedence</a><span>, unless it also contains another
        character map with the same name and higher import
        precedence.</span></p>

        <p>The optional <code>use-character-maps</code> attribute
        lists the names of further character maps that are included
        into this character map.</p>

        <p><a name="err-XTSE1590" id="err-XTSE1590"><span class=
        "error">[ERR XTSE1590]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        a name in the <code>use-character-maps</code> attribute
        <span>of the <a href=
        "index.html#element-output"><code>xsl:output</code></a> or <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        elements</span> does not match the <code>name</code>
        attribute of any <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        in the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a>.</p>

        <p><a name="err-XTSE1600" id="err-XTSE1600"><span class=
        "error">[ERR XTSE1600]</span></a> It is a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        a character map references itself, directly or indirectly,
        via a name in the <code>use-character-maps</code>
        attribute.</p>

        <p>It is not an error if the same character map is
        referenced more than once, directly or indirectly.</p>

        <p>An <a title="output definition" href=
        "index.html#dt-output-definition">output definition</a>, after
        recursive expansion of character maps referenced via its
        <code>use-character-maps</code> attribute, may contain
        several mappings for the same character. In this situation,
        the last character mapping takes precedence. To establish
        the ordering, the following rules are used:</p>

        <ul>
          <li>
            <p>Within a single <a href=
            "index.html#element-character-map"><code>xsl:character-map</code></a>
            element, the characters defined in character maps
            referenced in the <code>use-character-maps</code>
            attribute are considered before the characters defined
            in the child <a href=
            "index.html#element-output-character"><code>xsl:output-character</code></a>
            elements.</p>
          </li>

          <li>
            <p>The character maps referenced in a single
            <code>use-character-maps</code> attribute are
            considered in the order in which they are listed in
            that attribute. The expansion is depth-first: each
            referenced character map is fully expanded before the
            next one is considered.</p>
          </li>

          <li>
            <p>Two <a href=
            "index.html#element-output-character"><code>xsl:output-character</code></a>
            elements appearing as children of the same <a href=
            "index.html#element-character-map"><code>xsl:character-map</code></a>
            element are considered in document order.</p>
          </li>
        </ul>

        <p>The <a href=
        "index.html#element-output-character"><code>xsl:output-character</code></a>
        element is defined as follows:</p>

        <p class="element-syntax"><a name=
        "element-output-character" id=
        "element-output-character"></a><code>&lt;xsl:output-character<br />

        &#160;&#160;<b>character</b> = <var>char</var><br />
        &#160;&#160;<b>string</b> =
        <var>string</var>&#160;/&gt;</code></p>

        <p>The character map that is passed as a parameter to the
        serializer contains a mapping for the character specified
        in the <code>character</code> attribute to the string
        specified in the <code>string</code> attribute.</p>

        <p>Character mapping is not applied to characters for which
        output escaping has been disabled as described in <a href=
        "index.html#disable-output-escaping"><i>20.2 Disabling Output
        Escaping</i></a>.</p>

        <p>If a character is mapped, then it is not subjected to
        XML or HTML escaping.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e29242" id="d5e29242"></a>Example: Using
            Character Maps to Generate Non-XML Output
          </div>

          <p>Character maps can be useful when producing serialized
          output in a format that resembles, but is not strictly
          conformant to, HTML or XML. For example, when the output
          is a JSP page, there might be a need to generate the
          output:</p>

          <div class="exampleInner">
            <pre>
&lt;jsp:setProperty name="user" property="id" value='&lt;%= "id" + idValue %&gt;'/&gt;
</pre>
          </div>

          <p>Although this output is not well-formed XML or HTML,
          it is valid in Java Server Pages. This can be achieved by
          allocating three Unicode characters (which are not needed
          for any other purpose) to represent the strings
          <code>&lt;%</code>, <code>%&gt;</code>, and
          <code>"</code>, for example:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:character-map name="jsp"&gt;
  &lt;xsl:output-character character="«" string="&amp;lt;%"/&gt;   
  &lt;xsl:output-character character="»" string="%&amp;gt;"/&gt;
  &lt;xsl:output-character character="§" string='"'/&gt;
&lt;/xsl:character-map&gt;
</pre>
          </div>

          <p>When this character map is referenced in the <a href=
          "index.html#element-output"><code>xsl:output</code></a>
          declaration, the required output can be produced by
          writing the following in the stylesheet:</p>

          <div class="exampleInner">
            <pre>
&lt;jsp:setProperty name="user" property="id" value='«= §id§ + idValue »'/&gt;
</pre>
          </div>

          <p>This works <span>on the assumption that</span> when an
          apostrophe or quotation mark is generated as part of an
          attribute value by the use of character maps, the
          serializer will (where possible) use the other choice of
          delimiter around the attribute value.</p>
        </div>

        <p>&#160;</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e29274" id="d5e29274"></a>Example:
            Constructing a Composite Character Map
          </div>

          <p>The following example illustrates a composite
          character map constructed in a modular fashion:</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:output name="htmlDoc" use-character-maps="htmlDoc" /&gt;

&lt;xsl:character-map name="htmlDoc"
  use-character-maps="html-chars doc-entities windows-format" /&gt;
  
&lt;xsl:character-map name="html-chars"
  use-character-maps="latin1 ..." /&gt;

&lt;xsl:character-map name="latin1"&gt;
  &lt;xsl:output-character character="&amp;#160;" string="&amp;amp;nbsp;" /&gt;
  &lt;xsl:output-character character="&amp;#161;" string="&amp;amp;iexcl;" /&gt;
  ...
&lt;/xsl:character-map&gt;

&lt;xsl:character-map name="doc-entities"&gt;
  &lt;xsl:output-character character="&amp;#xE400;" string="&amp;amp;t-and-c;" /&gt;
  &lt;xsl:output-character character="&amp;#xE401;" string="&amp;amp;chap1;" /&gt;
  &lt;xsl:output-character character="&amp;#xE402;" string="&amp;amp;chap2;" /&gt;
  ...
&lt;/xsl:character-map&gt;

&lt;xsl:character-map name="windows-format"&gt;
  &lt;!-- newlines as CRLF --&gt;
  &lt;xsl:output-character character="&amp;#xA;" string="&amp;#xD;&amp;#xA;" /&gt;

  &lt;!-- tabs as three spaces --&gt;
  &lt;xsl:output-character character="&amp;#x9;" string="   " /&gt;

  &lt;!-- images for special characters --&gt;
  &lt;xsl:output-character character="&amp;#xF001;"
    string="&amp;lt;img src='special1.gif' /&amp;gt;" /&gt;
  &lt;xsl:output-character character="&amp;#xF002;"
    string="&amp;lt;img src='special2.gif' /&amp;gt;" /&gt;
  ...
&lt;/xsl:character-map&gt;
</pre>
          </div>
        </div>
      </div>

      <div class="div2">
        <h3><a name="disable-output-escaping" id=
        "disable-output-escaping"></a>20.2 Disabling Output
        Escaping</h3>

        <p>Normally, when using the XML, HTML, or XHTML output
        method, the serializer will escape special characters such
        as <code>&amp;</code> and <code>&lt;</code> when outputting
        text nodes. This ensures that the output is well-formed.
        However, it is sometimes convenient to be able to produce
        output that is almost, but not quite well-formed XML; for
        example, the output may include ill-formed sections which
        are intended to be transformed into well-formed XML by a
        subsequent non-XML-aware process. For this reason, XSLT
        defines a mechanism for disabling output escaping.</p>

        <p>This feature is <a title="deprecated" href=
        "index.html#dt-deprecated">deprecated</a>.</p>

        <p>This is an optional feature: it is not <span class=
        "verb">required</span> that a XSLT processor that
        implements the serialization option <span class=
        "verb">should</span> offer the ability to disable output
        escaping, and there is no conformance level that requires
        this feature.</p>

        <p>This feature requires an extension to the serializer
        described in <a href="index.html#xslt-xquery-serialization">[XSLT and
        XQuery Serialization]</a>. Conceptually, the <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a> provides an additional boolean property
        <code>disable-escaping</code> associated with every
        character in a text node. When this property is set, the
        normal action of the serializer to escape special
        characters such as <code>&amp;</code> and <code>&lt;</code>
        is suppressed.</p>

        <p>An <a href=
        "index.html#element-value-of"><code>xsl:value-of</code></a> or
        <a href="index.html#element-text"><code>xsl:text</code></a> element
        may have a <code>disable-output-escaping</code> attribute;
        the allowed values are <code>yes</code> or <code>no</code>.
        The default is <code>no</code>; if the value is
        <code>yes</code>, then every character in the text node
        generated by evaluating the <a href=
        "index.html#element-value-of"><code>xsl:value-of</code></a> or
        <a href="index.html#element-text"><code>xsl:text</code></a> element
        <span class="verb">should</span> have the
        <code>disable-output</code> property set.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e29357" id="d5e29357"></a>Example: Disable
            Output Escaping
          </div>

          <p>For example,</p>

          <div class="exampleInner">
            <pre>
&lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;&lt;/xsl:text&gt;
</pre>
          </div>

          <p>should generate the single character
          <code>&lt;</code>.</p>
        </div>

        <p>If output escaping is disabled for an <a href=
        "index.html#element-value-of"><code>xsl:value-of</code></a> or
        <a href="index.html#element-text"><code>xsl:text</code></a>
        instruction evaluated when <a title=
        "temporary output state" href=
        "index.html#dt-temporary-output-state">temporary output state</a> is
        in effect, the request to disable output escaping is
        ignored.</p>

        <p>If output escaping is disabled for text within an
        element that would normally be output using a CDATA
        section, because the element is listed in the
        <code>cdata-section-elements</code>, then the relevant text
        will not be included in a CDATA section. In effect, CDATA
        is treated as an alternative escaping mechanism, which is
        disabled by the <code>disable-output-escaping</code>
        option.</p>

        <div class="example">
          <div class="exampleHeader">
            <a name="d5e29388" id="d5e29388"></a>Example:
            Interaction of Output Escaping and CDATA
          </div>

          <p>For example, if <code>&lt;xsl:output
          cdata-section-elements="title"/&gt;</code> is specified,
          then the following instructions:</p>

          <div class="exampleInner">
            <pre>
&lt;title&gt;
  &lt;xsl:text disable-output-escaping="yes"&gt;This is not &amp;lt;hr/&amp;gt; good coding practice&lt;/xsl:text&gt;
&lt;/title&gt;
</pre>
          </div>

          <p>should generate the output:</p>

          <div class="exampleInner">
            <pre>
&lt;title&gt;&lt;![CDATA[This is not ]]&gt;&lt;hr/&gt;&lt;![CDATA[ good coding practice]]&gt;&lt;/title&gt;
</pre>
          </div>
        </div>

        <p>The <code>disable-output-escaping</code> attribute may
        be used with the <code>html</code> output method as well as
        with the <code>xml</code> output method. The
        <code>text</code> output method ignores the
        <code>disable-output-escaping</code> attribute, since it
        does not perform any output escaping.</p>

        <p>A <a title="processor" href=
        "index.html#dt-processor">processor</a> will only be able to disable
        output escaping if it controls how the <a title=
        "final result tree" href="index.html#dt-final-result-tree">final
        result tree</a> is output. This might not always be the
        case. For example, the result tree might be used as a
        <a title="source tree" href="index.html#dt-source-tree">source
        tree</a> for another XSLT transformation instead of being
        output. It is <a title="implementation-defined" href=
        "index.html#dt-implementation-defined">implementation-defined</a>
        whether (and under what circumstances) disabling output
        escaping is supported.</p>

        <p><a name="err-XTRE1620" id="err-XTRE1620"><span class=
        "error">[ERR XTRE1620]</span></a> It is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> if an
        <a href="index.html#element-value-of"><code>xsl:value-of</code></a>
        or <a href="index.html#element-text"><code>xsl:text</code></a>
        instruction specifies that output escaping is to be
        disabled and the implementation does not support this. The
        <a title="optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is to ignore the <code>disable-output-escaping</code>
        attribute.</p>

        <p><a name="err-XTRE1630" id="err-XTRE1630"><span class=
        "error">[ERR XTRE1630]</span></a> It is a <a title=
        "recoverable error" href=
        "index.html#dt-recoverable-error">recoverable dynamic error</a> if an
        <a href="index.html#element-value-of"><code>xsl:value-of</code></a>
        or <a href="index.html#element-text"><code>xsl:text</code></a>
        instruction specifies that output escaping is to be
        disabled when writing to a <a title="final result tree"
        href="index.html#dt-final-result-tree">final result tree</a> that is
        not being serialized. The <a title=
        "optional recovery action" href=
        "index.html#dt-optional-recovery-action">optional recovery action</a>
        is to ignore the <code>disable-output-escaping</code>
        attribute.</p>

        <p>If output escaping is disabled for a character that is
        not representable in the encoding that the <a title=
        "processor" href="index.html#dt-processor">processor</a> is using for
        output, the request to disable output escaping is ignored
        in respect of that character.</p>

        <p>Since disabling output escaping might not work with all
        implementations and can result in XML that is not
        well-formed, it <span class="verb">should</span> be used
        only when there is no alternative.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The facility to define character maps for use during
          serialization, as described in <a href=
          "index.html#character-maps"><i>20.1 Character Maps</i></a>, has
          been produced as an alternative mechanism that can be
          used in many situations where disabling of output
          escaping was previously necessary, without the same
          difficulties.</p>
        </div>
      </div>
    </div>

    <div class="div1">
      <h2><a name="conformance" id="conformance"></a>21
      Conformance</h2>

      <p>A <a title="processor" href="index.html#dt-processor">processor</a>
      that claims conformance with this specification <span class=
      "verb">must</span> claim conformance either as a <a title=
      "basic XSLT processor" href="index.html#dt-basic-xslt-processor">basic
      XSLT processor</a> or as a <a title=
      "schema-aware XSLT processor" href=
      "index.html#dt-schema-aware-xslt-processor">schema-aware XSLT
      processor</a>. The rules for these two conformance levels are
      defined in the following sections.</p>

      <p>A processor that claims conformance at either of these two
      levels <span class="verb">may</span> additionally claim
      conformance with either or both of the following optional
      features: the serialization feature, defined in <a href=
      "index.html#serialization-feature"><i>21.3 Serialization
      Feature</i></a>, and the backwards compatibility feature,
      defined in <a href="index.html#backwards-compatibility-feature"><i>21.4
      Backwards Compatibility Feature</i></a>.</p>

      <div class="note">
        <p class="prefix"><b>Note:</b></p>

        <p>There is no conformance level or feature defined in this
        specification that requires implementation of the static
        typing features described in <a href="index.html#xpath20">[XPath
        2.0]</a>. An XSLT processor may provide a user option to
        invoke static typing, but to be conformant with this
        specification it must allow a stylesheet to be processed
        with static typing disabled. The interaction of XSLT
        stylesheets with the static typing feature of XPath 2.0 has
        not been specified, so the results of using static typing,
        if available, are implementation-defined.</p>
      </div>

      <p>An XSLT processor takes as its inputs a stylesheet and one
      or more <span>XDM trees conforming to</span> the data model
      defined in <a href="index.html#xpath-datamodel">[Data Model]</a>. It is
      not <span class="verb">required</span> that the processor
      supports any particular method of constructing <span>XDM
      trees</span>, but conformance can only be tested if it
      provides a mechanism that enables <span>XDM trees</span>
      representing the stylesheet and primary source document to be
      constructed and supplied as input to the processor.</p>

      <p>The output of the XSLT processor consists of
      <span>zero</span> or more <a title="final result tree" href=
      "index.html#dt-final-result-tree">final result trees</a>. It is not
      <span class="verb">required</span> that the processor
      supports any particular method of accessing a final result
      tree, but if it does not support the serialization module,
      conformance can only be tested if it provides some
      alternative mechanism that enables access to the results of
      the transformation.</p>

      <p>Certain facilities in this specification are described as
      producing <a title="implementation-defined" href=
      "index.html#dt-implementation-defined">implementation-defined</a>
      results. A claim that asserts conformance with this
      specification <span class="verb">must</span> be accompanied
      by documentation stating the effect of each
      implementation-defined feature. For convenience, a
      non-normative checklist of implementation-defined features is
      provided at <a href="index.html#implementation-defined-features"><i>F
      Checklist of Implementation-Defined Features</i></a>.</p>

      <p>A conforming <a title="processor" href=
      "index.html#dt-processor">processor</a> <span class="verb">must</span>
      signal any <a title="static error" href=
      "index.html#dt-static-error">static error</a> occurring in the
      stylesheet, or in any XPath <a title="expression" href=
      "index.html#dt-expression">expression</a>, except where specified
      otherwise either for individual error conditions or under the
      general provisions for <a title=
      "forwards-compatible behavior" href=
      "index.html#dt-forwards-compatible-behavior">forwards compatible
      behavior</a> (see <a href="index.html#forwards"><i>3.9
      Forwards-Compatible Processing</i></a>). After signaling such
      an error, the processor <span class="verb">may</span>
      continue for the purpose of signaling additional errors, but
      <span class="verb">must</span> terminate abnormally without
      performing any transformation.</p>

      <p>When a <a title="dynamic error" href=
      "index.html#dt-dynamic-error">dynamic error</a> occurs during the
      course of a transformation, the action depends on whether the
      error is classified as a <a title="recoverable error" href=
      "index.html#dt-recoverable-error">recoverable error</a>. If a
      non-recoverable error occurs, the processor <span class=
      "verb">must</span> signal it and <span class=
      "verb">must</span> eventually terminate abnormally. If a
      recoverable error occurs, the processor <span class=
      "verb">must</span> either signal it and terminate abnormally,
      or it <span class="verb">must</span> take the defined
      recovery action and continue processing.</p>

      <p>Some errors, notably <a title="type errors" href=
      "index.html#dt-type-error">type errors</a>, <span class=
      "verb">may</span> be treated as <a title="static error" href=
      "index.html#dt-static-error">static errors</a> or <a title=
      "dynamic error" href="index.html#dt-dynamic-error">dynamic errors</a>
      at the discretion of the processor.</p>

      <p>A conforming processor <span class="verb">may</span>
      impose limits on the processing resources consumed by the
      processing of a stylesheet.</p>

      <div class="div2">
        <h3><a name="basic-conformance" id=
        "basic-conformance"></a>21.1 Basic XSLT Processor</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-basic-xslt-processor" id="dt-basic-xslt-processor"
        title="basic XSLT processor"></a>A <b>basic XSLT
        processor</b> is an XSLT processor that implements all the
        mandatory requirements of this specification with the
        exception of certain explicitly-identified constructs
        related to schema processing.<span class=
        "definition">]</span> These constructs are listed
        below.</p>

        <p>The mandatory requirements of this specification are
        taken to include the mandatory requirements of XPath 2.0,
        as described in <a href="index.html#xpath20">[XPath 2.0]</a>. A
        requirement is mandatory unless the specification includes
        wording (such as the use of the words <span class=
        "verb">should</span> or <span class="verb">may</span>) that
        clearly indicates that it is optional.</p>

        <p>A <a title="basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
        <span class="verb">must</span> enforce the following
        restrictions. It <span class="verb">must</span> signal a
        static or dynamic error when the restriction is violated,
        as described below.</p>

        <p><a name="err-XTSE1650" id="err-XTSE1650"><span class=
        "error">[ERR XTSE1650]</span></a> A <a title=
        "basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
        <span class="verb">must</span> signal a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> includes an <a href=
        "index.html#element-import-schema"><code>xsl:import-schema</code></a>
        declaration.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>A processor that rejects an <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          declaration will also reject any reference to a
          user-defined type defined in a schema, or to a
          user-defined element or attribute declaration; it will
          not, however, reject references to the built-in types
          listed in <a href="index.html#built-in-types"><i>3.13 Built-in
          Types</i></a>.</p>
        </div>

        <p><a name="err-XTSE1660" id="err-XTSE1660"><span class=
        "error">[ERR XTSE1660]</span></a> A <a title=
        "basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
        <span class="verb">must</span> signal a <a title=
        "static error" href="index.html#dt-static-error">static error</a> if
        the <a title="stylesheet" href=
        "index.html#dt-stylesheet">stylesheet</a> includes an
        <code>[xsl:]type</code> attribute, or an
        <code>[xsl:]validation</code> or
        <code>default-validation</code> attribute with a value
        other than <code>strip</code>.</p>

        <p>A <a title="basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
        constrains the data model as follows:</p>

        <ul>
          <li>
            <p>Atomic values <span class="verb">must</span> belong
            to one of the atomic types listed in <a href=
            "index.html#built-in-types"><i>3.13 Built-in Types</i></a>
            (except as noted below).</p>

            <p>An atomic value may also belong to an
            implementation-defined type that has been added to the
            context for use with <a title="extension function"
            href="index.html#dt-extension-function">extension functions</a>
            or <a title="extension instruction" href=
            "index.html#dt-extension-instruction">extension
            instructions</a>.</p>

            <p>The set of constructor functions available are
            limited to those that construct values of the above
            atomic types.</p>

            <p>The static context, which defines the full set of
            type names recognized by an XSLT processor and also by
            the XPath processor, includes these atomic types, plus
            <code>xs:anyType</code>, <code>xs:anySimpleType</code>,
            <span><code>xs:untyped</code></span>, and
            <span><code>xs:anyAtomicType</code></span>.</p>
          </li>

          <li>
            <p>Element nodes <span class="verb">must</span> be
            annotated with the <a title="type annotation" href=
            "index.html#dt-annotation">type annotation</a>
            <span><code>xs:untyped</code></span>, and attribute
            nodes with the type annotation
            <code>xs:untypedAtomic</code>.</p>
          </li>
        </ul>

        <p><a name="err-XTDE1665" id="err-XTDE1665"><span class=
        "error">[ERR XTDE1665]</span></a> A <a title=
        "basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
        <span class="verb">must</span> raise a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if the input to the processor includes a node
        with a <a title="type annotation" href=
        "index.html#dt-annotation">type annotation</a> other than
        <span><code>xs:untyped</code></span> or
        <span><code>xs:untypedAtomic</code></span>, or an atomic
        value of a type other than those which a basic XSLT
        processor supports. <span>This error will not arise if the
        <code>input-type-annotations</code> attribute is set to
        <code>strip</code>.</span></p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>Although this is expressed in terms of a requirement
          to detect invalid input, an alternative approach is for a
          basic XSLT processor to prevent this error condition
          occurring, by not providing any interfaces that would
          allow the situation to arise. A processor might, for
          example, implement a mapping from the PSVI to the data
          model that loses all non-trivial <a title=
          "type annotation" href="index.html#dt-annotation">type
          annotations</a>; or it might not accept input from a PSVI
          at all.</p>

          <p>The phrase <em>input to the processor</em> is
          deliberately wide: it includes the tree containing the
          <a title="initial context node" href=
          "index.html#dt-initial-context-node">initial context node</a>,
          trees passed as <a title="stylesheet parameter" href=
          "index.html#dt-stylesheet-parameter">stylesheet parameters</a>,
          trees accessed using the <a href=
          "index.html#function-document"><code>document</code></a>, <a href=
          "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
          <small>FO</small></sup>, and <a href=
          "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
          collection</code></a><sup><small>FO</small></sup>
          functions, and trees returned by <a title=
          "extension function" href=
          "index.html#dt-extension-function">extension functions</a> and
          <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension
          instructions</a>.</p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="schema-aware-conformance" id=
        "schema-aware-conformance"></a>21.2 Schema-Aware XSLT
        Processor</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-schema-aware-xslt-processor" id=
        "dt-schema-aware-xslt-processor" title=
        "schema-aware XSLT processor"></a>A <b>schema-aware XSLT
        processor</b> is an XSLT processor that implements all the
        mandatory requirements of this specification, including
        those features that a <a title="basic XSLT processor" href=
        "index.html#dt-basic-xslt-processor">basic XSLT processor</a> signals
        as an error. The mandatory requirements of this
        specification are taken to include the mandatory
        requirements of XPath 2.0, as described in <a href=
        "index.html#xpath20">[XPath 2.0]</a>. A requirement is mandatory
        unless the specification includes wording (such as the use
        of the words <span class="verb">should</span> or
        <span class="verb">may</span>) that clearly indicates that
        it is optional.<span class="definition">]</span></p>
      </div>

      <div class="div2">
        <h3><a name="serialization-feature" id=
        "serialization-feature"></a>21.3 Serialization Feature</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-serialization-feature" id="dt-serialization-feature"
        title="serialization feature"></a>A processor that claims
        conformance with the <b>serialization feature</b>
        <span class="verb">must</span> support the conversion of a
        <a title="final result tree" href=
        "index.html#dt-final-result-tree">final result tree</a> to a sequence
        of <span>octets</span> following the rules defined in
        <a href="index.html#serialization"><i>20
        Serialization</i></a>.<span class="definition">]</span> It
        <span class="verb">must</span> respect all the attributes
        of the <a href=
        "index.html#element-output"><code>xsl:output</code></a> and <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        declarations, and <span class="verb">must</span> provide
        all four output methods, <code>xml</code>,
        <code>xhtml</code>, <code>html</code>, and
        <code>text</code>. Where the specification uses words such
        as <span class="verb">must</span> and <span class=
        "verb">required</span>, then it <span class=
        "verb">must</span> serialize the result tree in precisely
        the way described; in other cases it <span class=
        "verb">may</span> use an alternative, equivalent
        representation.</p>

        <p>A processor may claim conformance with the serialization
        feature whether or not it supports the setting
        <code>disable-output-escaping="yes"</code> on <a href=
        "index.html#element-text"><code>xsl:text</code></a>, or <a href=
        "index.html#element-value-of"><code>xsl:value-of</code></a>.</p>

        <p>A processor that does not claim conformance with the
        serialization feature <span class="verb">must not</span>
        signal an error merely because the <a title="stylesheet"
        href="index.html#dt-stylesheet">stylesheet</a> contains <a href=
        "index.html#element-output"><code>xsl:output</code></a> or <a href=
        "index.html#element-character-map"><code>xsl:character-map</code></a>
        declarations, <span>or serialization attributes on the
        <a href=
        "index.html#element-result-document"><code>xsl:result-document</code></a>
        instruction. Such a processor <span class="verb">may</span>
        check that these declarations and attributes have valid
        values, but is not <span class="verb">required</span> to do
        so. Apart from optional validation,</span> these
        declarations <span class="verb">should</span> be
        ignored.</p>
      </div>

      <div class="div2">
        <h3><a name="backwards-compatibility-feature" id=
        "backwards-compatibility-feature"></a>21.4 Backwards
        Compatibility Feature</h3>

        <p><span class=
        "definition">[Definition:&#160;</span><a name=
        "dt-backwards-compatibility-feature" id=
        "dt-backwards-compatibility-feature" title=
        "backwards compatibility feature"></a>A processor that
        claims conformance with the <b>backwards compatibility
        feature</b> <span class="verb">must</span> support the
        processing of stylesheet instructions and XPath expressions
        with <a title="backwards compatible behavior" href=
        "index.html#dt-backwards-compatible-behavior">backwards compatible
        behavior</a>, as defined in <a href="index.html#backwards"><i>3.8
        Backwards-Compatible Processing</i></a>.<span class=
        "definition">]</span></p>

        <p>Note that a processor that does not claim conformance
        with the backwards compatibility feature <span class=
        "verb">must</span> raise a <a title=
        "non-recoverable dynamic error" href=
        "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
        error</a> if an instruction is evaluated containing an
        <code>[xsl:]version</code> attribute that invokes backwards
        compatible behavior <span class="error">[see <a href=
        "index.html#err-XTDE0160">ERR XTDE0160</a>]</span>.</p>

        <div class="note">
          <p class="prefix"><b>Note:</b></p>

          <p>The reason this is a dynamic error rather than a
          static error is to allow stylesheets to contain
          conditional logic, following different paths depending on
          whether the XSLT processor implements XSLT 1.0 or XSLT
          2.0. The selection of which path to use can be controlled
          by using the <a href=
          "index.html#function-system-property"><code>system-property</code></a>
          function to test the <code>xsl:version</code> system
          property.</p>
        </div>

        <p>A processor that claims conformance with the backwards
        compatibility feature <span class="verb">must</span> permit
        the use of the namespace axis in XPath expressions when
        backwards compatible behavior is enabled. In all other
        circumstances, support for the namespace axis is
        optional.</p>
      </div>
    </div>
  </div>

  <div class="back">
    <div class="div1">
      <h2><a name="references" id="references"></a>A
      References</h2>

      <div class="div2">
        <h3><a name="normative-references" id=
        "normative-references"></a>A.1 Normative References</h3>

        <dl>
          <dt class="label"><span><a name="xpath-datamodel" id=
          "xpath-datamodel"></a>Data Model</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xpath-datamodel/"><cite>XQuery
              1.0 and XPath 2.0 Data Model (XDM)</cite></a>, Norman
              Walsh, Mary Fernández, Ashok Malhotra, <em>et.
              al.</em>, Editors. World Wide Web Consortium, 23 Jan
              2007. This version is
              http://www.w3.org/TR/2007/REC-xpath-datamodel-20070123/.
              The <a href=
              "http://www.w3.org/TR/xpath-datamodel/">latest
              version</a> is available at
              http://www.w3.org/TR/xpath-datamodel/.
            </div>
          </dd>

          <dt class="label"><span><a name="xpath-functions" id=
          "xpath-functions"></a>Functions and Operators</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xpath-functions/"><cite>XQuery
              1.0 and XPath 2.0 Functions and Operators</cite></a>,
              Ashok Malhotra, Jim Melton, and Norman Walsh,
              Editors. World Wide Web Consortium, 23 Jan 2007. This
              version is
              http://www.w3.org/TR/2007/REC-xpath-functions-20070123/.
              The <a href=
              "http://www.w3.org/TR/xpath-functions/">latest
              version</a> is available at
              http://www.w3.org/TR/xpath-functions/.
            </div>
          </dd>

          <dt class="label"><span><a name="xml-infoset" id=
          "xml-infoset"></a>XML Information Set</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xml-infoset"><cite>XML
              Information Set (Second Edition)</cite></a>, John
              Cowan and Richard Tobin, Editors. World Wide Web
              Consortium, 04&#160;Feb&#160;2004. This version is
              http://www.w3.org/TR/2004/REC-xml-infoset-20040204.
              The <a href="http://www.w3.org/TR/xml-infoset">latest
              version</a> is available at
              http://www.w3.org/TR/xml-infoset.
            </div>
          </dd>

          <dt class="label"><span><a name="ISO3166" id=
          "ISO3166"></a>ISO 3166-1</span></dt>

          <dd>
            <div>
              ISO (International Organization for Standardization)
              <em>Codes for the representation of names of
              countries and their subdivisions - Part 1: Country
              codes</em> ISO 3166-1:1997.
            </div>
          </dd>

          <dt class="label"><span><a name="ISO8601" id=
          "ISO8601"></a>ISO 8601</span></dt>

          <dd>
            <div>
              ISO (International Organization for Standardization)
              <em>Data elements and interchange formats -
              Information interchange - Representation of dates and
              times.</em> ISO 8601:2000(E), Second edition,
              2000-12-15.
            </div>
          </dd>

          <dt class="label"><span><a name=
          "xslt-xquery-serialization" id=
          "xslt-xquery-serialization"></a>XSLT and XQuery
          Serialization</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xslt-xquery-serialization/"><cite>
              XSLT 2.0 and XQuery 1.0 Serialization</cite></a>,
              Joanne Tong, Michael Kay, Norman Walsh, <em>et.
              al.</em>, Editors. World Wide Web Consortium, 23 Jan
              2007. This version is
              http://www.w3.org/TR/2007/REC-xslt-xquery-serialization-20070123/.
              The <a href=
              "http://www.w3.org/TR/xslt-xquery-serialization/">latest
              version</a> is available at
              http://www.w3.org/TR/xslt-xquery-serialization/.
            </div>
          </dd>

          <dt class="label"><span><a name="REC-xml" id=
          "REC-xml"></a>XML 1.0</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xml"><cite>Extensible
              Markup Language (XML) 1.0 (Fourth
              Edition)</cite></a>, Eve Maler, Jean Paoli, François
              Yergeau, <em>et. al.</em>, Editors. World Wide Web
              Consortium, 16&#160;Aug&#160;2006. This version is
              http://www.w3.org/TR/2006/REC-xml-20060816. The
              <a href="http://www.w3.org/TR/xml">latest version</a>
              is available at http://www.w3.org/TR/xml.
            </div>
          </dd>

          <dt class="label"><span><a name="xml11" id=
          "xml11"></a>XML 1.1</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xml11/"><cite>Extensible Markup
              Language (XML) 1.1 (Second Edition)</cite></a>, Tim
              Bray, John Cowan, Jean Paoli, <em>et. al.</em>,
              Editors. World Wide Web Consortium,
              16&#160;Aug&#160;2006. This version is
              http://www.w3.org/TR/2006/REC-xml11-20060816. The
              <a href="http://www.w3.org/TR/xml11/">latest
              version</a> is available at
              http://www.w3.org/TR/xml11/.
            </div>
          </dd>

          <dt class="label"><span><a name="xmlbase" id=
          "xmlbase"></a>XML Base</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xmlbase/"><cite>XML
              Base</cite></a>, Jonathan Marsh, Editor. World Wide
              Web Consortium, 27&#160;Jun&#160;2001. This version
              is http://www.w3.org/TR/2001/REC-xmlbase-20010627/.
              The <a href="http://www.w3.org/TR/xmlbase/">latest
              version</a> is available at
              http://www.w3.org/TR/xmlbase/.
            </div>
          </dd>

          <dt class="label"><span><a name="xml-id" id=
          "xml-id"></a>xml:id</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xml-id/"><cite>xml:id
              Version 1.0</cite></a>, Norman Walsh, Daniel
              Veillard, and Jonathan Marsh, Editors. World Wide Web
              Consortium, 09&#160;Sep&#160;2005. This version is
              http://www.w3.org/TR/2005/REC-xml-id-20050909/. The
              <a href="http://www.w3.org/TR/xml-id/">latest
              version</a> is available at
              http://www.w3.org/TR/xml-id/.
            </div>
          </dd>

          <dt class="label"><span><a name="REC-xml-names" id=
          "REC-xml-names"></a>Namespaces in XML 1.0</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/REC-xml-names"><cite>Namespaces
              in XML</cite></a>, Andrew Layman, Dave Hollander, and
              Tim Bray, Editors. World Wide Web Consortium,
              14&#160;Jan&#160;1999. This version is
              http://www.w3.org/TR/1999/REC-xml-names-19990114. The
              <a href="http://www.w3.org/TR/REC-xml-names">latest
              version</a> is available at
              http://www.w3.org/TR/REC-xml-names.
            </div>
          </dd>

          <dt class="label"><span><a name="xml-names11" id=
          "xml-names11"></a>Namespaces in XML 1.1</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xml-names11/"><cite>Namespaces
              in XML 1.1 (Second Edition)</cite></a>, Tim Bray,
              Dave Hollander, Andrew Layman, and Richard Tobin,
              Editors. World Wide Web Consortium,
              16&#160;Aug&#160;2006. This version is
              http://www.w3.org/TR/2006/REC-xml-names11-20060816.
              The <a href=
              "http://www.w3.org/TR/xml-names11/">latest
              version</a> is available at
              http://www.w3.org/TR/xml-names11/.
            </div>
          </dd>

          <dt class="label"><span><a name="xmlschema-1" id=
          "xmlschema-1"></a>XML Schema Part 1</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xmlschema-1/"><cite>XML
              Schema Part 1: Structures Second Edition</cite></a>,
              Henry S. Thompson, David Beech, Noah Mendelsohn, and
              Murray Maloney, Editors. World Wide Web Consortium,
              28&#160;Oct&#160;2004. This version is
              http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/.
              The <a href=
              "http://www.w3.org/TR/xmlschema-1/">latest
              version</a> is available at
              http://www.w3.org/TR/xmlschema-1/.
            </div>
          </dd>

          <dt class="label"><span><a name="xmlschema-2" id=
          "xmlschema-2"></a>XML Schema Part 2</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xmlschema-2/"><cite>XML
              Schema Part 2: Datatypes Second Edition</cite></a>,
              Paul V. Biron and Ashok Malhotra, Editors. World Wide
              Web Consortium, 28&#160;Oct&#160;2004. This version
              is
              http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/.
              The <a href=
              "http://www.w3.org/TR/xmlschema-2/">latest
              version</a> is available at
              http://www.w3.org/TR/xmlschema-2/.
            </div>
          </dd>

          <dt class="label"><span><a name="xpath20" id=
          "xpath20"></a>XPath 2.0</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xpath20/"><cite>XML
              Path Language (XPath) 2.0</cite></a>, Don Chamberlin
              , Anders Berglund, Scott Boag, <em>et. al.</em>,
              Editors. World Wide Web Consortium, 23 Jan 2007. This
              version is
              http://www.w3.org/TR/2007/REC-xpath20-20070123/. The
              <a href="http://www.w3.org/TR/xpath20/">latest
              version</a> is available at
              http://www.w3.org/TR/xpath20/.
            </div>
          </dd>
        </dl>
      </div>

      <div class="div2">
        <h3><a name="other-references" id=
        "other-references"></a>A.2 Other References</h3>

        <dl>
          <dt class="label"><span><a name="CALCALC" id=
          "CALCALC"></a>Calendrical Calculations</span></dt>

          <dd>
            <div>
              Edward M. Reingold and Nachum Dershowitz.
              <em>Calendrical Calculations Millennium edition (2nd
              Edition)</em>. Cambridge University Press, ISBN 0 521
              77752 6
            </div>
          </dd>

          <dt class="label"><span><a name="DOM-Level-2-Core" id=
          "DOM-Level-2-Core"></a>DOM Level 2</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/DOM-Level-2-Core/"><cite>Document
              Object Model (DOM) Level 2 Core
              Specification</cite></a>, Philippe Le Hégaret, Steve
              Byrne, Arnaud Le Hors, <em>et. al.</em>, Editors.
              World Wide Web Consortium, 13&#160;Nov&#160;2000.
              This version is
              http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113.
              The <a href=
              "http://www.w3.org/TR/DOM-Level-2-Core/">latest
              version</a> is available at
              http://www.w3.org/TR/DOM-Level-2-Core/.
            </div>
          </dd>

          <dt class="label"><span><a name="RFC2119" id=
          "RFC2119"></a>RFC2119</span></dt>

          <dd>
            <div>
              S. Bradner. <em>Key words for use in RFCs to Indicate
              Requirement Levels</em>. IETF RFC 2119. See <a href=
              "http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>.
            </div>
          </dd>

          <dt class="label"><span><a name="RFC2376" id=
          "RFC2376"></a>RFC2376</span></dt>

          <dd>
            <div>
              E. Whitehead, M. Murata. <em>XML Media Types</em>.
              IETF RFC 2376. See <a href=
              "http://www.ietf.org/rfc/rfc2376.txt">http://www.ietf.org/rfc/rfc2376.txt</a>.
            </div>
          </dd>

          <dt class="label"><span><a name="RFC3023" id=
          "RFC3023"></a>RFC3023</span></dt>

          <dd>
            <div>
              M. Murata, S. St.Laurent, and D. Cohn. <em>XML Media
              Types</em>. IETF RFC 3023. See <a href=
              "http://www.ietf.org/rfc/rfc3023.txt">http://www.ietf.org/rfc/rfc3023.txt</a>.
              <span>References to RFC 3023 should be taken to refer
              to any document that supersedes RFC 3023.</span>
            </div>
          </dd>

          <dt class="label"><span><a name="RFC3986" id=
          "RFC3986"></a>RFC3986</span></dt>

          <dd>
            <div>
              T. Berners-Lee, R. Fielding, and L. Masinter.
              <em>Uniform Resource Identifiers (URI): Generic
              Syntax</em>. IETF RFC 3986. See <a href=
              "http://www.ietf.org/rfc/rfc3986.txt">http://www.ietf.org/rfc/rfc3986.txt</a>.
            </div>
          </dd>

          <dt class="label"><span><a name="RFC3987" id=
          "RFC3987"></a>RFC3987</span></dt>

          <dd>
            <div>
              M. Duerst, M. Suignard. <em>Internationalized
              Resource Identifiers (IRIs)</em>. IETF RFC 3987. See
              <a href=
              "http://www.ietf.org/rfc/rfc3987.txt">http://www.ietf.org/rfc/rfc3987.txt</a>.
            </div>
          </dd>

          <dt class="label"><span><a name="UNICODE-TR10" id=
          "UNICODE-TR10"></a>UNICODE TR10</span></dt>

          <dd>
            <div>
              Unicode Consortium. <em>Unicode Technical Standard
              #10. Unicode Collation Algorithm</em>. Unicode
              Technical Report. See <a href=
              "http://www.unicode.org/unicode/reports/tr10/">http://www.unicode.org/unicode/reports/tr10/</a>.
            </div>
          </dd>

          <dt class="label"><span><a name="xinclude" id=
          "xinclude"></a>XInclude</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xinclude/"><cite>XML
              Inclusions (XInclude) Version 1.0 (Second
              Edition)</cite></a>, David Orchard, Jonathan Marsh,
              and Daniel Veillard, Editors. World Wide Web
              Consortium, 15&#160;Nov&#160;2006. This version is
              http://www.w3.org/TR/2006/REC-xinclude-20061115/. The
              <a href="http://www.w3.org/TR/xinclude/">latest
              version</a> is available at
              http://www.w3.org/TR/xinclude/.
            </div>
          </dd>

          <dt class="label"><span><a name="xlink" id=
          "xlink"></a>XLink</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xlink/"><cite>XML
              Linking Language (XLink) Version 1.0</cite></a>,
              David Orchard, Eve Maler, and Steven DeRose, Editors.
              World Wide Web Consortium, 27&#160;Jun&#160;2001.
              This version is
              http://www.w3.org/TR/2001/REC-xlink-20010627/. The
              <a href="http://www.w3.org/TR/xlink/">latest
              version</a> is available at
              http://www.w3.org/TR/xlink/.
            </div>
          </dd>

          <dt class="label"><span><a name="SCHEMA-AND-XML-1.1" id=
          "SCHEMA-AND-XML-1.1"></a>XML Schema 1.0 and XML
          1.1</span></dt>

          <dd>
            <div>
              World Wide Web Consortium. <em>Processing XML 1.1
              documents with XML Schema 1.0 processors</em>. W3C
              Working Group Note 11 May 2005. See <a href=
              "http://www.w3.org/TR/2005/NOTE-xml11schema10-20050511/">
              http://www.w3.org/TR/2005/NOTE-xml11schema10-20050511/</a>
            </div>
          </dd>

          <dt class="label"><span><a name="xml-stylesheet" id=
          "xml-stylesheet"></a>XML Stylesheet</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xml-stylesheet"><cite>Associating
              Style Sheets with XML documents</cite></a>, James
              Clark, Editor. World Wide Web Consortium,
              29&#160;Jun&#160;1999. This version is
              http://www.w3.org/1999/06/REC-xml-stylesheet-19990629.
              The <a href=
              "http://www.w3.org/TR/xml-stylesheet">latest
              version</a> is available at
              http://www.w3.org/TR/xml-stylesheet.
            </div>
          </dd>

          <dt class="label"><span><a name="xptr-framework" id=
          "xptr-framework"></a>XPointer Framework</span></dt>

          <dd>
            <div>
              <a href=
              "http://www.w3.org/TR/xptr-framework/"><cite>XPointer
              Framework</cite></a>, Paul Grosso, Jonathan Marsh,
              Eve Maler, and Norman Walsh, Editors. World Wide Web
              Consortium, 25&#160;Mar&#160;2003. This version is
              http://www.w3.org/TR/2003/REC-xptr-framework-20030325/.
              The <a href=
              "http://www.w3.org/TR/xptr-framework/">latest
              version</a> is available at
              http://www.w3.org/TR/xptr-framework/.
            </div>
          </dd>

          <dt class="label"><span><a name="xsl" id=
          "xsl"></a>Extensible Stylesheet Language
          (XSL)</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xsl/"><cite>Extensible
              Stylesheet Language (XSL) Version 1.1</cite></a>,
              Anders Berglund, Editor. World Wide Web Consortium,
              05&#160;Dec&#160;2006. This version is
              http://www.w3.org/TR/2006/REC-xsl11-20061205/. The
              <a href="http://www.w3.org/TR/xsl/">latest
              version</a> is available at
              http://www.w3.org/TR/xsl/.
            </div>
          </dd>

          <dt class="label"><span><a name="xslt" id="xslt"></a>XSLT
          1.0</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xslt"><cite>XSL
              Transformations (XSLT) Version 1.0</cite></a>, James
              Clark, Editor. World Wide Web Consortium,
              16&#160;Nov&#160;1999. This version is
              http://www.w3.org/TR/1999/REC-xslt-19991116. The
              <a href="http://www.w3.org/TR/xslt">latest
              version</a> is available at
              http://www.w3.org/TR/xslt.
            </div>
          </dd>

          <dt class="label"><span><a name="xslt20req" id=
          "xslt20req"></a>XSLT 2.0 Requirements</span></dt>

          <dd>
            <div>
              <a href="http://www.w3.org/TR/xslt20req"><cite>XSLT
              Requirements Version 2.0</cite></a>, Steve Muench and
              Mark Scardina, Editors. World Wide Web Consortium,
              14&#160;Feb&#160;2001. This version is
              http://www.w3.org/TR/2001/WD-xslt20req-20010214. The
              <a href="http://www.w3.org/TR/xslt20req">latest
              version</a> is available at
              http://www.w3.org/TR/xslt20req.
            </div>
          </dd>
        </dl>
      </div>
    </div>

    <div class="div1">
      <h2><a name="xslt-mime-definition" id=
      "xslt-mime-definition"></a>B The XSLT Media Type</h2>

      <p>This appendix registers a new MIME media type,
      "<code>application/xslt+xml</code>".</p>

      <p>This information is being submitted to the IESG (Internet
      Engineering Steering Group) for review, approval, and
      registration with IANA (the Internet Assigned Numbers
      Authority).</p>

      <div class="div2">
        <h3><a name="media-type-registration" id=
        "media-type-registration"></a>B.1 Registration of MIME
        Media Type application/xslt+xml</h3>

        <dl>
          <dt class="label">MIME media type name:</dt>

          <dd>
            <p><code>application</code></p>
          </dd>

          <dt class="label">MIME subtype name:</dt>

          <dd>
            <p><code>xslt+xml</code></p>
          </dd>

          <dt class="label">Required parameters:</dt>

          <dd>
            <p>None.</p>
          </dd>

          <dt class="label">Optional parameters:</dt>

          <dd>
            <dl>
              <dt class="label"><code>charset</code></dt>

              <dd>
                <p>This parameter has identical semantics to the
                <code>charset</code> parameter of the
                <code>application/xml</code> media type as
                specified in <a href="index.html#RFC3023">[RFC3023]</a>.</p>
              </dd>
            </dl>
          </dd>

          <dt class="label">Encoding considerations:</dt>

          <dd>
            <p>By virtue of XSLT content being XML, it has the same
            considerations when sent as
            "<code>application/xslt+xml</code>" as does XML. See
            RFC 3023, section 3.2.</p>
          </dd>

          <dt class="label">Security considerations:</dt>

          <dd>
            <p>Several XSLT instructions may cause arbitrary URIs
            to be dereferenced. In this case, the security issues
            of <span><a href="index.html#RFC3986">[RFC3986]</a>, section
            7,</span> should be considered.</p>

            <p>In addition, because of the extensibility features
            for XSLT, it is possible that
            "<code>application/xslt+xml</code>" may describe
            content that has security implications beyond those
            described here. However, if the processor follows only
            the normative semantics of this specification, this
            content will be ignored. Only in the case where the
            processor recognizes and processes the additional
            content, or where further processing of that content is
            dispatched to other processors, would security issues
            potentially arise. And in that case, they would fall
            outside the domain of this registration document.</p>
          </dd>

          <dt class="label">Interoperability considerations:</dt>

          <dd>
            <p>This specification describes processing semantics
            that dictate behavior that must be followed when
            dealing with, among other things, unrecognized
            elements.</p>

            <p>Because XSLT is extensible, conformant
            "<code>application/xslt+xml</code>" processors can
            expect that content received is well-formed XML, but it
            cannot be guaranteed that the content is valid XSLT or
            that the processor will recognize all of the elements
            and attributes in the document.</p>
          </dd>

          <dt class="label">Published specification:</dt>

          <dd>
            <p>This media type registration is for XSLT stylesheet
            modules as described by the XSLT 2.0 specification,
            <span>which is located at <a href=
            "http://www.w3.org/TR/xslt20/">http://www.w3.org/TR/xslt20/</a>.</span>
            It is also appropriate to use this media type with
            earlier and later versions of the XSLT language.</p>
          </dd>

          <dt class="label">Applications which use this media
          type:</dt>

          <dd>
            <p>Existing XSLT 1.0 stylesheets are most often
            described using the unregistered media type
            "<code>text/xsl</code>".</p>

            <p>There is no experimental, vendor specific, or
            personal tree predecessor to
            "<code>application/xslt+xml</code>", reflecting the
            fact that no applications currently recognize it. This
            new type is being registered in order to allow for the
            expected deployment of XSLT 2.0 on the World Wide Web,
            as a first class XML application.</p>
          </dd>

          <dt class="label">Additional information:</dt>

          <dd>
            <dl>
              <dt class="label">Magic number(s):</dt>

              <dd>
                <p>There is no single initial octet sequence that
                is always present in XSLT documents.</p>
              </dd>

              <dt class="label">File extension(s):</dt>

              <dd>
                <p>XSLT documents are most often identified with
                the extensions "<code>.xsl</code>" or
                "<code>.xslt</code>".</p>
              </dd>

              <dt class="label">Macintosh File Type Code(s):</dt>

              <dd>
                <p>TEXT</p>
              </dd>
            </dl>
          </dd>

          <dt class="label">Person &amp; email address to contact
          for further information:</dt>

          <dd>
            <p>Norman Walsh, <code>&lt;<a href=
            "mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>&gt;</code>.</p>
          </dd>

          <dt class="label">Intended usage:</dt>

          <dd>
            <p>COMMON</p>
          </dd>

          <dt class="label">Author/Change controller:</dt>

          <dd>
            <p>The XSLT specification is a work product of the
            World Wide Web Consortium's XSL Working Group. The W3C
            has change control over these specifications.</p>
          </dd>
        </dl>
      </div>

      <div class="div2">
        <h3><a name="media-type-fragid" id=
        "media-type-fragid"></a>B.2 Fragment Identifiers</h3>

        <p>For documents labeled as
        "<code>application/xslt+xml</code>", the fragment
        identifier notation is exactly that for
        "<code>application/xml</code>", as specified in RFC
        3023.</p>
      </div>
    </div>

    <div class="div1">
      <h2><a name="glossary" id="glossary"></a>C Glossary
      (Non-Normative)</h2>

      <dl>
        <dt><a href="index.html#dt-qname">QName</a></dt>

        <dd>
          <p>A <b>QName</b> is always written in the form
          <code>(NCName ":")? NCName</code>, that is, a local name
          optionally preceded by a namespace prefix. When two
          QNames are compared, however, they are considered equal
          if the corresponding <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QNames</a> are the same, as
          described below.</p>
        </dd>

        <dt><a href="index.html#dt-uri-reference">URI Reference</a></dt>

        <dd>
          <p>Within this specification, the term <b>URI
          Reference</b>, unless otherwise stated, refers to a
          string in the lexical space of the <code>xs:anyURI</code>
          data type as defined in <a href="index.html#xmlschema-2">[XML
          Schema Part 2]</a>.</p>
        </dd>

        <dt><a href="index.html#xml-namespace">XML namespace</a></dt>

        <dd>
          <p>The <b>XML namespace</b>, <span>defined in <a href=
          "index.html#REC-xml-names">[Namespaces in XML 1.0]</a> as
          <code>http://www.w3.org/XML/1998/namespace</code></span>,
          is used for attributes such as <code>xml:lang</code>,
          <code>xml:space</code>, and <code>xml:id</code>.</p>
        </dd>

        <dt><a href="index.html#dt-compatibility-mode">XPath 1.0
        compatibility mode</a></dt>

        <dd>
          <p>The term <b>XPath 1.0 compatibility mode</b> is
          defined in <a href=
          "http://www.w3.org/TR/xpath20/#static_context">Section
          2.1.1 Static Context</a><sup><small>XP</small></sup>.
          This is a setting in the static context of an XPath
          expression; it has two values, <code>true</code> and
          <code>false</code>. When the value is set to true, the
          semantics of function calls and certain other operations
          are adjusted to give a greater degree of backwards
          compatibility between XPath 2.0 and XPath 1.0.</p>
        </dd>

        <dt><a href="index.html#dt-xslt-element">XSLT element</a></dt>

        <dd>
          <p>An <b>XSLT element</b> is an element in the <a title=
          "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a> whose syntax and semantics are defined in
          this specification.</p>
        </dd>

        <dt><a href="index.html#dt-xslt-instruction">XSLT
        instruction</a></dt>

        <dd>
          <p>An <b>XSLT instruction</b> is an <a title=
          "XSLT element" href="index.html#dt-xslt-element">XSLT element</a>
          whose syntax summary in this specification contains the
          annotation <code>&lt;!-- category: instruction
          --&gt;</code>.</p>
        </dd>

        <dt><a href="index.html#dt-xslt-namespace">XSLT namespace</a></dt>

        <dd>
          <p>The <b>XSLT namespace</b> has the URI
          <code>http://www.w3.org/1999/XSL/Transform</code>. It is
          used to identify elements, attributes, and other names
          that have a special meaning defined in this
          specification.</p>
        </dd>

        <dt><a href="index.html#dt-alias">alias</a></dt>

        <dd>
          <p>A stylesheet can use the <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          element to declare that a <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> is
          being used as an <b>alias</b> for a <a title=
          "target namespace URI" href=
          "index.html#dt-target-namespace-uri">target namespace URI</a>.</p>
        </dd>

        <dt><a href="index.html#dt-arity">arity</a></dt>

        <dd>
          <p>The <b>arity</b> of a stylesheet function is the
          number of <a href=
          "index.html#element-param"><code>xsl:param</code></a> elements in
          the function definition.</p>
        </dd>

        <dt><a href="index.html#dt-atomization">atomize</a></dt>

        <dd>
          <p>The term <b>atomization</b> is defined in <a href=
          "http://www.w3.org/TR/xpath20/#id-atomization">Section
          2.4.2 Atomization</a><sup><small>XP</small></sup>. It is
          a process that takes as input a sequence of nodes and
          atomic values, and returns a sequence of atomic values,
          in which the nodes are replaced by their typed values as
          defined in <a href="index.html#xpath-datamodel">[Data
          Model]</a>.</p>
        </dd>

        <dt><a href="index.html#dt-attribute-set">attribute set</a></dt>

        <dd>
          <p>The <a href=
          "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
          element defines a named <b>attribute set</b>: that is, a
          collection of attribute <span>definitions</span> that can
          be used repeatedly on different constructed elements.</p>
        </dd>

        <dt><a href="index.html#dt-attribute-value-template">attribute value
        template</a></dt>

        <dd>
          <p>In an attribute that is designated as an <b>attribute
          value template</b>, such as an attribute of a <a title=
          "literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>,
          an <a title="expression" href=
          "index.html#dt-expression">expression</a> can be used by
          surrounding the expression with curly brackets
          (<code>{}</code>)</p>
        </dd>

        <dt><a href="index.html#dt-backwards-compatibility-feature">backwards
        compatibility feature</a></dt>

        <dd>
          <p>A processor that claims conformance with the
          <b>backwards compatibility feature</b> <span class=
          "verb">must</span> support the processing of stylesheet
          instructions and XPath expressions with <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a>, as defined in <a href="index.html#backwards"><i>3.8
          Backwards-Compatible Processing</i></a>.</p>
        </dd>

        <dt><a href="index.html#dt-backwards-compatible-behavior">backwards
        compatible behavior</a></dt>

        <dd>
          <p>An element enables backwards-compatible behavior for
          itself, its attributes, its descendants and their
          attributes if it has an <code>[xsl:]version</code>
          attribute (see <a href="index.html#standard-attributes"><i>3.5
          Standard Attributes</i></a>) whose value is less than
          <code>2.0</code>.</p>
        </dd>

        <dt><a href="index.html#dt-base-output-uri">base output URI</a></dt>

        <dd>
          <p>The <b>base output URI</b> is a URI to be used as the
          base URI when resolving a relative URI allocated to a
          <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a>. If the
          transformation generates more than one final result tree,
          then typically each one will be allocated a URI relative
          to this base URI.</p>
        </dd>

        <dt><a href="index.html#dt-basic-xslt-processor">basic XSLT
        processor</a></dt>

        <dd>
          <p>A <b>basic XSLT processor</b> is an XSLT processor
          that implements all the mandatory requirements of this
          specification with the exception of certain
          explicitly-identified constructs related to schema
          processing.</p>
        </dd>

        <dt><a href="index.html#dt-character-map">character map</a></dt>

        <dd>
          <p>A <b>character map</b> allows a specific character
          appearing in a text or attribute node in the <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a> to be substituted by a specified string
          of characters during serialization.</p>
        </dd>

        <dt><a href="index.html#dt-circularity">circularity</a></dt>

        <dd>
          <p>A <b>circularity</b> is said to exist if a construct
          such as a <a title="global variable" href=
          "index.html#dt-global-variable">global variable</a>, an <a title=
          "attribute set" href="index.html#dt-attribute-set">attribute
          set</a>, or a <a title="key" href="index.html#dt-key">key</a> is
          defined in terms of itself. For example, if the <a title=
          "expression" href="index.html#dt-expression">expression</a> or
          <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>
          specifying the value of a <a title="global variable"
          href="index.html#dt-global-variable">global variable</a>
          <var>X</var> references a global variable <var>Y</var>,
          then the value for <var>Y</var> <span class=
          "verb">must</span> be computed before the value of
          <var>X</var>. A circularity exists if it is impossible to
          do this for all global variable definitions.</p>
        </dd>

        <dt><a href="index.html#dt-collation">collation</a></dt>

        <dd>
          <p>Facilities in XSLT 2.0 and XPath 2.0 that require
          strings to be ordered rely on the concept of a named
          <b>collation</b>. A collation is a set of rules that
          determine whether two strings are equal, and if not,
          which of them is to be sorted before the other.</p>
        </dd>

        <dt><a href="index.html#dt-context-item">context item</a></dt>

        <dd>
          <p>The <b>context item</b> is the item currently being
          processed. An item (see <a href="index.html#xpath-datamodel">[Data
          Model]</a>) is either an atomic value (such as an
          integer, date, or string), or a node. The context item is
          initially set to the <a title="initial context node"
          href="index.html#dt-initial-context-node">initial context node</a>
          supplied when the transformation is invoked (see <a href=
          "index.html#initiating"><i>2.3 Initiating a
          Transformation</i></a>). It changes whenever instructions
          such as <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          and <a href=
          "index.html#element-for-each"><code>xsl:for-each</code></a> are
          used to process a sequence of items; each item in such a
          sequence becomes the context item while that item is
          being processed.</p>
        </dd>

        <dt><a href="index.html#dt-context-node">context node</a></dt>

        <dd>
          <p>If the <a title="context item" href=
          "index.html#dt-context-item">context item</a> is a node (as
          distinct from an atomic value such as an integer), then
          it is also referred to as the <b>context node</b>. The
          context node is not an independent variable, it changes
          whenever the context item changes. When the context item
          is an atomic value, there is no context node.</p>
        </dd>

        <dt><a href="index.html#dt-context-position">context
        position</a></dt>

        <dd>
          <p>The <b>context position</b> is the position of the
          context item within the sequence of items currently being
          processed. It changes whenever the context item changes.
          When an instruction such as <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          or <a href=
          "index.html#element-for-each"><code>xsl:for-each</code></a> is used
          to process a sequence of items, the first item in the
          sequence is processed with a context position of 1, the
          second item with a context position of 2, and so on.</p>
        </dd>

        <dt><a href="index.html#dt-context-size">context size</a></dt>

        <dd>
          <p>The <b>context size</b> is the number of items in the
          sequence of items currently being processed. It changes
          whenever instructions such as <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          and <a href=
          "index.html#element-for-each"><code>xsl:for-each</code></a> are
          used to process a sequence of items; during the
          processing of each one of those items, the context size
          is set to the count of the number of items in the
          sequence (or equivalently, the position of the last item
          in the sequence).</p>
        </dd>

        <dt><a href="index.html#dt-core-function">core function</a></dt>

        <dd>
          <p>The term <b>core function</b> means a function that is
          specified in <a href="index.html#xpath-functions">[Functions and
          Operators]</a> and that is in the <a title=
          "standard function namespace" href=
          "index.html#dt-standard-function-namespace">standard function
          namespace</a>.</p>
        </dd>

        <dt><a href="index.html#dt-current-captured-substrings">current
        captured substrings</a></dt>

        <dd>
          <p>While the <a href=
          "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
          instruction is active, a set of <b>current captured
          substrings</b> is available, corresponding to the
          parenthesized sub-expressions of the regular
          expression.</p>
        </dd>

        <dt><a href="index.html#dt-current-group">current group</a></dt>

        <dd>
          <p>The evaluation context for XPath <a title="expression"
          href="index.html#dt-expression">expressions</a> includes a
          <span>component</span> called the <b>current group</b>,
          which is a sequence. The current group is the collection
          of related items that are processed collectively in one
          iteration of the <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          element.</p>
        </dd>

        <dt><a href="index.html#dt-current-grouping-key">current grouping
        key</a></dt>

        <dd>
          <p>The evaluation context for XPath <a title="expression"
          href="index.html#dt-expression">expressions</a> includes a
          component called the <b>current grouping key</b>, which
          is an atomic value. The current grouping key is <span>the
          <a title="grouping key" href="index.html#dt-grouping-key">grouping
          key</a></span> shared in common by all the items within
          the <a title="current group" href=
          "index.html#dt-current-group">current group</a>.</p>
        </dd>

        <dt><a href="index.html#dt-current-mode">current mode</a></dt>

        <dd>
          <p>At any point in the processing of a stylesheet, there
          is a <b>current mode</b>. When the transformation is
          initiated, the current mode is the <a title=
          "default mode" href="index.html#dt-default-mode">default mode</a>,
          <span>unless a different initial mode has been supplied,
          as described in <a href="index.html#initiating"><i>2.3 Initiating a
          Transformation</i></a>.</span> Whenever an <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction is evaluated, the current mode becomes the
          mode selected by this instruction.</p>
        </dd>

        <dt><a href="index.html#dt-current-template-rule">current template
        rule</a></dt>

        <dd>
          <p>At any point in the processing of a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>, there
          may be a <b>current template rule</b>. Whenever a
          <a title="template rule" href=
          "index.html#dt-template-rule">template rule</a> is chosen <span>as
          a result of evaluating <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>,
          the template rule becomes the current template rule for
          the evaluation of the rule's sequence constructor. When
          an <a href=
          "index.html#element-for-each"><code>xsl:for-each</code></a>,
          <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>,
          <span>or <a href=
          "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
          instruction is evaluated, or when evaluating a sequence
          constructor contained in an <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> or <a href=
          "index.html#element-key"><code>xsl:key</code></a> element, or
          when</span> a <a title="stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a> is
          called (see <a href="index.html#stylesheet-functions"><i>10.3
          Stylesheet Functions</i></a>), the current template rule
          becomes null for the evaluation of that instruction or
          function.</p>
        </dd>

        <dt><a href="index.html#dt-date-formatting-function">date formatting
        function</a></dt>

        <dd>
          <p>The three functions <a href=
          "index.html#function-format-date"><code>format-date</code></a>,
          <a href=
          "index.html#function-format-time"><code>format-time</code></a>, and
          <a href=
          "index.html#function-format-dateTime"><code>format-dateTime</code></a>
          are referred to collectively as the <b>date formatting
          functions</b>.</p>
        </dd>

        <dt><a href="index.html#dt-decimal-format">decimal format</a></dt>

        <dd>
          <p>All the <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declarations in a stylesheet that share the same name are
          grouped into a named <b>decimal format</b>; those that
          have no name are grouped into a single unnamed decimal
          format.</p>
        </dd>

        <dt><a href="index.html#dt-declaration">declaration</a></dt>

        <dd>
          <p>Top-level elements fall into two categories:
          declarations, and user-defined data elements. Top-level
          elements whose names are in the <a title="XSLT namespace"
          href="index.html#dt-xslt-namespace">XSLT namespace</a> are
          <b>declarations</b>. Top-level elements in any other
          namespace are <a title="user-defined data element" href=
          "index.html#dt-data-element">user-defined data elements</a> (see
          <a href="index.html#user-defined-top-level"><i>3.6.2 User-defined
          Data Elements</i></a>)</p>
        </dd>

        <dt><a href="index.html#dt-declaration-order">declaration
        order</a></dt>

        <dd>
          <p>The <a title="declaration" href=
          "index.html#dt-declaration">declarations</a> within a <a title=
          "stylesheet level" href="index.html#dt-stylesheet-level">stylesheet
          level</a> have a total ordering known as <b>declaration
          order</b>. The order of declarations within a stylesheet
          level is the same as the document order that would result
          if each stylesheet module were inserted textually in
          place of the <a href=
          "index.html#element-include"><code>xsl:include</code></a> element
          that references it.</p>
        </dd>

        <dt><a href="index.html#dt-default-collation">default
        collation</a></dt>

        <dd>
          <p>In this specification the term <b>default
          collation</b> means the collation that is used by XPath
          operators such as <code>eq</code> and <code>lt</code>
          appearing in XPath expressions within the stylesheet.</p>
        </dd>

        <dt><a href="index.html#dt-default-mode">default mode</a></dt>

        <dd>
          <p>There is always a <b>default mode</b> available. The
          default mode is an unnamed <a title="mode" href=
          "index.html#dt-mode">mode</a>, and it is used when no
          <code>mode</code> attribute is specified on an <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction.</p>
        </dd>

        <dt><a href="index.html#dt-default-priority">default
        priority</a></dt>

        <dd>
          <p>If no <code>priority</code> attribute is specified on
          the <a href=
          "index.html#element-template"><code>xsl:template</code></a>
          element, a <b>default priority</b> is computed, based on
          the syntax of the pattern supplied in the
          <code>match</code> attribute.</p>
        </dd>

        <dt><a href="index.html#dt-defining-element">defining
        element</a></dt>

        <dd>
          <p><span>A string in the form of a lexical QName</span>
          may occur as the value of an attribute node in a
          stylesheet module, or within an XPath <a title=
          "expression" href="index.html#dt-expression">expression</a>
          contained in such an attribute node, or as the result of
          evaluating an XPath expression contained in such an
          attribute node. The element containing this attribute
          node is referred to as the <b>defining element</b> of the
          QName.</p>
        </dd>

        <dt><a href="index.html#dt-deprecated">deprecated</a></dt>

        <dd>
          <p>Some constructs defined in this specification are
          described as being <b>deprecated</b>. The use of this
          term implies that stylesheet authors <span class=
          "verb">should not</span> use the construct, and that the
          construct may be removed in a later version of this
          specification.</p>
        </dd>

        <dt><a href="index.html#dt-dynamic-error">dynamic error</a></dt>

        <dd>
          <p>An error that is not detected until a source document
          is being transformed is referred to as a <b>dynamic
          error</b>.</p>
        </dd>

        <dt><a href="index.html#dt-effective-value">effective value</a></dt>

        <dd>
          <p>The result of evaluating an attribute value template
          is referred to as the <b>effective value</b> of the
          attribute.</p>
        </dd>

        <dt><a href="index.html#dt-embedded-stylesheet-module">embedded
        stylesheet module</a></dt>

        <dd>
          <p>An <b>embedded stylesheet module</b> is a stylesheet
          module that is embedded within another XML document,
          typically the source document that is being
          transformed.</p>
        </dd>

        <dt><a href="index.html#dt-expanded-qname">expanded-QName</a></dt>

        <dd>
          <p>An <b>expanded-QName</b> <span>contains a pair of
          values, namely a local name and an optional namespace
          URI. It may also contain a namespace prefix.</span> Two
          expanded-QNames are equal if the namespace URIs are the
          same (or both absent) and the local names are the same.
          <span>The prefix plays no part in the comparison, but is
          used only if the expanded-QName needs to be converted
          back to a string.</span></p>
        </dd>

        <dt><a href="index.html#dt-expression">expression</a></dt>

        <dd>
          <p>Within this specification, the term <b>XPath
          expression</b>, or simply <b>expression</b>, means a
          string that matches the production <span><a href=
          "http://www.w3.org/TR/xpath20/#doc-xpath-Expr">Expr</a><sup>
          <small>XP</small></sup></span> defined in <a href=
          "index.html#xpath20">[XPath 2.0]</a>.</p>
        </dd>

        <dt><a href="index.html#dt-extension-attribute">extension
        attribute</a></dt>

        <dd>
          <p>An element from the XSLT namespace may have any
          attribute not from the XSLT namespace, provided that the
          <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> (see <a href=
          "index.html#xpath20">[XPath 2.0]</a>) of the attribute has a
          non-null namespace URI. These attributes are referred to
          as <b>extension attributes</b>.</p>
        </dd>

        <dt><a href="index.html#dt-extension-function">extension
        function</a></dt>

        <dd>
          <p>An <b>extension function</b> is a function that is
          available for use within an XPath <a title="expression"
          href="index.html#dt-expression">expression</a>, other than a
          <a title="core function" href="index.html#dt-core-function">core
          function</a> defined in <a href=
          "index.html#xpath-functions">[Functions and Operators]</a>, an
          additional function defined in this XSLT specification,
          <span>a constructor function named after an atomic
          type,</span> or a <a title="stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a> defined
          using an <a href=
          "index.html#element-function"><code>xsl:function</code></a>
          declaration.</p>
        </dd>

        <dt><a href="index.html#dt-extension-instruction">extension
        instruction</a></dt>

        <dd>
          <p>An <b>extension instruction</b> is an element within a
          <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> that
          is in a namespace (not the <a title="XSLT namespace"
          href="index.html#dt-xslt-namespace">XSLT namespace</a>) designated
          as an extension namespace.</p>
        </dd>

        <dt><a href="index.html#dt-extension-namespace">extension
        namespace</a></dt>

        <dd>
          <p>The <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instruction</a>
          mechanism allows namespaces to be designated as
          <b>extension namespaces</b>. When a namespace is
          designated as an extension namespace and an element with
          a name from that namespace occurs in a <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, then
          the element is treated as an <a title="instruction" href=
          "index.html#dt-instruction">instruction</a> rather than as a
          <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result
          element</a>.</p>
        </dd>

        <dt><a href="index.html#dt-final-output-state">final output
        state</a></dt>

        <dd>
          <p>The first of the two <a title="output state" href=
          "index.html#dt-output-state">output states</a> is called <b>final
          output</b> state. This state applies when instructions
          are writing to a <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a>.</p>
        </dd>

        <dt><a href="index.html#dt-final-result-tree">final result
        tree</a></dt>

        <dd>
          <p>A <b>final result tree</b> is a <a title="result tree"
          href="index.html#dt-result-tree">result tree</a> that forms part of
          the final output of a transformation. Once created, the
          contents of a final result tree are not accessible within
          the stylesheet itself.</p>
        </dd>

        <dt><a href="index.html#dt-focus">focus</a></dt>

        <dd>
          <p>When a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> is
          evaluated, the <a title="processor" href=
          "index.html#dt-processor">processor</a> keeps track of which items
          are being processed by means of a set of implicit
          variables referred to collectively as the
          <b>focus</b>.</p>
        </dd>

        <dt><a href=
        "index.html#dt-forwards-compatible-behavior">forwards-compatible
        behavior</a></dt>

        <dd>
          <p>An element enables <b>forwards-compatible behavior</b>
          for itself, its attributes, its descendants and their
          attributes if it has an <code>[xsl:]version</code>
          attribute (see <a href="index.html#standard-attributes"><i>3.5
          Standard Attributes</i></a>) whose value is greater than
          <code>2.0</code>.</p>
        </dd>

        <dt><a href="index.html#dt-function-conversion-rules">function
        conversion rules</a></dt>

        <dd>
          <p>Except where otherwise indicated, the actual value of
          an <a title="expression" href=
          "index.html#dt-expression">expression</a> is converted to the
          <a title="required type" href=
          "index.html#dt-required-type">required type</a> using the
          <b>function conversion rules</b>. These are the rules
          defined in <a href="index.html#xpath20">[XPath 2.0]</a> for
          converting the supplied argument of a function call to
          the required type of that argument, as defined in the
          function signature. The relevant rules are those that
          apply when <a title="XPath 1.0 compatibility mode" href=
          "index.html#dt-compatibility-mode">XPath 1.0 compatibility mode</a>
          is set to <code>false</code>.</p>
        </dd>

        <dt><a href="index.html#dt-function-parameter">function
        parameter</a></dt>

        <dd>
          <p>An <a href="index.html#element-param"><code>xsl:param</code></a>
          element may appear as a child of an <a href=
          "index.html#element-function"><code>xsl:function</code></a>
          element, before any non-<a href=
          "index.html#element-param"><code>xsl:param</code></a> children of
          that element. Such a parameter is known as a <b>function
          parameter</b>. A function parameter is a <a title=
          "local variable" href="index.html#dt-local-variable">local
          variable</a> with the additional property that its value
          can be set when the function is called, using a function
          call in an XPath <a title="expression" href=
          "index.html#dt-expression">expression</a>.</p>
        </dd>

        <dt><a href="index.html#dt-global-variable">global variable</a></dt>

        <dd>
          <p>A top-level <a title="variable-binding element" href=
          "index.html#dt-variable-binding-element">variable-binding
          element</a> declares a <b>global variable</b> that is
          visible everywhere (except where it is <a title="shadows"
          href="index.html#dt-shadows">shadowed</a> by another binding).</p>
        </dd>

        <dt><a href="index.html#dt-group">group</a></dt>

        <dd>
          <p>The <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          instruction <span>allocates the items in an input
          sequence</span> into <b>groups</b> of items (that is, it
          establishes a collection of sequences) based either on
          common values of a grouping key, or on a <a title=
          "pattern" href="index.html#dt-pattern">pattern</a> that the initial
          or final node in a group must match.</p>
        </dd>

        <dt><a href="index.html#dt-grouping-key">grouping key</a></dt>

        <dd>
          <p>If either of the <code>group-by</code> attribute or
          <code>group-adjacent</code> attributes is present, then
          <b>grouping keys</b> are calculated for each item in the
          <a title="population" href=
          "index.html#dt-population">population</a>. <span>The grouping keys
          are the items in the sequence obtained by evaluating the
          expression contained in the <code>group-by</code>
          attribute or <code>group-adjacent</code> attribute,
          atomizing the result, and then casting an
          <code>xs:untypedAtomic</code> value to
          <code>xs:string</code>.</span></p>
        </dd>

        <dt><a href="index.html#dt-implementation">implementation</a></dt>

        <dd>
          <p>A specific product that performs the functions of an
          <a title="processor" href="index.html#dt-processor">XSLT
          processor</a> is referred to as an
          <b>implementation</b></p>
        </dd>

        <dt><a href=
        "index.html#dt-implementation-defined">implementation-defined</a></dt>

        <dd>
          <p>In this specification, the term
          <b>implementation-defined</b> refers to a feature where
          the implementation is allowed some flexibility, and where
          the choices made by the implementation <span class=
          "verb">must</span> be described in documentation that
          accompanies any conformance claim.</p>
        </dd>

        <dt><a href=
        "index.html#dt-implementation-dependent">implementation-dependent</a></dt>

        <dd>
          <p>The term <b>implementation-dependent</b> refers to a
          feature where the behavior <span class="verb">may</span>
          vary from one implementation to another, and where the
          vendor is not expected to provide a full specification of
          the behavior.</p>
        </dd>

        <dt><a href="index.html#dt-import-precedence">import
        precedence</a></dt>

        <dd>
          <p>A <a title="declaration" href=
          "index.html#dt-declaration">declaration</a> <var>D</var> in the
          stylesheet is defined to have lower <b>import
          precedence</b> than another declaration <var>E</var> if
          the stylesheet level containing <var>D</var> would be
          visited before the stylesheet level containing
          <var>E</var> in a post-order traversal of the import tree
          (that is, a traversal of the import tree in which a
          stylesheet level is visited after its children). Two
          declarations within the same stylesheet level have the
          same import precedence.</p>
        </dd>

        <dt><a href="index.html#dt-import-tree">import tree</a></dt>

        <dd>
          <p>The <a title="stylesheet level" href=
          "index.html#dt-stylesheet-level">stylesheet levels</a> making up a
          <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> are treated as forming an
          <b>import tree</b>. In the import tree, each stylesheet
          level has one child for each <a href=
          "index.html#element-import"><code>xsl:import</code></a> declaration
          that it contains.</p>
        </dd>

        <dt><a href="index.html#dt-in-scope-schema-component">in-scope schema
        component</a></dt>

        <dd>
          <p>The <a title="schema component" href=
          "index.html#dt-schema-component">schema components</a> that may be
          referenced by name in a <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> are referred to as the
          <b>in-scope schema components</b>. This set is the same
          throughout all the modules of a stylesheet.</p>
        </dd>

        <dt><a href="index.html#dt-initial-context-node">initial context
        node</a></dt>

        <dd>
          <p>A node that acts as the <b>initial context node</b>
          for the transformation. This node is accessible within
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> as the initial value of
          the XPath <a title="expression" href=
          "index.html#dt-expression">expressions</a> <code>.</code> (dot) and
          <code>self::node()</code>, as described in <a href=
          "index.html#focus"><i>5.4.3.1 Maintaining Position: the
          Focus</i></a></p>
        </dd>

        <dt><a href="index.html#dt-initial-item">initial item</a></dt>

        <dd>
          <p>For each <a title="group" href="index.html#dt-group">group</a>,
          the item within the group that is first in <a title=
          "population order" href="index.html#dt-population-order">population
          order</a> is known as the <b>initial item</b> of the
          group.</p>
        </dd>

        <dt><a href="index.html#dt-initial-sequence">initial
        sequence</a></dt>

        <dd>
          <p>The sequence to be sorted is referred to as the
          <b>initial sequence</b>.</p>
        </dd>

        <dt><a href="index.html#dt-initial-template">initial
        template</a></dt>

        <dd>
          <p>The transformation is performed by evaluating an
          <b>initial template</b>. If a <a title="named template"
          href="index.html#dt-named-template">named template</a> is supplied
          when the transformation is initiated, then this is the
          initial template; <span>otherwise, the initial template
          is the <a title="template rule" href=
          "index.html#dt-template-rule">template rule</a> selected according
          to the rules of the <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction for processing the <a title=
          "initial context node" href=
          "index.html#dt-initial-context-node">initial context node</a> in
          the initial <a title="mode" href=
          "index.html#dt-mode">mode</a>.</span></p>
        </dd>

        <dt><a href="index.html#dt-instruction">instruction</a></dt>

        <dd>
          <p>An <b>instruction</b> is either an <a title=
          "XSLT instruction" href="index.html#dt-xslt-instruction">XSLT
          instruction</a> or an <a title="extension instruction"
          href="index.html#dt-extension-instruction">extension
          instruction</a>.</p>
        </dd>

        <dt><a href="index.html#dt-key">key</a></dt>

        <dd>
          <p>A <b>key</b> is defined as a set of <a href=
          "index.html#element-key"><code>xsl:key</code></a> declarations in
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> that share the same
          name.</p>
        </dd>

        <dt><a href="index.html#dt-key-specifier">key specifier</a></dt>

        <dd>
          <p>The expression in the <code>use</code> attribute and
          the <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>
          within an <a href="index.html#element-key"><code>xsl:key</code></a>
          declaration are referred to collectively as the <b>key
          specifier</b>. The key specifier determines the values
          that may be used to find a node using this <a title="key"
          href="index.html#dt-key">key</a>.</p>
        </dd>

        <dt><a href="index.html#dt-lexical-qname">lexical QName</a></dt>

        <dd>
          <p>A <b>lexical QName</b> is a string representing a
          <a title="QName" href="index.html#dt-qname">QName</a> in the form
          <code>(NCName ":")? NCName</code>, that is, a local name
          optionally preceded by a namespace prefix.</p>
        </dd>

        <dt><a href="index.html#dt-literal-namespace-uri">literal namespace
        URI</a></dt>

        <dd>
          <p>A namespace URI in the stylesheet tree that is being
          used to specify a namespace URI in the <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a> is
          called a <b>literal namespace URI</b>.</p>
        </dd>

        <dt><a href="index.html#dt-literal-result-element">literal result
        element</a></dt>

        <dd>
          <p>In a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, an
          element in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> that does not belong to
          the <a title="XSLT namespace" href=
          "index.html#dt-xslt-namespace">XSLT namespace</a> and that is not
          an <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instruction</a>
          (see <a href="index.html#extension-instruction"><i>18.2 Extension
          Instructions</i></a>) is classified as a <b>literal
          result element</b>.</p>
        </dd>

        <dt><a href="index.html#dt-local-variable">local variable</a></dt>

        <dd>
          <p>As well as being allowed as <a title="declaration"
          href="index.html#dt-declaration">declaration</a> elements, the
          <a href="index.html#element-variable"><code>xsl:variable</code></a>
          element is also allowed in <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructors</a>.
          Such a variable is known as a <b>local variable</b>.</p>
        </dd>

        <dt><a href="index.html#dt-mode">mode</a></dt>

        <dd>
          <p><b>Modes</b> allow a node in a <a title="source tree"
          href="index.html#dt-source-tree">source tree</a> to be processed
          multiple times, each time producing a different result.
          They also allow different sets of <a title=
          "template rule" href="index.html#dt-template-rule">template
          rules</a> to be active when processing different trees,
          for example when processing documents loaded using the
          <a href="index.html#function-document"><code>document</code></a>
          function (see <a href="index.html#document"><i>16.1 Multiple Source
          Documents</i></a>) or when processing <a title=
          "temporary tree" href="index.html#dt-temporary-tree">temporary
          trees</a>.</p>
        </dd>

        <dt><a href="index.html#dt-named-template">named template</a></dt>

        <dd>
          <p>Templates can be invoked by name. An <a href=
          "index.html#element-template"><code>xsl:template</code></a> element
          with a <code>name</code> attribute defines a <b>named
          template</b>.</p>
        </dd>

        <dt><a href="index.html#dt-namespace-fixup">namespace fixup</a></dt>

        <dd>
          <p>The rules for the individual XSLT instructions that
          construct a <a title="result tree" href=
          "index.html#dt-result-tree">result tree</a> (see <a href=
          "index.html#creating-new-nodes"><i>11 Creating Nodes and
          Sequences</i></a>) prescribe some of the situations in
          which namespace nodes are written to the tree. These
          rules, however, are not sufficient to ensure that the
          prescribed constraints are always satisfied. The XSLT
          processor <span class="verb">must</span> therefore add
          additional namespace nodes to satisfy these constraints.
          This process is referred to as <b>namespace
          fixup</b>.</p>
        </dd>

        <dt><a href="index.html#dt-nonrec-dynamic-error">non-recoverable
        dynamic error</a></dt>

        <dd>
          <p>A <a title="dynamic error" href=
          "index.html#dt-dynamic-error">dynamic error</a> that is not
          recoverable is referred to as a <b>non-recoverable
          dynamic error</b>. When a non-recoverable dynamic error
          occurs, the <a title="processor" href=
          "index.html#dt-processor">processor</a> <span class=
          "verb">must</span> signal the error, and the
          transformation fails.</p>
        </dd>

        <dt><a href="index.html#dt-optional-recovery-action">optional
        recovery action</a></dt>

        <dd>
          <p>If an implementation chooses to recover from a
          <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a>, it
          <span class="verb">must</span> take the <b>optional
          recovery action</b> defined for that error condition in
          this specification.</p>
        </dd>

        <dt><a href="index.html#dt-first-appearance">order of first
        appearance</a></dt>

        <dd>
          <p>There is an ordering among <a title="group" href=
          "index.html#dt-group">groups</a> referred to as the <b>order of
          first appearance</b>. A group <var>G</var> is defined to
          precede a group <var>H</var> in order of first appearance
          if the <a title="initial item" href=
          "index.html#dt-initial-item">initial item</a> of <var>G</var>
          precedes the initial item of <var>H</var> in population
          order. <span>If two groups <var>G</var> and <var>H</var>
          have the same initial item (because the item is in both
          groups) then <var>G</var> precedes <var>H</var> if the
          <a title="grouping key" href="index.html#dt-grouping-key">grouping
          key</a> of <var>G</var> precedes the grouping key of
          <var>H</var> in the sequence that results from evaluating
          the <code>group-by</code> expression of this initial
          item.</span></p>
        </dd>

        <dt><a href="index.html#dt-output-definition">output
        definition</a></dt>

        <dd>
          <p>All the <a href=
          "index.html#element-output"><code>xsl:output</code></a>
          declarations in a stylesheet that share the same name are
          grouped into a named <b>output definition</b>; those that
          have no name are grouped into a single unnamed output
          definition.</p>
        </dd>

        <dt><a href="index.html#dt-output-state">output state</a></dt>

        <dd>
          <p>Each instruction in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> is evaluated in one of
          two possible <b>output states</b>: <a title=
          "final output state" href="index.html#dt-final-output-state">final
          output state</a> or <a title="temporary output state"
          href="index.html#dt-temporary-output-state">temporary output
          state</a></p>
        </dd>

        <dt><a href="index.html#dt-parameter">parameter</a></dt>

        <dd>
          <p>The <a href=
          "index.html#element-param"><code>xsl:param</code></a> element
          declares a <b>parameter</b>, which may be a <a title=
          "stylesheet parameter" href=
          "index.html#dt-stylesheet-parameter">stylesheet parameter</a>, a
          <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a>, or a
          <a title="function parameter" href=
          "index.html#dt-function-parameter">function parameter</a>. A
          parameter is a <a title="variable" href=
          "index.html#dt-variable">variable</a> with the additional property
          that its value can be set by the caller when the
          stylesheet, the template, or the function is invoked.</p>
        </dd>

        <dt><a href="index.html#dt-pattern">pattern</a></dt>

        <dd>
          <p>A <b>pattern</b> specifies a set of conditions on a
          node. A node that satisfies the conditions matches the
          pattern; a node that does not satisfy the conditions does
          not match the pattern. The syntax for patterns is a
          subset of the syntax for <a title="expression" href=
          "index.html#dt-expression">expressions</a>.</p>
        </dd>

        <dt><a href="index.html#dt-picture-string">picture string</a></dt>

        <dd>
          <p>The formatting of a number is controlled by a
          <b>picture string</b>. The picture string is a sequence
          of characters, in which the characters assigned to the
          variables <var>decimal-separator-sign</var>,
          <var>grouping-sign</var>, <var>zero-digit-sign</var>,
          <var>digit-sign</var> and
          <var>pattern-separator-sign</var> are classified as
          active characters, and all other characters (including
          the <var>percent-sign</var> and
          <var>per-mille-sign</var>) are classified as passive
          characters.</p>
        </dd>

        <dt><a href="index.html#dt-place-marker">place marker</a></dt>

        <dd>
          <p>The <a href=
          "index.html#element-number"><code>xsl:number</code></a> instruction
          performs two tasks: firstly, determining a <b>place
          marker</b> (this is a sequence of integers, to allow for
          hierarchic numbering schemes such as <code>1.12.2</code>
          or <code>3(c)ii</code>), and secondly, formatting the
          place marker for output as a text node in the result
          sequence.</p>
        </dd>

        <dt><a href="index.html#dt-population">population</a></dt>

        <dd>
          <p>The sequence of items to be grouped, which is referred
          to as the <b>population</b>, is determined by evaluating
          the XPath <a title="expression" href=
          "index.html#dt-expression">expression</a> contained in the
          <code>select</code> attribute.</p>
        </dd>

        <dt><a href="index.html#dt-population-order">population
        order</a></dt>

        <dd>
          <p>The population is treated as a sequence; the order of
          items in this sequence is referred to as <b>population
          order</b></p>
        </dd>

        <dt><a href="index.html#dt-principal-stylesheet-module">principal
        stylesheet module</a></dt>

        <dd>
          <p>A <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> may consist of several
          <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a>, contained
          in different XML documents. For a given transformation,
          one of these functions as the <b>principal stylesheet
          module</b>. The complete <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> is assembled by finding
          the <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a> referenced
          directly or indirectly from the principal stylesheet
          module using <a href=
          "index.html#element-include"><code>xsl:include</code></a> and
          <a href="index.html#element-import"><code>xsl:import</code></a>
          elements: see <a href="index.html#include"><i>3.10.2 Stylesheet
          Inclusion</i></a> and <a href="index.html#import"><i>3.10.3
          Stylesheet Import</i></a>.</p>
        </dd>

        <dt><a href="index.html#dt-processing-order">processing
        order</a></dt>

        <dd>
          <p>There is another ordering among groups referred to as
          <b>processing order</b>. <span>If group <var>R</var>
          precedes group <var>S</var> in processing order, then in
          the result sequence returned by the <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          instruction the items generated by processing group
          <var>R</var> will precede the items generated by
          processing group <var>S</var>.</span></p>
        </dd>

        <dt><a href="index.html#dt-processor">processor</a></dt>

        <dd>
          <p>The software responsible for transforming source trees
          into result trees using an XSLT stylesheet is referred to
          as the <b>processor</b>. This is sometimes expanded to
          <em>XSLT processor</em> to avoid any confusion with other
          processors, for example an XML processor.</p>
        </dd>

        <dt><a href="index.html#dt-recoverable-error">recoverable
        error</a></dt>

        <dd>
          <p>Some dynamic errors are classed as <b>recoverable
          errors</b>. When a recoverable error occurs, this
          specification allows the processor either to signal the
          error (by reporting the error condition and terminating
          execution) or to take a defined recovery action and
          continue processing.</p>
        </dd>

        <dt><a href="index.html#dt-required-type">required type</a></dt>

        <dd>
          <p>The context within a <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> where an XPath <a title=
          "expression" href="index.html#dt-expression">expression</a>
          <span>appears may specify</span> the <b>required type</b>
          of the expression. The required type indicates the type
          of the value that the expression is expected to
          return.</p>
        </dd>

        <dt><a href="index.html#dt-reserved-namespace">reserved
        namespace</a></dt>

        <dd>
          <p>The XSLT namespace, together with certain other
          namespaces recognized by an XSLT processor, are
          classified as <b>reserved namespaces</b> and <span class=
          "verb">must</span> be used only as specified in this and
          related specifications.</p>
        </dd>

        <dt><a href="index.html#dt-result-tree">result tree</a></dt>

        <dd>
          <p>The term <b>result tree</b> is used to refer to any
          tree constructed by <a title="instruction" href=
          "index.html#dt-instruction">instructions</a> in the stylesheet. A
          result tree is either a <a title="final result tree"
          href="index.html#dt-final-result-tree">final result tree</a> or a
          <a title="temporary tree" href=
          "index.html#dt-temporary-tree">temporary tree</a>.</p>
        </dd>

        <dt><a href="index.html#dt-schema-component">schema
        component</a></dt>

        <dd>
          <p>Type definitions and element and attribute
          declarations are referred to collectively as <b>schema
          components</b>.</p>
        </dd>

        <dt><a href="index.html#dt-schema-instance-namespace">schema instance
        namespace</a></dt>

        <dd>
          <p>The <b>schema instance namespace</b>
          <code>http://www.w3.org/2001/XMLSchema-instance</code> is
          used as defined in <a href="index.html#xmlschema-1">[XML Schema
          Part 1]</a></p>
        </dd>

        <dt><a href="index.html#dt-schema-namespace">schema
        namespace</a></dt>

        <dd>
          <p>The <b>schema namespace</b>
          <code>http://www.w3.org/2001/XMLSchema</code> is used as
          defined in <a href="index.html#xmlschema-1">[XML Schema Part
          1]</a></p>
        </dd>

        <dt><a href="index.html#dt-schema-aware-xslt-processor">schema-aware
        XSLT processor</a></dt>

        <dd>
          <p>A <b>schema-aware XSLT processor</b> is an XSLT
          processor that implements all the mandatory requirements
          of this specification, including those features that a
          <a title="basic XSLT processor" href=
          "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
          signals as an error. The mandatory requirements of this
          specification are taken to include the mandatory
          requirements of XPath 2.0, as described in <a href=
          "index.html#xpath20">[XPath 2.0]</a>. A requirement is mandatory
          unless the specification includes wording (such as the
          use of the words <span class="verb">should</span> or
          <span class="verb">may</span>) that clearly indicates
          that it is optional.</p>
        </dd>

        <dt><a href="index.html#dt-sequence-constructor">sequence
        constructor</a></dt>

        <dd>
          <p>A <b>sequence constructor</b> is a sequence of zero or
          more sibling nodes in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> that can be evaluated to
          return a sequence of nodes and atomic values. The way
          that the resulting sequence is used depends on the
          containing instruction.</p>
        </dd>

        <dt><a href="index.html#dt-serialization">serialization</a></dt>

        <dd>
          <p>A frequent requirement is to output a <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a> as an XML document (or in other formats
          such as HTML). This process is referred to as
          <b>serialization</b>.</p>
        </dd>

        <dt><a href="index.html#dt-serialization-error">serialization
        error</a></dt>

        <dd>
          <p>If a transformation has successfully produced a
          <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a>, it is
          still possible that errors may occur in serializing the
          result tree. For example, it may be impossible to
          serialize the result tree using the encoding selected by
          the user. Such an error is referred to as a
          <b>serialization error</b>.</p>
        </dd>

        <dt><a href="index.html#dt-serialization-feature">serialization
        feature</a></dt>

        <dd>
          <p>A processor that claims conformance with the
          <b>serialization feature</b> <span class=
          "verb">must</span> support the conversion of a <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a> to a sequence of <span>octets</span>
          following the rules defined in <a href=
          "index.html#serialization"><i>20 Serialization</i></a>.</p>
        </dd>

        <dt><a href="index.html#dt-shadows">shadows</a></dt>

        <dd>
          <p>A binding <b>shadows</b> another binding if the
          binding occurs at a point where the other binding is
          visible, and the bindings have the same name.</p>
        </dd>

        <dt><a href="index.html#dt-simplified-stylesheet-module">simplified
        stylesheet module</a></dt>

        <dd>
          <p>A <b>simplified stylesheet module</b> is a tree, or
          part of a tree, consisting of a <a title=
          "literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>
          together with its descendant nodes and associated
          attributes and namespaces. This element is not itself in
          the XSLT namespace, but it <span class="verb">must</span>
          have an <code>xsl:version</code> attribute, which implies
          that it <span class="verb">must</span> have a namespace
          node that declares a binding for the XSLT namespace. For
          further details see <a href=
          "index.html#simplified-stylesheet"><i>3.7 Simplified Stylesheet
          Modules</i></a>.</p>
        </dd>

        <dt><a href="index.html#dt-singleton-focus">singleton focus</a></dt>

        <dd>
          <p>A <b>singleton focus</b> based on a node <var>N</var>
          has the <a title="context item" href=
          "index.html#dt-context-item">context item</a> (and therefore the
          <a title="context node" href="index.html#dt-context-node">context
          node</a>) set to <var>N</var>, and the <a title=
          "context position" href="index.html#dt-context-position">context
          position</a> and <a title="context size" href=
          "index.html#dt-context-size">context size</a> both set to 1
          (one).</p>
        </dd>

        <dt><a href="index.html#dt-sort-key-component">sort key
        component</a></dt>

        <dd>
          <p>Within a <a title="sort key specification" href=
          "index.html#dt-sort-key-specification">sort key specification</a>,
          each <a href="index.html#element-sort"><code>xsl:sort</code></a>
          element defines one <b>sort key component</b>.</p>
        </dd>

        <dt><a href="index.html#dt-sort-key-specification">sort key
        specification</a></dt>

        <dd>
          <p>A <b>sort key specification</b> is a sequence of one
          or more adjacent <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> elements which
          together define rules for sorting the items in an input
          sequence to form a sorted sequence.</p>
        </dd>

        <dt><a href="index.html#dt-sort-key-value">sort key value</a></dt>

        <dd>
          <p>For each item in the <a title="initial sequence" href=
          "index.html#dt-initial-sequence">initial sequence</a>, a value is
          computed for each <a title="sort key component" href=
          "index.html#dt-sort-key-component">sort key component</a> within
          the <a title="sort key specification" href=
          "index.html#dt-sort-key-specification">sort key specification</a>.
          The value computed for an item by using the
          <var>N</var>th sort key component is referred to as the
          <var>N</var>th <b>sort key value</b> of that item.</p>
        </dd>

        <dt><a href="index.html#dt-sorted-sequence">sorted sequence</a></dt>

        <dd>
          <p>The sequence after sorting as defined by the <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> elements is
          referred to as the <b>sorted sequence</b>.</p>
        </dd>

        <dt><a href="index.html#dt-source-tree">source tree</a></dt>

        <dd>
          <p>The term <b>source tree</b> means any tree provided as
          input to the transformation. This includes the document
          containing the <a title="initial context node" href=
          "index.html#dt-initial-context-node">initial context node</a> if
          any, documents containing nodes supplied as the values of
          <a title="stylesheet parameter" href=
          "index.html#dt-stylesheet-parameter">stylesheet parameters</a>,
          documents obtained from the results of functions such as
          <a href="index.html#function-document"><code>document</code></a>,
          <a href=
          "http://www.w3.org/TR/xpath-functions/#func-doc"><code>doc</code></a><sup>
          <small>FO</small></sup>, and <a href=
          "http://www.w3.org/TR/xpath-functions/#func-collection"><code>
          collection</code></a><sup><small>FO</small></sup>, and
          documents returned by extension functions or extension
          instructions. In the context of a particular XSLT
          instruction, the term <b>source tree</b> means any tree
          provided as input to that instruction; this may be a
          source tree of the transformation as a whole, or it may
          be a <a title="temporary tree" href=
          "index.html#dt-temporary-tree">temporary tree</a> produced during
          the course of the transformation.</p>
        </dd>

        <dt><a href="index.html#dt-stable">stable</a></dt>

        <dd>
          <p>A <a title="sort key specification" href=
          "index.html#dt-sort-key-specification">sort key specification</a>
          is said to be <b>stable</b> if its first <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element has no
          <code>stable</code> attribute, or has a
          <code>stable</code> attribute whose <a title=
          "effective value" href="index.html#dt-effective-value">effective
          value</a> is <code>yes</code>.</p>
        </dd>

        <dt><a href="index.html#dt-standalone-stylesheet-module">standalone
        stylesheet module</a></dt>

        <dd>
          <p>A <b>standalone stylesheet module</b> is a stylesheet
          module that comprises the whole of an XML document.</p>
        </dd>

        <dt><a href="index.html#dt-standard-attributes">standard
        attributes</a></dt>

        <dd>
          <p>There are a number of <b>standard attributes</b> that
          may appear on any <a title="XSLT element" href=
          "index.html#dt-xslt-element">XSLT element</a>: specifically
          <code>version</code>,
          <code>exclude-result-prefixes</code>,
          <code>extension-element-prefixes</code>,
          <code>xpath-default-namespace</code><span>,
          <code>default-collation</code>, and
          <code>use-when</code>.</span></p>
        </dd>

        <dt><a href="index.html#dt-standard-function-namespace">standard
        function namespace</a></dt>

        <dd>
          <p>The <b>standard function namespace</b>
          <code>http://www.w3.org/2005/xpath-functions</code> is
          used for functions in the function library defined in
          <a href="index.html#xpath-functions">[Functions and Operators]</a>
          and standard functions defined in this specification.</p>
        </dd>

        <dt><a href="index.html#dt-standard-stylesheet-module">standard
        stylesheet module</a></dt>

        <dd>
          <p>A <b>standard stylesheet module</b> is a tree, or part
          of a tree, consisting of an <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a> or
          <a href=
          "index.html#element-transform"><code>xsl:transform</code></a>
          element (see <a href="index.html#stylesheet-element"><i>3.6
          Stylesheet Element</i></a>) together with its descendant
          nodes and associated attributes and namespaces.</p>
        </dd>

        <dt><a href="index.html#dt-static-error">static error</a></dt>

        <dd>
          <p>An error that is detected by examining a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> before
          execution starts (that is, before the source document and
          values of stylesheet parameters are available) is
          referred to as a <b>static error</b>.</p>
        </dd>

        <dt><a href="index.html#dt-string-value">string value</a></dt>

        <dd>
          <p>The term <b>string value</b> is defined in <a href=
          "http://www.w3.org/TR/xpath-datamodel/#dm-string-value">Section
          5.13 string-value
          Accessor</a><sup><small>DM</small></sup>. Every node has
          a <a title="string value" href="index.html#dt-string-value">string
          value</a>. For example, the <a title="string value" href=
          "index.html#dt-string-value">string value</a> of an element is the
          concatenation of the <a title="string value" href=
          "index.html#dt-string-value">string values</a> of all its
          descendant text nodes.</p>
        </dd>

        <dt><a href="index.html#dt-stylesheet">stylesheet</a></dt>

        <dd>
          <p>A transformation in the XSLT language is expressed in
          the form of a <b>stylesheet</b>, whose syntax is
          well-formed XML <a href="index.html#REC-xml">[XML 1.0]</a>
          conforming to the Namespaces in XML Recommendation
          <a href="index.html#REC-xml-names">[Namespaces in XML 1.0]</a>.</p>
        </dd>

        <dt><a href="index.html#dt-stylesheet-function">stylesheet
        function</a></dt>

        <dd>
          <p>An <a href=
          "index.html#element-function"><code>xsl:function</code></a>
          declaration declares the name, parameters, and
          implementation of a <b>stylesheet function</b> that can
          be called from any XPath <a title="expression" href=
          "index.html#dt-expression">expression</a> within the <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>.</p>
        </dd>

        <dt><a href="index.html#dt-stylesheet-level">stylesheet
        level</a></dt>

        <dd>
          <p>A <b>stylesheet level</b> is a collection of <a title=
          "stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet modules</a> connected
          using <a href=
          "index.html#element-include"><code>xsl:include</code></a>
          declarations: specifically, two stylesheet modules
          <var>A</var> and <var>B</var> are part of the same
          stylesheet level if one of them includes the other by
          means of an <a href=
          "index.html#element-include"><code>xsl:include</code></a>
          declaration, or if there is a third stylesheet module
          <var>C</var> that is in the same stylesheet level as both
          <var>A</var> and <var>B</var>.</p>
        </dd>

        <dt><a href="index.html#dt-stylesheet-module">stylesheet
        module</a></dt>

        <dd>
          <p>A <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> consists of one or more
          <b>stylesheet modules</b>, each one forming all or part
          of an XML document.</p>
        </dd>

        <dt><a href="index.html#dt-stylesheet-parameter">stylesheet
        parameter</a></dt>

        <dd>
          <p>A top-level <a href=
          "index.html#element-param"><code>xsl:param</code></a> element
          declares a <b>stylesheet parameter</b>. A stylesheet
          parameter is a global variable with the additional
          property that its value can be supplied by the caller
          when a transformation is initiated.</p>
        </dd>

        <dt><a href="index.html#dt-supplied-value">supplied value</a></dt>

        <dd>
          <p>The value of the variable is computed using the
          <a title="expression" href=
          "index.html#dt-expression">expression</a> given in the
          <code>select</code> attribute or the contained <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, as
          described in <a href="index.html#variable-values"><i>9.3 Values of
          Variables and Parameters</i></a>. This value is referred
          to as the <b>supplied value</b> of the variable.</p>
        </dd>

        <dt><a href="index.html#dt-target-namespace-uri">target namespace
        URI</a></dt>

        <dd>
          <p>The namespace URI that is to be used in the <a title=
          "result tree" href="index.html#dt-result-tree">result tree</a> as a
          substitute for a <a title="literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> is
          called the <b>target namespace URI</b>.</p>
        </dd>

        <dt><a href="index.html#dt-template">template</a></dt>

        <dd>
          <p>An <a href=
          "index.html#element-template"><code>xsl:template</code></a>
          declaration defines a <b>template</b>, which contains a
          <span><a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence
          constructor</a></span> for creating nodes and/or atomic
          values. A template can serve either as a <a title=
          "template rule" href="index.html#dt-template-rule">template
          rule</a>, invoked by matching nodes against a <a title=
          "pattern" href="index.html#dt-pattern">pattern</a>, or as a
          <a title="named template" href="index.html#dt-named-template">named
          template</a>, invoked explicitly by name. It is also
          possible for the same template to serve in both
          capacities.</p>
        </dd>

        <dt><a href="index.html#dt-template-parameter">template
        parameter</a></dt>

        <dd>
          <p>An <a href="index.html#element-param"><code>xsl:param</code></a>
          element may appear as a child of an <a href=
          "index.html#element-template"><code>xsl:template</code></a>
          element, before any non-<a href=
          "index.html#element-param"><code>xsl:param</code></a> children of
          that element. Such a parameter is known as a <b>template
          parameter</b>. A template parameter is a <a title=
          "local variable" href="index.html#dt-local-variable">local
          variable</a> with the additional property that its value
          can be set when the template is called, using any of the
          instructions <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          <span>or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>.</p>
        </dd>

        <dt><a href="index.html#dt-template-rule">template rule</a></dt>

        <dd>
          <p>A stylesheet contains a set of <b>template rules</b>
          (see <a href="index.html#rules"><i>6 Template Rules</i></a>). A
          template rule has three parts: a <a title="pattern" href=
          "index.html#dt-pattern">pattern</a> that is matched against nodes,
          a (possibly empty) set of <a title="template parameter"
          href="index.html#dt-template-parameter">template parameters</a>,
          and a <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> that
          is evaluated to produce a sequence of items.</p>
        </dd>

        <dt><a href="index.html#dt-temporary-output-state">temporary output
        state</a></dt>

        <dd>
          <p>The second of the two <a title="output state" href=
          "index.html#dt-output-state">output states</a> is called
          <b>temporary output</b> state. This state applies when
          instructions are writing to a <a title="temporary tree"
          href="index.html#dt-temporary-tree">temporary tree</a> or any other
          non-final destination.</p>
        </dd>

        <dt><a href="index.html#dt-temporary-tree">temporary tree</a></dt>

        <dd>
          <p>The term <b>temporary tree</b> means any tree that is
          neither a <a title="source tree" href=
          "index.html#dt-source-tree">source tree</a> nor a <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result tree</a>.</p>
        </dd>

        <dt><a href="index.html#dt-top-level">top-level</a></dt>

        <dd>
          <p>An element occurring as a child of an <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element is called a <b>top-level</b> element.</p>
        </dd>

        <dt><a href="index.html#dt-tunnel-parameter">tunnel
        parameter</a></dt>

        <dd>
          <p>A parameter passed to a template may be defined as a
          <b>tunnel parameter</b>. Tunnel parameters have the
          property that they are automatically passed on by the
          called template to any further templates that it calls,
          and so on recursively.</p>
        </dd>

        <dt><a href="index.html#dt-annotation">type annotation</a></dt>

        <dd>
          <p>The term <b>type annotation</b> is used in this
          specification to refer to the value returned by the
          <code>dm:type-name</code> accessor of a node: see
          <a href="http://www.w3.org/TR/xpath-datamodel/#dm-type-name">
          Section 5.14 type-name
          Accessor</a><sup><small>DM</small></sup>.</p>
        </dd>

        <dt><a href="index.html#dt-type-error">type errors</a></dt>

        <dd>
          <p>Certain errors are classified as <b>type errors</b>. A
          type error occurs when the value supplied as input to an
          operation is of the wrong type for that operation, for
          example when an integer is supplied to an operation that
          expects a node.</p>
        </dd>

        <dt><a href="index.html#dt-typed-value">typed value</a></dt>

        <dd>
          <p>The term <b>typed value</b> is defined in <a href=
          "http://www.w3.org/TR/xpath-datamodel/#dm-typed-value">Section
          5.15 typed-value
          Accessor</a><sup><small>DM</small></sup>. Every node
          except an element defined in the schema with element-only
          content has a <a title="string value" href=
          "index.html#dt-string-value">typed value</a>. For example, the
          <a title="typed value" href="index.html#dt-typed-value">typed
          value</a> of an attribute of type <code>xs:IDREFS</code>
          is a sequence of zero or more <code>xs:IDREF</code>
          values.</p>
        </dd>

        <dt><a href="index.html#dt-data-element">user-defined data
        element</a></dt>

        <dd>
          <p>In addition to <a title="declaration" href=
          "index.html#dt-declaration">declarations</a>, the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element may contain any element not from the <a title=
          "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>, provided that the <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> of the element
          has a non-null namespace URI. Such elements are referred
          to as <b>user-defined data elements</b>.</p>
        </dd>

        <dt><a href="index.html#dt-value">value</a></dt>

        <dd>
          <p>A variable is a binding between a name and a value.
          The <b>value</b> of a variable is any sequence (of nodes
          and/or atomic values), as defined in <a href=
          "index.html#xpath-datamodel">[Data Model]</a>.</p>
        </dd>

        <dt><a href="index.html#dt-variable">variable</a></dt>

        <dd>
          <p>The <a href=
          "index.html#element-variable"><code>xsl:variable</code></a> element
          declares a <b>variable</b>, which may be a <a title=
          "global variable" href="index.html#dt-global-variable">global
          variable</a> or a <a title="local variable" href=
          "index.html#dt-local-variable">local variable</a>.</p>
        </dd>

        <dt><a href="index.html#dt-variable-binding-element">variable-binding
        element</a></dt>

        <dd>
          <p>The two elements <a href=
          "index.html#element-variable"><code>xsl:variable</code></a> and
          <a href="index.html#element-param"><code>xsl:param</code></a> are
          referred to as <b>variable-binding elements</b></p>
        </dd>

        <dt><a href="index.html#dt-whitespace-text-node">whitespace text
        node</a></dt>

        <dd>
          <p>A <b>whitespace text node</b> is a text node whose
          content consists entirely of whitespace characters (that
          is, #x09, #x0A, #x0D, or #x20).</p>
        </dd>
      </dl>
    </div>

    <div class="div1">
      <h2><a name="element-syntax-summary" id=
      "element-syntax-summary"></a>D Element Syntax Summary
      (Non-Normative)</h2>

      <p>The syntax of each XSLT element is summarized below,
      together with the context in the stylesheet where the element
      may appear. Some elements (specifically, instructions) are
      allowed as a child of any element that is allowed to contain
      a sequence constructor. These elements are:</p>

      <ul>
        <li>Literal result elements</li>

        <li>Extension instructions, if so defined</li>
      </ul>

      <p><b><a href=
      "index.html#element-analyze-string">xsl:analyze-string</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:analyze-string<br />
            &#160;&#160;<b>select</b> = <var>expression</var><br />
            &#160;&#160;<b>regex</b> = { <var>string</var> }<br />
            &#160;&#160;flags? = { <var>string</var> }&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-matching-substring">xsl:matching-substring</a>?,
            <a href=
            "index.html#element-non-matching-substring">xsl:non-matching-substring</a>?,
            <a href="index.html#element-fallback">xsl:fallback</a>*)
            --&gt;<br />
            &lt;/xsl:analyze-string&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-apply-imports">xsl:apply-imports</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:apply-imports&gt;<br />
            &#160;&#160;&lt;!-- Content: <a href=
            "index.html#element-with-param">xsl:with-param</a>* --&gt;<br />
            &lt;/xsl:apply-imports&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-apply-templates">xsl:apply-templates</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:apply-templates<br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;mode? = <var>token</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-sort">xsl:sort</a> | <a href=
            "index.html#element-with-param">xsl:with-param</a>)* --&gt;<br />
            &lt;/xsl:apply-templates&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-attribute">xsl:attribute</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:attribute<br />
            &#160;&#160;<b>name</b> = { <var>qname</var> }<br />
            &#160;&#160;namespace? = { <var>uri-reference</var>
            }<br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;separator? = { <var>string</var> }<br />
            &#160;&#160;type? = <var>qname</var><br />
            &#160;&#160;validation? = "strict" | "lax" | "preserve"
            | "strip"&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:attribute&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:attribute-set</code></li>

              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-attribute-set">xsl:attribute-set</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:attribute-set<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;use-attribute-sets? =
            <var>qnames</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: <a href=
            "index.html#element-attribute">xsl:attribute</a>* --&gt;<br />
            &lt;/xsl:attribute-set&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-call-template">xsl:call-template</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:call-template<br />
            &#160;&#160;<b>name</b> = <var>qname</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: <a href=
            "index.html#element-with-param">xsl:with-param</a>* --&gt;<br />
            &lt;/xsl:call-template&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-character-map">xsl:character-map</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:character-map<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;use-character-maps? =
            <var>qnames</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-output-character">xsl:output-character</a>*)
            --&gt;<br />
            &lt;/xsl:character-map&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-choose">xsl:choose</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:choose&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-when">xsl:when</a>+, <a href=
            "index.html#element-otherwise">xsl:otherwise</a>?) --&gt;<br />
            &lt;/xsl:choose&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-comment">xsl:comment</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:comment<br />
            &#160;&#160;select? = <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:comment&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-copy">xsl:copy</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:copy<br />
            &#160;&#160;copy-namespaces? = "yes" | "no"<br />
            &#160;&#160;inherit-namespaces? = "yes" | "no"<br />
            &#160;&#160;use-attribute-sets? =
            <var>qnames</var><br />
            &#160;&#160;type? = <var>qname</var><br />
            &#160;&#160;validation? = "strict" | "lax" | "preserve"
            | "strip"&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:copy&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-copy-of">xsl:copy-of</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:copy-of<br />
            &#160;&#160;<b>select</b> = <var>expression</var><br />
            &#160;&#160;copy-namespaces? = "yes" | "no"<br />
            &#160;&#160;type? = <var>qname</var><br />
            &#160;&#160;validation? = "strict" | "lax" | "preserve"
            | "strip"&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-decimal-format">xsl:decimal-format</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:decimal-format<br />
            &#160;&#160;name? = <var>qname</var><br />
            &#160;&#160;decimal-separator? = <var>char</var><br />
            &#160;&#160;grouping-separator? = <var>char</var><br />
            &#160;&#160;infinity? = <var>string</var><br />
            &#160;&#160;minus-sign? = <var>char</var><br />
            &#160;&#160;NaN? = <var>string</var><br />
            &#160;&#160;percent? = <var>char</var><br />
            &#160;&#160;per-mille? = <var>char</var><br />
            &#160;&#160;zero-digit? = <var>char</var><br />
            &#160;&#160;digit? = <var>char</var><br />
            &#160;&#160;pattern-separator? =
            <var>char</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-document">xsl:document</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:document<br />
            &#160;&#160;validation? = "strict" | "lax" | "preserve"
            | "strip"<br />
            &#160;&#160;type? = <var>qname</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:document&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-element">xsl:element</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:element<br />
            &#160;&#160;<b>name</b> = { <var>qname</var> }<br />
            &#160;&#160;namespace? = { <var>uri-reference</var>
            }<br />
            &#160;&#160;inherit-namespaces? = "yes" | "no"<br />
            &#160;&#160;use-attribute-sets? =
            <var>qnames</var><br />
            &#160;&#160;type? = <var>qname</var><br />
            &#160;&#160;validation? = "strict" | "lax" | "preserve"
            | "strip"&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:element&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-fallback">xsl:fallback</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:fallback&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:fallback&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-for-each">xsl:for-each</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:for-each<br />
            &#160;&#160;<b>select</b> =
            <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-sort">xsl:sort</a>*,
            <var>sequence-constructor</var>) --&gt;<br />
            &lt;/xsl:for-each&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-for-each-group">xsl:for-each-group</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:for-each-group<br />
            &#160;&#160;<b>select</b> = <var>expression</var><br />
            &#160;&#160;group-by? = <var>expression</var><br />
            &#160;&#160;group-adjacent? =
            <var>expression</var><br />
            &#160;&#160;group-starting-with? =
            <var>pattern</var><br />
            &#160;&#160;group-ending-with? =
            <var>pattern</var><br />
            &#160;&#160;collation? = { <var>uri</var> }&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-sort">xsl:sort</a>*,
            <var>sequence-constructor</var>) --&gt;<br />
            &lt;/xsl:for-each-group&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-function">xsl:function</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:function<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;as? = <var>sequence-type</var><br />
            &#160;&#160;override? = "yes" | "no"&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-param">xsl:param</a>*,
            <var>sequence-constructor</var>) --&gt;<br />
            &lt;/xsl:function&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-if">xsl:if</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:if<br />
            &#160;&#160;<b>test</b> =
            <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:if&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-import">xsl:import</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:import<br />
            &#160;&#160;<b>href</b> =
            <var>uri-reference</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-import-schema">xsl:import-schema</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:import-schema<br />
            &#160;&#160;namespace? = <var>uri-reference</var><br />
            &#160;&#160;schema-location? =
            <var>uri-reference</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: xs:schema? --&gt;<br />
            &lt;/xsl:import-schema&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-include">xsl:include</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:include<br />
            &#160;&#160;<b>href</b> =
            <var>uri-reference</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-key">xsl:key</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:key<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;<b>match</b> = <var>pattern</var><br />
            &#160;&#160;use? = <var>expression</var><br />
            &#160;&#160;collation? = <var>uri</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:key&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-matching-substring">xsl:matching-substring</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:matching-substring&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:matching-substring&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:analyze-string</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-message">xsl:message</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:message<br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;terminate? = { "yes" | "no" }&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:message&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>

              <li><code>xsl:function</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-namespace">xsl:namespace</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:namespace<br />
            &#160;&#160;<b>name</b> = { <var>ncname</var> }<br />
            &#160;&#160;select? = <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:namespace&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-namespace-alias">xsl:namespace-alias</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:namespace-alias<br />
            &#160;&#160;<b>stylesheet-prefix</b> =
            <var>prefix</var> | "#default"<br />
            &#160;&#160;<b>result-prefix</b> = <var>prefix</var> |
            "#default"&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-next-match">xsl:next-match</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:next-match&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-with-param">xsl:with-param</a> | <a href=
            "index.html#element-fallback">xsl:fallback</a>)* --&gt;<br />
            &lt;/xsl:next-match&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-non-matching-substring">xsl:non-matching-substring</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:non-matching-substring&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:non-matching-substring&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:analyze-string</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-number">xsl:number</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:number<br />
            &#160;&#160;value? = <var>expression</var><br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;level? = "single" | "multiple" |
            "any"<br />
            &#160;&#160;count? = <var>pattern</var><br />
            &#160;&#160;from? = <var>pattern</var><br />
            &#160;&#160;format? = { <var>string</var> }<br />
            &#160;&#160;lang? = { <var>nmtoken</var> }<br />
            &#160;&#160;letter-value? = { "alphabetic" |
            "traditional" }<br />
            &#160;&#160;ordinal? = { <var>string</var> }<br />
            &#160;&#160;grouping-separator? = { <var>char</var>
            }<br />
            &#160;&#160;grouping-size? = { <var>number</var>
            }&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-otherwise">xsl:otherwise</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:otherwise&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:otherwise&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:choose</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-output">xsl:output</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:output<br />
            &#160;&#160;name? = <var>qname</var><br />
            &#160;&#160;method? = "xml" | "html" | "xhtml" | "text"
            | <var>qname-but-not-ncname</var><br />
            &#160;&#160;byte-order-mark? = "yes" | "no"<br />
            &#160;&#160;cdata-section-elements? =
            <var>qnames</var><br />
            &#160;&#160;doctype-public? = <var>string</var><br />
            &#160;&#160;doctype-system? = <var>string</var><br />
            &#160;&#160;encoding? = <var>string</var><br />
            &#160;&#160;escape-uri-attributes? = "yes" | "no"<br />
            &#160;&#160;include-content-type? = "yes" | "no"<br />
            &#160;&#160;indent? = "yes" | "no"<br />
            &#160;&#160;media-type? = <var>string</var><br />
            &#160;&#160;normalization-form? = "NFC" | "NFD" |
            "NFKC" | "NFKD" | "fully-normalized" | "none" |
            <var>nmtoken</var><br />
            &#160;&#160;omit-xml-declaration? = "yes" | "no"<br />
            &#160;&#160;standalone? = "yes" | "no" | "omit"<br />
            &#160;&#160;undeclare-prefixes? = "yes" | "no"<br />
            &#160;&#160;use-character-maps? =
            <var>qnames</var><br />
            &#160;&#160;version? =
            <var>nmtoken</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-output-character">xsl:output-character</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:output-character<br />
            &#160;&#160;<b>character</b> = <var>char</var><br />
            &#160;&#160;<b>string</b> =
            <var>string</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:character-map</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-param">xsl:param</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:param<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;as? = <var>sequence-type</var><br />
            &#160;&#160;required? = "yes" | "no"<br />
            &#160;&#160;tunnel? = "yes" | "no"&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:param&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>

              <li><code>xsl:function</code></li>

              <li><code>xsl:template</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-perform-sort">xsl:perform-sort</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:perform-sort<br />
            &#160;&#160;select? = <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-sort">xsl:sort</a>+,
            <var>sequence-constructor</var>) --&gt;<br />
            &lt;/xsl:perform-sort&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-preserve-space">xsl:preserve-space</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:preserve-space<br />
            &#160;&#160;<b>elements</b> =
            <var>tokens</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-processing-instruction">xsl:processing-instruction</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:processing-instruction<br />
            &#160;&#160;<b>name</b> = { <var>ncname</var> }<br />
            &#160;&#160;select? = <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:processing-instruction&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-result-document">xsl:result-document</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:result-document<br />
            &#160;&#160;format? = { <var>qname</var> }<br />
            &#160;&#160;href? = { <var>uri-reference</var> }<br />
            &#160;&#160;validation? = "strict" | "lax" | "preserve"
            | "strip"<br />
            &#160;&#160;type? = <var>qname</var><br />
            &#160;&#160;method? = { "xml" | "html" | "xhtml" |
            "text" | <var>qname-but-not-ncname</var> }<br />
            &#160;&#160;byte-order-mark? = { "yes" | "no" }<br />
            &#160;&#160;cdata-section-elements? = {
            <var>qnames</var> }<br />
            &#160;&#160;doctype-public? = { <var>string</var>
            }<br />
            &#160;&#160;doctype-system? = { <var>string</var>
            }<br />
            &#160;&#160;encoding? = { <var>string</var> }<br />
            &#160;&#160;escape-uri-attributes? = { "yes" | "no"
            }<br />
            &#160;&#160;include-content-type? = { "yes" | "no"
            }<br />
            &#160;&#160;indent? = { "yes" | "no" }<br />
            &#160;&#160;media-type? = { <var>string</var> }<br />
            &#160;&#160;normalization-form? = { "NFC" | "NFD" |
            "NFKC" | "NFKD" | "fully-normalized" | "none" |
            <var>nmtoken</var> }<br />
            &#160;&#160;omit-xml-declaration? = { "yes" | "no"
            }<br />
            &#160;&#160;standalone? = { "yes" | "no" | "omit"
            }<br />
            &#160;&#160;undeclare-prefixes? = { "yes" | "no"
            }<br />
            &#160;&#160;use-character-maps? =
            <var>qnames</var><br />
            &#160;&#160;output-version? = { <var>nmtoken</var>
            }&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:result-document&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-sequence">xsl:sequence</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:sequence<br />
            &#160;&#160;<b>select</b> =
            <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: <a href=
            "index.html#element-fallback">xsl:fallback</a>* --&gt;<br />
            &lt;/xsl:sequence&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-sort">xsl:sort</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:sort<br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;lang? = { <var>nmtoken</var> }<br />
            &#160;&#160;order? = { "ascending" | "descending"
            }<br />
            &#160;&#160;collation? = { <var>uri</var> }<br />
            &#160;&#160;stable? = { "yes" | "no" }<br />
            &#160;&#160;case-order? = { "upper-first" |
            "lower-first" }<br />
            &#160;&#160;data-type? = { "text" | "number" |
            <var>qname-but-not-ncname</var> }&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:sort&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:apply-templates</code></li>

              <li><code>xsl:for-each</code></li>

              <li><code>xsl:for-each-group</code></li>

              <li><code>xsl:perform-sort</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-strip-space">xsl:strip-space</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:strip-space<br />
            &#160;&#160;<b>elements</b> =
            <var>tokens</var>&#160;/&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-stylesheet">xsl:stylesheet</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:stylesheet<br />
            &#160;&#160;id? = <var>id</var><br />
            &#160;&#160;extension-element-prefixes? =
            <var>tokens</var><br />
            &#160;&#160;exclude-result-prefixes? =
            <var>tokens</var><br />
            &#160;&#160;<b>version</b> = <var>number</var><br />
            &#160;&#160;xpath-default-namespace? =
            <var>uri</var><br />
            &#160;&#160;default-validation? = "preserve" |
            "strip"<br />
            &#160;&#160;default-collation? =
            <var>uri-list</var><br />
            &#160;&#160;input-type-annotations? = "preserve" |
            "strip" | "unspecified"&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-import">xsl:import</a>*,
            <var>other-declarations</var>) --&gt;<br />
            &lt;/xsl:stylesheet&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>None</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-template">xsl:template</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:template<br />
            &#160;&#160;match? = <var>pattern</var><br />
            &#160;&#160;name? = <var>qname</var><br />
            &#160;&#160;priority? = <var>number</var><br />
            &#160;&#160;mode? = <var>tokens</var><br />
            &#160;&#160;as? = <var>sequence-type</var>&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-param">xsl:param</a>*,
            <var>sequence-constructor</var>) --&gt;<br />
            &lt;/xsl:template&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-text">xsl:text</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:text<br />
            &#160;&#160;<span class=
            "grayed">[disable-output-escaping]?</span> = "yes" |
            "no"&gt;<br />
            &#160;&#160;&lt;!-- Content: #PCDATA --&gt;<br />
            &lt;/xsl:text&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-transform">xsl:transform</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:transform<br />
            &#160;&#160;id? = <var>id</var><br />
            &#160;&#160;extension-element-prefixes? =
            <var>tokens</var><br />
            &#160;&#160;exclude-result-prefixes? =
            <var>tokens</var><br />
            &#160;&#160;<b>version</b> = <var>number</var><br />
            &#160;&#160;xpath-default-namespace? =
            <var>uri</var><br />
            &#160;&#160;default-validation? = "preserve" |
            "strip"<br />
            &#160;&#160;default-collation? =
            <var>uri-list</var><br />
            &#160;&#160;input-type-annotations? = "preserve" |
            "strip" | "unspecified"&gt;<br />
            &#160;&#160;&lt;!-- Content: (<a href=
            "index.html#element-import">xsl:import</a>*,
            <var>other-declarations</var>) --&gt;<br />
            &lt;/xsl:transform&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>None</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-value-of">xsl:value-of</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:value-of<br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;separator? = { <var>string</var> }<br />
            &#160;&#160;<span class=
            "grayed">[disable-output-escaping]?</span> = "yes" |
            "no"&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:value-of&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-variable">xsl:variable</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Category:</i> declaration instruction</p>

            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:variable<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;as? = <var>sequence-type</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:variable&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:stylesheet</code></li>

              <li><code>xsl:transform</code></li>

              <li><code>xsl:function</code></li>

              <li>any XSLT element whose content model is
              <i>sequence constructor</i></li>

              <li>any literal result element</li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href="index.html#element-when">xsl:when</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:when<br />
            &#160;&#160;<b>test</b> =
            <var>expression</var>&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:when&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:choose</code></li>
            </ul>
          </td>
        </tr>
      </table>

      <p><b><a href=
      "index.html#element-with-param">xsl:with-param</a></b></p>

      <table width="100%">
        <tr>
          <td width="10%">&#160;</td>

          <td>
            <p><i>Model:</i></p>

            <p class="element-syntax-summary">
            <code>&lt;xsl:with-param<br />
            &#160;&#160;<b>name</b> = <var>qname</var><br />
            &#160;&#160;select? = <var>expression</var><br />
            &#160;&#160;as? = <var>sequence-type</var><br />
            &#160;&#160;tunnel? = "yes" | "no"&gt;<br />
            &#160;&#160;&lt;!-- Content:
            <var>sequence-constructor</var> --&gt;<br />
            &lt;/xsl:with-param&gt;</code></p>

            <p><i>Permitted parent elements:</i></p>

            <ul>
              <li><code>xsl:apply-templates</code></li>

              <li><code>xsl:apply-imports</code></li>

              <li><code>xsl:call-template</code></li>

              <li><code>xsl:next-match</code></li>
            </ul>
          </td>
        </tr>
      </table>
    </div>

    <div class="div1">
      <h2><a name="error-summary" id="error-summary"></a>E Summary
      of Error Conditions (Non-Normative)</h2>

      <p>This appendix provides a summary of error conditions that
      a processor may signal. This list is not exhaustive or
      definitive. The errors are numbered for ease of reference,
      but there is no implication that an implementation
      <span class="verb">must</span> signal errors using these
      error codes, or that applications can test for these codes.
      Moreover, implementations are not <span class=
      "verb">required</span> to signal errors using the descriptive
      text used here.</p>

      <p><b>Static errors</b></p>

      <dl>
        <dt><a href="index.html#err-XTSE0010"><span class="error">ERR
        XTSE0010</span></a></dt>

        <dd>
          <p>A <a title="static error" href=
          "index.html#dt-static-error">static error</a> is signaled if an
          XSLT-defined element is used in a context where it is not
          permitted, if a <span class="verb">required</span>
          attribute is omitted, or if the content of the element
          does not correspond to the content that is allowed for
          the element.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0020"><span class="error">ERR
        XTSE0020</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an attribute
          (other than an attribute written using curly brackets in
          a position where an <a title="attribute value template"
          href="index.html#dt-attribute-value-template">attribute value
          template</a> is permitted) contains a value that is not
          one of the permitted values for that attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0080"><span class="error">ERR
        XTSE0080</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> to use a <a title=
          "reserved namespace" href=
          "index.html#dt-reserved-namespace">reserved namespace</a> in the
          name of a <a title="named template" href=
          "index.html#dt-named-template">named template</a>, a <a title=
          "mode" href="index.html#dt-mode">mode</a>, an <a title=
          "attribute set" href="index.html#dt-attribute-set">attribute
          set</a>, a <a title="key" href="index.html#dt-key">key</a>, a
          <a title="decimal format" href=
          "index.html#dt-decimal-format">decimal-format</a>, a <a title=
          "variable" href="index.html#dt-variable">variable</a> or <a title=
          "parameter" href="index.html#dt-parameter">parameter</a>, a
          <a title="stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a>, a
          named <a title="output definition" href=
          "index.html#dt-output-definition">output definition</a>, or a
          <a title="character map" href=
          "index.html#dt-character-map">character map</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0090"><span class="error">ERR
        XTSE0090</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> for an element from
          the XSLT namespace to have an attribute whose namespace
          is either null (that is, an attribute with an unprefixed
          name) or the XSLT namespace, other than attributes
          defined for the element in this document.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0110"><span class="error">ERR
        XTSE0110</span></a></dt>

        <dd>
          <p>The value of the <code>version</code> attribute
          <span class="verb">must</span> be a number: specifically,
          it <span class="verb">must</span> be a <span>a valid
          instance of the type <code>xs:decimal</code> as defined
          in <a href="index.html#xmlschema-2">[XML Schema Part
          2]</a></span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0120"><span class="error">ERR
        XTSE0120</span></a></dt>

        <dd>
          <p>An <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element <span class="verb">must not</span> have any text
          node children.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0125"><span class="error">ERR
        XTSE0125</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the value of an
          <code>[xsl:]default-collation</code> attribute<span>,
          after resolving against the base URI,</span> contains no
          URI that the implementation recognizes as a collation
          URI.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0130"><span class="error">ERR
        XTSE0130</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element has a child element whose name has a null
          namespace URI.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0150"><span class="error">ERR
        XTSE0150</span></a></dt>

        <dd>
          <p>A <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>
          that is used as the outermost element of a simplified
          stylesheet module <span class="verb">must</span> have an
          <code>xsl:version</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0165"><span class="error">ERR
        XTSE0165</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the processor is
          not able to retrieve the resource identified by the URI
          reference [ in the <code>href</code> attribute of
          <a href="index.html#element-include"><code>xsl:include</code></a>
          or <a href="index.html#element-import"><code>xsl:import</code></a>]
          , or if the resource that is retrieved does not contain a
          stylesheet module conforming to this specification.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0170"><span class="error">ERR
        XTSE0170</span></a></dt>

        <dd>
          <p>An <a href=
          "index.html#element-include"><code>xsl:include</code></a> element
          <span class="verb">must</span> be a <a title="top-level"
          href="index.html#dt-top-level">top-level</a> element.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0180"><span class="error">ERR
        XTSE0180</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a stylesheet
          module directly or indirectly includes itself.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0190"><span class="error">ERR
        XTSE0190</span></a></dt>

        <dd>
          <p>An <a href=
          "index.html#element-import"><code>xsl:import</code></a> element
          <span class="verb">must</span> be a <a title="top-level"
          href="index.html#dt-top-level">top-level</a> element.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0200"><span class="error">ERR
        XTSE0200</span></a></dt>

        <dd>
          <p>The <a href=
          "index.html#element-import"><code>xsl:import</code></a> element
          children <span class="verb">must</span> precede all other
          element children of an <a href=
          "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
          element, including any <a href=
          "index.html#element-include"><code>xsl:include</code></a> element
          children and any <a title="user-defined data element"
          href="index.html#dt-data-element">user-defined data
          elements</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0210"><span class="error">ERR
        XTSE0210</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a stylesheet
          module directly or indirectly imports itself.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0215"><span class="error">ERR
        XTSE0215</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          element that contains an <code>xs:schema</code> element
          has a <code>schema-location</code> attribute, or if it
          has a <code>namespace</code> attribute that conflicts
          with the target namespace of the contained schema.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0220"><span class="error">ERR
        XTSE0220</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the synthetic
          schema document does not satisfy the constraints
          described in <a href="index.html#xmlschema-1">[XML Schema Part
          1]</a> (section 5.1, <em>Errors in Schema Construction
          and Structure</em>). This includes, without loss of
          generality, conflicts such as multiple definitions of the
          same name.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0260"><span class="error">ERR
        XTSE0260</span></a></dt>

        <dd>
          <p>Within an <a title="XSLT element" href=
          "index.html#dt-xslt-element">XSLT element</a> that is <span class=
          "verb">required</span> to be empty, any content other
          than comments or processing instructions, including any
          <a title="whitespace text node" href=
          "index.html#dt-whitespace-text-node">whitespace text node</a>
          preserved using the <code>xml:space="preserve"</code>
          attribute, is a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0265"><span class="error">ERR
        XTSE0265</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if there is a
          <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet module</a> in the
          <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> that specifies
          <code>input-type-annotations="strip"</code> and another
          <a title="stylesheet module" href=
          "index.html#dt-stylesheet-module">stylesheet module</a> that
          specifies
          <code>input-type-annotations="preserve"</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0280"><span class="error">ERR
        XTSE0280</span></a></dt>

        <dd>
          <p>In the case of a <span>prefixed</span> <a title=
          "QName" href="index.html#dt-qname">QName</a> used as the value of
          an attribute in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>, or appearing within an
          XPath <a title="expression" href=
          "index.html#dt-expression">expression</a> in the stylesheet, it is
          a <a title="static error" href="index.html#dt-static-error">static
          error</a> if the <a title="defining element" href=
          "index.html#dt-defining-element">defining element</a> has no
          namespace node whose name matches the prefix of the
          <a title="QName" href="index.html#dt-qname">QName</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0340"><span class="error">ERR
        XTSE0340</span></a></dt>

        <dd>
          <p>Where an attribute is defined to contain a <a title=
          "pattern" href="index.html#dt-pattern">pattern</a>, it is a
          <a title="static error" href="index.html#dt-static-error">static
          error</a> if the pattern does not match the production
          <a href="index.html#NT-Pattern">Pattern</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0350"><span class="error">ERR
        XTSE0350</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an unescaped left
          curly bracket appears in a fixed part of an attribute
          value template without a matching right curly
          bracket.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0370"><span class="error">ERR
        XTSE0370</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an unescaped right
          curly bracket occurs in a fixed part of an attribute
          value template.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0500"><span class="error">ERR
        XTSE0500</span></a></dt>

        <dd>
          <p>An <a href=
          "index.html#element-template"><code>xsl:template</code></a> element
          <span class="verb">must</span> have either a
          <code>match</code> attribute or a <code>name</code>
          attribute, or both. An <a href=
          "index.html#element-template"><code>xsl:template</code></a> element
          that has no <code>match</code> attribute <span class=
          "verb">must</span> have no <code>mode</code> attribute
          and no <code>priority</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0530"><span class="error">ERR
        XTSE0530</span></a></dt>

        <dd>
          <p>The value of this attribute [the <code>priority</code>
          attribute of the <a href=
          "index.html#element-template"><code>xsl:template</code></a>
          element] <span class="verb">must</span> <span>conform to
          the rules for the <code>xs:decimal</code> type defined in
          <a href="index.html#xmlschema-2">[XML Schema Part 2]</a>. Negative
          values are permitted.</span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0550"><span class="error">ERR
        XTSE0550</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the list [of modes
          in the <code>mode</code> attribute of <a href=
          "index.html#element-template"><code>xsl:template</code></a>] is
          empty, if the same token is included more than once in
          the list, if the list contains an invalid token, or if
          the token <code>#all</code> appears together with any
          other value.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0580"><span class="error">ERR
        XTSE0580</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if two parameters of
          a template or of a stylesheet function have the same
          name.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0620"><span class="error">ERR
        XTSE0620</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a <a title=
          "variable-binding element" href=
          "index.html#dt-variable-binding-element">variable-binding
          element</a> has a <code>select</code> attribute and has
          non-empty content.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0630"><span class="error">ERR
        XTSE0630</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
          contains more than one binding of a global variable with
          the same name and same <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a><span>,
          unless it also contains another binding with the same
          name and higher import precedence</span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0650"><span class="error">ERR
        XTSE0650</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
          contains an <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          instruction whose <code>name</code> attribute does not
          match the <code>name</code> attribute of any <a href=
          "index.html#element-template"><code>xsl:template</code></a> in the
          <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0660"><span class="error">ERR
        XTSE0660</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
          contains more than one <a title="template" href=
          "index.html#dt-template">template</a> with the same name and the
          same <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a><span>,
          unless it also contains a <a title="template" href=
          "index.html#dt-template">template</a> with the same name and higher
          <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a></span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0670"><span class="error">ERR
        XTSE0670</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a single <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          <span>or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>
          element contains two or more <a href=
          "index.html#element-with-param"><code>xsl:with-param</code></a>
          elements with <span>matching <code>name</code>
          attributes</span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0680"><span class="error">ERR
        XTSE0680</span></a></dt>

        <dd>
          <p>In the case of <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>,
          it is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> to pass a
          <span>non-tunnel</span> parameter named <var>x</var> to a
          template that does not have a <a title=
          "template parameter" href=
          "index.html#dt-template-parameter">template parameter</a> named
          <var>x</var><span>, unless <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled for the <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          instruction</span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0690"><span class="error">ERR
        XTSE0690</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a template that is
          invoked using <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          declares a <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a>
          specifying <code>required="yes"</code> <span>and not
          specifying <code>tunnel="yes"</code></span>, if no value
          for this parameter is supplied by the calling
          instruction.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0710"><span class="error">ERR
        XTSE0710</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the value of the
          <code>use-attribute-sets</code> attribute of an <a href=
          "index.html#element-copy"><code>xsl:copy</code></a>, <a href=
          "index.html#element-element"><code>xsl:element</code></a>, or
          <a href=
          "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
          element, or the <code>xsl:use-attribute-sets</code>
          attribute of a <a title="literal result element" href=
          "index.html#dt-literal-result-element">literal result element</a>,
          is not a <span>whitespace-separated</span> sequence of
          <a title="QName" href="index.html#dt-qname">QNames</a>, or if it
          contains a QName that does not match the
          <code>name</code> attribute of any <a href=
          "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
          declaration in the stylesheet.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0720"><span class="error">ERR
        XTSE0720</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an <a href=
          "index.html#element-attribute-set"><code>xsl:attribute-set</code></a>
          element directly or indirectly references itself via the
          names contained in the <code>use-attribute-sets</code>
          attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0740"><span class="error">ERR
        XTSE0740</span></a></dt>

        <dd>
          <p>A <a title="stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a>
          <span class="verb">must</span> have a prefixed name, to
          remove any risk of a clash with a function in the default
          function namespace. It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the name has no
          prefix.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0760"><span class="error">ERR
        XTSE0760</span></a></dt>

        <dd>
          <p>Because arguments to a stylesheet function call
          <span class="verb">must</span> all be specified, the
          <a href="index.html#element-param"><code>xsl:param</code></a>
          elements within an <a href=
          "index.html#element-function"><code>xsl:function</code></a> element
          <span class="verb">must not</span> specify a default
          value: this means they <span class="verb">must</span> be
          empty, and <span class="verb">must not</span> have a
          <code>select</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0770"><span class="error">ERR
        XTSE0770</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> for a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> to
          contain two or more functions with the same <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a>, the same
          <a title="arity" href="index.html#dt-arity">arity</a>, and the same
          <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a>, unless
          there is another function with the same <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> and arity, and a
          higher import precedence.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0805"><span class="error">ERR
        XTSE0805</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an attribute on a
          literal result element is in the <a title=
          "XSLT namespace" href="index.html#dt-xslt-namespace">XSLT
          namespace</a>, unless it is one of the attributes
          explicitly defined in this specification.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0808"><span class="error">ERR
        XTSE0808</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a namespace prefix
          is used within the
          <code>[xsl:]exclude-result-prefixes</code> attribute and
          there is no namespace binding in scope for that
          prefix.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0809"><span class="error">ERR
        XTSE0809</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the value
          <code>#default</code> is used within the
          <code>[xsl:]exclude-result-prefixes</code> attribute and
          the parent element of the
          <code>[xsl:]exclude-result-prefixes</code> attribute has
          no default namespace.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0810"><span class="error">ERR
        XTSE0810</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if there is more than
          one such declaration [more than one <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          declaration] with the same <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> and
          the same <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a> and
          different values for the <a title="target namespace URI"
          href="index.html#dt-target-namespace-uri">target namespace URI</a>,
          unless there is also an <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          declaration with the same <a title=
          "literal namespace URI" href=
          "index.html#dt-literal-namespace-uri">literal namespace URI</a> and
          a higher import precedence.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0812"><span class="error">ERR
        XTSE0812</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a value other than
          <code>#default</code> is specified for either the
          <code>stylesheet-prefix</code> or the
          <code>result-prefix</code> attributes of the <a href=
          "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
          element when there is no in-scope binding for that
          namespace prefix.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0840"><span class="error">ERR
        XTSE0840</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the
          <code>select</code> attribute of the <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          element is present unless the element has empty
          content.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0870"><span class="error">ERR
        XTSE0870</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the
          <code>select</code> attribute of the <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a> element
          is present when the content of the element is non-empty,
          or if the <code>select</code> attribute is absent when
          the content is empty.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0880"><span class="error">ERR
        XTSE0880</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the
          <code>select</code> attribute of the <a href=
          "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
          element is present unless the element has empty
          content.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0910"><span class="error">ERR
        XTSE0910</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the
          <code>select</code> attribute of the <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          element is present when the element has content other
          than one or more <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          instructions, or if the <code>select</code> attribute is
          absent when the element has empty content.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0940"><span class="error">ERR
        XTSE0940</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the
          <code>select</code> attribute of the <a href=
          "index.html#element-comment"><code>xsl:comment</code></a> element
          is present unless the element has empty content.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0950"><span class="error">ERR
        XTTE0950</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> to use the <a href=
          "index.html#element-copy"><code>xsl:copy</code></a> or <a href=
          "index.html#element-copy-of"><code>xsl:copy-of</code></a>
          instruction to copy a node that has namespace-sensitive
          content if the <code>copy-namespaces</code> attribute has
          the value <code>no</code> and its explicit or implicit
          <code>validation</code> attribute has the value
          <code>preserve</code>. It is also a type error if either
          of these instructions (with
          <code>validation="preserve"</code>) is used to copy an
          attribute having namespace-sensitive content, unless the
          parent element is also copied. A node has
          namespace-sensitive content if its typed value contains
          an item of type <code>xs:QName</code> or
          <code>xs:NOTATION</code> or a type derived therefrom. The
          reason this is an error is because the validity of the
          content depends on the namespace context being
          preserved.</p>
        </dd>

        <dt><a href="index.html#err-XTSE0975"><span class="error">ERR
        XTSE0975</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the
          <code>value</code> attribute of <a href=
          "index.html#element-number"><code>xsl:number</code></a> is present
          unless the <code>select</code>, <code>level</code>,
          <code>count</code>, and <code>from</code> attributes are
          all absent.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1015"><span class="error">ERR
        XTSE1015</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element with a
          <code>select</code> attribute has non-empty content.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1017"><span class="error">ERR
        XTSE1017</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element other
          than the first in a sequence of sibling <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> elements has a
          <code>stable</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1040"><span class="error">ERR
        XTSE1040</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an <a href=
          "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>
          instruction with a <code>select</code> attribute has any
          content other than <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> and <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          instructions.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1060"><span class="error">ERR
        XTSE1060</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the <a href=
          "index.html#function-current-group"><code>current-group</code></a>
          function is used within a <a title="pattern" href=
          "index.html#dt-pattern">pattern</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1070"><span class="error">ERR
        XTSE1070</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the <a href=
          "index.html#function-current-grouping-key"><code>current-grouping-key</code></a>
          function is used within a <a title="pattern" href=
          "index.html#dt-pattern">pattern</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1080"><span class="error">ERR
        XTSE1080</span></a></dt>

        <dd>
          <p>These four attributes [the <code>group-by</code>,
          <code>group-adjacent</code>,
          <code>group-starting-with</code>, and
          <code>group-ending-with</code> attributes of <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          ] are mutually exclusive: it is a <a title="static error"
          href="index.html#dt-static-error">static error</a> if none of these
          four attributes is present, or if more than one of them
          is present.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1090"><span class="error">ERR
        XTSE1090</span></a></dt>

        <dd>
          <p>It is an error to specify the <code>collation</code>
          attribute if neither the <code>group-by</code> attribute
          nor <code>group-adjacent</code> attribute is
          specified.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1130"><span class="error">ERR
        XTSE1130</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the <a href=
          "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
          instruction contains neither an <a href=
          "index.html#element-matching-substring"><code>xsl:matching-substring</code></a>
          nor an <a href=
          "index.html#element-non-matching-substring"><code>xsl:non-matching-substring</code></a>
          element.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1205"><span class="error">ERR
        XTSE1205</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if an <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration has a
          <code>use</code> attribute and has non-empty content, or
          if it has empty content and no <code>use</code>
          attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1210"><span class="error">ERR
        XTSE1210</span></a></dt>

        <dd>
          <p>It is a static error if the <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration has a
          <code>collation</code> attribute whose value <span>(after
          resolving against the base URI)</span> is not a URI
          recognized by the implementation as referring to a
          collation.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1220"><span class="error">ERR
        XTSE1220</span></a></dt>

        <dd>
          <p>It is a static error if there are several <a href=
          "index.html#element-key"><code>xsl:key</code></a> declarations in
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> with the same key name
          and different effective collations. Two collations are
          the same if their URIs are equal under the rules for
          comparing <code>xs:anyURI</code> values, or if the
          implementation can determine that they are different URIs
          referring to the same collation.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1290"><span class="error">ERR
        XTSE1290</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a named or unnamed
          <a title="decimal format" href=
          "index.html#dt-decimal-format">decimal format</a> contains two
          conflicting values for the same attribute in different
          <a href=
          "index.html#element-decimal-format"><code>xsl:decimal-format</code></a>
          declarations having the same <a title="import precedence"
          href="index.html#dt-import-precedence">import precedence</a>,
          unless there is another definition of the same attribute
          with higher import precedence.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1295"><span class="error">ERR
        XTSE1295</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the character
          specified in the <code>zero-digit</code> attribute is not
          a digit or is a digit that does not have the numeric
          value zero.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1300"><span class="error">ERR
        XTSE1300</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if, for any named or
          unnamed decimal format, the variables representing
          characters used in a <a title="picture string" href=
          "index.html#dt-picture-string">picture string</a> do not each have
          distinct values. These variables are
          <var>decimal-separator-sign</var>,
          <var>grouping-sign</var>, <var>percent-sign</var>,
          <var>per-mille-sign</var>, <var>digit-zero-sign</var>,
          <var>digit-sign</var>, and
          <var>pattern-separator-sign</var>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1430"><span class="error">ERR
        XTSE1430</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if there is no
          namespace bound to the prefix on the element bearing the
          <code>[xsl:]extension-element-prefixes</code> attribute
          <span>or, when <code>#default</code> is specified, if
          there is no default namespace</span>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1505"><span class="error">ERR
        XTSE1505</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if both the
          <code>[xsl:]type</code> and <code>[xsl:]validation</code>
          attributes are present on the <a href=
          "index.html#element-element"><code>xsl:element</code></a>, <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>,
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>,
          <span><a href=
          "index.html#element-document"><code>xsl:document</code></a></span>,
          or <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instructions, or on a <a title="literal result element"
          href="index.html#dt-literal-result-element">literal result
          element</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1520"><span class="error">ERR
        XTSE1520</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the value of the
          <code>type</code> attribute of an <a href=
          "index.html#element-element"><code>xsl:element</code></a>, <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>,
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>,
          <span><a href=
          "index.html#element-document"><code>xsl:document</code></a>,</span>
          or <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction, or the <code>xsl:type</code> attribute of a
          literal result element, is not a valid
          <code>QName</code>, or if it uses a prefix that is not
          defined in an in-scope namespace declaration, or if the
          QName is not the name of a type definition included in
          the <a title="in-scope schema component" href=
          "index.html#dt-in-scope-schema-component">in-scope schema
          components</a> for the stylesheet.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1530"><span class="error">ERR
        XTSE1530</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the value of the
          <code>type</code> attribute of an <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction refers to a complex type definition</p>
        </dd>

        <dt><a href="index.html#err-XTSE1560"><span class="error">ERR
        XTSE1560</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if two <a href=
          "index.html#element-output"><code>xsl:output</code></a>
          declarations within an <a title="output definition" href=
          "index.html#dt-output-definition">output definition</a> specify
          explicit values for the same attribute (other than
          <code>cdata-section-elements</code> and
          <code>use-character-maps</code>), with the values of the
          attributes being not equal, unless there is another
          <a href="index.html#element-output"><code>xsl:output</code></a>
          declaration within the same <a title="output definition"
          href="index.html#dt-output-definition">output definition</a> that
          has higher import precedence and that specifies an
          explicit value for the same attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1570"><span class="error">ERR
        XTSE1570</span></a></dt>

        <dd>
          <p>The value [of the <code>method</code> attribute on
          <a href="index.html#element-output"><code>xsl:output</code></a> ]
          <span class="verb">must</span> <span>(if present)</span>
          be a valid <a title="QName" href="index.html#dt-qname">QName</a>.
          If the <a title="QName" href="index.html#dt-qname">QName</a> does
          not have a prefix, then it identifies a method specified
          in <a href="index.html#xslt-xquery-serialization">[XSLT and XQuery
          Serialization]</a> and <span class="verb">must</span> be
          one of <code>xml</code>, <code>html</code>,
          <code>xhtml</code>, or <code>text</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1580"><span class="error">ERR
        XTSE1580</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a>
          contains two or more character maps with the same name
          and the same <a title="import precedence" href=
          "index.html#dt-import-precedence">import precedence</a><span>,
          unless it also contains another character map with the
          same name and higher import precedence.</span></p>
        </dd>

        <dt><a href="index.html#err-XTSE1590"><span class="error">ERR
        XTSE1590</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a name in the
          <code>use-character-maps</code> attribute <span>of the
          <a href="index.html#element-output"><code>xsl:output</code></a> or
          <a href=
          "index.html#element-character-map"><code>xsl:character-map</code></a>
          elements</span> does not match the <code>name</code>
          attribute of any <a href=
          "index.html#element-character-map"><code>xsl:character-map</code></a>
          in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1600"><span class="error">ERR
        XTSE1600</span></a></dt>

        <dd>
          <p>It is a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if a character map
          references itself, directly or indirectly, via a name in
          the <code>use-character-maps</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1650"><span class="error">ERR
        XTSE1650</span></a></dt>

        <dd>
          <p>A <a title="basic XSLT processor" href=
          "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
          <span class="verb">must</span> signal a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> includes an <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          declaration.</p>
        </dd>

        <dt><a href="index.html#err-XTSE1660"><span class="error">ERR
        XTSE1660</span></a></dt>

        <dd>
          <p>A <a title="basic XSLT processor" href=
          "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
          <span class="verb">must</span> signal a <a title=
          "static error" href="index.html#dt-static-error">static error</a>
          if the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> includes an
          <code>[xsl:]type</code> attribute, or an
          <code>[xsl:]validation</code> or
          <code>default-validation</code> attribute with a value
          other than <code>strip</code>.</p>
        </dd>
      </dl>

      <p><b>Type errors</b></p>

      <dl>
        <dt><a href="index.html#err-XTTE0505"><span class="error">ERR
        XTTE0505</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the result of
          evaluating the <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>
          cannot be converted to the required type.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0510"><span class="error">ERR
        XTTE0510</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if an <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
          instruction with no <code>select</code> attribute is
          evaluated when the <a title="context item" href=
          "index.html#dt-context-item">context item</a> is not a node.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0520"><span class="error">ERR
        XTTE0520</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the sequence returned
          by the <code>select</code> expression [of <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>]
          contains an item that is not a node.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0570"><span class="error">ERR
        XTTE0570</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the <a title=
          "supplied value" href="index.html#dt-supplied-value">supplied
          value</a> of a variable cannot be converted to the
          required type.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0590"><span class="error">ERR
        XTTE0590</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the conversion of the
          <a title="supplied value" href=
          "index.html#dt-supplied-value">supplied value</a> of a parameter to
          its required type fails.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0600"><span class="error">ERR
        XTTE0600</span></a></dt>

        <dd>
          <p>If a default value is given explicitly, that is, if
          there is either a <code>select</code> attribute or a
          non-empty <a title="sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, then
          it is a <a title="type errors" href="index.html#dt-type-error">type
          error</a> if the default value cannot be converted to the
          required type, using the <a title=
          "function conversion rules" href=
          "index.html#dt-function-conversion-rules">function conversion
          rules</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0780"><span class="error">ERR
        XTTE0780</span></a></dt>

        <dd>
          <p>If the <code>as</code> attribute [of <a href=
          "index.html#element-function"><code>xsl:function</code></a> ] is
          specified, then the result evaluated by the <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> (see
          <a href="index.html#sequence-constructors"><i>5.7 Sequence
          Constructors</i></a>) is converted to the required type,
          using the <a title="function conversion rules" href=
          "index.html#dt-function-conversion-rules">function conversion
          rules</a>. It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if this conversion
          fails.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0790"><span class="error">ERR
        XTTE0790</span></a></dt>

        <dd>
          <p>If the value of a parameter to a <a title=
          "stylesheet function" href=
          "index.html#dt-stylesheet-function">stylesheet function</a> cannot
          be converted to the required type, a <a title=
          "type errors" href="index.html#dt-type-error">type error</a> is
          signaled.</p>
        </dd>

        <dt><a href="index.html#err-XTTE0990"><span class="error">ERR
        XTTE0990</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the <a href=
          "index.html#element-number"><code>xsl:number</code></a> instruction
          is evaluated, with no <code>value</code> or
          <code>select</code> attribute, when the <a title=
          "context item" href="index.html#dt-context-item">context item</a>
          is not a node.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1000"><span class="error">ERR
        XTTE1000</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the result of
          evaluating the <code>select</code> attribute of the
          <a href="index.html#element-number"><code>xsl:number</code></a>
          instruction is anything other than a single node.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1020"><span class="error">ERR
        XTTE1020</span></a></dt>

        <dd>
          <p>If any <a title="sort key value" href=
          "index.html#dt-sort-key-value">sort key value</a>, after <a title=
          "atomize" href="index.html#dt-atomization">atomization</a> and any
          type conversion <span class="verb">required</span> by the
          <code>data-type</code> attribute, is a sequence
          containing more than one item, then the effect depends on
          whether the <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> element is
          evaluated with <a title="backwards compatible behavior"
          href="index.html#dt-backwards-compatible-behavior">backwards
          compatible behavior</a>. With backwards compatible
          behavior, the effective sort key value is the first item
          in the sequence. In other cases, this is a <a title=
          "type errors" href="index.html#dt-type-error">type error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1100"><span class="error">ERR
        XTTE1100</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if the <span>grouping key
          evaluated using</span> the <code>group-adjacent</code>
          attribute is an empty sequence, or a sequence containing
          more than one item.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1120"><span class="error">ERR
        XTTE1120</span></a></dt>

        <dd>
          <p>When the <code>group-starting-with</code> or
          <code>group-ending-with</code> attribute [of the <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          instruction] is used, it is a <a title="type errors"
          href="index.html#dt-type-error">type error</a> if the result of
          evaluating the <code>select</code> expression contains an
          item that is not a node.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1510"><span class="error">ERR
        XTTE1510</span></a></dt>

        <dd>
          <p>If the <code>validation</code> attribute of an
          <a href="index.html#element-element"><code>xsl:element</code></a>,
          <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>,
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>,
          or <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction, or the <code>xsl:validation</code> attribute
          of a literal result element, has the effective value
          <code>strict</code>, and schema validity assessment
          concludes that the validity of the element or attribute
          is invalid or unknown, a type error occurs. As with other
          type errors, the error <span class="verb">may</span> be
          signaled statically if it can be detected statically.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1512"><span class="error">ERR
        XTTE1512</span></a></dt>

        <dd>
          <p>If the <code>validation</code> attribute of an
          <a href="index.html#element-element"><code>xsl:element</code></a>,
          <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>,
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>,
          or <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction, or the <code>xsl:validation</code> attribute
          of a literal result element, has the effective value
          <code>strict</code>, and there is no matching top-level
          declaration in the schema, then a type error occurs. As
          with other type errors, the error <span class=
          "verb">may</span> be signaled statically if it can be
          detected statically.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1515"><span class="error">ERR
        XTTE1515</span></a></dt>

        <dd>
          <p>If the <code>validation</code> attribute of an
          <a href="index.html#element-element"><code>xsl:element</code></a>,
          <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>,
          <a href="index.html#element-copy"><code>xsl:copy</code></a>,
          <a href="index.html#element-copy-of"><code>xsl:copy-of</code></a>,
          or <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction, or the <code>xsl:validation</code> attribute
          of a literal result element, has the effective value
          <code>lax</code>, and schema validity assessment
          concludes that the element or attribute is invalid, a
          type error occurs. As with other type errors, the error
          <span class="verb">may</span> be signaled statically if
          it can be detected statically.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1540"><span class="error">ERR
        XTTE1540</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if an
          <code>[xsl:]type</code> attribute is defined for a
          constructed element or attribute, and the outcome of
          schema validity assessment against that type is that the
          <code>validity</code> property of that element or
          attribute information item is other than
          <code>valid</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1545"><span class="error">ERR
        XTTE1545</span></a></dt>

        <dd>
          <p>A <a title="type errors" href="index.html#dt-type-error">type
          error</a> occurs if a <code>type</code> or
          <code>validation</code> attribute is defined (explicitly
          or implicitly) for an instruction that constructs a new
          attribute node, if the effect of this is to cause the
          attribute value to be validated against a type that is
          derived from, or constructed by list or union from, the
          primitive types <code>xs:QName</code> or
          <code>xs:NOTATION</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1550"><span class="error">ERR
        XTTE1550</span></a></dt>

        <dd>
          <p>A <a title="type errors" href="index.html#dt-type-error">type
          error</a> occurs [when a document node is validated]
          unless the children of the document node comprise exactly
          one element node, no text nodes, and zero or more comment
          and processing instruction nodes, in any order.</p>
        </dd>

        <dt><a href="index.html#err-XTTE1555"><span class="error">ERR
        XTTE1555</span></a></dt>

        <dd>
          <p>It is a <a title="type errors" href=
          "index.html#dt-type-error">type error</a> if, when validating a
          document node, document-level constraints are not
          satisfied. These constraints include identity constraints
          (<code>xs:unique</code>, <code>xs:key</code>, and
          <code>xs:keyref</code>) and ID/IDREF constraints.</p>
        </dd>
      </dl>

      <p><b>Dynamic errors</b></p>

      <dl>
        <dt><a href="index.html#err-XTDE0030"><span class="error">ERR
        XTDE0030</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of an attribute
          written using curly brackets, in a position where an
          <a title="attribute value template" href=
          "index.html#dt-attribute-value-template">attribute value
          template</a> is permitted, is a value that is not one of
          the permitted values for that attribute. If the processor
          is able to detect the error statically (for example, when
          any XPath expressions within the curly brackets can be
          evaluated statically), then the processor may optionally
          signal this as a static error.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0040"><span class="error">ERR
        XTDE0040</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the invocation of the <a title="stylesheet"
          href="index.html#dt-stylesheet">stylesheet</a> specifies a template
          name that does not match the <a title="expanded-QName"
          href="index.html#dt-expanded-qname">expanded-QName</a> of a named
          template defined in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0045"><span class="error">ERR
        XTDE0045</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the invocation of the <a title="stylesheet"
          href="index.html#dt-stylesheet">stylesheet</a> specifies an initial
          <a title="mode" href="index.html#dt-mode">mode</a> (other than the
          default mode) that does not match the <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> in the
          <code>mode</code> attribute of any template defined in
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0047"><span class="error">ERR
        XTDE0047</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the invocation of the <a title="stylesheet"
          href="index.html#dt-stylesheet">stylesheet</a> specifies both an
          initial <a title="mode" href="index.html#dt-mode">mode</a> and an
          initial template.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0050"><span class="error">ERR
        XTDE0050</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the stylesheet that is invoked declares a
          visible <a title="stylesheet parameter" href=
          "index.html#dt-stylesheet-parameter">stylesheet parameter</a> with
          <code>required="yes"</code> and no value for this
          parameter is supplied during the invocation of the
          stylesheet. A stylesheet parameter is visible if it is
          not masked by another global variable or parameter with
          the same name and higher <a title="import precedence"
          href="index.html#dt-import-precedence">import precedence</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0060"><span class="error">ERR
        XTDE0060</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="initial template" href=
          "index.html#dt-initial-template">initial template</a> defines a
          <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a> that
          specifies <code>required="yes"</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0160"><span class="error">ERR
        XTDE0160</span></a></dt>

        <dd>
          <p>If an implementation does not support
          backwards-compatible behavior, then it is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if any element is evaluated that enables
          backwards-compatible behavior.</p>
        </dd>

        <dt><a href="index.html#err-XTRE0270"><span class="error">ERR
        XTRE0270</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          this [the process of finding an <a href=
          "index.html#element-strip-space"><code>xsl:strip-space</code></a>
          or <a href=
          "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>
          declaration to match an element in the source document]
          leaves more than one match<span>, unless all the matched
          declarations are equivalent (that is, they are all
          <a href=
          "index.html#element-strip-space"><code>xsl:strip-space</code></a>
          or they are all <a href=
          "index.html#element-preserve-space"><code>xsl:preserve-space</code></a>)</span>.<br />

          <i>&#160;&#160;&#160;&#160;Action:</i> <span>The
          <a title="optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to select, from the matches that are left,
          the one that occurs last in <a title="declaration order"
          href="index.html#dt-declaration-order">declaration
          order</a>.</span></p>
        </dd>

        <dt><a href="index.html#err-XTDE0290"><span class="error">ERR
        XTDE0290</span></a></dt>

        <dd>
          <p>Where the result of evaluating an XPath expression (or
          an attribute value template) is required to be a
          <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a>, <span>then unless otherwise specified</span>
          it is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="defining element" href=
          "index.html#dt-defining-element">defining element</a> has no
          namespace node whose name matches the prefix of the
          <a title="lexical QName" href="index.html#dt-lexical-qname">lexical
          QName</a>. <span>This error <span class="verb">may</span>
          be signaled as a <a title="static error" href=
          "index.html#dt-static-error">static error</a> if the value of the
          expression can be determined statically.</span></p>
        </dd>

        <dt><a href="index.html#err-XTDE0410"><span class="error">ERR
        XTDE0410</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the result sequence used to construct the
          content of an element node contains a namespace node or
          attribute node that is preceded in the sequence by a node
          that is neither a namespace node nor an attribute
          node.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0420"><span class="error">ERR
        XTDE0420</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the result sequence used to construct the
          content of a document node contains a namespace node or
          attribute node.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0430"><span class="error">ERR
        XTDE0430</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the result sequence contains two or more
          namespace nodes having the same name but different
          <a title="string value" href="index.html#dt-string-value">string
          values</a> (that is, namespace nodes that map the same
          prefix to different namespace URIs).</p>
        </dd>

        <dt><a href="index.html#err-XTDE0440"><span class="error">ERR
        XTDE0440</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the result sequence contains a namespace
          node with no name and the element node being constructed
          has a null namespace URI (that is, it is an error to
          define a default namespace when the element is in no
          namespace).</p>
        </dd>

        <dt><a href="index.html#err-XTDE0485"><span class="error">ERR
        XTDE0485</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if namespace fixup is performed on an element
          that contains among the typed values of the element and
          its attributes two values of type <code>xs:QName</code>
          or <code>xs:NOTATION</code> containing conflicting
          namespace prefixes, that is, two values that use the same
          prefix to refer to different namespace URIs.</p>
        </dd>

        <dt><a href="index.html#err-XTRE0540"><span class="error">ERR
        XTRE0540</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          the conflict resolution algorithm for template rules
          leaves more than one matching template rule.<br />
          <i>&#160;&#160;&#160;&#160;Action:</i> The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to select, from the matching template rules
          that are left, the one that occurs last in <a title=
          "declaration order" href=
          "index.html#dt-declaration-order">declaration order</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0560"><span class="error">ERR
        XTDE0560</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
          <span>or <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a></span>
          is evaluated when the <a title="current template rule"
          href="index.html#dt-current-template-rule">current template
          rule</a> is null.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0610"><span class="error">ERR
        XTDE0610</span></a></dt>

        <dd>
          <p>If an optional parameter has no <code>select</code>
          attribute and has an empty <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a>, and
          if there is an <code>as</code> attribute, then the
          default value of the parameter is an empty sequence. If
          the empty sequence is not a valid instance of the
          required type defined in the <code>as</code> attribute,
          then the parameter is treated as a required parameter,
          which means that it is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the caller supplies no value for the
          parameter.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0640"><span class="error">ERR
        XTDE0640</span></a></dt>

        <dd>
          <p>In general, a <a title="circularity" href=
          "index.html#dt-circularity">circularity</a> in a <a title=
          "stylesheet" href="index.html#dt-stylesheet">stylesheet</a> is a
          <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0700"><span class="error">ERR
        XTDE0700</span></a></dt>

        <dd>
          <p>In other cases, [with <a href=
          "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>,
          <a href=
          "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>,
          and <a href=
          "index.html#element-next-match"><code>xsl:next-match</code></a>, or
          <a href=
          "index.html#element-call-template"><code>xsl:call-template</code></a>
          with <a title="tunnel parameter" href=
          "index.html#dt-tunnel-parameter">tunnel parameters</a>] it is a
          <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the template that is invoked declares a
          <a title="template parameter" href=
          "index.html#dt-template-parameter">template parameter</a> with
          <code>required="yes"</code> and no value for this
          parameter is supplied by the calling instruction.</p>
        </dd>

        <dt><a href="index.html#err-XTRE0795"><span class="error">ERR
        XTRE0795</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          the name of a constructed attribute is
          <code>xml:space</code> and the value is not either
          <code>default</code> or <code>preserve</code>.<br />
          <i>&#160;&#160;&#160;&#160;Action:</i> The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to construct the attribute with the value
          as requested.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0820"><span class="error">ERR
        XTDE0820</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute [of the <a href=
          "index.html#element-element"><code>xsl:element</code></a>
          instruction] is not a <a title="lexical QName" href=
          "index.html#dt-lexical-qname">lexical QName</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0830"><span class="error">ERR
        XTDE0830</span></a></dt>

        <dd>
          <p>In the case of an <a href=
          "index.html#element-element"><code>xsl:element</code></a>
          instruction with no <code>namespace</code> attribute, it
          is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute is a <a title="QName" href=
          "index.html#dt-qname">QName</a> whose prefix is not declared in an
          in-scope namespace declaration for the <a href=
          "index.html#element-element"><code>xsl:element</code></a>
          instruction.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0835"><span class="error">ERR
        XTDE0835</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>namespace</code> attribute [of the <a href=
          "index.html#element-element"><code>xsl:element</code></a>
          instruction] is not in the lexical space of the
          <code>xs:anyURI</code> data type.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0850"><span class="error">ERR
        XTDE0850</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute [of an <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction] is not a <a title="lexical QName" href=
          "index.html#dt-lexical-qname">lexical QName</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0855"><span class="error">ERR
        XTDE0855</span></a></dt>

        <dd>
          <p>In the case of an <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction with no <code>namespace</code> attribute, it
          is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute is the string
          <code>xmlns</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0860"><span class="error">ERR
        XTDE0860</span></a></dt>

        <dd>
          <p>In the case of an <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction with no <code>namespace</code> attribute, it
          is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute is a <a title="lexical QName"
          href="index.html#dt-lexical-qname">lexical QName</a> whose prefix
          is not declared in an in-scope namespace declaration for
          the <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0865"><span class="error">ERR
        XTDE0865</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>namespace</code> attribute [of the <a href=
          "index.html#element-attribute"><code>xsl:attribute</code></a>
          instruction] is not in the lexical space of the
          <code>xs:anyURI</code> data type.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0890"><span class="error">ERR
        XTDE0890</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute [of the <a href=
          "index.html#element-processing-instruction"><code>xsl:processing-instruction</code></a>
          instruction] is not both an <a href=
          "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
          <small>Names</small></sup> and a <a href=
          "http://www.w3.org/TR/2000/REC-xml-20001006#NT-PITarget">PITarget</a><sup>
          <small>XML</small></sup>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0905"><span class="error">ERR
        XTDE0905</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the string value of the new namespace node
          [created using <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>] is
          not valid in the lexical space of the data type
          <code>xs:anyURI</code>. <span class="error">[see <a href=
          "index.html#err-XTDE0835">ERR XTDE0835</a>]</span></p>
        </dd>

        <dt><a href="index.html#err-XTDE0920"><span class="error">ERR
        XTDE0920</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>name</code> attribute [of the <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          instruction] is neither a zero-length string nor an
          <a href=
          "http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a><sup>
          <small>Names</small></sup>, or if it is
          <code>xmlns</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0925"><span class="error">ERR
        XTDE0925</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          instruction generates a namespace node whose name is
          <code>xml</code> and whose string value is not
          <code>http://www.w3.org/XML/1998/namespace</code>, or a
          namespace node whose string value is
          <code>http://www.w3.org/XML/1998/namespace</code> and
          whose name is not <code>xml</code>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0930"><span class="error">ERR
        XTDE0930</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if evaluating the <span><code>select</code>
          attribute or the contained <a title=
          "sequence constructor" href=
          "index.html#dt-sequence-constructor">sequence constructor</a> of an
          <a href=
          "index.html#element-namespace"><code>xsl:namespace</code></a>
          instruction</span> results in a zero-length string.</p>
        </dd>

        <dt><a href="index.html#err-XTDE0980"><span class="error">ERR
        XTDE0980</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if any undiscarded item in the atomized
          sequence supplied as the value of the <code>value</code>
          attribute of <a href=
          "index.html#element-number"><code>xsl:number</code></a> cannot be
          converted to an integer, or if the resulting integer is
          less than 0 (zero).</p>
        </dd>

        <dt><a href="index.html#err-XTDE1030"><span class="error">ERR
        XTDE1030</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if, for any <a title="sort key component" href=
          "index.html#dt-sort-key-component">sort key component</a>, the set
          of <a title="sort key value" href=
          "index.html#dt-sort-key-value">sort key values</a> evaluated for
          all the items in the <a title="initial sequence" href=
          "index.html#dt-initial-sequence">initial sequence</a>, after any
          type conversion requested, contains a pair of ordinary
          values for which the result of the XPath <code>lt</code>
          operator is an error.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1035"><span class="error">ERR
        XTDE1035</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <code>collation</code> attribute of
          <a href="index.html#element-sort"><code>xsl:sort</code></a> (after
          resolving against the base URI) is not a URI that is
          recognized by the implementation as referring to a
          collation.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1110"><span class="error">ERR
        XTDE1110</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the collation URI specified to <a href=
          "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
          <span>(after resolving against the base URI)</span> is a
          collation that is not recognized by the implementation.
          (For notes, <span class="error">[see <a href=
          "index.html#err-XTDE1035">ERR XTDE1035</a>]</span>.)</p>
        </dd>

        <dt><a href="index.html#err-XTDE1140"><span class="error">ERR
        XTDE1140</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>regex</code> attribute [of the <a href=
          "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
          instruction] does not conform to the <span class=
          "verb">required</span> syntax for regular expressions, as
          specified in <a href="index.html#xpath-functions">[Functions and
          Operators]</a>. If the regular expression is known
          statically (for example, if the attribute does not
          contain any <a title="expression" href=
          "index.html#dt-expression">expressions</a> enclosed in curly
          brackets) then the processor <span class=
          "verb">may</span> signal the error as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1145"><span class="error">ERR
        XTDE1145</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>flags</code> attribute [of the <a href=
          "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
          instruction] has a value other than the values defined in
          <a href="index.html#xpath-functions">[Functions and Operators]</a>.
          If the value of the attribute is known statically (for
          example, if the attribute does not contain any <a title=
          "expression" href="index.html#dt-expression">expressions</a>
          enclosed in curly brackets) then the processor
          <span class="verb">may</span> signal the error as a
          <a title="static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1150"><span class="error">ERR
        XTDE1150</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>regex</code> attribute [of the <a href=
          "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
          instruction] is a regular expression that matches a
          zero-length string: or more specifically, if the regular
          expression <code>$r</code> and flags <code>$f</code> are
          such that <code>matches("", $r, $f)</code> returns true.
          If the regular expression is known statically (for
          example, if the attribute does not contain any <a title=
          "expression" href="index.html#dt-expression">expressions</a>
          enclosed in curly brackets) then the processor
          <span class="verb">may</span> signal the error as a
          <a title="static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTRE1160"><span class="error">ERR
        XTRE1160</span></a></dt>

        <dd>
          <p>When a URI reference [supplied to the <a href=
          "index.html#function-document"><code>document</code></a> function]
          contains a fragment identifier, it is a <a title=
          "recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          the media type is not one that is recognized by the
          processor, or if the fragment identifier does not conform
          to the rules for fragment identifiers for that media
          type, or if the fragment identifier selects something
          other than a sequence of nodes (for example, if it
          selects a range of characters within a text node).<br />
          <i>&#160;&#160;&#160;&#160;Action:</i> The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to ignore the fragment identifier and
          return the document node.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1170"><span class="error">ERR
        XTDE1170</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if a URI [supplied in the first argument to the
          <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function] <span>contains a fragment identifier,</span> or
          if it cannot be used to retrieve a resource containing
          text.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1190"><span class="error">ERR
        XTDE1190</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if a resource [retrieved using the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function] contains octets that cannot be decoded into
          Unicode characters using the specified encoding, or if
          the resulting characters are not permitted XML
          characters. This includes the case where the <a title=
          "processor" href="index.html#dt-processor">processor</a> does not
          support the requested encoding.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1200"><span class="error">ERR
        XTDE1200</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the second argument of the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function is omitted and the <a title="processor" href=
          "index.html#dt-processor">processor</a> cannot infer the encoding
          using external information and the encoding is not
          UTF-8.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1260"><span class="error">ERR
        XTDE1260</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the value [of the first argument to the
          <a href="index.html#function-key"><code>key</code></a> function] is
          not a valid QName, or if there is no namespace
          declaration in scope for the prefix of the QName, or if
          the name obtained by expanding the QName is not the same
          as the expanded name of any <a href=
          "index.html#element-key"><code>xsl:key</code></a> declaration in
          the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>. If the processor is able
          to detect the error statically (for example, when the
          argument is supplied as a string literal), then the
          processor <span class="verb">may</span> optionally signal
          this as a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1270"><span class="error">ERR
        XTDE1270</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> to call the <a href=
          "index.html#function-key"><code>key</code></a> function with two
          arguments if there is no <a title="context node" href=
          "index.html#dt-context-node">context node</a>, <span>or if the root
          of the tree containing the context node is not a document
          node</span>; or to call the function with three arguments
          if the root of the tree containing the node supplied in
          the third argument is not a document node.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1280"><span class="error">ERR
        XTDE1280</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the name specified as the
          <code>$decimal-format-name</code> argument [ to the
          <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function] <span>is not a valid <a title="QName" href=
          "index.html#dt-qname">QName</a>, or if its prefix has not been
          declared in an in-scope namespace declaration</span>, or
          if the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> does not contain a
          declaration of a decimal-format with a matching <a title=
          "expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a>. If the processor
          is able to detect the error statically (for example, when
          the argument is supplied as a string literal), then the
          processor <span class="verb">may</span> optionally signal
          this as a <a title="static error" href=
          "index.html#dt-static-error">static error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1310"><span class="error">ERR
        XTDE1310</span></a></dt>

        <dd>
          <p>The <a title="picture string" href=
          "index.html#dt-picture-string">picture string</a> [supplied to the
          <a href=
          "index.html#function-format-number"><code>format-number</code></a>
          function] <span class="verb">must</span> conform to the
          following rules. [ See full specification.] It is a
          <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the picture string does not satisfy these
          rules.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1340"><span class="error">ERR
        XTDE1340</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the syntax of the picture [used for
          date/time formatting] is incorrect.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1350"><span class="error">ERR
        XTDE1350</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if a component specifier within the picture
          [used for date/time formatting] refers to components that
          are not available in the given type of
          <code>$value</code>, for example if the picture supplied
          to the <a href=
          "index.html#function-format-time"><code>format-time</code></a>
          refers to the year, month, or day component.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1360"><span class="error">ERR
        XTDE1360</span></a></dt>

        <dd>
          <p>If the <a href=
          "index.html#function-current"><code>current</code></a> function is
          evaluated within an expression that is evaluated when the
          context item is undefined, a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> occurs.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1370"><span class="error">ERR
        XTDE1370</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a href=
          "index.html#function-unparsed-entity-uri"><code>unparsed-entity-uri</code></a>
          function is called when there is no <a title=
          "context node" href="index.html#dt-context-node">context node</a>,
          or when the root of the tree containing the context node
          is not a document node.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1380"><span class="error">ERR
        XTDE1380</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a href=
          "index.html#function-unparsed-entity-public-id"><code>unparsed-entity-public-id</code></a>
          function is called when there is no <a title=
          "context node" href="index.html#dt-context-node">context node</a>,
          or when the root of the tree containing the context node
          is not a document node.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1390"><span class="error">ERR
        XTDE1390</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the value [supplied as the
          <code>$property-name</code> argument to the <a href=
          "index.html#function-system-property"><code>system-property</code></a>
          function] is not a valid QName, or if there is no
          namespace declaration in scope for the prefix of the
          QName. If the processor is able to detect the error
          statically (for example, when the argument is supplied as
          a string literal), then the processor <span class=
          "verb">may</span> optionally signal this as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTMM9000"><span class="error">ERR
        XTMM9000</span></a></dt>

        <dd>
          <p>When a transformation is terminated by use of
          <code>xsl:message terminate="yes"</code>, the effect is
          the same as when a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> occurs during the transformation.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1400"><span class="error">ERR
        XTDE1400</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the argument [passed to the <a href=
          "index.html#function-function-available"><code>function-available</code></a>
          function] does not evaluate to a string that is a valid
          <a title="QName" href="index.html#dt-qname">QName</a>, or if there
          is no namespace declaration in scope for the prefix of
          the <a title="QName" href="index.html#dt-qname">QName</a>. If the
          processor is able to detect the error statically (for
          example, when the argument is supplied as a string
          literal), then the processor <span class=
          "verb">may</span> optionally signal this as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1420"><span class="error">ERR
        XTDE1420</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the arguments supplied to a call on an
          extension function do not satisfy the rules defined for
          that particular extension function, or if the extension
          function reports an error, or if the result of the
          extension function cannot be converted to an XPath
          value.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1425"><span class="error">ERR
        XTDE1425</span></a></dt>

        <dd>
          <p>When <a title="backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled, it is a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> to evaluate an extension function call if no
          implementation of the extension function is
          available.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1428"><span class="error">ERR
        XTDE1428</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the argument [passed to the <a href=
          "index.html#function-type-available"><code>type-available</code></a>
          function] does not evaluate to a string that is a valid
          <a title="QName" href="index.html#dt-qname">QName</a>, or if there
          is no namespace declaration in scope for the prefix of
          the <a title="QName" href="index.html#dt-qname">QName</a>. If the
          processor is able to detect the error statically (for
          example, when the argument is supplied as a string
          literal), then the processor <span class=
          "verb">may</span> optionally signal this as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1440"><span class="error">ERR
        XTDE1440</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the argument [passed to the <a href=
          "index.html#function-element-available"><code>element-available</code></a>
          function] does not evaluate to a string that is a valid
          <a title="QName" href="index.html#dt-qname">QName</a>, or if there
          is no namespace declaration in scope for the prefix of
          the <a title="QName" href="index.html#dt-qname">QName</a>. If the
          processor is able to detect the error statically (for
          example, when the argument is supplied as a string
          literal), then the processor <span class=
          "verb">may</span> optionally signal this as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1450"><span class="error">ERR
        XTDE1450</span></a></dt>

        <dd>
          <p>When a <a title="processor" href=
          "index.html#dt-processor">processor</a> performs fallback for an
          <a title="extension instruction" href=
          "index.html#dt-extension-instruction">extension instruction</a>
          that is not recognized, if the instruction element has
          one or more <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          children, then the content of each of the <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          children <span class="verb">must</span> be evaluated; it
          is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if it has no <a href=
          "index.html#element-fallback"><code>xsl:fallback</code></a>
          children.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1460"><span class="error">ERR
        XTDE1460</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the <a title="effective value" href=
          "index.html#dt-effective-value">effective value</a> of the
          <code>format</code> attribute [of an <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          element] is not a valid <a title="lexical QName" href=
          "index.html#dt-lexical-qname">lexical QName</a>, or if it does not
          match the <a title="expanded-QName" href=
          "index.html#dt-expanded-qname">expanded-QName</a> of an <a title=
          "output definition" href="index.html#dt-output-definition">output
          definition</a> in the <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a>. If the processor is able
          to detect the error statically (for example, when the
          <code>format</code> attribute contains no curly
          brackets), then the processor <span class=
          "verb">may</span> optionally signal this as a <a title=
          "static error" href="index.html#dt-static-error">static
          error</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1480"><span class="error">ERR
        XTDE1480</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> to evaluate the <a href=
          "index.html#element-result-document"><code>xsl:result-document</code></a>
          instruction in <a title="temporary output state" href=
          "index.html#dt-temporary-output-state">temporary output
          state</a>.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1490"><span class="error">ERR
        XTDE1490</span></a></dt>

        <dd>
          <p>It is a <a title="non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> for a transformation to generate two or more
          <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result trees</a> with the
          same URI.</p>
        </dd>

        <dt><a href="index.html#err-XTRE1495"><span class="error">ERR
        XTRE1495</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> for
          a transformation to generate two or more <a title=
          "final result tree" href="index.html#dt-final-result-tree">final
          result trees</a> with URIs that identify the same
          physical resource. The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is <a title="implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>,
          since it may be impossible for the processor to detect
          the error.</p>
        </dd>

        <dt><a href="index.html#err-XTRE1500"><span class="error">ERR
        XTRE1500</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> for
          a <a title="stylesheet" href=
          "index.html#dt-stylesheet">stylesheet</a> to write to an external
          resource and read from the same resource during a single
          transformation, whether or not the same URI is used to
          access the resource in both cases.<br />
          <i>&#160;&#160;&#160;&#160;Action:</i> The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is <a title="implementation-dependent" href=
          "index.html#dt-implementation-dependent">implementation-dependent</a>:
          implementations are not <span class=
          "verb">required</span> to detect the error condition.
          <span>Note that if the error is not detected, it is
          undefined whether the document that is read from the
          resource reflects its state before or after the result
          tree is written.</span></p>
        </dd>

        <dt><a href="index.html#err-XTRE1620"><span class="error">ERR
        XTRE1620</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          an <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a> or
          <a href="index.html#element-text"><code>xsl:text</code></a>
          instruction specifies that output escaping is to be
          disabled and the implementation does not support
          this.<br />
          <i>&#160;&#160;&#160;&#160;Action:</i> The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to ignore the
          <code>disable-output-escaping</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTRE1630"><span class="error">ERR
        XTRE1630</span></a></dt>

        <dd>
          <p>It is a <a title="recoverable error" href=
          "index.html#dt-recoverable-error">recoverable dynamic error</a> if
          an <a href=
          "index.html#element-value-of"><code>xsl:value-of</code></a> or
          <a href="index.html#element-text"><code>xsl:text</code></a>
          instruction specifies that output escaping is to be
          disabled when writing to a <a title="final result tree"
          href="index.html#dt-final-result-tree">final result tree</a> that
          is not being serialized.<br />
          <i>&#160;&#160;&#160;&#160;Action:</i> The <a title=
          "optional recovery action" href=
          "index.html#dt-optional-recovery-action">optional recovery
          action</a> is to ignore the
          <code>disable-output-escaping</code> attribute.</p>
        </dd>

        <dt><a href="index.html#err-XTDE1665"><span class="error">ERR
        XTDE1665</span></a></dt>

        <dd>
          <p>A <a title="basic XSLT processor" href=
          "index.html#dt-basic-xslt-processor">basic XSLT processor</a>
          <span class="verb">must</span> raise a <a title=
          "non-recoverable dynamic error" href=
          "index.html#dt-nonrec-dynamic-error">non-recoverable dynamic
          error</a> if the input to the processor includes a node
          with a <a title="type annotation" href=
          "index.html#dt-annotation">type annotation</a> other than
          <span><code>xs:untyped</code></span> or
          <span><code>xs:untypedAtomic</code></span>, or an atomic
          value of a type other than those which a basic XSLT
          processor supports.</p>
        </dd>
      </dl>
    </div>

    <div class="div1">
      <h2><a name="implementation-defined-features" id=
      "implementation-defined-features"></a>F Checklist of
      Implementation-Defined Features (Non-Normative)</h2>

      <p>This appendix provides a summary of XSLT language features
      whose effect is explicitly <a title="implementation-defined"
      href="index.html#dt-implementation-defined">implementation-defined</a>.
      The conformance rules (see <a href="index.html#conformance"><i>21
      Conformance</i></a>) require vendors to provide documentation
      that explains how these choices have been exercised.</p>

      <ol>
        <li>
          <p>The way in which an XSLT processor is invoked, and the
          way in which values are supplied for the source document,
          starting node, <a title="stylesheet parameter" href=
          "index.html#dt-stylesheet-parameter">stylesheet parameters</a>, and
          <a title="base output URI" href=
          "index.html#dt-base-output-uri">base output URI</a>, are
          implementation-defined. (See <a href="index.html#initiating"><i>2.3
          Initiating a Transformation</i></a>)</p>
        </li>

        <li>
          <p>The mechanisms for creating new extension instructions
          and extension functions are implementation-defined. (See
          <a href="index.html#extensibility"><i>2.7
          Extensibility</i></a>)</p>
        </li>

        <li>
          <p>Where the specification provides a choice between
          signaling a dynamic error or recovering, the decision
          that is made (but not the recovery action itself) is
          implementation-defined. (See <a href="index.html#errors"><i>2.9
          Error Handling</i></a>)</p>
        </li>

        <li>
          <p>It is implementation-defined whether type errors are
          signaled statically. (See <a href="index.html#errors"><i>2.9 Error
          Handling</i></a>)</p>
        </li>

        <li>
          <p>The set of namespaces that are specially recognized by
          the implementation (for example, for user-defined data
          elements, and <a title="extension attribute" href=
          "index.html#dt-extension-attribute">extension attributes</a>) is
          implementation-defined. (See <a href=
          "index.html#user-defined-top-level"><i>3.6.2 User-defined Data
          Elements</i></a>)</p>
        </li>

        <li>
          <p>The effect of user-defined data elements whose name is
          in a namespace recognized by the implementation is
          implementation-defined. (See <a href=
          "index.html#user-defined-top-level"><i>3.6.2 User-defined Data
          Elements</i></a>)</p>
        </li>

        <li>
          <p>It is implementation-defined whether an XSLT 2.0
          processor supports backwards-compatible behavior. (See
          <a href="index.html#backwards"><i>3.8 Backwards-Compatible
          Processing</i></a>)</p>
        </li>

        <li>
          <p>It is implementation-defined what forms of URI
          reference are acceptable in the <code>href</code>
          attribute of the <a href=
          "index.html#element-include"><code>xsl:include</code></a> and
          <a href="index.html#element-import"><code>xsl:import</code></a>
          elements, for example, the URI schemes that may be used,
          the forms of fragment identifier that may be used, and
          the media types that are supported. (See <a href=
          "index.html#locating-modules"><i>3.10.1 Locating Stylesheet
          Modules</i></a>)</p>
        </li>

        <li>
          <p>An implementation may define mechanisms, above and
          beyond <a href=
          "index.html#element-import-schema"><code>xsl:import-schema</code></a>
          that allow <a title="schema component" href=
          "index.html#dt-schema-component">schema components</a> such as type
          definitions to be made available within a stylesheet.
          (See <a href="index.html#built-in-types"><i>3.13 Built-in
          Types</i></a>)</p>
        </li>

        <li>
          <p>It is implementation-defined which versions of XML and
          XML Namespaces (1.0 and/or 1.1) are supported. (See
          <a href="index.html#xml-versions"><i>4.1 XML Versions</i></a>)</p>
        </li>

        <li>
          <p>Limits on the value space of primitive data types,
          where not fixed by <a href="index.html#xmlschema-2">[XML Schema
          Part 2]</a>, are implementation-defined. (See <a href=
          "index.html#limits"><i>4.6 Limits</i></a>)</p>
        </li>

        <li>
          <p>The implicit timezone for a transformation is
          implementation-defined. (See <a href=
          "index.html#evaluation-context"><i>5.4.3.2 Other components of the
          XPath Dynamic Context</i></a>)</p>
        </li>

        <li>
          <p>If an <code>xml:id</code> attribute that has not been
          subjected to attribute value normalization is copied from
          a source tree to a result tree, it is
          implementation-defined whether attribute value
          normalization will be applied during the copy process.
          (See <a href="index.html#shallow-copy"><i>11.9.1 Shallow
          Copy</i></a>)</p>
        </li>

        <li>
          <p>The numbering sequences supported by the <a href=
          "index.html#element-number"><code>xsl:number</code></a>
          instructions, beyond those defined in this specification,
          are implementation-defined. (See <a href=
          "index.html#convert"><i>12.3 Number to String Conversion
          Attributes</i></a>)</p>
        </li>

        <li>
          <p>There <span class="verb">may</span> be
          implementation-defined upper bounds on the numbers that
          can be formatted by <a href=
          "index.html#element-number"><code>xsl:number</code></a> using any
          particular numbering sequence. (See <a href=
          "index.html#convert"><i>12.3 Number to String Conversion
          Attributes</i></a>)</p>
        </li>

        <li>
          <p>The set of languages for which numbering is supported
          by <a href="index.html#element-number"><code>xsl:number</code></a>,
          and the method of choosing a default language, are
          implementation-defined. (See <a href="index.html#convert"><i>12.3
          Number to String Conversion Attributes</i></a>)</p>
        </li>

        <li>
          <p>If the <code>data-type</code> attribute of the
          <a href="index.html#element-sort"><code>xsl:sort</code></a> element
          has a value other than <code>text</code> or
          <code>number</code>, the effect is
          implementation-defined. (See <a href=
          "index.html#comparing-sort-keys"><i>13.1.2 Comparing Sort Key
          Values</i></a>)</p>
        </li>

        <li>
          <p>The facilities for defining collations and allocating
          URIs to identify them are implementation-defined. (See
          <a href="index.html#collating-sequences"><i>13.1.3 Sorting Using
          Collations</i></a>)</p>
        </li>

        <li>
          <p>The algorithm used by <a href=
          "index.html#element-sort"><code>xsl:sort</code></a> to locate a
          collation, given the values of the <code>lang</code> and
          <code>case-order</code> attributes, is
          implementation-defined. (See <a href=
          "index.html#collating-sequences"><i>13.1.3 Sorting Using
          Collations</i></a>)</p>
        </li>

        <li>
          <p>The set of media types recognized by the processor,
          for the purpose of interpreting fragment identifiers in
          URI references passed to the <a href=
          "index.html#function-document"><code>document</code></a> function,
          is implementation-defined. (See <a href=
          "index.html#document"><i>16.1 Multiple Source
          Documents</i></a>)</p>
        </li>

        <li>
          <p>The set of encodings recognized by the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function, other than <code>utf-8</code> and
          <code>utf-16</code>, is <a title="implementation-defined"
          href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          (See <a href="index.html#unparsed-text"><i>16.2 Reading Text
          Files</i></a>)</p>
        </li>

        <li>
          <p>If no encoding is specified on a call to the <a href=
          "index.html#function-unparsed-text"><code>unparsed-text</code></a>
          function, the processor <span class="verb">may</span> use
          <a title="implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>
          heuristics to determine the likely encoding. (See
          <a href="index.html#unparsed-text"><i>16.2 Reading Text
          Files</i></a>)</p>
        </li>

        <li>
          <p>The set of languages, calendars, and countries that
          are supported in the <a title="date formatting function"
          href="index.html#dt-date-formatting-function">date formatting
          functions</a> is implementation-defined. If any of these
          arguments is omitted or set to an empty sequence, the
          default is implementation-defined. (See <a href=
          "index.html#lang-cal-country"><i>16.5.2 The Language, Calendar, and
          Country Arguments</i></a>)</p>
        </li>

        <li>
          <p>The choice of the names and abbreviations used in any
          given language for calendar units such as days of the
          week and months of the year is <a title=
          "implementation-defined" href=
          "index.html#dt-implementation-defined">implementation-defined</a>.
          (See <a href="index.html#lang-cal-country"><i>16.5.2 The Language,
          Calendar, and Country Arguments</i></a>)</p>
        </li>

        <li>
          <p>The values returned by the <a href=
          "index.html#function-system-property"><code>system-property</code></a>
          function, and the names of the additional properties that
          are recognized, are implementation-defined. (See <a href=
          "index.html#system-property"><i>16.6.5 system-property</i></a>)</p>
        </li>

        <li>
          <p>The destination and formatting of messages written
          using the <a href=
          "index.html#element-message"><code>xsl:message</code></a>
          instruction are implementation-defined. (See <a href=
          "index.html#message"><i>17 Messages</i></a>)</p>
        </li>

        <li>
          <p>The effect of an extension function returning a string
          containing characters that are not legal in XML is
          implementation-defined. (See <a href=
          "index.html#calling-extension-functions"><i>18.1.2 Calling
          Extension Functions</i></a>)</p>
        </li>

        <li>
          <p>The way in which external objects are represented in
          the type system is implementation-defined. (See <a href=
          "index.html#external-objects"><i>18.1.3 External
          Objects</i></a>)</p>
        </li>

        <li>
          <p>The way in which a final result tree is delivered to
          an application is implementation-defined. (See <a href=
          "index.html#result-trees"><i>19 Final Result Trees</i></a>)</p>
        </li>

        <li>
          <p>Implementations <span class="verb">may</span> provide
          additional mechanisms allowing users to define the way in
          which <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result trees</a> are
          processed. (See <a href="index.html#creating-result-trees"><i>19.1
          Creating Final Result Trees</i></a>)</p>
        </li>

        <li>
          <p>If serialization is supported, then the location to
          which a <a title="final result tree" href=
          "index.html#dt-final-result-tree">final result tree</a> is
          serialized is implementation-defined, subject to the
          constraint that relative URIs used to reference one tree
          from another remain valid. (See <a href=
          "index.html#serialization"><i>20 Serialization</i></a>)</p>
        </li>

        <li>
          <p>The default value of the <code>encoding</code>
          attribute of the <a href=
          "index.html#element-output"><code>xsl:output</code></a> element is
          implementation-defined. (See <a href=
          "index.html#serialization"><i>20 Serialization</i></a>)</p>
        </li>

        <li>
          <p>It is implementation-defined which versions of XML,
          HTML, and XHTML are supported in the <code>version</code>
          attribute of the <a href=
          "index.html#element-output"><code>xsl:output</code></a>
          declaration. (See <a href="index.html#serialization"><i>20
          Serialization</i></a>)</p>
        </li>

        <li>
          <p>The default value of the <code>byte-order-mark</code>
          serialization parameter is implementation-defined in the
          case of UTF-8 encoding. (See <a href=
          "index.html#serialization"><i>20 Serialization</i></a>)</p>
        </li>

        <li>
          <p>It is implementation-defined whether, and under what
          circumstances, disabling output escaping is supported.
          (See <a href="index.html#disable-output-escaping"><i>20.2 Disabling
          Output Escaping</i></a>)</p>
        </li>
      </ol>
    </div>

    <div class="div1">
      <h2><a name="schema-for-xslt" id="schema-for-xslt"></a>G
      Schema for XSLT Stylesheets (Non-Normative)</h2>

      <p>The following schema describes the structure of an XSLT
      stylesheet module. It does not define all the constraints
      that apply to a stylesheet (for example, it does not attempt
      to define a data type that precisely represents attributes
      containing XPath <a title="expression" href=
      "index.html#dt-expression">expressions</a>). <span>However, every valid
      stylesheet module conforms to this schema, unless it contains
      elements that invoke <a title="forwards-compatible behavior"
      href=
      "index.html#dt-forwards-compatible-behavior">forwards-compatible-behavior</a>.</span></p>

      <p>A copy of this schema is available at <a href=
      "http://www.w3.org/2007/schema-for-xslt20.xsd">http://www.w3.org/2007/schema-for-xslt20.xsd</a></p>
      <pre>
&lt;?xml version="1.0"?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/XSL/Transform" elementFormDefault="qualified" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
&lt;xs:annotation&gt;
  &lt;xs:documentation&gt;
  
    This is a schema for XSLT 2.0 stylesheets.
    
    It defines all the elements that appear in the XSLT namespace; it also
    provides hooks that allow the inclusion of user-defined literal result elements,
    extension instructions, and top-level data elements.
    
    The schema is derived (with kind permission) from a schema for XSLT 1.0 stylesheets
    produced by Asir S Vedamuthu of WebMethods Inc.
    
    This schema is available for use under the conditions of the W3C Software License
    published at http://www.w3.org/Consortium/Legal/copyright-software-19980720
    
    The schema is organized as follows:
    
    PART A: definitions of complex types and model groups used as the basis 
            for element definitions
    PART B: definitions of individual XSLT elements
    PART C: definitions for literal result elements
    PART D: definitions of simple types used in attribute definitions
    
    This schema does not attempt to define all the constraints that apply to a valid
    XSLT 2.0 stylesheet module. It is the intention that all valid stylesheet modules 
    should conform to this schema; however, the schema is non-normative and in the event 
    of any conflict, the text of the Recommendation takes precedence.

    This schema does not implement the special rules that apply when a stylesheet
    has sections that use forwards-compatible-mode. In this mode, setting version="3.0"
    allows elements from the XSLT namespace to be used that are not defined in XSLT 2.0.

    Simplified stylesheets (those with a literal result element as the outermost element)
    will validate against this schema only if validation starts in lax mode.
    
    This version is dated 2005-02-11
    Authors: Michael H Kay, Saxonica Limited
             Jeni Tennison, Jeni Tennison Consulting Ltd.
    
  &lt;/xs:documentation&gt;
&lt;/xs:annotation&gt;   
&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
 
&lt;!--
The declaration of xml:space and xml:lang may need to be commented out because
of problems processing the schema using various tools
--&gt;
      
&lt;xs:import namespace="http://www.w3.org/XML/1998/namespace" 
  schemaLocation="http://www.w3.org/2001/xml.xsd"/&gt;

&lt;!-- 
    An XSLT stylesheet may contain an in-line schema within an xsl:import-schema element,
    so the Schema for schemas needs to be imported
--&gt;
  
&lt;xs:import namespace="http://www.w3.org/2001/XMLSchema"
                  schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/&gt;

&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
&lt;xs:annotation&gt;
  &lt;xs:documentation&gt;
    PART A: definitions of complex types and model groups used as the basis 
            for element definitions
  &lt;/xs:documentation&gt;
&lt;/xs:annotation&gt;   
&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;

&lt;xs:complexType name="generic-element-type" mixed="true"&gt;
  &lt;xs:attribute name="default-collation" type="xsl:uri-list"/&gt;
  &lt;xs:attribute name="exclude-result-prefixes" type="xsl:prefix-list-or-all"/&gt;
  &lt;xs:attribute name="extension-element-prefixes" type="xsl:prefix-list"/&gt;
  &lt;xs:attribute name="use-when" type="xsl:expression"/&gt;
  &lt;xs:attribute name="xpath-default-namespace" type="xs:anyURI"/&gt;
  &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;
&lt;/xs:complexType&gt;

&lt;xs:complexType name="versioned-element-type" mixed="true"&gt;
  &lt;xs:complexContent&gt;
    &lt;xs:extension base="xsl:generic-element-type"&gt;    
      &lt;xs:attribute name="version" type="xs:decimal" use="optional"/&gt;
    &lt;/xs:extension&gt;
  &lt;/xs:complexContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:complexType name="element-only-versioned-element-type" mixed="false"&gt;
  &lt;xs:complexContent&gt;
    &lt;xs:restriction base="xsl:versioned-element-type"&gt;
      &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:complexContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:complexType name="sequence-constructor"&gt;
  &lt;xs:complexContent mixed="true"&gt;
    &lt;xs:extension base="xsl:versioned-element-type"&gt;    
      &lt;xs:group ref="xsl:sequence-constructor-group" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:extension&gt;
  &lt;/xs:complexContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:group name="sequence-constructor-group"&gt;
  &lt;xs:choice&gt;
    &lt;xs:element ref="xsl:variable"/&gt;
    &lt;xs:element ref="xsl:instruction"/&gt;
    &lt;xs:group ref="xsl:result-elements"/&gt;
  &lt;/xs:choice&gt;
&lt;/xs:group&gt;

&lt;xs:element name="declaration" type="xsl:generic-element-type" abstract="true"/&gt;

&lt;xs:element name="instruction" type="xsl:versioned-element-type" abstract="true"/&gt;

&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
&lt;xs:annotation&gt;
  &lt;xs:documentation&gt;
    PART B: definitions of individual XSLT elements    
    Elements are listed in alphabetical order.    
  &lt;/xs:documentation&gt;
&lt;/xs:annotation&gt;   
&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;

&lt;xs:element name="analyze-string" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:matching-substring" minOccurs="0"/&gt;
          &lt;xs:element ref="xsl:non-matching-substring" minOccurs="0"/&gt;
          &lt;xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="select" type="xsl:expression" use="required"/&gt;
        &lt;xs:attribute name="regex" type="xsl:avt" use="required"/&gt;
        &lt;xs:attribute name="flags" type="xsl:avt" default=""/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="apply-imports" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="apply-templates" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:element ref="xsl:sort"/&gt;
          &lt;xs:element ref="xsl:with-param"/&gt;
        &lt;/xs:choice&gt;
        &lt;xs:attribute name="select" type="xsl:expression" default="child::node()"/&gt;
        &lt;xs:attribute name="mode" type="xsl:mode"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="attribute" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:avt" use="required"/&gt;
        &lt;xs:attribute name="namespace" type="xsl:avt"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="separator" type="xsl:avt"/&gt;   
        &lt;xs:attribute name="type" type="xsl:QName"/&gt;
        &lt;xs:attribute name="validation" type="xsl:validation-type"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;        

&lt;xs:element name="attribute-set" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:element ref="xsl:attribute"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="use-attribute-sets" type="xsl:QNames" default=""/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="call-template" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="character-map" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:output-character" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="use-character-maps" type="xsl:QNames" default=""/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="choose" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:when" maxOccurs="unbounded"/&gt;
          &lt;xs:element ref="xsl:otherwise" minOccurs="0"/&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="comment" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="copy" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/&gt;
        &lt;xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/&gt;
        &lt;xs:attribute name="use-attribute-sets" type="xsl:QNames" default=""/&gt;
        &lt;xs:attribute name="type" type="xsl:QName"/&gt;
        &lt;xs:attribute name="validation" type="xsl:validation-type"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="copy-of" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:attribute name="select" type="xsl:expression" use="required"/&gt;
        &lt;xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/&gt;
        &lt;xs:attribute name="type" type="xsl:QName"/&gt;
        &lt;xs:attribute name="validation" type="xsl:validation-type"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="decimal-format" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:attribute name="name" type="xsl:QName"/&gt;
        &lt;xs:attribute name="decimal-separator" type="xsl:char" default="."/&gt;
        &lt;xs:attribute name="grouping-separator" type="xsl:char" default=","/&gt;
        &lt;xs:attribute name="infinity" type="xs:string" default="Infinity"/&gt;
        &lt;xs:attribute name="minus-sign" type="xsl:char" default="-"/&gt;
        &lt;xs:attribute name="NaN" type="xs:string" default="NaN"/&gt;
        &lt;xs:attribute name="percent" type="xsl:char" default="%"/&gt;
        &lt;xs:attribute name="per-mille" type="xsl:char" default="&amp;#x2030;"/&gt;
        &lt;xs:attribute name="zero-digit" type="xsl:char" default="0"/&gt;
        &lt;xs:attribute name="digit" type="xsl:char" default="#"/&gt;
        &lt;xs:attribute name="pattern-separator" type="xsl:char" default=";"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="element" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType mixed="true"&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:avt" use="required"/&gt;
        &lt;xs:attribute name="namespace" type="xsl:avt"/&gt;
        &lt;xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/&gt;
        &lt;xs:attribute name="use-attribute-sets" type="xsl:QNames" default=""/&gt;
        &lt;xs:attribute name="type" type="xsl:QName"/&gt;
        &lt;xs:attribute name="validation" type="xsl:validation-type"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="fallback" substitutionGroup="xsl:instruction" type="xsl:sequence-constructor"/&gt;

&lt;xs:element name="for-each" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;xs:group ref="xsl:sequence-constructor-group" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="select" type="xsl:expression" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="for-each-group" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;xs:group ref="xsl:sequence-constructor-group" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="select" type="xsl:expression" use="required"/&gt;
        &lt;xs:attribute name="group-by" type="xsl:expression"/&gt;
        &lt;xs:attribute name="group-adjacent" type="xsl:expression"/&gt;            
        &lt;xs:attribute name="group-starting-with" type="xsl:pattern"/&gt;            
        &lt;xs:attribute name="group-ending-with" type="xsl:pattern"/&gt;            
        &lt;xs:attribute name="collation" type="xs:anyURI"/&gt;            
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="function" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;xs:group ref="xsl:sequence-constructor-group" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="override" type="xsl:yes-or-no" default="yes"/&gt;
        &lt;xs:attribute name="as" type="xsl:sequence-type" default="item()*"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="if" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="test" type="xsl:expression" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="import"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:attribute name="href" type="xs:anyURI" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="import-schema" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xs:schema" minOccurs="0" maxOccurs="1"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="namespace" type="xs:anyURI"/&gt;
        &lt;xs:attribute name="schema-location" type="xs:anyURI"/&gt;                  
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="include" substitutionGroup="xsl:declaration"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:complexContent&gt;
        &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
          &lt;xs:attribute name="href" type="xs:anyURI" use="required"/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="key" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="match" type="xsl:pattern" use="required"/&gt;
        &lt;xs:attribute name="use" type="xsl:expression"/&gt;
        &lt;xs:attribute name="collation" type="xs:anyURI"/&gt;               
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="matching-substring" type="xsl:sequence-constructor"/&gt;

&lt;xs:element name="message" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="terminate" type="xsl:avt" default="no"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="namespace" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:avt" use="required"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="namespace-alias" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:attribute name="stylesheet-prefix" type="xsl:prefix-or-default" use="required"/&gt;
        &lt;xs:attribute name="result-prefix" type="xsl:prefix-or-default" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="next-match" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:element ref="xsl:with-param"/&gt;
          &lt;xs:element ref="xsl:fallback"/&gt;
        &lt;/xs:choice&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="non-matching-substring" type="xsl:sequence-constructor"/&gt;

&lt;xs:element name="number" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:attribute name="value" type="xsl:expression"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="level" type="xsl:level" default="single"/&gt;
        &lt;xs:attribute name="count" type="xsl:pattern"/&gt;
        &lt;xs:attribute name="from" type="xsl:pattern"/&gt;
        &lt;xs:attribute name="format" type="xsl:avt" default="1"/&gt;
        &lt;xs:attribute name="lang" type="xsl:avt"/&gt;
        &lt;xs:attribute name="letter-value" type="xsl:avt"/&gt;
        &lt;xs:attribute name="ordinal" type="xsl:avt"/&gt;        
        &lt;xs:attribute name="grouping-separator" type="xsl:avt"/&gt;
        &lt;xs:attribute name="grouping-size" type="xsl:avt"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="otherwise" type="xsl:sequence-constructor"/&gt;

&lt;xs:element name="output" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:generic-element-type"&gt;
        &lt;xs:attribute name="name" type="xsl:QName"/&gt;
        &lt;xs:attribute name="method" type="xsl:method"/&gt;
        &lt;xs:attribute name="byte-order-mark" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="cdata-section-elements" type="xsl:QNames"/&gt;
        &lt;xs:attribute name="doctype-public" type="xs:string"/&gt;
        &lt;xs:attribute name="doctype-system" type="xs:string"/&gt;
        &lt;xs:attribute name="encoding" type="xs:string"/&gt;
        &lt;xs:attribute name="escape-uri-attributes" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="include-content-type" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="indent" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="media-type" type="xs:string"/&gt;
        &lt;xs:attribute name="normalization-form" type="xs:NMTOKEN"/&gt;
        &lt;xs:attribute name="omit-xml-declaration" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="standalone" type="xsl:yes-or-no-or-omit"/&gt;
        &lt;xs:attribute name="undeclare-prefixes" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="use-character-maps" type="xsl:QNames"/&gt;
        &lt;xs:attribute name="version" type="xs:NMTOKEN"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="output-character"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:attribute name="character" type="xsl:char" use="required"/&gt;
        &lt;xs:attribute name="string" type="xs:string" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="param"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="as" type="xsl:sequence-type"/&gt;
        &lt;xs:attribute name="required" type="xsl:yes-or-no"/&gt;
        &lt;xs:attribute name="tunnel" type="xsl:yes-or-no"/&gt;        
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="perform-sort" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:sort" minOccurs="1" maxOccurs="unbounded"/&gt;
          &lt;xs:group ref="xsl:sequence-constructor-group" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="preserve-space" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:attribute name="elements" type="xsl:nametests" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="processing-instruction" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:avt" use="required"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="result-document" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="format" type="xsl:avt"/&gt;
        &lt;xs:attribute name="href" type="xsl:avt"/&gt;
        &lt;xs:attribute name="type" type="xsl:QName"/&gt;
        &lt;xs:attribute name="validation" type="xsl:validation-type"/&gt;
        &lt;xs:attribute name="method" type="xsl:avt"/&gt;
        &lt;xs:attribute name="byte-order-mark" type="xsl:avt"/&gt;
        &lt;xs:attribute name="cdata-section-elements" type="xsl:avt"/&gt;
        &lt;xs:attribute name="doctype-public" type="xsl:avt"/&gt;
        &lt;xs:attribute name="doctype-system" type="xsl:avt"/&gt;
        &lt;xs:attribute name="encoding" type="xsl:avt"/&gt;
        &lt;xs:attribute name="escape-uri-attributes" type="xsl:avt"/&gt;
        &lt;xs:attribute name="include-content-type" type="xsl:avt"/&gt;
        &lt;xs:attribute name="indent" type="xsl:avt"/&gt;
        &lt;xs:attribute name="media-type" type="xsl:avt"/&gt;
        &lt;xs:attribute name="normalization-form" type="xsl:avt"/&gt;
        &lt;xs:attribute name="omit-xml-declaration" type="xsl:avt"/&gt;
        &lt;xs:attribute name="standalone" type="xsl:avt"/&gt;
        &lt;xs:attribute name="undeclare-prefixes" type="xsl:avt"/&gt;
        &lt;xs:attribute name="use-character-maps" type="xsl:QNames"/&gt;
        &lt;xs:attribute name="output-version" type="xsl:avt"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="sequence" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="as" type="xsl:sequence-type"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="sort"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;  
        &lt;xs:attribute name="lang" type="xsl:avt"/&gt;        
        &lt;xs:attribute name="data-type" type="xsl:avt" default="text"/&gt;        
        &lt;xs:attribute name="order" type="xsl:avt" default="ascending"/&gt;        
        &lt;xs:attribute name="case-order" type="xsl:avt"/&gt;
        &lt;xs:attribute name="collation" type="xsl:avt"/&gt;
        &lt;xs:attribute name="stable" type="xsl:yes-or-no"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="strip-space" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:element-only-versioned-element-type"&gt;
        &lt;xs:attribute name="elements" type="xsl:nametests" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="stylesheet" substitutionGroup="xsl:transform"/&gt;

&lt;xs:element name="template" substitutionGroup="xsl:declaration"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:versioned-element-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;xs:group ref="xsl:sequence-constructor-group" minOccurs="0" maxOccurs="unbounded"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="match" type="xsl:pattern"/&gt;
        &lt;xs:attribute name="priority" type="xs:decimal"/&gt;
        &lt;xs:attribute name="mode" type="xsl:modes"/&gt;
        &lt;xs:attribute name="name" type="xsl:QName"/&gt;
        &lt;xs:attribute name="as" type="xsl:sequence-type" default="item()*"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:complexType name="text-element-base-type"&gt;
  &lt;xs:simpleContent&gt;
    &lt;xs:restriction base="xsl:versioned-element-type"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"/&gt;
      &lt;/xs:simpleType&gt;
      &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:element name="text" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:simpleContent&gt;
      &lt;xs:extension base="xsl:text-element-base-type"&gt;
        &lt;xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:simpleContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:complexType name="transform-element-base-type"&gt;
  &lt;xs:complexContent&gt;
    &lt;xs:restriction base="xsl:element-only-versioned-element-type"&gt;
      &lt;xs:attribute name="version" type="xs:decimal" use="required"/&gt;
      &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:complexContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:element name="transform"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="xsl:transform-element-base-type"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element ref="xsl:import" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
            &lt;xs:element ref="xsl:declaration"/&gt;
            &lt;xs:element ref="xsl:variable"/&gt;
            &lt;xs:element ref="xsl:param"/&gt;              
            &lt;xs:any namespace="##other" processContents="lax"/&gt; &lt;!-- weaker than XSLT 1.0 --&gt;
          &lt;/xs:choice&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="id" type="xs:ID"/&gt;
        &lt;xs:attribute name="default-validation" type="xsl:validation-strip-or-preserve" default="strip"/&gt;
        &lt;xs:attribute name="input-type-annotations" type="xsl:input-type-annotations-type" default="unspecified"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="value-of" substitutionGroup="xsl:instruction"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="separator" type="xsl:avt"/&gt;            
        &lt;xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="variable"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression" use="optional"/&gt;
        &lt;xs:attribute name="as" type="xsl:sequence-type" use="optional"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="when"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="test" type="xsl:expression" use="required"/&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:element name="with-param"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:complexContent mixed="true"&gt;
      &lt;xs:extension base="xsl:sequence-constructor"&gt;
        &lt;xs:attribute name="name" type="xsl:QName" use="required"/&gt;
        &lt;xs:attribute name="select" type="xsl:expression"/&gt;
        &lt;xs:attribute name="as" type="xsl:sequence-type"/&gt;
        &lt;xs:attribute name="tunnel" type="xsl:yes-or-no"/&gt;   
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
&lt;xs:annotation&gt;
  &lt;xs:documentation&gt;
    PART C: definition of literal result elements
    
    There are three ways to define the literal result elements
    permissible in a stylesheet.
    
    (a) do nothing. This allows any element to be used as a literal
        result element, provided it is not in the XSLT namespace
    
    (b) declare all permitted literal result elements as members
        of the xsl:literal-result-element substitution group
        
    (c) redefine the model group xsl:result-elements to accommodate
        all permitted literal result elements.
        
    Literal result elements are allowed to take certain attributes
    in the XSLT namespace. These are defined in the attribute group
    literal-result-element-attributes, which can be included in the
    definition of any literal result element.
    
  &lt;/xs:documentation&gt;
&lt;/xs:annotation&gt;   
&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;

&lt;xs:element name="literal-result-element" abstract="true" type="xs:anyType"/&gt;

&lt;xs:attributeGroup name="literal-result-element-attributes"&gt;
  &lt;xs:attribute name="default-collation" form="qualified" type="xsl:uri-list"/&gt;
  &lt;xs:attribute name="extension-element-prefixes" form="qualified" type="xsl:prefixes"/&gt;
  &lt;xs:attribute name="exclude-result-prefixes" form="qualified" type="xsl:prefixes"/&gt;
  &lt;xs:attribute name="xpath-default-namespace" form="qualified" type="xs:anyURI"/&gt;    
  &lt;xs:attribute name="inherit-namespaces" form="qualified" type="xsl:yes-or-no" default="yes"/&gt;
  &lt;xs:attribute name="use-attribute-sets" form="qualified" type="xsl:QNames" default=""/&gt;
  &lt;xs:attribute name="use-when" form="qualified" type="xsl:expression"/&gt;
  &lt;xs:attribute name="version" form="qualified" type="xs:decimal"/&gt;
  &lt;xs:attribute name="type" form="qualified" type="xsl:QName"/&gt;
  &lt;xs:attribute name="validation" form="qualified" type="xsl:validation-type"/&gt;
&lt;/xs:attributeGroup&gt;

&lt;xs:group name="result-elements"&gt;
  &lt;xs:choice&gt;
    &lt;xs:element ref="xsl:literal-result-element"/&gt;
    &lt;xs:any namespace="##other" processContents="lax"/&gt;
    &lt;xs:any namespace="##local" processContents="lax"/&gt;
  &lt;/xs:choice&gt;
&lt;/xs:group&gt;


&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
&lt;xs:annotation&gt;
  &lt;xs:documentation&gt;
    PART D: definitions of simple types used in stylesheet attributes 
  &lt;/xs:documentation&gt;
&lt;/xs:annotation&gt;   
&lt;!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --&gt;

&lt;xs:simpleType name="avt"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      This type is used for all attributes that allow an attribute value template.
      The general rules for the syntax of attribute value templates, and the specific
      rules for each such attribute, are described in the XSLT 2.0 Recommendation.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:string"/&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="char"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      A string containing exactly one character.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:string"&gt;
    &lt;xs:length value="1"/&gt;
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="expression"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      An XPath 2.0 expression.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:token"&gt;
    &lt;xs:pattern value=".+"/&gt;
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="input-type-annotations-type"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      Describes how type annotations in source documents are handled.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:token"&gt;
    &lt;xs:enumeration value="preserve"/&gt;
    &lt;xs:enumeration value="strip"/&gt;   
    &lt;xs:enumeration value="unspecified"/&gt;        
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="level"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      The level attribute of xsl:number: 
      one of single, multiple, or any.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:NCName"&gt;
    &lt;xs:enumeration value="single"/&gt;
    &lt;xs:enumeration value="multiple"/&gt;
    &lt;xs:enumeration value="any"/&gt;
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="mode"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      The mode attribute of xsl:apply-templates: 
      either a QName, or #current, or #default.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:union memberTypes="xsl:QName"&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:token"&gt;
        &lt;xs:enumeration value="#default"/&gt;
        &lt;xs:enumeration value="#current"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:union&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="modes"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      The mode attribute of xsl:template: 
      either a list, each member being either a QName or #default;
      or the value #all
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:union&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:list&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:union memberTypes="xsl:QName"&gt;
            &lt;xs:simpleType&gt;
              &lt;xs:restriction base="xs:token"&gt;
                &lt;xs:enumeration value="#default"/&gt;
              &lt;/xs:restriction&gt;
            &lt;/xs:simpleType&gt;
          &lt;/xs:union&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:list&gt;
    &lt;/xs:simpleType&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:token"&gt;
        &lt;xs:enumeration value="#all"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:union&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="nametests"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      A list of NameTests, as defined in the XPath 2.0 Recommendation.
      Each NameTest is either a QName, or "*", or "prefix:*", or "*:localname"
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:list&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:union memberTypes="xsl:QName"&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base="xs:token"&gt;
            &lt;xs:enumeration value="*"/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base="xs:token"&gt;
            &lt;xs:pattern value="\i\c*:\*"/&gt;
            &lt;xs:pattern value="\*:\i\c*"/&gt;            
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:union&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:list&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="prefixes"&gt;
  &lt;xs:list itemType="xs:NCName"/&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="prefix-list-or-all"&gt;
  &lt;xs:union memberTypes="xsl:prefix-list"&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:token"&gt;
        &lt;xs:enumeration value="#all"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:union&gt;
&lt;/xs:simpleType&gt;
      
&lt;xs:simpleType name="prefix-list"&gt;
  &lt;xs:list itemType="xsl:prefix-or-default"/&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="method"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      The method attribute of xsl:output:
      Either one of the recognized names "xml", "xhtml", "html", "text",
      or a QName that must include a prefix.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:union&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:NCName"&gt;
        &lt;xs:enumeration value="xml"/&gt;
        &lt;xs:enumeration value="xhtml"/&gt;
        &lt;xs:enumeration value="html"/&gt;
        &lt;xs:enumeration value="text"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xsl:QName"&gt;
        &lt;xs:pattern value="\c*:\c*"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:union&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="pattern"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      A match pattern as defined in the XSLT 2.0 Recommendation.
      The syntax for patterns is a restricted form of the syntax for
      XPath 2.0 expressions.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xsl:expression"/&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="prefix-or-default"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      Either a namespace prefix, or #default.
      Used in the xsl:namespace-alias element.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:union memberTypes="xs:NCName"&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:token"&gt;
        &lt;xs:enumeration value="#default"/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:union&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="QNames"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      A list of QNames.
      Used in the [xsl:]use-attribute-sets attribute of various elements,
      and in the cdata-section-elements attribute of xsl:output
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:list itemType="xsl:QName"/&gt;          
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="QName"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      A QName.
      This schema does not use the built-in type xs:QName, but rather defines its own
      QName type. Although xs:QName would define the correct validation on these attributes,
      a schema processor would expand unprefixed QNames incorrectly when constructing the PSVI,
      because (as defined in XML Schema errata) an unprefixed xs:QName is assumed to be in
      the default namespace, which is not the correct assumption for XSLT.
      The data type is defined as a restriction of the built-in type Name, restricted
      so that it can only contain one colon which must not be the first or last character.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:Name"&gt;
    &lt;xs:pattern value="([^:]+:)?[^:]+"/&gt;      
  &lt;/xs:restriction&gt;        
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="sequence-type"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      The description of a data type, conforming to the
      SequenceType production defined in the XPath 2.0 Recommendation
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:token"&gt;
    &lt;xs:pattern value=".+"/&gt;      
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="uri-list"&gt;
  &lt;xs:list itemType="xs:anyURI"/&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="validation-strip-or-preserve"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      Describes different ways of type-annotating an element or attribute.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xsl:validation-type"&gt;
    &lt;xs:enumeration value="preserve"/&gt;
    &lt;xs:enumeration value="strip"/&gt;    
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="validation-type"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      Describes different ways of type-annotating an element or attribute.
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:token"&gt;
    &lt;xs:enumeration value="strict"/&gt;
    &lt;xs:enumeration value="lax"/&gt;
    &lt;xs:enumeration value="preserve"/&gt;
    &lt;xs:enumeration value="strip"/&gt;    
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="yes-or-no"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      One of the values "yes" or "no".
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:token"&gt;
    &lt;xs:enumeration value="yes"/&gt;
    &lt;xs:enumeration value="no"/&gt;
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;xs:simpleType name="yes-or-no-or-omit"&gt;
  &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;
      One of the values "yes" or "no" or "omit".
    &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  &lt;xs:restriction base="xs:token"&gt;
    &lt;xs:enumeration value="yes"/&gt;
    &lt;xs:enumeration value="no"/&gt;
    &lt;xs:enumeration value="omit"/&gt;
  &lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

&lt;/xs:schema&gt;
</pre>
    </div>

    <div class="div1">
      <h2><a name="acknowledgements" id="acknowledgements"></a>H
      Acknowledgements (Non-Normative)</h2>

      <p>This specification was developed and approved for
      publication by the W3C XSL Working Group (WG). WG approval of
      this specification does not necessarily imply that all WG
      members voted for its approval.</p>

      <p>The chair of the XSL WG is Sharon Adler, IBM. The XSL
      Working Group includes two overlapping teams working on XSLT
      and XSL Formatting Objects. The members of the XSL WG
      currently engaged in XSLT activities are:</p>

      <table border="1" cellpadding="5">
        <thead>
          <tr>
            <th>Participant</th>

            <th>Affiliation</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td>Colin Paul Adams</td>

            <td>Invited Expert</td>
          </tr>

          <tr>
            <td>Anders Berglund</td>

            <td>IBM</td>
          </tr>

          <tr>
            <td>Scott Boag</td>

            <td>IBM</td>
          </tr>

          <tr>
            <td>Michael Kay</td>

            <td>Invited Expert</td>
          </tr>

          <tr>
            <td>Alex Milowski</td>

            <td>Invited Expert</td>
          </tr>

          <tr>
            <td>William Peterson</td>

            <td>Novell, Inc</td>
          </tr>

          <tr>
            <td>Michael Sperberg-McQueen</td>

            <td>W3C</td>
          </tr>

          <tr>
            <td>Zarella Rendon</td>

            <td>Invited Expert</td>
          </tr>

          <tr>
            <td>Jeni Tennison</td>

            <td>Invited Expert</td>
          </tr>

          <tr>
            <td>Joanne Tong</td>

            <td>IBM</td>
          </tr>

          <tr>
            <td>Norm Walsh</td>

            <td>Sun Microsystems Inc.</td>
          </tr>

          <tr>
            <td>Mohamed Zergaoui</td>

            <td>Innovimax SARL</td>
          </tr>

          <tr>
            <td>(vacancy)</td>

            <td>Oracle</td>
          </tr>
        </tbody>
      </table>

      <p>Alternates are listed only where they have taken an active
      part in working group discussions. However, the group
      acknowledges the support that many members receive from
      colleagues in their organizations, whether or not they are
      officially appointed as alternates.</p>

      <p>The W3C representative on the XSL Working Group is Michael
      Sperberg-McQueen.</p>

      <p>The following individuals made significant contributions
      to XSLT 2.0 while they were members of the Working Group, and
      in some cases afterwards:</p>

      <blockquote>
        <p>James Clark, Invited Expert<br />
        Jonathan Marsh, Microsoft<br />
        Steve Muench, Oracle<br />
        Steve Zilles, Adobe<br />
        Evan Lenz, XYZFind<br />
        Mark Scardina, Oracle<br />
        Kristoffer Rose, IBM<br />
        Henry Zongaro, IBM<br />
        Henry Thompson, University of Edinburgh<br />
        K Karun, Oracle</p>
      </blockquote>

      <p>The working group wishes to acknowledge the contribution
      made by David Marston of IBM especially to the new
      specification of the <a href=
      "index.html#function-format-number"><code>format-number</code></a>
      function.</p>

      <p>This specification builds on the success of the XSLT 1.0
      Recommendation. For a list of contributors to XSLT 1.0, see
      <a href="index.html#xslt">[XSLT 1.0]</a>.</p>
    </div>

    <div class="div1">
      <h2><a name="requirements-checklist" id=
      "requirements-checklist"></a>I Checklist of Requirements
      (Non-Normative)</h2>

      <p>This section provides a checklist of progress against the
      published XSLT 2.0 Requirements document (see <a href=
      "index.html#xslt20req">[XSLT 2.0 Requirements]</a>).</p>

      <p><b><i>Requirement 1</i></b></p>

      <p><span class="verb">must</span>&#160;Maintain Backwards
      Compatibility with XSLT 1.1 [Read this as "with XSLT
      1.0"]</p>

      <p>Any stylesheet whose behavior is fully defined in XSLT 1.0
      and which generates no errors will produce the same result
      tree under XSLT 2.0</p>

      <p><i>Response</i></p>

      <p>See <a href="index.html#incompatibilities"><i>J.1 Incompatible
      Changes</i></a></p>

      <p><b><i>Requirement 2</i></b></p>

      <p><span class="verb">must</span> Match Elements with Null
      Values</p>

      <p>A stylesheet should be able to match elements and
      attributes whose value is explicitly null.</p>

      <p><i>Response</i></p>

      <p>This has been handled as an XPath 2.0 requirement. <span>A
      new function <a href=
      "http://www.w3.org/TR/xpath-functions/#func-nilled"><code>nilled</code></a><sup>
      <small>FO</small></sup> is available to test whether an
      element has been marked as nil after schema
      validation.</span></p>

      <p><b><i>Requirement 3</i></b></p>

      <p><span class="verb">should</span>&#160;Allow Included
      Documents to "Encapsulate" Local Stylesheets</p>

      <p>XSLT 2.0 <span class="verb">should</span> define a
      mechanism to allow the templates in a stylesheet associated
      with a secondary source document, to be imported and used to
      format the included fragment, taking precedence over any
      applicable templates in the current stylesheet.</p>

      <p><i>Response</i></p>

      <p>The facility to define modes has been generalized, making
      it easier to define a distinct set of template rules for
      processing a particular document.</p>

      <p><b><i>Requirement 4</i></b></p>

      <p>Could&#160;Support Accessing Infoset Items for XML
      Declaration</p>

      <p>A stylesheet COULD be able to access information like the
      version and encoding from the XML declaration of a
      document.</p>

      <p><i>Response</i></p>

      <p>No new facilities have been provided in this area, because
      this information is not available in the data model.</p>

      <p><b><i>Requirement 5</i></b></p>

      <p>Could&#160;Provide QName Aware String Functions</p>

      <p>Users manipulating documents (for example stylesheets,
      schemas) that have QName-valued element or attribute content
      need functions that take a string containing a QName as their
      argument, convert it to an <a title="expanded-QName" href=
      "index.html#dt-expanded-qname">expanded-QName</a> using either the
      namespace declarations in scope at that point in the
      stylesheet, or the namespace declarations in scope for a
      specific source node, and return properties of the <a title=
      "expanded-QName" href="index.html#dt-expanded-qname">expanded-QName</a>
      such as its namespace URI and local name.</p>

      <p><i>Response</i></p>

      <p>Functions operating on QNames are included in the XPath
      2.0 Functions and Operators document: see <a href=
      "index.html#xpath-functions">[Functions and Operators]</a>.</p>

      <p><b><i>Requirement 6</i></b></p>

      <p>Could&#160;Enable Constructing a Namespace with Computed
      Name</p>

      <p>Provide an <a href=
      "index.html#element-namespace"><code>xsl:namespace</code></a> analog to
      <a href="index.html#element-element"><code>xsl:element</code></a> for
      constructing a namespace node with a computed prefix and
      URI.</p>

      <p><i>Response</i></p>

      <p>An <a href=
      "index.html#element-namespace"><code>xsl:namespace</code></a>
      instruction has been added: see <a href=
      "index.html#creating-namespace-nodes"><i>11.7 Creating Namespace
      Nodes</i></a>.</p>

      <p><b><i>Requirement 7</i></b></p>

      <p>Could&#160;Simplify Resolving Prefix Conflicts in
      QName-Valued Attributes</p>

      <p>XSLT 2.0 could simplify the renaming of conflicting
      namespace prefixes in result tree fragments, particularly for
      attributes declared in a schema as being QNames. Once the
      processor knows an attribute value is a QName, an XSLT
      processor <span class="verb">should</span> be able to rename
      prefixes and generate namespace declarations to preserve the
      semantics of that attribute value, just as it does for
      attribute names.</p>

      <p><i>Response</i></p>

      <p>If an attribute is typed as a QName in the schema, the new
      XPath 2.0 functions can be used to manipulate it as required
      at application level. This <span>is considered</span>
      sufficient to meet the requirement.</p>

      <p><b><i>Requirement 8</i></b></p>

      <p>Could&#160;Support XHTML Output Method</p>

      <p>Complementing the existing output methods for html, xml,
      and text, an xhtml output method could be provided to
      simplify transformations which target XHTML output.</p>

      <p><i>Response</i></p>

      <p>An XHTML output method is now provided: see <a href=
      "index.html#xslt-xquery-serialization">[XSLT and XQuery
      Serialization]</a></p>

      <p><b><i>Requirement 9</i></b></p>

      <p><span class="verb">must</span>&#160;Allow Matching on
      Default Namespace Without Explicit Prefix</p>

      <p>Many users stumble trying to match an element with a
      default namespace.</p>

      <p><i>Response</i></p>

      <p>A new <code>[xsl:]xpath-default-namespace</code> attribute
      is provided for this purpose: see <a href=
      "index.html#unprefixed-qnames"><i>5.2 Unprefixed QNames in Expressions
      and Patterns</i></a></p>

      <p><b><i>Requirement 10</i></b></p>

      <p><span class="verb">must</span>&#160;Add Date Formatting
      Functions</p>

      <p>One of the more frequent requests from XSLT 1.0 users is
      the ability to format date information with similar control
      to XSLT's format-number. XML Schema introduces several kinds
      of date and time datatypes which will further increase the
      demand for date formatting during transformations.
      Functionality similar to that provided by
      java.text.SimpleDateFormat. A date analog of XSLT's named
      xsl:decimal-format may be required to handle locale-specific
      date formatting issues.</p>

      <p><i>Response</i></p>

      <p>A set of date formatting functions has been specified: see
      <a href="index.html#format-date"><i>16.5 Formatting Dates and
      Times</i></a></p>

      <p><b><i>Requirement 11</i></b></p>

      <p><span class="verb">must</span>&#160;Simplify Accessing
      Id's and Key's in Other Documents</p>

      <p>Currently it is cumbersome to lookup nodes by id() or
      key() in documents other than the source document. Users
      <span class="verb">must</span> first use an xsl:for-each
      instruction, selecting the desired document() to make it the
      current node, then relative XPath expressions within the
      scope of the xsl:for-each can refer to id() or key() as
      desired.</p>

      <p><i>Response</i></p>

      <p>The requirement is met by the generalization of path
      syntax in XPath 2.0. It is now possible to use a path
      expression such as
      <code>document('a.xml')/id('A001')</code>.</p>

      <p><b><i>Requirement 12</i></b></p>

      <p><span class="verb">should</span>&#160;Provide Function to
      Absolutize Relative URIs</p>

      <p>There <span class="verb">should</span> be a way in XSLT
      2.0 to create an absolute URI. The functionality <span class=
      "verb">should</span> allow passing a node-set and return a
      <a title="string value" href="index.html#dt-string-value">string
      value</a> representing the absolute URI resolved with respect
      to the base URI of the current node.</p>

      <p><i>Response</i></p>

      <p>A function <a href=
      "http://www.w3.org/TR/xpath-functions/#func-resolve-uri"><code>
      resolve-uri</code></a><sup><small>FO</small></sup> is now
      defined in <a href="index.html#xpath-functions">[Functions and
      Operators]</a>.</p>

      <p><b><i>Requirement 13</i></b></p>

      <p><span class="verb">should</span>&#160;Include Unparsed
      Text from an External Resource</p>

      <p>Frequently stylesheets <span class="verb">must</span>
      import text from external resources. Today users have to
      resort to <a title="extension function" href=
      "index.html#dt-extension-function">extension functions</a> to
      accomplish this because XSLT 1.0 only provides the document()
      function which, while useful, can only read external
      resources that are well-formed XML documents.</p>

      <p><i>Response</i></p>

      <p>A function <a href=
      "index.html#function-unparsed-text"><code>unparsed-text</code></a> has
      been added: see <a href="index.html#unparsed-text"><i>16.2 Reading Text
      Files</i></a></p>

      <p><b><i>Requirement 14</i></b></p>

      <p><span class="verb">should</span>&#160;Allow Authoring
      Extension Functions in XSLT</p>

      <p>As part of the XSLT 1.1 work done on <a title=
      "extension function" href="index.html#dt-extension-function">extension
      functions</a>, a proposal to author XSLT extension functions
      in XSLT itself was deferred for reconsideration in XSLT 2.0.
      This would allow the functions in an extension namespace to
      be implemented in "pure" XSLT, without resulting to external
      programming languages.</p>

      <p><i>Response</i></p>

      <p>A solution to this requirement, the <a href=
      "index.html#element-function"><code>xsl:function</code></a> element, is
      included in this specification. See <a href=
      "index.html#stylesheet-functions"><i>10.3 Stylesheet
      Functions</i></a>.</p>

      <p><b><i>Requirement 15</i></b></p>

      <p><span class="verb">should</span>&#160;Output Character
      Entity References Instead of Numeric Character Entities</p>

      <p>Users have frequently requested the ability to have the
      output of their transformation use (named) character
      references instead of the numeric character entity. The
      ability to control this preference as the level of the whole
      document is sufficient. For example, rather than seeing
      &amp;#160; in the output, the user could request to see the
      equivalent &amp;nbsp; instead.</p>

      <p><i>Response</i></p>

      <p>The serialization specification gives the implementation
      discretion on how special characters are output. A user who
      wishes to force the use of named character references can
      achieve this using the new <a href=
      "index.html#element-character-map"><code>xsl:character-map</code></a>
      declaration.</p>

      <p><b><i>Requirement 16</i></b></p>

      <p><span class="verb">should</span>&#160;Construct Entity
      Reference by Name</p>

      <p>Analogous to the ability to create elements and
      attributes, users have expressed a desire to construct named
      entity references.</p>

      <p><i>Response</i></p>

      <p>No solution has been provided to this requirement; it is
      difficult, because entity references are not defined in the
      data model.</p>

      <p><b><i>Requirement 17</i></b></p>

      <p><span class="verb">should</span>&#160;Support for Unicode
      String Normalization</p>

      <p>For reliable string comparison of Unicode strings, users
      need the ability to apply Unicode normalization before
      comparing the strings.</p>

      <p><i>Response</i></p>

      <p>This requirement has been addressed by the provision of
      the <a href=
      "http://www.w3.org/TR/xpath-functions/#func-normalize-unicode">
      <code>normalize-unicode</code></a><sup><small>FO</small></sup>
      function described in <a href="index.html#xpath-functions">[Functions
      and Operators]</a>. In addition, a serialization parameter
      <code>normalization-form</code> has been added.</p>

      <p><b><i>Requirement 18</i></b></p>

      <p><span class="verb">should</span>&#160;Standardize
      Extension Element Language Bindings</p>

      <p>XSLT 1.1 undertook the standardization of language
      bindings for XSLT <a title="extension function" href=
      "index.html#dt-extension-function">extension functions</a>. For XSLT
      2.0, analogous bindings <span class="verb">should</span> be
      provided for extension elements [now renamed <a title=
      "extension instruction" href=
      "index.html#dt-extension-instruction">extension instructions</a>].</p>

      <p><i>Response</i></p>

      <p>The XSL Working Group has decided not to pursue this
      requirement, and the attempt to standardize language bindings
      for extension functions that appeared in the XSLT 1.1 Working
      Draft has now been withdrawn. The Working Group decided that
      language bindings would be better published separately from
      the core XSLT specification.</p>

      <p><b><i>Requirement 19</i></b></p>

      <p>Could&#160;Improve Efficiency of Transformations on Large
      Documents</p>

      <p>Many useful transformations take place on large documents
      consisting of thousands of repeating "sub-documents". Today
      transformations over these documents are impractical due to
      the need to have the entire source tree in memory. Enabling
      "progressive" transformations, where the processor is able to
      produce progressively more output as more input is received,
      is tantamount to avoiding the need for XSLT processors to
      have random access to the entire source document. This might
      be accomplished by:</p>

      <p>Identifying a core subset of XPath that does not require
      random access to the source tree, or</p>

      <p>Consider a "transform all subtrees" mode where the
      stylesheet says, "Apply the transformation implied by this
      stylesheet to each node that matches XXX, considered as the
      root of a separate tree, and copy all the results of these
      mini-transformations as separate subtrees on to the final
      result tree."</p>

      <p><i>Response</i></p>

      <p>The Working Group observes that implementation techniques
      for XSLT processing have advanced considerably since this
      requirement was written, and that further research developing
      new approaches continues both in industry and academia. In
      the light of these developments, the Working Group has
      decided that it would be inappropriate at this stage to
      identify language features or subsets designed specifically
      to enable progressive transformations.</p>

      <p><b><i>Requirement 20</i></b></p>

      <p>Could&#160;Support Reverse IDREF attributes</p>

      <p>Given a particular value of an ID, produce a list of all
      elements that have an IDREF or IDREFS attribute which refers
      to this ID.</p>

      <p>This functionality can be accomplished using the current
      &lt;xsl:key&gt; and key() mechanism.</p>

      <p><i>Response</i></p>

      <p>The <a href=
      "http://www.w3.org/TR/xpath-functions/#func-idref"><code>idref</code></a><sup>
      <small>FO</small></sup> function defined in <a href=
      "index.html#xpath-functions">[Functions and Operators]</a> has been
      introduced in response to this requirement.</p>

      <p><b><i>Requirement 21</i></b></p>

      <p>Could&#160;Support Case-Insensitive Comparisons</p>

      <p>XSLT 2.0 could expand its comparison functionality to
      include support for case-insensitive string comparison.</p>

      <p><i>Response</i></p>

      <p>This is an XPath 2.0 requirement. XPath 2.0 includes
      functions to convert strings to uppercase or lowercase, it
      also includes functions to compare strings using a named
      collating sequence, which provides the option of using a
      collating sequence that treats uppercase and lowercase as
      equal.</p>

      <p><b><i>Requirement 22</i></b></p>

      <p>Could&#160;Support Lexigraphic String Comparisons</p>

      <p>We don't let users compare strings like $x &gt; 'a'.</p>

      <p><i>Response</i></p>

      <p>This requirement has been addressed in XPath 2.0.</p>

      <p><b><i>Requirement 23</i></b></p>

      <p>Could&#160;Allow Comparing Nodes Based on Document
      Order</p>

      <p>Support the ability to test whether one node comes before
      another in document order.</p>

      <p><i>Response</i></p>

      <p>This requirement has been addressed in XPath 2.0, using
      the operators <code>&lt;&lt;</code> and
      <code>&gt;&gt;</code>.</p>

      <p><b><i>Requirement 24</i></b></p>

      <p>Could&#160;Improve Support for Unparsed Entities</p>

      <p>In XSLT 1.0 there is an asymmetry in support for unparsed
      entities. They can be handled on input but not on output. In
      particular, there is no way to do an identity transformation
      that preserves them. At a minimum we need the ability to
      retrieve the Public ID of an unparsed entity.</p>

      <p><i>Response</i></p>

      <p>A function to retrieve the public identifier of an
      unparsed entity has been added. However, no facilities have
      been provided to include unparsed entities in a result
      document.</p>

      <p><b><i>Requirement 25</i></b></p>

      <p>Could&#160;Allow Processing a Node with the "Next Best
      Matching" Template</p>

      <p>In the construction of large stylesheets for complex
      documents, it is often necessary to construct templates that
      implement special behavior for a particular instance of an
      element, and then apply the normal styling for that element.
      Currently this is not possible because <a href=
      "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
      specifies that for any given node only a single template will
      be selected and instantiated.</p>

      <p>Currently the processor determines a list of matching
      templates and then discards all but the one with the highest
      priority. In order to support this requirement, the processor
      would retain the list of matching templates sorted in
      priority order. A new instruction, for example <a href=
      "index.html#element-next-match"><code>xsl:next-match</code></a>, in a
      template would simply trigger the next template in the list
      of matching templates. This "next best match" recursion
      naturally bottoms out at the builtin template which can be
      seen as the lowest priority matching template for every match
      pattern.</p>

      <p><i>Response</i></p>

      <p>An <a href=
      "index.html#element-next-match"><code>xsl:next-match</code></a>
      instruction has been added.</p>

      <p><b><i>Requirement 26</i></b></p>

      <p>Could&#160;Make Coercions Symmetric By Allowing Scalar to
      Nodeset Conversion</p>

      <p>Presently, no datatype can be coerced or cast to a
      node-set. By allowing a <a title="string value" href=
      "index.html#dt-string-value">string value</a> to convert to a node-set,
      some user "gotchas" could be avoided.</p>

      <p><i>Response</i></p>

      <p>The availability of sequences of strings or numbers
      probably meets most of the use-cases envisaged by this
      requirement.</p>

      <p><b><i>Requirement 27</i></b></p>

      <p><span class="verb">must</span>&#160;Simplify Constructing
      and Copying Typed Content</p>

      <p>It <span class="verb">must</span> be possible to construct
      XML Schema-typed elements and attributes. In addition, when
      copying an element or an attribute to the result, it
      <span class="verb">should</span> be possible to preserve the
      type during the process.</p>

      <p><i>Response</i></p>

      <p>Facilities to validate constructed and copied element and
      attribute nodes are defined in this specification; these
      elements and attributes will carry a type annotation
      indicating their XML Schema type. In addition, it is possible
      to specify when copying nodes whether type annotations should
      be preserved or removed.</p>

      <p><b><i>Requirement 28</i></b></p>

      <p><span class="verb">must</span>&#160;Support Sorting Nodes
      Based on XML Schema Type</p>

      <p>XSLT 1.0 supports sorting based on string-valued and
      number-valued expressions. XML Schema: Datatypes introduces
      new scalar types (for example, date) with well-known sort
      orders. It <span class="verb">must</span> be possible to sort
      based on these extended set of scalar data types. Since XML
      Schema: Datatypes does not define an ordering for complex
      types, this sorting support <span class="verb">should</span>
      only be considered for simple types.</p>

      <p><span class="verb">should</span> be consistent with
      whatever we define for the matrix of conversion and
      comparisons.</p>

      <p><i>Response</i></p>

      <p>Sorting based on any schema-defined primitive data type
      with a total ordering is included in this specification.</p>

      <p><b><i>Requirement 29</i></b></p>

      <p>Could&#160;Support Scientific Notation in Number
      Formatting</p>

      <p>Several users have requested the ability to have the
      existing format-number() function extended to format numbers
      using Scientific Notation.</p>

      <p><i>Response</i></p>

      <p>Simple scientific formatting is now available through
      support for the schema-defined <code>xs:float</code> and
      <code>xs:double</code> data types; casting a large or small
      value of these types to a string produces a representation of
      the value in scientific notation. The Working Group believes
      that this will meet the requirement in most cases, and has
      therefore decided not to enhance the <a href=
      "index.html#function-format-number"><code>format-number</code></a>
      further to introduce scientific notation. Users with more
      specialized requirements can write their own functions.</p>

      <p><b><i>Requirement 30</i></b></p>

      <p>Could&#160;Provide Ability to Detect Whether "Rich" Schema
      Information is Available</p>

      <p>A stylesheet that requires XML Schema type-related
      functionality could be able to test whether a "rich"
      Post-Schema-Validated Infoset is available from the XML
      Schema processor, so that the stylesheet can provide fallback
      behavior or choose to exit with <code>xsl:message
      abort="yes"</code>.</p>

      <p><i>Response</i></p>

      <p>This requirement is satisified through the <code>instance
      of</code> operator in XPath 2.0, which allows expressions to
      determine the type of element and attribute nodes, using
      information from the schema. The details of how these
      expressions behave when there is no schema are defined in the
      XPath specifications.</p>

      <p><b><i>Requirement 31</i></b></p>

      <p><span class="verb">must</span>&#160;Simplify Grouping</p>

      <p>Grouping is complicated in XSLT 1.0. It <span class=
      "verb">must</span> be possible for users to group nodes in a
      document based on common string-values, common names, or
      common values for any other expression</p>

      <p>In addition XSLT <span class="verb">must</span> allow
      grouping based on sequential position, for example selecting
      groups of adjacent &lt;P&gt; elements. Ideally it
      <span class="verb">should</span> also make it easier to do
      fixed-size grouping as well, for example groups of three
      adjacent nodes, for laying out data in multiple columns. For
      each group of nodes identified, it <span class=
      "verb">must</span> be possible to instantiate a template for
      the group. Grouping <span class="verb">must</span> be
      "nestable" to multiple levels so that groups of distinct
      nodes can be identified, then from among the distinct groups
      selected, further sub-grouping of distinct node in the
      current group can be done.</p>

      <p><i>Response</i></p>

      <p>A new <a href=
      "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
      instruction is provided: see <a href="index.html#grouping"><i>14
      Grouping</i></a>. In addition, many of the new functions and
      operators provided in XPath 2.0 make these algorithms easier
      to write.</p>
    </div>

    <div class="div1">
      <h2><a name="changes" id="changes"></a>J Changes from XSLT
      1.0 (Non-Normative)</h2>

      <div class="div2">
        <h3><a name="incompatibilities" id=
        "incompatibilities"></a>J.1 Incompatible Changes</h3>

        <p>This section lists all known cases where a stylesheet
        that was valid (produced no errors) under XSLT 1.0, and
        whose behavior was fully specified by XSLT 1.0, will
        produce different results under XSLT 2.0.</p>

        <p>Most of the discussion is concerned with compatibility
        in the absence of a schema: that is, it is assumed that the
        source document being transformed has no schema when
        processed using XSLT 1.0, and that no schema is added when
        moving to XSLT 2.0. Some additional factors that come into
        play when a schema is added are noted at the end of the
        section.</p>

        <div class="div3">
          <h4><a name="incompatibility-stripping" id=
          "incompatibility-stripping"></a>J.1.1 Tree construction:
          whitespace stripping</h4>

          <p>Both in XSLT 1.0 and in XSLT 2.0, the XSLT
          specification places no constraints on the way in which
          source trees are constructed. For XSLT 2.0, however, the
          <a href="index.html#xpath-datamodel">[Data Model]</a> specification
          describes explicit processes for constructing a tree from
          an Infoset or a PSVI, while also permitting other
          processes to be used. The process described in <a href=
          "index.html#xpath-datamodel">[Data Model]</a> has the effect of
          stripping <a title="whitespace text node" href=
          "index.html#dt-whitespace-text-node">whitespace text nodes</a> from
          elements declared to have element-only content. Although
          the XSLT 1.0 specification did not preclude such
          behavior, it differs from the way that most existing XSLT
          1.0 implementations work. It is <span class=
          "verb">recommended</span> that an XSLT 2.0 implementation
          wishing to provide maximum interoperability and backwards
          compatibility should offer the user the option either to
          construct source trees using the processes described in
          <a href="index.html#xpath-datamodel">[Data Model]</a>, or
          alternatively to retain or remove whitespace according to
          the common practice of previous XSLT 1.0
          implementations.</p>

          <p>To write transformations that give the same result
          regardless of the whitespace stripping applied during
          tree construction, stylesheet authors can:</p>

          <ul>
            <li>
              <p>use the <a href=
              "index.html#element-strip-space"><code>xsl:strip-space</code></a>
              declaration to remove <a title="whitespace text node"
              href="index.html#dt-whitespace-text-node">whitespace text
              nodes</a> from elements having element-only content
              (this has no effect if the whitespace has already
              been stripped)</p>
            </li>

            <li>
              <p>use instructions such as
              <code>&lt;xsl:apply-templates select="*"/&gt;</code>
              that cause only the element children of the context
              node to be processed, and not its text nodes.</p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="incompatibility-serialization" id=
          "incompatibility-serialization"></a>J.1.2 Changes in
          Serialization Behavior</h4>

          <p>The specification of the output of <a title=
          "serialization" href=
          "index.html#dt-serialization">serialization</a> is more
          prescriptive than in XSLT 1.0. For example, the
          <code>html</code> output method is <span class=
          "verb">required</span> to detect invalid HTML characters.
          Also, certain combinations of serialization parameters
          are now defined to be errors. Furthermore, XSLT 1.0
          implementations were allowed to add additional <a href=
          "index.html#element-output"><code>xsl:output</code></a> attributes
          that modified the behavior of the serializer. Some such
          extensions might be non-conformant under the stricter
          rules of XSLT 2.0. For example, some XSLT 1.0 processors
          provided an extension attribute to switch off the
          creation of <code>meta</code> elements by the
          <code>html</code> output method (a facility that is now
          provided as standard). A conformant XSLT 2.0 processor is
          not allowed to provide such extensions.</p>

          <p>Where necessary, implementations <span class=
          "verb">may</span> provide additional serialization
          methods designed to mimic more closely the behavior of
          specific XSLT 1.0 serializers.</p>
        </div>

        <div class="div3">
          <h4><a name="backwards-compatibility-behavior" id=
          "backwards-compatibility-behavior"></a>J.1.3 Backwards
          Compatibility Behavior</h4>

          <p>Some XSLT constructs behave differently under XSLT 2.0
          depending on whether <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled. In these cases, the behavior may
          be made compatible with XSLT 1.0 by ensuring that
          <a title="backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled (which is done using the
          <code>[xsl:]version</code> attribute).</p>

          <p>These constructs are as follows:</p>

          <ol class="enumar">
            <li>
              <p>If the <a href=
              "index.html#element-value-of"><code>xsl:value-of</code></a>
              instruction has no <code>separator</code> attribute,
              and the value of the <code>select</code> expression
              is a sequence of more than one item, then under XSLT
              2.0 all items in the sequence will be output, space
              separated, while in XSLT 1.0, all items after the
              first will be discarded.</p>
            </li>

            <li>
              <p>If the <a title="effective value" href=
              "index.html#dt-effective-value">effective value</a> of an
              <a title="attribute value template" href=
              "index.html#dt-attribute-value-template">attribute value
              template</a> is a sequence of more than one item,
              then under XSLT 2.0 all items in the sequence will be
              output, space separated, while in XSLT 1.0, all items
              after the first will be discarded.</p>
            </li>

            <li>
              <p>If the expression in the <code>value</code>
              attribute of the <a href=
              "index.html#element-number"><code>xsl:number</code></a>
              instruction returns a sequence of more than one item,
              then under XSLT 2.0 all items in the sequence will be
              output, as defined by the <code>format</code>
              attribute, but under XSLT 1.0, all items after the
              first will be discarded. If the sequence is empty,
              then under XSLT 2.0 nothing will be output (other
              than a prefix and suffix if requested), but under
              XSLT 1.0, the output is "NaN". If the first item in
              the sequence cannot be converted to a number, then
              XSLT 2.0 signals a non-recoverable error, while XSLT
              1.0 outputs "NaN".</p>

              <p>If the expression in the <code>value</code>
              attribute of <a href=
              "index.html#element-number"><code>xsl:number</code></a> returns
              an empty sequence or a sequence including non-numeric
              values, an XSLT 2.0 processor may signal a
              recoverable error; but with backwards compatibility
              enabled, it outputs <code>NaN</code>.</p>
            </li>

            <li>
              <p>If the <a title="atomize" href=
              "index.html#dt-atomization">atomized</a> value of the
              <code>select</code> attribute of the <a href=
              "index.html#element-sort"><code>xsl:sort</code></a> element is
              a sequence of more than one item, then under XSLT 2.0
              an error will be signaled, while in XSLT 1.0, all
              items after the first will be discarded.</p>
            </li>

            <li>
              <p>If an <a href=
              "index.html#element-call-template"><code>xsl:call-template</code></a>
              instruction supplies a parameter that does not
              correspond to any <a title="template parameter" href=
              "index.html#dt-template-parameter">template parameter</a> in
              the template being called, then under XSLT 2.0 a
              <a title="static error" href=
              "index.html#dt-static-error">static error</a> is signaled, but
              under XSLT 1.0 the extra parameter is ignored.</p>
            </li>

            <li>
              <p>It is normally a <a title="static error" href=
              "index.html#dt-static-error">static error</a> if an XPath
              expression contains a call to an unknown function.
              But when backwards compatible behavior is enabled,
              this is a <a title="non-recoverable dynamic error"
              href="index.html#dt-nonrec-dynamic-error">non-recoverable
              dynamic error</a>, which occurs only if the function
              call is actually evaluated.</p>
            </li>

            <li>
              <p>An XSLT 1.0 processor compared the value of the
              expression in the <code>use</code> attribute of
              <a href="index.html#element-key"><code>xsl:key</code></a> to
              the value supplied in the second argument of the
              <a href="index.html#function-key"><code>key</code></a> function
              by converting both to strings. An XSLT 2.0 processor
              normally compares the values as supplied. The XSLT
              1.0 behavior is retained if any of the <a href=
              "index.html#element-key"><code>xsl:key</code></a> elements
              making up the <a title="key" href="index.html#dt-key">key</a>
              definition enables backwards-compatible behavior.</p>
            </li>

            <li>
              <p>If no output method is explicitly requested, and
              the first element node output appears to be an XHTML
              document element, then under XSLT 2.0 the output
              method defaults to XHTML; with backwards
              compatibility enabled, the XML output method will be
              used.</p>
            </li>
          </ol>

          <p>Backwards compatible behavior also affects the results
          of certain XPath expressions, as defined in <a href=
          "index.html#xpath20">[XPath 2.0]</a>.</p>
        </div>

        <div class="div3">
          <h4><a name="incompatibility-without-schema" id=
          "incompatibility-without-schema"></a>J.1.4
          Incompatibility in the Absence of a Schema</h4>

          <p>If the source documents supplied as input to a
          transformation contain no type information generated from
          a schema then the known areas of incompatibility are as
          follows. These apply whether or not <a title=
          "backwards compatible behavior" href=
          "index.html#dt-backwards-compatible-behavior">backwards compatible
          behavior</a> is enabled.</p>

          <ol class="enumar">
            <li>
              <p>A stylesheet that specifies a version number other
              than 1.0 was defined in XSLT 1.0 to execute in
              forwards-compatible mode; if such a stylesheet uses
              features that are not defined in XSLT 2.0 then errors
              may be signaled by an XSLT 2.0 processor that would
              not be signaled by an XSLT 1.0 processor.</p>
            </li>

            <li>
              <p>At XSLT 1.0 the <a href=
              "index.html#function-system-property"><code>system-property</code></a>
              function, when called with a first argument of
              <code>"xsl:version"</code>, returned 1.0 as a number.
              At XSLT 2.0 it returns "2.0" as a string. The
              <span class="verb">recommended</span> way of testing
              this property is, for example, <code>&lt;xsl:if
              test="number(system-property('xsl:version')) &amp;lt;
              2.0"&gt;</code>, which will work with either an XSLT
              1.0 or an XSLT 2.0 processor.</p>
            </li>

            <li>
              <p>At XSLT 2.0 it is an error to specify the
              <code>mode</code> or <code>priority</code> attribute
              on an <a href=
              "index.html#element-template"><code>xsl:template</code></a>
              element having no <code>match</code> attribute. At
              XSLT 1.0 the attributes were silently ignored in this
              situation.</p>
            </li>

            <li>
              <p>When an <a href=
              "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
              or <a href=
              "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
              instruction causes a built-in template rule to be
              invoked, then any parameters that are supplied are
              automatically passed on to any further template
              rules. This did not happen in XSLT 1.0.</p>
            </li>

            <li>
              <p>In XSLT 1.0 it was a recoverable error to create
              any node other than a text node while constructing
              the value of an attribute, comment, or
              processing-instruction; the recovery action was to
              ignore the offending node and its content. In XSLT
              2.0 this is no longer an error, and the specified
              action is to atomize the node. An XSLT 2.0 processor
              will therefore not produce the same results as an
              XSLT 1.0 processor that took the error recovery
              action.</p>
            </li>

            <li>
              <p>XSLT 1.0 defined a number of recoverable error
              conditions which in XSLT 2.0 have become
              non-recoverable errors. Under XSLT 1.0, a stylesheet
              that triggered such errors would fail under some XSLT
              processors and succeed (or at any rate, continue to
              completion) under others. Under XSLT 2.0 such a
              stylesheet will fail under all processors. Notable
              examples of such errors are constructing an element
              or attribute with an invalid name, generating
              attributes as children of a document node, and
              generating an attribute of an element after
              generating one or more children for the element. This
              change has been made in the interests of
              interoperability. In classifying such errors as
              non-recoverable, the Working Group used the criterion
              that no stylesheet author would be likely to write
              code that deliberately triggered the error and relied
              on the recovery action.</p>
            </li>

            <li>
              <p>In XSLT 1.0, the semantics of tree construction
              were described as being top-down, in XSLT 2.0 they
              are described bottom up. In nearly all cases the end
              result is the same. One difference arises in the case
              of a tree that is constructed to contain an attribute
              node within a document node within an element node,
              using an instruction such as the following:</p>

              <div class="example">
                <div class="exampleHeader">
                  <a name="d5e31247" id="d5e31247"></a>Example:
                  Attribute within Document within Element
                </div>

                <div class="exampleInner">
                  <pre>
&lt;xsl:template match="/"&gt;
  &lt;e&gt;
    &lt;xsl:copy&gt;
      &lt;xsl:attribute name="a"&gt;5&lt;/xsl:attribute&gt;
    &lt;/xsl:copy&gt;
  &lt;/e&gt;
&lt;/xsl:template&gt;
</pre>
                </div>
              </div>

              <p>In XSLT 1.0, the <a href=
              "index.html#element-copy"><code>xsl:copy</code></a> did
              nothing, and the attribute <code>a</code> was then
              attached to the element <code>e</code>. In XSLT 2.0,
              an error occurs when attaching the attribute
              <code>a</code> to the document node constructed by
              <a href="index.html#element-copy"><code>xsl:copy</code></a>,
              because this happens before the resulting document
              node is copied to the content of the constructed
              element.</p>
            </li>

            <li>
              <p>In XSLT 1.0 it was not an error for the
              <code>namespace</code> attribute of <a href=
              "index.html#element-element"><code>xsl:element</code></a> or
              <a href=
              "index.html#element-attribute"><code>xsl:attribute</code></a>
              to evaluate to an invalid URI. Since many XML parsers
              accept any string as a namespace name, this rarely
              caused problems. The <a href="index.html#xpath-datamodel">[Data
              Model]</a>, however, requires the name of a node to
              be an <code>xs:QName</code>, and the namespace part
              of an <code>xs:QName</code> is always an
              <code>xs:anyURI</code>. It is therefore now defined
              to be an error to create an element or attribute node
              in a namespace whose name is not a valid instance of
              <code>xs:anyURI</code>. <span>In practice, however,
              implementations have some flexibility in how
              rigorously they validate namespace URIs.</span></p>
            </li>

            <li>
              <p>It is now a static error for the stylesheet to
              contain two conflicting <a href=
              "index.html#element-namespace-alias"><code>xsl:namespace-alias</code></a>
              declarations with the same import precedence.</p>
            </li>

            <li>
              <p>It is now a static error for an <a href=
              "index.html#element-number"><code>xsl:number</code></a>
              instruction to contain both a <code>value</code>
              attribute and a <code>level</code>,
              <code>from</code>, or <code>count</code> attribute.
              In XSLT 1.0 the <code>value</code> attribute took
              precedence and the other attributes were silently
              ignored.</p>
            </li>

            <li>
              <p>When the <code>data-type</code> attribute of
              <a href="index.html#element-sort"><code>xsl:sort</code></a> has
              the value <code>number</code>, an XSLT 1.0 processor
              would evaluate the sort key as a string, and convert
              the result to a number. An XSLT 2.0 processor
              evaluates the sort key as a number directly. This
              only affects the outcome in cases where <span>in XSLT
              1.0,</span> conversion of a number to a string and
              then back to a number does not produce the original
              number, as is the case for example with the number
              <span>positive infinity</span>.</p>
            </li>

            <li>
              <p>When the <code>data-type</code> attribute of
              <a href="index.html#element-sort"><code>xsl:sort</code></a> is
              omitted, an XSLT 1.0 processor would convert the sort
              key values to strings, and sort them as strings. An
              XSLT 2.0 processor will sort them according to their
              actual dynamic type. This means, for example, that if
              the sort key component specifies <code>&lt;xsl:sort
              select="string-length(.)"/&gt;</code>, an XSLT 2.0
              processor will do a numeric sort where an XSLT 1.0
              processor would have done an alphabetic sort.</p>
            </li>

            <li>
              <p>When the <code>data-type</code> attribute of
              <a href="index.html#element-sort"><code>xsl:sort</code></a> is
              omitted or has the value "text", an XSLT 1.0
              processor treats a sort key whose value is an empty
              node-set as being equal to a sort key whose value is
              a zero-length string. XSLT 2.0 sorts the empty
              sequence before the zero-length string. This means
              that if there are two sort keys, say
              <code>&lt;xsl:sort select="@a"/&gt;</code> and
              <code>&lt;xsl:sort select="@b"/&gt;</code>, then an
              XSLT 1.0 processor will sort the element <code>&lt;x
              b="2"/&gt;</code> after <code>&lt;x a=""
              b="1"/&gt;</code>, while an XSLT 2.0 processor will
              produce the opposite ordering.</p>
            </li>

            <li>
              <p>The specification of the <a href=
              "index.html#function-format-number"><code>format-number</code></a>
              function has been rewritten to remove the normative
              dependency on the Java JDK 1.1 specification. The JDK
              1.1 specification left aspects of the behavior
              undefined; it is therefore likely that some cases
              will give different results.</p>

              <p>The ability to include literal text in the format
              picture enclosed in single quotes has been removed;
              any stylesheet that uses this feature will need to be
              modified, for example to display the literal text
              using the <a href=
              "http://www.w3.org/TR/xpath-functions/#func-concat"><code>
              concat</code></a><sup><small>FO</small></sup>
              function instead.</p>

              <p>One specific difference between the XSLT 2.0
              specification and a JDK-based implementation is in
              the handling of the negative sub-picture. JDK
              releases subsequent to JDK 1.1 have added the
              provision: <em>If there is an explicit negative
              subpattern [sub-picture], it serves only to specify
              the negative prefix and suffix; the number of digits,
              minimal digits, and other characteristics are all the
              same as the positive pattern [sub-picture].</em> This
              statement was not present in the JDK 1.1
              specification, and therefore it is not necessarily
              how every XSLT 1.0 implementation will behave, but it
              does describe the behavior of some XSLT 1.0
              implementations that use the JDK directly. This
              behavior is not correct in XSLT 2.0: the negative
              sub-picture <span class="verb">must</span> be used as
              written when the number is negative.</p>
            </li>

            <li>
              <p>The recovery action has changed for the error
              condition where the processor cannot handle the
              fragment identifier in a URI passed as an argument to
              the <a href=
              "index.html#function-document"><code>document</code></a>
              function. XSLT 1.0 specified that the entire URI
              reference should be ignored. XSLT 2.0 specifies that
              the fragment identifier should be ignored.</p>
            </li>

            <li>
              <p>XSLT 1.0 allowed the URI returned by the <a href=
              "index.html#function-unparsed-entity-uri"><code>unparsed-entity-uri</code></a>
              function to be derived from some combination of the
              system identifier and the public identifier in the
              source XML. XSLT 2.0 returns the system identifier as
              defined in the Infoset, resolved using the base URI
              of the source document. A new function is provided to
              return the public identifier.</p>
            </li>

            <li>
              <p>The default priority of the pattern
              <code>match="/"</code> has changed from +0.5 to -0.5.
              The effect of this is that if there are any template
              rules that specify <code>match="/"</code> with an
              explicit user-specified priority between -0.5 and
              +0.5, these will now be chosen in preference to a
              template rule that specifies <code>match="/"</code>
              with no explicit priority; previously such rules
              would never have been invoked.</p>
            </li>

            <li>
              <p>In XSLT 1.0 it was possible to create a processing
              instruction in the result tree whose string value
              contained a leading space. However, such leading
              spaces would be lost after serialization and parsing.
              In XSLT 2.0, any leading spaces in the string value
              of the processing instruction are removed at the time
              the node is created.</p>
            </li>

            <li>
              <p>At XSLT 1.0 there were no restrictions on the
              namespaces that could be used for the names of
              user-defined stylesheet objects such as keys,
              variables, and named templates. In XSLT 2.0, certain
              namespaces (for example the XSLT namespace and the
              XML Schema namespace) are reserved.</p>
            </li>

            <li>
              <p>An erratum to XSLT 1.0 specified what has become
              known as "sticky disable-output-escaping":
              specifically, that it should be possible to use
              <code>disable-output-escaping</code> when writing a
              node to a temporary tree, and that this information
              would be retained for use when the same node was
              later copied to a final result tree and serialized.
              XSLT 2.0 no longer specifies this behavior (though it
              permits it, at the discretion of the implementation).
              The use cases for this facility have been satisfied
              by a completely different mechanism, the concept of
              character maps (see <a href="index.html#character-maps"><i>20.1
              Character Maps</i></a>).</p>
            </li>
          </ol>
        </div>

        <div class="div3">
          <h4><a name="compatibility-with-schema" id=
          "compatibility-with-schema"></a>J.1.5 Compatibility in
          the Presence of a Schema</h4>

          <p>An XSLT 1.0 processor ignored all information about
          data types that might be obtained from a schema
          associated with a source document. An XSLT 2.0 processor
          will take account of such information, <span>unless the
          <code>input-type-annotations</code> attribute is set to
          <code>strip</code></span>. This may lead to a number of
          differences in behavior. This section attempts only to
          give some examples of the kind of differences that might
          be expected when schema information is made
          available:</p>

          <ul>
            <li>
              <p>Operations such as sorting will be sensitive to
              the data type of the items being sorted. For example,
              if the data type of a sort key component is defined
              in the schema as a date, then in the absence of a
              <code>data-type</code> attribute on the <a href=
              "index.html#element-sort"><code>xsl:sort</code></a> element,
              the sequence will be sorted in date order. With XSLT
              1.0, the dates would be compared and sorted as
              strings.</p>
            </li>

            <li>
              <p>Certain operations that are permitted on untyped
              data are not permitted on typed data, if the type of
              the data is inappropriate for the operation.
              <span>For example, the <a href=
              "http://www.w3.org/TR/xpath-functions/#func-substring">
              <code>substring</code></a><sup><small>FO</small></sup>
              function expects its first argument to be a
              string</span>. It is acceptable to supply an untyped
              value, which will be automatically converted to a
              string, but it is not acceptable to supply a value
              which has been annotated (as a result of schema
              processing) as an integer or a date.</p>
            </li>

            <li>
              <p>When an attribute value such as <code>colors="red
              green blue"</code> is processed without a schema, the
              value is considered to be a single string. When
              schema validation is applied, assuming the type is a
              list type like <code>xs:NMTOKENS</code>, the value
              will be treated as a sequence of three strings. This
              affects the results of many operations, for example
              comparison of the value with another string.
              <span>With this attribute value, the expression
              <code>contains(@colors, "green")</code> returns true
              in XPath 1.0 and also in XPath 2.0 if
              <code>input-type-annotations</code> is set to
              <code>strip</code>. In XPath 2.0, with a schema-aware
              processor and with
              <code>input-type-annotations</code> set to
              <code>preserve</code>, the same expression returns
              false with backwards-compatibility enabled, and
              raises an error with backwards compatibility
              disabled.</span></p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="xpath-compatibility" id=
          "xpath-compatibility"></a>J.1.6 XPath 2.0 Backwards
          Compatibility</h4>

          <p>Information about incompatibilities between XPath 2.0
          and XPath 1.0 is included in <a href="index.html#xpath20">[XPath
          2.0]</a></p>

          <p>Incompatibilities in the specification of individual
          functions in the <a title="core function" href=
          "index.html#dt-core-function">core function</a> library are listed
          in <a href="index.html#xpath-functions">[Functions and
          Operators]</a></p>
        </div>
      </div>

      <div class="div2">
        <h3><a name="changes-since-1.0" id=
        "changes-since-1.0"></a>J.2 New Functionality</h3>

        <p>This section summarizes the new functionality offered in
        XSLT 2.0, compared with XSLT 1.0. These are arranged in
        three groups. Firstly, the changes that pervade the entire
        text. Secondly, the major new features introduced. And
        thirdly, a catalog of minor technical changes.</p>

        <p>Changes since the <span>November 2006 Proposed
        Recommendation</span> are listed separately: see <a href=
        "index.html#changes-2007-01"><i>J.2.4 Changes since Proposed
        Recommendation</i></a>.</p>

        <p>In addition to these changes, reported <a href=
        "http://www.w3.org/1999/11/REC-xslt-19991116-errata/">errors</a>
        in XSLT 1.0 have been fixed.</p>

        <div class="div3">
          <h4><a name="pervasive-changes" id=
          "pervasive-changes"></a>J.2.1 Pervasive changes</h4>

          <ul>
            <li>
              <p>There has been significant re-arrangement of the
              text. More terminology definitions have been
              hyperlinked, and a glossary (see <a href=
              "index.html#glossary"><i>C Glossary</i></a>) has been added.
              Additional appendices summarize the error conditions
              and implementation-defined features of the
              specification.</p>
            </li>

            <li>
              <p>The specifications of many features (for example
              keys, <a href=
              "index.html#element-number"><code>xsl:number</code></a>, the
              <a href=
              "index.html#function-format-number"><code>format-number</code></a>
              function, the <a href=
              "index.html#element-import"><code>xsl:import</code></a>
              mechanism, and the description of attribute sets)
              have been rewritten to make them clearer and more
              precise.</p>
            </li>

            <li>
              <p>Many changes have been made to support the
              <span>XDM</span> data model, notably the support for
              sequences as a replacement for the node-sets of XPath
              1.0. This has affected the specification of elements
              such as <a href=
              "index.html#element-for-each"><code>xsl:for-each</code></a>,
              <a href=
              "index.html#element-value-of"><code>xsl:value-of</code></a>,
              and <a href=
              "index.html#element-sort"><code>xsl:sort</code></a>, and has
              led to the introduction of new instructions such as
              <a href=
              "index.html#element-sequence"><code>xsl:sequence</code></a>.</p>
            </li>

            <li>
              <p>The processing model is described differently:
              instead of instructions "writing to the result tree",
              they now return sequences of values. This change is
              largely one of terminology, but it also means that it
              is now possible for XSLT stylesheets to manipulate
              arbitrary sequences, including sequences containing
              parentless element or attribute nodes.</p>
            </li>

            <li>
              <p>The description of the evaluation context has been
              changed. The concepts of current node and current
              node list have been replaced by the XPath concepts of
              context item, context position, and context size.</p>
            </li>

            <li>
              <p>With the introduction of support for XML Schema
              within XPath 2.0, XSLT now supports stronger data
              typing, while retaining backwards compatibility. In
              particular, the types of variables and parameters can
              now be specified explicitly, and schema validation
              can be invoked for result trees and for elements and
              attributes in temporary trees.</p>
            </li>

            <li>
              <p>The description of error handling has been
              improved (see <a href="index.html#errors"><i>2.9 Error
              Handling</i></a>). This formalizes the difference
              between static and dynamic errors, and tightens the
              rules that define which errors must be signaled under
              which conditions.</p>
            </li>

            <li>
              <p>The terms <a title="implementation-defined" href=
              "index.html#dt-implementation-defined">implementation-defined</a>
              and <a title="implementation-dependent" href=
              "index.html#dt-implementation-dependent">implementation-dependent</a>
              are now defined and used consistently, and a
              checklist of implementation-defined features is
              provided (see <a href=
              "index.html#implementation-defined-features"><i>F Checklist of
              Implementation-Defined Features</i></a>).</p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="major-features" id=
          "major-features"></a>J.2.2 Major Features</h4>

          <ul>
            <li>
              <p>XSLT 2.0 is designed to work with XPath 2.0 rather
              than XPath 1.0. This brings an enhanced data model
              with a type system based on sequences of nodes or
              atomic values, support for all the built-in types
              defined in XML Schema, and a wide range of new
              functions and operators.</p>
            </li>

            <li>
              <p>The result tree fragment data-type is eliminated.
              <a title="variable-binding element" href=
              "index.html#dt-variable-binding-element">A variable-binding
              element</a> with content (and no <code>as</code>
              attribute) now constructs a <a title="temporary tree"
              href="index.html#dt-temporary-tree">temporary tree</a>, and the
              value of the variable is the root node of this tree
              (see <a href="index.html#variable-values"><i>9.3 Values of
              Variables and Parameters</i></a>). With an
              <code>as</code> attribute, a variable-binding element
              may be used to construct an arbitrary sequence. These
              features eliminate the need for the
              <code>xx:node-set</code> extension function provided
              by many XSLT 1.0 implementations.</p>
            </li>

            <li>
              <p>Facilities are introduced for grouping of nodes
              (the <a href=
              "index.html#element-for-each-group"><code>xsl:for-each-group</code></a>
              instruction, and the <code>current-group()</code> and
              <code>current-grouping-key()</code> functions). See
              <a href="index.html#grouping"><i>14 Grouping</i></a></p>
            </li>

            <li>
              <p>It is now possible to create user-defined
              functions within the stylesheet, that can be called
              from XPath expressions. See <a href=
              "index.html#stylesheet-functions"><i>10.3 Stylesheet
              Functions</i></a>.</p>
            </li>

            <li>
              <p>A transformation is allowed to produce multiple
              result trees. See <a href=
              "index.html#creating-result-trees"><i>19.1 Creating Final
              Result Trees</i></a>.</p>
            </li>

            <li>
              <p>A new instruction <a href=
              "index.html#element-analyze-string"><code>xsl:analyze-string</code></a>
              is provided to process text by matching it against a
              regular expression.</p>
            </li>

            <li>
              <p>It is possible to declare the types of variables
              and parameters, and the result types of templates and
              functions. The types may either be built-in types, or
              user-defined types imported from a schema using a new
              <a href=
              "index.html#element-import-schema"><code>xsl:import-schema</code></a>
              declaration.</p>
            </li>

            <li>
              <p>A stylesheet is able to attach type annotations to
              elements and attributes in a result tree, and also in
              temporary trees, and to make use of any type
              annotations that exist in a source tree. Result trees
              and temporary trees can be validated against a
              schema.</p>
            </li>

            <li>
              <p>A transformation may now be invoked by calling a
              named template. This creates the potential for a
              transformation to process large collections of input
              documents. <span>The input to such a transformation
              may be obtained using the <a href=
              "http://www.w3.org/TR/xpath-functions/#func-collection">
              <code>collection</code></a><sup><small>FO</small></sup>
              function defined in <a href=
              "index.html#xpath-functions">[Functions and Operators]</a>, or
              it may be supplied as a <a title=
              "stylesheet parameter" href=
              "index.html#dt-stylesheet-parameter">stylesheet
              parameter</a>.</span></p>
            </li>

            <li>
              <p>Comparisons between values used for grouping, for
              sorting, and for keys can be performed using the
              rules for any supported data type, including the
              ability to select named collations for performing
              string comparison. These complement the new
              facilities in XPath 2.0, which are also invoked
              automatically when matching template rules.</p>
            </li>

            <li>
              <p>The <a href=
              "index.html#element-for-each"><code>xsl:for-each</code></a>
              instruction is able to process any sequence, not only
              a sequence of nodes.</p>
            </li>

            <li>
              <p>An XHTML output method has been added. The details
              are described in <a href=
              "index.html#xslt-xquery-serialization">[XSLT and XQuery
              Serialization]</a>.</p>
            </li>

            <li>
              <p>A <code>collation</code> attribute has been added
              to the <a href=
              "index.html#element-sort"><code>xsl:sort</code></a> element to
              allow sorting using a user-defined collation.</p>
            </li>

            <li>
              <p>A new <a href=
              "index.html#element-next-match"><code>xsl:next-match</code></a>
              is provided to allow multiple template rules to be
              applied to the same source node.</p>
            </li>

            <li>
              <p>A new <a href=
              "index.html#element-character-map"><code>xsl:character-map</code></a>
              declaration is available to control the serialization
              of individual characters. This is intended as a
              replacement for some use-cases where
              <code>disable-output-escaping</code> was previously
              necessary.</p>
            </li>

            <li>
              <p>Functions have been added for formatting dates and
              times. See <a href="index.html#format-date"><i>16.5 Formatting
              Dates and Times</i></a></p>
            </li>

            <li>
              <p>The new facility of <a title="tunnel parameter"
              href="index.html#dt-tunnel-parameter">tunnel parameters</a>
              allows parameters to be set that affect an entire
              phase of the transformation, without requiring them
              to be passed explicitly in every template call.</p>
            </li>

            <li>
              <p>Many instructions that previously constructed a
              value using child instructions can now alternatively
              construct the value using a <code>select</code>
              attribute; and conversely, instructions that
              previously required a <code>select</code> attribute
              can now use child instructions.</p>
            </li>

            <li>
              <p>The <a href=
              "index.html#element-template"><code>xsl:template</code></a>
              declaration can now declare a template rule that
              applies to several different modes; and the <a href=
              "index.html#element-apply-templates"><code>xsl:apply-templates</code></a>
              instruction can cause processing to continue in the
              current mode.</p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="minor-changes" id="minor-changes"></a>J.2.3
          Minor Changes</h4>

          <ul>
            <li>
              <p>Instead of allowing the output method complete
              freedom to add namespace nodes, a process of
              namespace fixup is applied to the result tree before
              it is output; this same namespace fixup process is
              also applied to documents constructed using
              variable-binding elements with content (see <a href=
              "index.html#namespace-fixup"><i>5.7.3 Namespace
              Fixup</i></a>).</p>
            </li>

            <li>
              <p>Support for XML Base has been added.</p>
            </li>

            <li>
              <p>An <a href=
              "index.html#element-apply-imports"><code>xsl:apply-imports</code></a>
              element is allowed to have parameters (see <a href=
              "index.html#apply-imports"><i>6.7 Overriding Template
              Rules</i></a> and <a href="index.html#with-param"><i>10.1.1
              Passing Parameters to Templates</i></a>).</p>
            </li>

            <li>
              <p><a title="extension function" href=
              "index.html#dt-extension-function">Extension functions</a> are
              allowed to return external objects, which do not have
              any of the builtin XPath types.</p>
            </li>

            <li>
              <p>The specification for patterns (<a href=
              "index.html#patterns"><i>5.5 Patterns</i></a>) has been revised
              to align it with the new XPath grammar. The formal
              semantics of patterns has been simplified: this
              became possible because of the extra compositionality
              now available in the expression grammar. The syntax
              and semantics of patterns remains essentially
              unchanged, except that XPath 2.0 expressions can be
              used within predicates.</p>
            </li>

            <li>
              <p>A backwards-compatible processing mode is
              introduced. See <a href="index.html#backwards"><i>3.8
              Backwards-Compatible Processing</i></a></p>
            </li>

            <li>
              <p>The <a href=
              "index.html#function-system-property"><code>system-property</code></a>
              function now always returns a string. Several new
              system properties have been defined. See <a href=
              "index.html#system-property"><i>16.6.5
              system-property</i></a>.</p>
            </li>

            <li>
              <p>With <code>&lt;xsl:message
              terminate="yes"&gt;</code>, the processor now
              <em><span class="verb">must</span></em> terminate
              processing. Previously the word <em><span class=
              "verb">should</span></em> was used. See <a href=
              "index.html#message"><i>17 Messages</i></a>.</p>
            </li>

            <li>
              <p>A number of new serialization parameters have been
              introduced.</p>
            </li>

            <li>
              <p>A new instruction <a href=
              "index.html#element-namespace"><code>xsl:namespace</code></a>
              is available, for creating namespace nodes: see
              <a href="index.html#creating-namespace-nodes"><i>11.7 Creating
              Namespace Nodes</i></a>.</p>
            </li>

            <li>
              <p>A new instruction <a href=
              "index.html#element-perform-sort"><code>xsl:perform-sort</code></a>
              is available, for returning a sorted sequence.</p>
            </li>

            <li>
              <p>A new <code>[xsl:]xpath-default-namespace</code>
              attribute is available to define the default
              namespace for unqualified names in an XPath
              expression or XSLT pattern.</p>
            </li>

            <li>
              <p>The attributes <code>[xsl:]version</code>,
              <code>[xsl:]exclude-result-prefixes</code>, and
              <code>[xsl:]extension-element-prefixes</code>, as
              well as the new
              <code>[xsl:]xpath-default-namespace</code> and
              <code>[xsl:]default-collation</code>, can be used on
              any <a title="XSLT element" href=
              "index.html#dt-xslt-element">XSLT element</a>, not only on
              <a href=
              "index.html#element-stylesheet"><code>xsl:stylesheet</code></a>
              and on literal result elements as before. In
              particular, they can now be used on the <a href=
              "index.html#element-template"><code>xsl:template</code></a>
              element.</p>
            </li>

            <li>
              <p>A new <a href=
              "index.html#function-unparsed-text"><code>unparsed-text</code></a>
              function is introduced. It allows the contents of an
              external text file to be read as a string.</p>
            </li>

            <li>
              <p>Restrictions on the use of variables within
              patterns and key definitions have been removed; in
              their place a more general statement of the
              restrictions preventing circularity has been
              formulated. The <a href=
              "index.html#function-current"><code>current</code></a> function
              may also now be used within patterns.</p>
            </li>

            <li>
              <p>The built-in templates for element and document
              nodes now pass any supplied parameter values on to
              the templates that they call.</p>
            </li>

            <li>
              <p>A detailed specification of the <a href=
              "index.html#function-format-number"><code>format-number</code></a>
              function is now provided, removing the reliance on
              specifications in Java JDK 1.1.</p>
            </li>
          </ul>
        </div>

        <div class="div3">
          <h4><a name="changes-2007-01" id=
          "changes-2007-01"></a>J.2.4 Changes since Proposed
          Recommendation</h4>

          <p>The following changes have been made since publication
          of the <a href=
          "http://www.w3.org/TR/2006/PR-xslt20-20061121/">Proposed
          Recommendation</a>. Each change contains a reference to
          its discussion and rationale, for example the relevant
          issue number in the <a href=
          "http://www.w3.org/Bugs/Public/">W3C public Bugzilla
          database</a>.</p>

          <ul>
            <li>
              <p>In <a href="index.html#analyze-string"><i>15.1 The
              xsl:analyze-string instruction</i></a>, the paragraph
              describing the permitted contents of the instruction
              has been clarified. (The sentence "Both elements are
              optional, and neither may appear more than once." was
              considered awkward). This editorial change was made
              in response to a <a href=
              "http://lists.w3.org/Archives/Public/public-qt-comments/2006Jan/0083">
              public comment</a> made during the Candidate
              Recommendation phase.</p>
            </li>

            <li>
              <p>In <a href="index.html#result-trees"><i>19 Final Result
              Trees</i></a> it was stated that the result of a
              transformation consisted of zero or more result
              trees; while <a href=
              "index.html#executing-a-transformation"><i>2.4 Executing a
              Transformation</i></a> stated (correctly) that it
              consisted of one or more. The former statement has
              been revised. A cross-reference between the two
              sections has been added for clarification. (Bugzilla
              4031)</p>
            </li>

            <li>
              <p>Some trivial syntax errors in examples have been
              fixed. (Bugzilla 4149)</p>
            </li>
          </ul>

          <p>The <a href=
          "http://www.w3.org/TR/2006/PR-xslt20-20061121/">Proposed
          Recommendation</a> contains a complete list of published
          working drafts prepared during the development of this
          specification, and a detailed history of changes may be
          assembled by viewing the change log present in each
          draft. For most of the drafts, a version is available in
          which changes are visually highlighted.</p>
        </div>
      </div>
    </div>
  </div>
</body>
</html>