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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>The XML C parser and toolkit of Gnome</title>
<meta name="GENERATOR" content="amaya 8.8.5, see http://www.w3.org/Amaya/">
<meta http-equiv="content-type" content="text/html">
</head>
<body bgcolor="#ffffff">
<h1 align="center">The XML C parser and toolkit of Gnome</h1>
<h1>Note: this is the flat content of the <a
href="index.html">website</a></h1>
<h1 style="text-align: center">libxml, a.k.a. gnome-xml</h1>
<p></p>
<p
style="text-align: right; font-style: italic; font-size: 10pt">"Programmingwith
libxml2 is like the thrilling embrace of an exotic stranger." <a
href="http://diveintomark.org/archives/2004/02/18/libxml2">MarkPilgrim</a></p>
<p>Libxml2 is the XML C parser and toolkit developed for the Gnome
project(but usable outside of the Gnome platform), it is free software
availableunder the <a
href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>.
XML itself is a metalanguage to design markup languages, i.e.text language
where semantic and structure are added to the content usingextra "markup"
information enclosed between angle brackets. HTML is the mostwell-known
markup language. Though the library is written in C <a href="python.html">a
variety of language bindings</a>make it available inother environments.</p>
<p>Libxml2 is known to be very portable, the library should build and
workwithout serious troubles on a variety of systems (Linux, Unix,
Windows,CygWin, MacOS, MacOS X, RISC Os, OS/2, VMS, QNX, MVS, ...)</p>
<p>Libxml2 implements a number of existing standards related to
markuplanguages:</p>
<ul>
<li>the XML standard: <a
href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</a></li>
<li>Namespaces in XML: <a
href="http://www.w3.org/TR/REC-xml-names/">http://www.w3.org/TR/REC-xml-names/</a></li>
<li>XML Base: <a
href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a></li>
<li><a href="http://www.cis.ohio-state.edu/rfc/rfc2396.txt">RFC
2396</a>:Uniform Resource Identifiers <a
href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a></li>
<li>XML Path Language (XPath) 1.0: <a
href="http://www.w3.org/TR/xpath">http://www.w3.org/TR/xpath</a></li>
<li>HTML4 parser: <a
href="http://www.w3.org/TR/html401/">http://www.w3.org/TR/html401/</a></li>
<li>XML Pointer Language (XPointer) Version 1.0: <a
href="http://www.w3.org/TR/xptr">http://www.w3.org/TR/xptr</a></li>
<li>XML Inclusions (XInclude) Version 1.0: <a
href="http://www.w3.org/TR/xinclude/">http://www.w3.org/TR/xinclude/</a></li>
<li>ISO-8859-x encodings, as well as <a
href="http://www.cis.ohio-state.edu/rfc/rfc2044.txt">rfc2044</a>[UTF-8]and
<a
href="http://www.cis.ohio-state.edu/rfc/rfc2781.txt">rfc2781</a>[UTF-16]
Unicode encodings, and more if using iconv support</li>
<li>part of SGML Open Technical Resolution TR9401:1997</li>
<li>XML Catalogs Working Draft 06 August 2001: <a
href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html">http://www.oasis-open.org/committees/entity/spec-2001-08-06.html</a></li>
<li>Canonical XML Version 1.0: <a
href="http://www.w3.org/TR/xml-c14n">http://www.w3.org/TR/xml-c14n</a>and
the Exclusive XML Canonicalization CR draft <a
href="http://www.w3.org/TR/xml-exc-c14n">http://www.w3.org/TR/xml-exc-c14n</a></li>
<li>Relax NG, ISO/IEC 19757-2:2003, <a
href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html">http://www.oasis-open.org/committees/relax-ng/spec-20011203.html</a></li>
<li>W3C XML Schemas Part 2: Datatypes <a
href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/">REC 02
May2001</a></li>
<li>W3C <a href="http://www.w3.org/TR/xml-id/">xml:id</a>Working Draft
7April 2004</li>
</ul>
<p>In most cases libxml2 tries to implement the specifications in arelatively
strictly compliant way. As of release 2.4.16, libxml2 passed all1800+ tests
from the <a
href="http://www.oasis-open.org/committees/xml-conformance/">OASIS XML
TestsSuite</a>.</p>
<p>To some extent libxml2 provides support for the following
additionalspecifications but doesn't claim to implement them completely:</p>
<ul>
<li>Document Object Model (DOM) <a
href="http://www.w3.org/TR/DOM-Level-2-Core/">http://www.w3.org/TR/DOM-Level-2-Core/</a>the
document model, but it doesn't implement the API itself, gdome2 doesthis
on top of libxml2</li>
<li><a href="http://www.cis.ohio-state.edu/rfc/rfc959.txt">RFC
959</a>:libxml2 implements a basic FTP client code</li>
<li><a href="http://www.cis.ohio-state.edu/rfc/rfc1945.txt">RFC
1945</a>:HTTP/1.0, again a basic HTTP client code</li>
<li>SAX: a SAX2 like interface and a minimal SAX1 implementation
compatiblewith early expat versions</li>
</ul>
<p>A partial implementation of <a
href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/">XML Schemas Part1:
Structure</a>is being worked on but it would be far too early to make
anyconformance statement about it at the moment.</p>
<p>Separate documents:</p>
<ul>
<li><a href="http://xmlsoft.org/XSLT/">the libxslt page</a>providing
animplementation of XSLT 1.0 and common extensions like EXSLT
forlibxml2</li>
<li><a href="http://www.cs.unibo.it/~casarini/gdome2/">the gdome2 page</a>:
a standard DOM2 implementation for libxml2</li>
<li><a href="http://www.aleksey.com/xmlsec/">the XMLSec page</a>:
animplementation of <a href="http://www.w3.org/TR/xmldsig-core/">W3C
XMLDigital Signature</a>for libxml2</li>
<li>also check the related links section below for more related and
activeprojects.</li>
</ul>
<!----------------<p>Results of the <a
href="http://xmlbench.sourceforge.net/results/benchmark/index.html">xmlbench
benchmark</a> on sourceforge February 2004 (smaller is better):</p>
<p align="center"><img src="benchmark.png"
alt="benchmark results for Expat Xerces libxml2 Oracle and Sun toolkits"></p>
-------------->
<p>Logo designed by <a href="mailto:liyanage@access.ch">Marc Liyanage</a>.</p>
<h2><a name="Introducti">Introduction</a></h2>
<p>This document describes libxml, the <a
href="http://www.w3.org/XML/">XML</a>C parser and toolkit developed for the<a
href="http://www.gnome.org/">Gnome</a>project. <a
href="http://www.w3.org/XML/">XML is a standard</a>for building
tag-basedstructured documents/data.</p>
<p>Here are some key points about libxml:</p>
<ul>
<li>Libxml2 exports Push (progressive) and Pull (blocking) type
parserinterfaces for both XML and HTML.</li>
<li>Libxml2 can do DTD validation at parse time, using a parsed
documentinstance, or with an arbitrary DTD.</li>
<li>Libxml2 includes complete <a
href="http://www.w3.org/TR/xpath">XPath</a>, <a
href="http://www.w3.org/TR/xptr">XPointer</a>and <a
href="http://www.w3.org/TR/xinclude">XInclude</a>implementations.</li>
<li>It is written in plain C, making as few assumptions as possible,
andsticking closely to ANSI C/POSIX for easy embedding. Works
onLinux/Unix/Windows, ported to a number of other platforms.</li>
<li>Basic support for HTTP and FTP client allowing applications to
fetchremote resources.</li>
<li>The design is modular, most of the extensions can be compiled out.</li>
<li>The internal document representation is as close as possible to the <a
href="http://www.w3.org/DOM/">DOM</a>interfaces.</li>
<li>Libxml2 also has a <a
href="http://www.megginson.com/SAX/index.html">SAX like interface</a>;the
interface is designed to be compatible with <a
href="http://www.jclark.com/xml/expat.html">Expat</a>.</li>
<li>This library is released under the <a
href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>.
See the Copyright file in the distribution for the precisewording.</li>
</ul>
<p>Warning: unless you are forced to because your application links with
aGnome-1.X library requiring it, <strong><span
style="background-color: #FF0000">Do Not Use libxml1</span></strong>,
uselibxml2</p>
<h2><a name="FAQ">FAQ</a></h2>
<p>Table of Contents:</p>
<ul>
<li><a href="FAQ.html#License">License(s)</a></li>
<li><a href="FAQ.html#Installati">Installation</a></li>
<li><a href="FAQ.html#Compilatio">Compilation</a></li>
<li><a href="FAQ.html#Developer">Developer corner</a></li>
</ul>
<h3><a name="License">License</a>(s)</h3>
<ol>
<li><em>Licensing Terms for libxml</em>
<p>libxml2 is released under the <a
href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>;
see the file Copyright in the distribution for the precisewording</p>
</li>
<li><em>Can I embed libxml2 in a proprietary application ?</em>
<p>Yes. The MIT License allows you to keep proprietary the changes
youmade to libxml, but it would be graceful to send-back bug fixes
andimprovements as patches for possible incorporation in the
maindevelopment tree.</p>
</li>
</ol>
<h3><a name="Installati">Installation</a></h3>
<ol>
<li><strong><span style="background-color: #FF0000">Do Not
Uselibxml1</span></strong>, use libxml2</li>
<li><em>Where can I get libxml</em>?
<p>The original distribution comes from <a
href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>or <a
href="ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/">gnome.org</a></p>
<p>Most Linux and BSD distributions include libxml, this is probably
thesafer way for end-users to use libxml.</p>
<p>David Doolin provides precompiled Windows versions at <a
href="http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/ ">http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/</a></p>
</li>
<li><em>I see libxml and libxml2 releases, which one should I install ?</em>
<ul>
<li>If you are not constrained by backward compatibility issues
withexisting applications, install libxml2 only</li>
<li>If you are not doing development, you can safely install
both.Usually the packages <a
href="http://rpmfind.net/linux/RPM/libxml.html">libxml</a>and <a
href="http://rpmfind.net/linux/RPM/libxml2.html">libxml2</a>arecompatible
(this is not the case for development packages).</li>
<li>If you are a developer and your system provides separate
packagingfor shared libraries and the development components, it is
possibleto install libxml and libxml2, and also <a
href="http://rpmfind.net/linux/RPM/libxml-devel.html">libxml-devel</a>and
<a
href="http://rpmfind.net/linux/RPM/libxml2-devel.html">libxml2-devel</a>too
for libxml2 >= 2.3.0</li>
<li>If you are developing a new application, please develop
againstlibxml2(-devel)</li>
</ul>
</li>
<li><em>I can't install the libxml package, it conflicts with libxml0</em>
<p>You probably have an old libxml0 package used to provide the
sharedlibrary for libxml.so.0, you can probably safely remove it. The
libxmlpackages provided on <a
href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>providelibxml.so.0</p>
</li>
<li><em>I can't install the libxml(2) RPM package due to
faileddependencies</em>
<p>The most generic solution is to re-fetch the latest src.rpm ,
andrebuild it locally with</p>
<p><code>rpm --rebuild libxml(2)-xxx.src.rpm</code>.</p>
<p>If everything goes well it will generate two binary rpm packages
(oneproviding the shared libs and xmllint, and the other one, the
-develpackage, providing includes, static libraries and scripts needed to
buildapplications with libxml(2)) that you can install locally.</p>
</li>
</ol>
<h3><a name="Compilatio">Compilation</a></h3>
<ol>
<li><em>What is the process to compile libxml2 ?</em>
<p>As most UNIX libraries libxml2 follows the "standard":</p>
<p><code>gunzip -c xxx.tar.gz | tar xvf -</code></p>
<p><code>cd libxml-xxxx</code></p>
<p><code>./configure --help</code></p>
<p>to see the options, then the compilation/installation proper</p>
<p><code>./configure [possible options]</code></p>
<p><code>make</code></p>
<p><code>make install</code></p>
<p>At that point you may have to rerun ldconfig or a similar utility
toupdate your list of installed shared libs.</p>
</li>
<li><em>What other libraries are needed to compile/install libxml2 ?</em>
<p>Libxml2 does not require any other library, the normal C ANSI
APIshould be sufficient (please report any violation to this rule you
mayfind).</p>
<p>However if found at configuration time libxml2 will detect and use
thefollowing libs:</p>
<ul>
<li><a href="http://www.info-zip.org/pub/infozip/zlib/">libz</a>:
ahighly portable and available widely compression library.</li>
<li>iconv: a powerful character encoding conversion library. It
isincluded by default in recent glibc libraries, so it doesn't need
tobe installed specifically on Linux. It now seems a <a
href="http://www.opennc.org/onlinepubs/7908799/xsh/iconv.html">partof
the official UNIX</a>specification. Here is one <a
href="http://www.gnu.org/software/libiconv/">implementation of
thelibrary</a>which source can be found <a
href="ftp://ftp.ilog.fr/pub/Users/haible/gnu/">here</a>.</li>
</ul>
</li>
<li><em>Make check fails on some platforms</em>
<p>Sometimes the regression tests' results don't completely match
thevalue produced by the parser, and the makefile uses diff to print
thedelta. On some platforms the diff return breaks the compilation
process;if the diff is small this is probably not a serious problem.</p>
<p>Sometimes (especially on Solaris) make checks fail due to
limitationsin make. Try using GNU-make instead.</p>
</li>
<li><em>I use the CVS version and there is no configure script</em>
<p>The configure script (and other Makefiles) are generated. Use
theautogen.sh script to regenerate the configure script and
Makefiles,like:</p>
<p><code>./autogen.sh --prefix=/usr --disable-shared</code></p>
</li>
<li><em>I have troubles when running make tests with gcc-3.0</em>
<p>It seems the initial release of gcc-3.0 has a problem with
theoptimizer which miscompiles the URI module. Please use
anothercompiler.</p>
</li>
</ol>
<h3><a name="Developer">Developer</a>corner</h3>
<ol>
<li><em>Troubles compiling or linking programs using libxml2</em>
<p>Usually the problem comes from the fact that the compiler doesn't
getthe right compilation or linking flags. There is a small shell
script<code>xml2-config</code>which is installed as part of libxml2
usualinstall process which provides those flags. Use</p>
<p><code>xml2-config --cflags</code></p>
<p>to get the compilation flags and</p>
<p><code>xml2-config --libs</code></p>
<p>to get the linker flags. Usually this is done directly from
theMakefile as:</p>
<p><code>CFLAGS=`xml2-config --cflags`</code></p>
<p><code>LIBS=`xml2-config --libs`</code></p>
</li>
<li><em>I want to install my own copy of libxml2 in my home directory
andlink my programs against it, but it doesn't work</em>
<p>There are many different ways to accomplish this. Here is one way
todo this under Linux. Suppose your home directory is
<code>/home/user.</code>Then:</p>
<ul>
<li>Create a subdirectory, let's call it <code>myxml</code></li>
<li>unpack the libxml2 distribution into that subdirectory</li>
<li>chdir into the unpacked distribution(<code>/home/user/myxml/libxml2
</code>)</li>
<li>configure the library using the "<code>--prefix</code>"
switch,specifying an installation subdirectory
in<code>/home/user/myxml</code>, e.g.
<p><code>./configure --prefix
/home/user/myxml/xmlinst</code>{otherconfiguration options}</p>
</li>
<li>now run <code>make</code>followed by <code>make install</code></li>
<li>At this point, the installation subdirectory contains the
complete"private" include files, library files and binary program
files (e.g.xmllint), located in
<p><code>/home/user/myxml/xmlinst/lib,/home/user/myxml/xmlinst/include
</code>and <code>/home/user/myxml/xmlinst/bin</code></p>
respectively.</li>
<li>In order to use this "private" library, you should first add it
tothe beginning of your default PATH (so that your own private
programfiles such as xmllint will be used instead of the normal
systemones). To do this, the Bash command would be
<p><code>export PATH=/home/user/myxml/xmlinst/bin:$PATH</code></p>
</li>
<li>Now suppose you have a program <code>test1.c</code>that you
wouldlike to compile with your "private" library. Simply compile it
usingthe command
<p><code>gcc `xml2-config --cflags --libs` -o test test.c</code></p>
Note that, because your PATH has been set with
<code>/home/user/myxml/xmlinst/bin</code>at the beginning, the
xml2-configprogram which you just installed will be used instead of
the systemdefault one, and this will <em>automatically</em>get the
correctlibraries linked with your program.</li>
</ul>
</li>
<p></p>
<li><em>xmlDocDump() generates output on one line.</em>
<p>Libxml2 will not <strong>invent</strong>spaces in the content of
adocument since <strong>all spaces in the content of a document
aresignificant</strong>. If you build a tree from the API and
wantindentation:</p>
<ol>
<li>the correct way is to generate those yourself too.</li>
<li>the dangerous way is to ask libxml2 to add those blanks to
yourcontent <strong>modifying the content of your document in
theprocess</strong>. The result may not be what you expect. There
is<strong>NO</strong>way to guarantee that such a modification
won'taffect other parts of the content of your document. See <a
href="http://xmlsoft.org/html/libxml-parser.html#xmlKeepBlanksDefault">xmlKeepBlanksDefault()</a>and
<a
href="http://xmlsoft.org/html/libxml-tree.html#xmlSaveFormatFile">xmlSaveFormatFile()</a></li>
</ol>
</li>
<li>Extra nodes in the document:
<p><em>For a XML file as below:</em></p>
<pre><?xml version="1.0"?>
<PLAN xmlns="http://www.argus.ca/autotest/1.0/">
<NODE CommFlag="0"/>
<NODE CommFlag="1"/>
</PLAN></pre>
<p><em>after parsing it with the
functionpxmlDoc=xmlParseFile(...);</em></p>
<p><em>I want to the get the content of the first node (node with
theCommFlag="0")</em></p>
<p><em>so I did it as following;</em></p>
<pre>xmlNodePtr pnode;
pnode=pxmlDoc->children->children;</pre>
<p><em>but it does not work. If I change it to</em></p>
<pre>pnode=pxmlDoc->children->children->next;</pre>
<p><em>then it works. Can someone explain it to me.</em></p>
<p></p>
<p>In XML all characters in the content of the document are
significant<strong>including blanks and formatting line
breaks</strong>.</p>
<p>The extra nodes you are wondering about are just that, text nodes
withthe formatting spaces which are part of the document but that people
tendto forget. There is a function <a
href="http://xmlsoft.org/html/libxml-parser.html">xmlKeepBlanksDefault()</a>to
remove those at parse time, but that's an heuristic, and itsuse should be
limited to cases where you are certain there is nomixed-content in the
document.</p>
</li>
<li><em>I get compilation errors of existing code like when
accessing<strong>root</strong>or <strong>child fields</strong>of
nodes.</em>
<p>You are compiling code developed for libxml version 1 and using
alibxml2 development environment. Either switch back to libxml v1 devel
oreven better fix the code to compile with libxml2 (or both) by <a
href="upgrade.html">following the instructions</a>.</p>
</li>
<li><em>I get compilation errors about non
existing<strong>xmlRootNode</strong>or
<strong>xmlChildrenNode</strong>fields.</em>
<p>The source code you are using has been <a
href="upgrade.html">upgraded</a>to be able to compile with both libxmland
libxml2, but you need to install a more recent version:libxml(-devel)
>= 1.8.8 or libxml2(-devel) >= 2.1.0</p>
</li>
<li><em>XPath implementation looks seriously broken</em>
<p>XPath implementation prior to 2.3.0 was really incomplete. Upgrade toa
recent version, there are no known bugs in the current version.</p>
</li>
<li><em>The example provided in the web page does not compile.</em>
<p>It's hard to maintain the documentation in sync with the
code<grin/> ...</p>
<p>Check the previous points 1/ and 2/ raised before, and please
sendpatches.</p>
</li>
<li><em>Where can I get more examples and information than provided on
theweb page?</em>
<p>Ideally a libxml2 book would be nice. I have no such plan ... But
youcan:</p>
<ul>
<li>check more deeply the <a
href="html/libxml-lib.html">existinggenerated doc</a></li>
<li>have a look at <a href="examples/index.html">the set
ofexamples</a>.</li>
<li>look for examples of use for libxml2 function using the Gnome
code.For example the following will query the full Gnome CVS base for
theuse of the <strong>xmlAddChild()</strong>function:
<p><a
href="http://cvs.gnome.org/lxr/search?string=xmlAddChild">http://cvs.gnome.org/lxr/search?string=xmlAddChild</a></p>
<p>This may be slow, a large hardware donation to the gnome
projectcould cure this :-)</p>
</li>
<li><a
href="http://cvs.gnome.org/bonsai/rview.cgi?cvsroot=/cvs/gnome&dir=gnome-xml">Browsethe
libxml2 source</a>, I try to write code as clean and documentedas
possible, so looking at it may be helpful. In particular the codeof
xmllint.c and of the various testXXX.c test programs shouldprovide
good examples of how to do things with the library.</li>
</ul>
</li>
<li>What about C++ ?
<p>libxml2 is written in pure C in order to allow easy reuse on a
numberof platforms, including embedded systems. I don't intend to convert
toC++.</p>
<p>There is however a C++ wrapper which may fulfill your needs:</p>
<ul>
<li>by Ari Johnson <ari@btigate.com>:
<p>Website: <a
href="http://libxmlplusplus.sourceforge.net/">http://libxmlplusplus.sourceforge.net/</a></p>
<p>Download: <a
href="http://sourceforge.net/project/showfiles.php?group_id=12999">http://sourceforge.net/project/showfiles.php?group_id=12999</a></p>
</li>
<!-- Website is currently unavailable as of 2003-08-02
<li>by Peter Jones <pjones@pmade.org>
<p>Website: <a
href="http://pmade.org/pjones/software/xmlwrapp/">http://pmade.org/pjones/software/xmlwrapp/</a></p>
</li>
-->
</ul>
</li>
<li>How to validate a document a posteriori ?
<p>It is possible to validate documents which had not been validated
atinitial parsing time or documents which have been built from
scratchusing the API. Use the <a
href="http://xmlsoft.org/html/libxml-valid.html#xmlValidateDtd">xmlValidateDtd()</a>function.
It is also possible to simply add a DTD to an existingdocument:</p>
<pre>xmlDocPtr doc; /* your existing document */
xmlDtdPtr dtd = xmlParseDTD(NULL, filename_of_dtd); /* parse the DTD */
dtd->name = xmlStrDup((xmlChar*)"root_name"); /* use the given root */
doc->intSubset = dtd;
if (doc->children == NULL) xmlAddChild((xmlNodePtr)doc, (xmlNodePtr)dtd);
else xmlAddPrevSibling(doc->children, (xmlNodePtr)dtd);
</pre>
</li>
<li>So what is this funky "xmlChar" used all the time?
<p>It is a null terminated sequence of utf-8 characters. And only
utf-8!You need to convert strings encoded in different ways to utf-8
beforepassing them to the API. This can be accomplished with the iconv
libraryfor instance.</p>
</li>
<li>etc ...</li>
</ol>
<p></p>
<h2><a name="Documentat">Developer Menu</a></h2>
<p>There are several on-line resources related to using libxml:</p>
<ol>
<li>Use the <a href="search.php">search engine</a>to look
upinformation.</li>
<li>Check the <a href="FAQ.html">FAQ.</a></li>
<li>Check the <a
href="http://xmlsoft.org/html/libxml-lib.html">extensivedocumentation</a>automatically
extracted from code comments.</li>
<li>Look at the documentation about <a
href="encoding.html">libxmlinternationalization support</a>.</li>
<li>This page provides a global overview and <a
href="example.html">someexamples</a>on how to use libxml.</li>
<li><a href="examples/index.html">Code examples</a></li>
<li>John Fleck's libxml2 tutorial: <a href="tutorial/index.html">html</a>or
<a href="tutorial/xmltutorial.pdf">pdf</a>.</li>
<li>If you need to parse large files, check the <a
href="xmlreader.html">xmlReader</a>API tutorial</li>
<li><a href="mailto:james@daa.com.au">James Henstridge</a>wrote <a
href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">some
nicedocumentation</a>explaining how to use the libxml SAX interface.</li>
<li>George Lebl wrote <a
href="http://www-106.ibm.com/developerworks/library/l-gnome3/">an
articlefor IBM developerWorks</a>about using libxml.</li>
<li>Check <a href="http://cvs.gnome.org/lxr/source/gnome-xml/TODO">the
TODOfile</a>.</li>
<li>Read the <a href="upgrade.html">1.x to 2.x upgrade path</a>description.
If you are starting a new project using libxml you shouldreally use the
2.x version.</li>
<li>And don't forget to look at the <a
href="http://mail.gnome.org/archives/xml/">mailing-list archive</a>.</li>
</ol>
<h2><a name="Reporting">Reporting bugs and getting help</a></h2>
<p>Well, bugs or missing features are always possible, and I will make apoint
of fixing them in a timely fashion. The best way to report a bug is touse the
<a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Gnomebug
tracking database</a>(make sure to use the "libxml2" module name). Ilook at
reports there regularly and it's good to have a reminder when a bugis still
open. Be sure to specify that the bug is for the package libxml2.</p>
<p>For small problems you can try to get help on IRC, the #xml channel
onirc.gnome.org (port 6667) usually have a few person subscribed which may
help(but there is no garantee and if a real issue is raised it should go on
themailing-list for archival).</p>
<p>There is also a mailing-list <a
href="mailto:xml@gnome.org">xml@gnome.org</a>for libxml, with an <a
href="http://mail.gnome.org/archives/xml/">on-line archive</a>(<a
href="http://xmlsoft.org/messages">old</a>). To subscribe to this list,please
visit the <a href="http://mail.gnome.org/mailman/listinfo/xml">associated
Web</a>page andfollow the instructions. <strong>Do not send code, I won't
debug it</strong>(but patches are really appreciated!).</p>
<p>Please note that with the current amount of virus and SPAM, sending mailto
the list without being subscribed won't work. There is *far too manybounces*
(in the order of a thousand a day !) I cannot approve them manuallyanymore.
If your mail to the list bounced waiting for administrator approval,it is
LOST ! Repost it and fix the problem triggering the error. Also pleasenote
that <span style="color: #FF0000; background-color: #FFFFFF">emails witha
legal warning asking to not copy or redistribute freely the informationsthey
contain</span>are <strong>NOT</strong>acceptable for the mailing-list,such
mail will as much as possible be discarded automatically, and are lesslikely
to be answered if they made it to the list, <strong>DO NOT</strong>post to
the list from an email address where such legal requirements areautomatically
added, get private paying support if you can't shareinformations.</p>
<p>Check the following <strong><span
style="color: #FF0000">beforeposting</span></strong>:</p>
<ul>
<li>Read the <a href="FAQ.html">FAQ</a>and <a href="search.php">use
thesearch engine</a>to get information related to your problem.</li>
<li>Make sure you are <a href="ftp://xmlsoft.org/libxml2/">using a
recentversion</a>, and that the problem still shows up in a recent
version.</li>
<li>Check the <a
href="http://mail.gnome.org/archives/xml/">listarchives</a>to see if the
problem was reported already. In this casethere is probably a fix
available, similarly check the <a
href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">registeredopen
bugs</a>.</li>
<li>Make sure you can reproduce the bug with xmllint or one of the
testprograms found in source in the distribution.</li>
<li>Please send the command showing the error as well as the input (as
anattachment)</li>
</ul>
<p>Then send the bug with associated information to reproduce it to the <a
href="mailto:xml@gnome.org">xml@gnome.org</a>list; if it's really
libxmlrelated I will approve it. Please do not send mail to me directly, it
makesthings really hard to track and in some cases I am not the best person
toanswer a given question, ask on the list.</p>
<p>To <span style="color: #E50000">be really clear about support</span>:</p>
<ul>
<li>Support or help <span style="color: #E50000">requests MUST be sent
tothe list or on bugzilla</span>in case of problems, so that the
Questionand Answers can be shared publicly. Failing to do so carries the
implicitmessage "I want free support but I don't want to share the
benefits withothers" and is not welcome. I will automatically Carbon-Copy
thexml@gnome.org mailing list for any technical reply made about libxml2
orlibxslt.</li>
<li>There is <span style="color: #E50000">no garantee of support</span>,
ifyour question remains unanswered after a week, repost it, making sure
yougave all the detail needed and the information requested.</li>
<li>Failing to provide information as requested or double checking firstfor
prior feedback also carries the implicit message "the time of thelibrary
maintainers is less valuable than my time" and might not bewelcome.</li>
</ul>
<p>Of course, bugs reported with a suggested patch for fixing them
willprobably be processed faster than those without.</p>
<p>If you're looking for help, a quick look at <a
href="http://mail.gnome.org/archives/xml/">the list archive</a>may
actuallyprovide the answer. I usually send source samples when answering
libxml2usage questions. The <a
href="http://xmlsoft.org/html/book1.html">auto-generated
documentation</a>isnot as polished as I would like (i need to learn more
about DocBook), butit's a good starting point.</p>
<h2><a name="help">How to help</a></h2>
<p>You can help the project in various ways, the best thing to do first is
tosubscribe to the mailing-list as explained before, check the <a
href="http://mail.gnome.org/archives/xml/">archives </a>and the <a
href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Gnome
bugdatabase</a>:</p>
<ol>
<li>Provide patches when you find problems.</li>
<li>Provide the diffs when you port libxml2 to a new platform. They may
notbe integrated in all cases but help pinpointing portability
problemsand</li>
<li>Provide documentation fixes (either as patches to the code comments
oras HTML diffs).</li>
<li>Provide new documentations pieces (translations, examples, etc...).</li>
<li>Check the TODO file and try to close one of the items.</li>
<li>Take one of the points raised in the archive or the bug database
andprovide a fix. <a href="mailto:daniel@veillard.com">Get in touch with
me</a>before to avoid synchronization problems and check that the
suggestedfix will fit in nicely :-)</li>
</ol>
<h2><a name="Downloads">Downloads</a></h2>
<p>The latest versions of libxml2 can be found on the <a
href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>server ( <a
href="http://xmlsoft.org/sources/">HTTP</a>, <a
href="ftp://xmlsoft.org/libxml2/">FTP</a>and rsync are available), there is
alsomirrors (<a href="ftp://ftp.planetmirror.com/pub/xmlsoft/">Australia</a>(
<a href="http://xmlsoft.planetmirror.com/">Web</a>), <a
href="ftp://fr.rpmfind.net/pub/libxml/">France</a>) or on the <a
href="ftp://ftp.gnome.org/pub/GNOME/MIRRORS.html">Gnome FTP server</a>as <a
href="ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/">source archive</a>,
Antonin Sprinzl also provide <a
href="ftp://gd.tuwien.ac.at/pub/libxml/">amirror in Austria</a>. (NOTE that
you need both the <a
href="http://rpmfind.net/linux/RPM/libxml2.html">libxml(2)</a>and <a
href="http://rpmfind.net/linux/RPM/libxml2-devel.html">libxml(2)-devel</a>packages
installed to compile applications using libxml.)</p>
<p>You can find all the history of libxml(2) and libxslt releases in the <a
href="http://xmlsoft.org/sources/old/">old</a>directory. The
precompiledWindows binaries made by Igor Zlatovic are available in the <a
href="http://xmlsoft.org/sources/win32/">win32</a>directory.</p>
<p>Binary ports:</p>
<ul>
<li>Red Hat RPMs for i386 are available directly on <a
href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>, the source RPM will
compile onany architecture supported by Red Hat.</li>
<li><a href="mailto:igor@zlatkovic.com">Igor Zlatkovic</a>is now
themaintainer of the Windows port, <a
href="http://www.zlatkovic.com/projects/libxml/index.html">he
providesbinaries</a>.</li>
<li>Blastwave provides <a
href="http://www.blastwave.org/packages.php/libxml2">Solarisbinaries</a>.</li>
<li><a href="mailto:Steve.Ball@explain.com.au">Steve Ball</a>provides <a
href="http://www.explain.com.au/oss/libxml2xslt.html">Mac Os
Xbinaries</a>.</li>
<li>The HP-UX porting center provides <a
href="http://hpux.connect.org.uk/hppd/hpux/Gnome/">HP-UX binaries</a></li>
<li>Bull provides precompiled <a
href="http://gnome.bullfreeware.com/new_index.html">RPMs for
AIX</a>aspatr of their GNOME packages</li>
</ul>
<p>If you know other supported binary ports, please <a
href="http://veillard.com/">contact me</a>.</p>
<p><a name="Snapshot">Snapshot:</a></p>
<ul>
<li>Code from the W3C cvs base libxml2 module, updated hourly <a
href="ftp://xmlsoft.org/libxml2/libxml2-cvs-snapshot.tar.gz">libxml2-cvs-snapshot.tar.gz</a>.</li>
<li>Docs, content of the web site, the list archive included <a
href="ftp://xmlsoft.org/libxml2/libxml-docs.tar.gz">libxml-docs.tar.gz</a>.</li>
</ul>
<p><a name="Contribs">Contributions:</a></p>
<p>I do accept external contributions, especially if compiling on
anotherplatform, get in touch with the list to upload the package, wrappers
forvarious languages have been provided, and can be found in the <a
href="python.html">bindings section</a></p>
<p>Libxml2 is also available from CVS:</p>
<ul>
<li><p>The <a href="http://cvs.gnome.org/viewcvs/libxml2/">Gnome
CVSbase</a>. Check the <a
href="http://developer.gnome.org/tools/cvs.html">Gnome CVS Tools</a>page;
the CVS module is <b>libxml2</b>.</p>
</li>
<li>The <strong>libxslt</strong>module is also present there</li>
</ul>
<h2><a name="News">Releases</a></h2>
<p>Items not finished and worked on, get in touch with the list if you wantto
help those</p>
<ul>
<li>More testing on RelaxNG</li>
<li>Finishing up <a
href="http://www.w3.org/TR/xmlschema-1/">XMLSchemas</a></li>
</ul>
<p>The <a href="ChangeLog.html">change log</a>describes the recents commitsto
the <a href="http://cvs.gnome.org/viewcvs/libxml2/">CVS</a>code base.</p>
<p>There is the list of public releases:</p>
<h3>2.6.25: Jun 6 2006</h3>
<ul>
<li>portability fixes: Python detection (Joseph Sacco), compilation error
(William Brack and Graham Bennett), LynxOS patch (Olli Savia)</li>
<li>bug fixes: encoding buffer problem, mix of code and data in xmlIO.c
(Kjartan Maraas), entities in XSD validation (Kasimier Buchcik), various
XSD validation fixes (Kasimier), memory leak in pattern (Rob Richards and
Kasimier), attribute with colon in name (Rob Richards), XPath leak in
error reporting (Aleksey Sanin), XInclude text include of self
document.</li>
<li>improvements: Xpath optimizations (Kasimier), XPath object cache
(Kasimier), </li>
</ul>
<h3>2.6.24: Apr 28 2006</h3>
<ul>
<li>Portability fixes: configure on Windows, testapi compile on
windows(Kasimier Buchcik, venkat naidu), Borland C++ 6 compile (Eric
Zurcher),HP-UX compiler workaround (Rick Jones), xml2-config bugfix,
gcc-4.1cleanups, Python detection scheme (Joseph Sacco), UTF-8 file paths
onWindows (Roland Schwingel).</li>
<li>Improvements: xmlDOMWrapReconcileNamespaces xmlDOMWrapCloneNode
(KasimierBuchcik), XML catalog debugging (Rick Jones), update to Unicode
4.01.</li>
<li>Bug fixes: xmlParseChunk() problem in 2.6.23, xmlParseInNodeContext()on
HTML docs, URI behaviour on Windows (Rob Richards), comment streamingbug,
xmlParseComment (with William Brack), regexp bug fixes (DV &Youri
Golovanov), xmlGetNodePath on text/CDATA (Kasimier),one Relax-NG
interleave bug, xmllint --path and --valid,XSD bugfixes (Kasimier),
remove debugleft in Python bindings (Nic Ferrier), xmlCatalogAdd bug
(Martin Cole),xmlSetProp fixes (Rob Richards), HTML IDness (Rob
Richards), a largenumber of cleanups and small fixes based on Coverity
reports, bugin character ranges, Unicode tables const (Aivars Kalvans),
schemasfix (Stefan Kost), xmlRelaxNGParse error
deallocation,xmlSchemaAddSchemaDoc error deallocation, error handling on
unallowedcode point, ixmllint --nonet to never reach the net (Gary
Coady),line break in writer after end PI (Jason Viers).</li>
<li>Documentation: man pages updates and cleanups (Daniel Leidert).</li>
<li>New features: Relax NG structure error handlers.</li>
</ul>
<h3>2.6.23: Jan 5 2006</h3>
<ul>
<li>portability fixes: Windows (Rob Richards), getaddrinfo on Windows(Kolja
Nowak, Rob Richards), icc warnings (Kjartan Maraas),--with-minimum
compilation fixes (William Brack), error case handling fixon Solaris
(Albert Chin), don't use 'list' as parameter name reported bySamuel Diaz
Garcia, more old Unices portability fixes (Albert Chin),MinGW compilation
(Mark Junker), HP-UX compiler warnings (RickJones),</li>
<li>code cleanup: xmlReportError (Adrian Mouat), remove
xmlBufferClose(Geert Jansen), unreachable code (Oleksandr Kononenko),
refactoringparsing code (Bjorn Reese)</li>
<li>bug fixes: xmlBuildRelativeURI and empty path (William
Brack),combinatory explosion and performances in regexp code, leak
inxmlTextReaderReadString(), xmlStringLenDecodeEntities problem
(MassimoMorara), Identity Constraints bugs and a segfault (Kasimier
Buchcik),XPath pattern based evaluation bugs (DV &
Kasimier),xmlSchemaContentModelDump() memory leak (Kasimier), potential
leak inxmlSchemaCheckCSelectorXPath(), xmlTextWriterVSprintf() misuse
ofvsnprintf (William Brack), XHTML serialization fix (Rob Richards),
CRLFsplit problem (William), issues with non-namespaced attributes
inxmlAddChild() xmlAddNextSibling() and xmlAddPrevSibling() (Rob
Richards),HTML parsing of script, Python must not output to stdout (Nic
Ferrier),exclusive C14N namespace visibility (Aleksey Sanin), XSD
dataypetotalDigits bug (Kasimier Buchcik), error handling when writing to
anxmlBuffer (Rob Richards), runtest schemas error not reported
(HisashiFujinaka), signed/unsigned problem in date/time code (Albert
Chin), fixXSI driven XSD validation (Kasimier), parsing of xs:decimal
(Kasimier),fix DTD writer output (Rob Richards), leak in
xmlTextReaderReadInnerXml(Gary Coady), regexp bug affecting schemas
(Kasimier), configuration ofruntime debugging (Kasimier),
xmlNodeBufGetContent bug on entity refs(Oleksandr Kononenko),
xmlRegExecPushString2 bug (Sreeni Nair),compilation and build fixes
(Michael Day), removed dependancies onxmlSchemaValidError (Kasimier), bug
with <xml:foo/>, more XPathpattern based evaluation fixes
(Kasimier)</li>
<li>improvements: XSD Schemas redefinitions/restrictions (KasimierBuchcik),
node copy checks and fix for attribute (Rob Richards), countedtransition
bug in regexps, ctxt->standalone = -2 to indicate nostandalone
attribute was found, add xmlSchemaSetParserStructuredErrors()(Kasimier
Buchcik), add xmlTextReaderSchemaValidateCtxt() to API(Kasimier), handle
gzipped HTTP resources (Gary Coady), addhtmlDocDumpMemoryFormat. (Rob
Richards),</li>
<li>documentation: typo (Michael Day), libxml man page (Albert Chin),
savefunction to XML buffer (Geert Jansen), small doc fix (Aron
Stansvik),</li>
</ul>
<h3>2.6.22: Sep 12 2005</h3>
<ul>
<li>build fixes: compile without schematron (Stéphane Bidoul)</li>
<li>bug fixes: xmlDebugDumpNode on namespace node (Oleg Paraschenko)i,CDATA
push parser bug, xmlElemDump problem with XHTML1 doc,XML_FEATURE_xxx
clash with expat headers renamed XML_WITH_xxx, fix someoutput formatting
for meta element (Rob Richards), script and styleXHTML1 serialization
(David Madore), Attribute derivation fixups in XSD(Kasimier Buchcik),
better IDC error reports (Kasimier Buchcik)</li>
<li>improvements: add XML_SAVE_NO_EMPTY xmlSaveOption (Rob Richards),
addXML_SAVE_NO_XHTML xmlSaveOption, XML Schemas improvements preparing
forderive (Kasimier Buchcik).</li>
<li>documentation: generation of gtk-doc like docs, integration
withdevhelp.</li>
</ul>
<h3>2.6.21: Sep 4 2005</h3>
<ul>
<li>build fixes: Cygwin portability fixes (Gerrit P. Haase),
callingconvention problems on Windows (Marcus Boerger), cleanups based on
Linus'sparse tool, update of win32/configure.js (Rob Richards), remove
warningson Windows(Marcus Boerger), compilation without SAX1, detection
of thePython binary, use $GCC inestad of $CC = 'gcc' (Andrew W.
Nosenko),compilation/link with threads and old gcc, compile problem by
C370 onZ/OS,</li>
<li>bug fixes: http_proxy environments (Peter Breitenlohner), HTML UTF-8bug
(Jiri Netolicky), XPath NaN compare bug (William Brack),htmlParseScript
potential bug, Schemas regexp handling of spaces, Base64Schemas
comparisons NIST passes, automata build error xsd:all,xmlGetNodePath for
namespaced attributes (Alexander Pohoyda), xmlSchemasforeign namespaces
handling, XML Schemas facet comparison (KupriyanovAnatolij),
xmlSchemaPSimpleTypeErr error report (Kasimier Buchcik), xml:namespace
ahndling in Schemas (Kasimier), empty model group in Schemas(Kasimier),
wilcard in Schemas (Kasimier), URI composition (William),xs:anyType in
Schemas (Kasimier), Python resolver emmitting errormessages directly,
Python xmlAttr.parent (Jakub Piotr Clapa), trying tofix the file path/URI
conversion, xmlTextReaderGetAttribute fix (RobRichards),
xmlSchemaFreeAnnot memleak (Kasimier), HTML UTF-8serialization, streaming
XPath, Schemas determinism detection problem,XInclude bug, Schemas
context type (Dean Hill), validation fix (DerekPoon),
xmlTextReaderGetAttribute[Ns] namespaces (Rob Richards), Schemastype fix
(Kuba Nowakowski), UTF-8 parser bug, error in encoding
handling,xmlGetLineNo fixes, bug on entities handling, entity name
extraction inerror handling with XInclude, text nodes in HTML body tags
(Gary Coady),xml:id and IDness at the treee level fixes, XPath streaming
patternsbugs.</li>
<li>improvements: structured interfaces for schemas and RNG error
reports(Marcus Boerger), optimization of the char data inner loop
parsing(thanks to Behdad Esfahbod for the idea), schematron validation
thoughnot finished yet, xmlSaveOption to omit XML declaration, keyref
matcherror reports (Kasimier), formal expression handling code not
pluggedyet, more lax mode for the HTML parser, parser XML_PARSE_COMPACT
optionfor text nodes allocation.</li>
<li>documentation: xmllint man page had --nonet duplicated</li>
</ul>
<h3>2.6.20: Jul 10 2005</h3>
<ul>
<li>build fixes: Windows build (Rob Richards), Mingw compilation
(IgorZlatkovic), Windows Makefile (Igor), gcc warnings (Kasimier
andandriy@google.com), use gcc weak references to pthread to avoid
thepthread dependancy on Linux, compilation problem (Steve Nairn),
compilingof subset (Morten Welinder), IPv6/ss_family compilation (William
Brack),compilation when disabling parts of the library, standalone
testdistribution.</li>
<li>bug fixes: bug in lang(), memory cleanup on errors (William Brack),HTTP
query strings (Aron Stansvik), memory leak in DTD (William),
integeroverflow in XPath (William), nanoftp buffer size, pattern "." apth
fixup(Kasimier), leak in tree reported by Malcolm Rowe, replaceNode
patch(Brent Hendricks), CDATA with NULL content (Mark Vakoc), xml:base
fixupon XInclude (William), pattern fixes (William), attribute bug
inexclusive c14n (Aleksey Sanin), xml:space and xml:lang with SAX2
(RobRichards), namespace trouble in complex parsing (Malcolm Rowe), XSD
typeQNames fixes (Kasimier), XPath streaming fixups (William), RelaxNG
bug(Rob Richards), Schemas for Schemas fixes (Kasimier), removal of ID
(RobRichards), a small RelaxNG leak, HTML parsing in push mode bug
(JamesBursa), failure to detect UTF-8 parsing bugs in CDATA
sections,areBlanks() heuristic failure, duplicate attributes in DTD
bug(William).</li>
<li>improvements: lot of work on Schemas by Kasimier Buchcik both
onconformance and streaming, Schemas validation messages (Kasimier
Buchcik,Matthew Burgess), namespace removal at the python level
(BrentHendricks), Update to new Schemas regression tests from
W3C/Nist(Kasimier), xmlSchemaValidateFile() (Kasimier), implementation
ofxmlTextReaderReadInnerXml and xmlTextReaderReadOuterXml (James
Wert),standalone test framework and programs, new DOM import
APIsxmlDOMWrapReconcileNamespaces() xmlDOMWrapAdoptNode()
andxmlDOMWrapRemoveNode(), extension of xmllint capabilities for SAX
andSchemas regression tests, xmlStopParser() available in pull mode
too,ienhancement to xmllint --shell namespaces support, Windows port of
thestandalone testing tools (Kasimier and
William),xmlSchemaValidateStream() xmlSchemaSAXPlug() and
xmlSchemaSAXUnplug() SAXSchemas APIs, Schemas xmlReader support.</li>
</ul>
<h3>2.6.19: Apr 02 2005</h3>
<ul>
<li>build fixes: drop .la from RPMs, --with-minimum build fix
(WilliamBrack), use XML_SOCKLEN_T instead of SOCKLEN_T because it breaks
with AIX5.3 compiler, fixed elfgcchack.h generation and PLT reduction
code onLinux/ELF/gcc4</li>
<li>bug fixes: schemas type decimal fixups (William Brack), xmmlint
returncode (Gerry Murphy), small schemas fixes (Matthew Burgess and
GUYFabrice), workaround "DAV:" namespace brokeness in c14n (Aleksey
Sanin),segfault in Schemas (Kasimier Buchcik), Schemas attribute
validation(Kasimier), Prop related functions and xmlNewNodeEatName (Rob
Richards),HTML serialization of name attribute on a elements, Python
error handlersleaks and improvement (Brent Hendricks), uninitialized
variable inencoding code, Relax-NG validation bug, potential crash
ifgnorableWhitespace is NULL, xmlSAXParseDoc and xmlParseDoc
signatures,switched back to assuming UTF-8 in case no encoding is given
atserialization time</li>
<li>improvements: lot of work on Schemas by Kasimier Buchcik on
facetschecking and also mixed handling.</li>
<li></li>
</ul>
<h3>2.6.18: Mar 13 2005</h3>
<ul>
<li>build fixes: warnings (Peter Breitenlohner), testapi.c
generation,Bakefile support (Francesco Montorsi), Windows compilation
(Joel Reed),some gcc4 fixes, HP-UX portability fixes (Rick Jones).</li>
<li>bug fixes: xmlSchemaElementDump namespace (Kasimier Buchcik), push
andxmlreader stopping on non-fatal errors, thread support for
dictionnariesreference counting (Gary Coady), internal subset and push
problem, URLsaved in xmlCopyDoc, various schemas bug fixes (Kasimier),
Python pathsfixup (Stephane Bidoul), xmlGetNodePath and namespaces,
xmlSetNsProp fix(Mike Hommey), warning should not count as error (William
Brack),xmlCreatePushParser empty chunk, XInclude parser flags (William),
cleanupFTP and HTTP code to reuse the uri parsing and IPv6
(William),xmlTextWriterStartAttributeNS fix (Rob Richards),
XMLLINT_INDENT beingempty (William), xmlWriter bugs (Rob Richards),
multithreading on Windows(Rich Salz), xmlSearchNsByHref fix (Kasimier),
Python binding leak (BrentHendricks), aliasing bug exposed by gcc4 on
s390, xmlTextReaderNext bug(Rob Richards), Schemas decimal type fixes
(William Brack),xmlByteConsumed static buffer (Ben Maurer).</li>
<li>improvement: speedup parsing comments and DTDs, dictionnary support
forhash tables, Schemas Identity constraints (Kasimier), streaming
XPathsubset, xmlTextReaderReadString added (Bjorn Reese), Schemas
canonicalvalues handling (Kasimier), add xmlTextReaderByteConsumed
(AronStansvik),</li>
<li>Documentation: Wiki support (Joel Reed)</li>
</ul>
<h3>2.6.17: Jan 16 2005</h3>
<ul>
<li>build fixes: Windows, warnings removal (William Brack),maintainer-clean
dependency(William), build in a different directory(William), fixing
--with-minimum configure build (William), BeOS build(Marcin Konicki),
Python-2.4 detection (William), compilation on AIX (DanMcNichol)</li>
<li>bug fixes: xmlTextReaderHasAttributes (Rob Richards),
xmlCtxtReadFile()to use the catalog(s), loop on output (William Brack),
XPath memory leak,ID deallocation problem (Steve Shepard), debugDumpNode
crash (William),warning not using error callback (William), xmlStopParser
bug (William),UTF-16 with BOM on DTDs (William), namespace bug on empty
elements inpush mode (Rob Richards), line and col computations fixups
(AlekseySanin), xmlURIEscape fix (William), xmlXPathErr on bad range
(William),patterns with too many steps, bug in RNG choice optimization,
line numbersometimes missing.</li>
<li>improvements: XSD Schemas (Kasimier Buchcik), python
generator(William), xmlUTF8Strpos speedup (William), unicode Python
strings(William), XSD error reports (Kasimier Buchcik), Python __str__
callserialize().</li>
<li>new APIs: added xmlDictExists(), GetLineNumber and GetColumnNumber
forthe xmlReader (Aleksey Sanin), Dynamic Shared Libraries APIs (mostly
JoelReed), error extraction API from regexps, new XMLSave option for
format(Phil Shafer)</li>
<li>documentation: site improvement (John Fleck), FAQ entries(William).</li>
</ul>
<h3>2.6.16: Nov 10 2004</h3>
<ul>
<li>general hardening and bug fixing crossing all the API based on
newautomated regression testing</li>
<li>build fix: IPv6 build and test on AIX (Dodji Seketeli)</li>
<li>bug fixes: problem with XML::Libxml reported by Petr Pajas,
encodingconversion functions return values, UTF-8 bug affecting XPath
reported byMarkus Bertheau, catalog problem with NULL entries (William
Brack)</li>
<li>documentation: fix to xmllint man page, some API function
descritpionwere updated.</li>
<li>improvements: DTD validation APIs provided at the Python level
(BrentHendricks)</li>
</ul>
<h3>2.6.15: Oct 27 2004</h3>
<ul>
<li>security fixes on the nanoftp and nanohttp modules</li>
<li>build fixes: xmllint detection bug in configure, building outside
thesource tree (Thomas Fitzsimmons)</li>
<li>bug fixes: HTML parser on broken ASCII chars in names (William),
Pythonpaths (Malcolm Tredinnick), xmlHasNsProp and default namespace
(William),saving to python file objects (Malcolm Tredinnick), DTD lookup
fix(Malcolm), save back <group> in catalogs (William), tree
buildfixes (DV and Rob Richards), Schemas memory bug, structured error
handleron Python 64bits, thread local memory deallocation, memory leak
reportedby Volker Roth, xmlValidateDtd in the presence of an internal
subset,entities and _private problem (William), xmlBuildRelativeURI
error(William).</li>
<li>improvements: better XInclude error reports (William), tree
debuggingmodule and tests, convenience functions at the Reader API
(GrahamBennett), add support for PI in the HTML parser.</li>
</ul>
<h3>2.6.14: Sep 29 2004</h3>
<ul>
<li>build fixes: configure paths for xmllint and xsltproc,
compilationwithout HTML parser, compilation warning cleanups (William
Brack &Malcolm Tredinnick), VMS makefile update (Craig Berry),</li>
<li>bug fixes: xmlGetUTF8Char (William Brack), QName properties
(KasimierBuchcik), XInclude testing, Notation serialization,
UTF8ToISO8859xtranscoding (Mark Itzcovitz), lots of XML Schemas cleanup
and fixes(Kasimier), ChangeLog cleanup (Stepan Kasal), memory fixes (Mark
Vakoc),handling of failed realloc(), out of bound array adressing in
Schemasdate handling, Python space/tabs cleanups (Malcolm Tredinnick),
NMTOKENSE20 validation fix (Malcolm),</li>
<li>improvements: added W3C XML Schemas testsuite (Kasimier Buchcik),
addxmlSchemaValidateOneElement (Kasimier), Python exception
hierearchy(Malcolm Tredinnick), Python libxml2 driver improvement
(MalcolmTredinnick), Schemas support for
xsi:schemaLocation,xsi:noNamespaceSchemaLocation, xsi:type (Kasimier
Buchcik)</li>
</ul>
<h3>2.6.13: Aug 31 2004</h3>
<ul>
<li>build fixes: Windows and zlib (Igor Zlatkovic), -O flag with
gcc,Solaris compiler warning, fixing RPM BuildRequires,</li>
<li>fixes: DTD loading on Windows (Igor), Schemas error reports
APIs(Kasimier Buchcik), Schemas validation crash, xmlCheckUTF8 (William
Brackand Julius Mittenzwei), Schemas facet check (Kasimier), default
namespaceproblem (William), Schemas hexbinary empty values, encoding
error couldgenrate a serialization loop.</li>
<li>Improvements: Schemas validity improvements (Kasimier), added --pathand
--load-trace options to xmllint</li>
<li>documentation: tutorial update (John Fleck)</li>
</ul>
<h3>2.6.12: Aug 22 2004</h3>
<ul>
<li>build fixes: fix --with-minimum, elfgcchack.h fixes
(PeterBreitenlohner), perl path lookup (William), diff on Solaris
(AlbertChin), some 64bits cleanups.</li>
<li>Python: avoid a warning with 2.3 (William Brack), tab and space
mixes(William), wrapper generator fixes (William), Cygwin support (Gerrit
P.Haase), node wrapper fix (Marc-Antoine Parent), XML Schemas
support(Torkel Lyng)</li>
<li>Schemas: a lot of bug fixes and improvements from Kasimier Buchcik</li>
<li>fixes: RVT fixes (William), XPath context resets bug (William),
memorydebug (Steve Hay), catalog white space handling (Peter
Breitenlohner),xmlReader state after attribute reading (William),
structured errorhandler (William), XInclude generated xml:base fixup
(William), Windowsmemory reallocation problem (Steve Hay), Out of Memory
conditionshandling (William and Olivier Andrieu), htmlNewDoc() charset
bug,htmlReadMemory init (William), a posteriori validation DTD
base(William), notations serialization missing, xmlGetNodePath
(Dodji),xmlCheckUTF8 (Diego Tartara), missing line numbers on
entity(William)</li>
<li>improvements: DocBook catalog build scrip (William), xmlcatalog
tool(Albert Chin), xmllint --c14n option, no_proxy environment (Mike
Hommey),xmlParseInNodeContext() addition, extend xmllint --shell, allow
XIncludeto not generate start/end nodes, extend xmllint --version to
include CVStag (William)</li>
<li>documentation: web pages fixes, validity API docs fixes
(William)schemas API fix (Eric Haszlakiewicz), xmllint man page (John
Fleck)</li>
</ul>
<h3>2.6.11: July 5 2004</h3>
<ul>
<li>Schemas: a lot of changes and improvements by Kasimier Buchcik
forattributes, namespaces and simple types.</li>
<li>build fixes: --with-minimum (William Brack), some gcc
cleanup(William), --with-thread-alloc (William)</li>
<li>portability: Windows binary package change (Igor Zlatkovic),
Catalogpath on Windows</li>
<li>documentation: update to the tutorial (John Fleck), xmllint return
code(John Fleck), man pages (Ville Skytta),</li>
<li>bug fixes: C14N bug serializing namespaces (Aleksey Sanin),
testSAXproperly initialize the library (William), empty node set in
XPath(William), xmlSchemas errors (William), invalid charref problem
pointedby Morus Walter, XInclude xml:base generation (William), Relax-NG
bugwith div processing (William), XPointer and xml:base
problem(William),Reader and entities, xmllint return code for schemas
(William), readerstreaming problem (Steve Ball), DTD serialization
problem (William),libxml.m4 fixes (Mike Hommey), do not provide
destructors as methods onPython classes, xmlReader buffer bug, Python
bindings memory interfacesimprovement (with Stéphane Bidoul), Fixed the
push parser to be back tosynchronous behaviour.</li>
<li>improvement: custom per-thread I/O enhancement (Rob Richards),
registernamespace in debug shell (Stefano Debenedetti), Python based
regressiontest for non-Unix users (William), dynamically increase the
number ofXPath extension functions in Python and fix a memory leak
(Marc-AntoineParent and William)</li>
<li>performance: hack done with Arjan van de Ven to reduce ELF footprintand
generated code on Linux, plus use gcc runtime profiling to optimizethe
code generated in the RPM packages.</li>
</ul>
<h3>2.6.10: May 17 2004</h3>
<ul>
<li>Web page generated for ChangeLog</li>
<li>build fixes: --without-html problems, make check without make all</li>
<li>portability: problem with xpath.c on Windows (MSC and Borland),
memcmpvs. strncmp on Solaris, XPath tests on Windows (Mark Vakoc), C++ do
notuse "list" as parameter name, make tests work with Python 1.5
(EdDavis),</li>
<li>improvements: made xmlTextReaderMode public, small buffers
resizing(Morten Welinder), add --maxmem option to xmllint,
addxmlPopInputCallback() for Matt Sergeant, refactoring of
serializationescaping, added escaping customization</li>
<li>bugfixes: xsd:extension (Taihei Goi), assorted regexp bugs
(WilliamBrack), xmlReader end of stream problem, node deregistration with
reader,URI escaping and filemanes, XHTML1 formatting (Nick Wellnhofer),
regexptransition reduction (William), various XSD Schemas fixes
(KasimierBuchcik), XInclude fallback problem (William), weird problems
with DTD(William), structured error handler callback context (William),
reversexmlEncodeSpecialChars() behaviour back to escaping '"'</li>
</ul>
<h3>2.6.9: Apr 18 2004</h3>
<ul>
<li>implement xml:id Working Draft, relaxed XPath id() checking</li>
<li>bugfixes: xmlCtxtReset (Brent Hendricks), line number and CDATA
(DaveBeckett), Relax-NG compilation (William Brack), Regexp patches
(withWilliam), xmlUriEscape (Mark Vakoc), a Relax-NG notAllowed problem
(withWilliam), Relax-NG name classes compares (William), XInclude
duplicatefallback (William), external DTD encoding detection (William), a
DTDvalidation bug (William), xmlReader Close() fix, recusive
extentionschemas</li>
<li>improvements: use xmlRead* APIs in test tools (Mark Vakoc),
indentingsave optimization, better handle IIS broken HTTP redirect
behaviour (IanHummel), HTML parser frameset (James Bursa), libxml2-python
RPMdependancy, XML Schemas union support (Kasimier Buchcik), warning
removalclanup (William), keep ChangeLog compressed when installing from
RPMs</li>
<li>documentation: examples and xmlDocDumpMemory docs (John Fleck),
newexample (load, xpath, modify, save), xmlCatalogDump() comments,</li>
<li>Windows: Borland C++ builder (Eric Zurcher), work around
Microsoftcompiler NaN handling bug (Mark Vakoc)</li>
</ul>
<h3>2.6.8: Mar 23 2004</h3>
<ul>
<li>First step of the cleanup of the serialization code and APIs</li>
<li>XML Schemas: mixed content (Adam Dickmeiss), QName handling fixes
(AdamDickmeiss), anyURI for "" (John Belmonte)</li>
<li>Python: Canonicalization C14N support added (Anthony Carrico)</li>
<li>xmlDocCopyNode() extension (William)</li>
<li>Relax-NG: fix when processing XInclude results (William),
externalreference in interleave (William), missing error on
<choice>failure (William), memory leak in schemas datatype
facets.</li>
<li>xmlWriter: patch for better DTD support (Alfred Mickautsch)</li>
<li>bug fixes: xmlXPathLangFunction memory leak (Mike Hommey and
WilliamBrack), no ID errors if using HTML_PARSE_NOERROR, xmlcatalog
fallbacks toURI on SYSTEM lookup failure, XInclude parse flags
inheritance (William),XInclude and XPointer fixes for entities (William),
XML parser bugreported by Holger Rauch, nanohttp fd leak (William),
regexps chargroups '-' handling (William), dictionnary reference counting
problems,do not close stderr.</li>
<li>performance patches from Petr Pajas</li>
<li>Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey)</li>
<li>compilation and portability fixes: --without-valid, catalog
cleanups(Peter Breitenlohner), MingW patch (Roland Schwingel),
cross-compilationto Windows (Christophe de Vienne), --with-html-dir
fixup (Julio MerinoVidal), Windows build (Eric Zurcher)</li>
</ul>
<h3>2.6.7: Feb 23 2004</h3>
<ul>
<li>documentation: tutorial updates (John Fleck), benchmark results</li>
<li>xmlWriter: updates and fixes (Alfred Mickautsch, Lucas Brasilino)</li>
<li>XPath optimization (Petr Pajas)</li>
<li>DTD ID handling optimization</li>
<li>bugfixes: xpath number with > 19 fractional (William Brack),
pushmode with unescaped '>' characters, fix xmllint --stream --timing,
fixxmllint --memory --stream memory usage,
xmlAttrSerializeTxtContenthandling NULL, trying to fix Relax-NG/Perl
interface.</li>
<li>python: 2.3 compatibility, whitespace fixes (Malcolm Tredinnick)</li>
<li>Added relaxng option to xmllint --shell</li>
</ul>
<h3>2.6.6: Feb 12 2004</h3>
<ul>
<li>nanohttp and nanoftp: buffer overflow error on URI parsing (Igor
andWilliam) reported by Yuuichi Teranishi</li>
<li>bugfixes: make test and path issues, xmlWriter attribute
serialization(William Brack), xmlWriter indentation (William), schemas
validation(Eric Haszlakiewicz), XInclude dictionnaries issues (William
and OlegParaschenko), XInclude empty fallback (William), HTML warnings
(William),XPointer in XInclude (William), Python namespace
serialization,isolat1ToUTF8 bound error (Alfred Mickautsch), output of
parameterentities in internal subset (William), internal subset bug in
push mode,<xs:all> fix (Alexey Sarytchev)</li>
<li>Build: fix for automake-1.8 (Alexander Winston), warnings
removal(Philip Ludlam), SOCKLEN_T detection fixes (Daniel Richard),
fix--with-minimum configuration.</li>
<li>XInclude: allow the 2001 namespace without warning.</li>
<li>Documentation: missing example/index.html (John Fleck),
versiondependancies (John Fleck)</li>
<li>reader API: structured error reporting (Steve Ball)</li>
<li>Windows compilation: mingw, msys (Mikhail Grushinskiy),
functionprototype (Cameron Johnson), MSVC6 compiler warnings,
_WINSOCKAPI_patch</li>
<li>Parsers: added xmlByteConsumed(ctxt) API to get the byte offest
ininput.</li>
</ul>
<h3>2.6.5: Jan 25 2004</h3>
<ul>
<li>Bugfixes: dictionnaries for schemas (William Brack), regexp
segfault(William), xs:all problem (William), a number of XPointer
bugfixes(William), xmllint error go to stderr, DTD validation problem
withnamespace, memory leak (William), SAX1 cleanup and minimal options
fixes(Mark Vadoc), parser context reset on error (Shaun McCance), XPath
unionevaluation problem (William) , xmlReallocLoc with NULL (Aleksey
Sanin),XML Schemas double free (Steve Ball), XInclude with no href,
argumentcallbacks order for XPath callbacks (Frederic Peters)</li>
<li>Documentation: python scripts (William Brack), xslt stylesheets
(JohnFleck), doc (Sven Zimmerman), I/O example.</li>
<li>Python bindings: fixes (William), enum support (Stéphane
Bidoul),structured error reporting (Stéphane Bidoul)</li>
<li>XInclude: various fixes for conformance, problem related to
dictionnaryreferences (William & me), recursion (William)</li>
<li>xmlWriter: indentation (Lucas Brasilino), memory leaks
(AlfredMickautsch),</li>
<li>xmlSchemas: normalizedString datatype (John Belmonte)</li>
<li>code cleanup for strings functions (William)</li>
<li>Windows: compiler patches (Mark Vakoc)</li>
<li>Parser optimizations, a few new XPath and dictionnary APIs for
futureXSLT optimizations.</li>
</ul>
<h3>2.6.4: Dec 24 2003</h3>
<ul>
<li>Windows build fixes (Igor Zlatkovic)</li>
<li>Some serious XInclude problems reported by Oleg Paraschenko and</li>
<li>Unix and Makefile packaging fixes (me, William Brack,</li>
<li>Documentation improvements (John Fleck, William Brack), example
fix(Lucas Brasilino)</li>
<li>bugfixes: xmlTextReaderExpand() with xmlReaderWalker, XPath handling
ofNULL strings (William Brack) , API building reader or parser
fromfiledescriptor should not close it, changed XPath sorting to be
stableagain (William Brack), xmlGetNodePath() generating '(null)'
(WilliamBrack), DTD validation and namespace bug (William Brack), XML
Schemasdouble inclusion behaviour</li>
</ul>
<h3>2.6.3: Dec 10 2003</h3>
<ul>
<li>documentation updates and cleanup (DV, William Brack, John Fleck)</li>
<li>added a repository of examples, examples from Aleksey Sanin,
DodjiSeketeli, Alfred Mickautsch</li>
<li>Windows updates: Mark Vakoc, Igor Zlatkovic, Eric Zurcher,
Mingw(Kenneth Haley)</li>
<li>Unicode range checking (William Brack)</li>
<li>code cleanup (William Brack)</li>
<li>Python bindings: doc (John Fleck), bug fixes</li>
<li>UTF-16 cleanup and BOM issues (William Brack)</li>
<li>bug fixes: ID and xmlReader validation, XPath (William Brack),xmlWriter
(Alfred Mickautsch), hash.h inclusion problem, HTML parser(James Bursa),
attribute defaulting and validation, some serializationcleanups,
XML_GET_LINE macro, memory debug when using threads (WilliamBrack),
serialization of attributes and entities content, xmlWriter(Daniel
Schulman)</li>
<li>XInclude bugfix, new APIs and update to the last version including
thenamespace change.</li>
<li>XML Schemas improvements: include (Robert Stepanek), import
andnamespace handling, fixed the regression tests troubles, added
examplesbased on Eric van der Vlist book, regexp fixes</li>
<li>preliminary pattern support for streaming (needed for
schemasconstraints), added xmlTextReaderPreservePattern() to collect
subdocumentwhen streaming.</li>
<li>various fixes in the structured error handling</li>
</ul>
<h3>2.6.2: Nov 4 2003</h3>
<ul>
<li>XPath context unregistration fixes</li>
<li>text node coalescing fixes (Mark Lilback)</li>
<li>API to screate a W3C Schemas from an existing document (Steve Ball)</li>
<li>BeOS patches (Marcin 'Shard' Konicki)</li>
<li>xmlStrVPrintf function added (Aleksey Sanin)</li>
<li>compilation fixes (Mark Vakoc)</li>
<li>stdin parsing fix (William Brack)</li>
<li>a posteriori DTD validation fixes</li>
<li>xmlReader bug fixes: Walker fixes, python bindings</li>
<li>fixed xmlStopParser() to really stop the parser and errors</li>
<li>always generate line numbers when using the new xmlReadxxxfunctions</li>
<li>added XInclude support to the xmlReader interface</li>
<li>implemented XML_PARSE_NONET parser option</li>
<li>DocBook XSLT processing bug fixed</li>
<li>HTML serialization for <p> elements (William Brack and me)</li>
<li>XPointer failure in XInclude are now handled as resource errors</li>
<li>fixed xmllint --html to use the HTML serializer on output
(added--xmlout to implement the previous behaviour of saving it using the
XMLserializer)</li>
</ul>
<h3>2.6.1: Oct 28 2003</h3>
<ul>
<li>Mostly bugfixes after the big 2.6.0 changes</li>
<li>Unix compilation patches: libxml.m4 (Patrick Welche), warnings
cleanup(William Brack)</li>
<li>Windows compilation patches (Joachim Bauch, Stephane Bidoul,
IgorZlatkovic)</li>
<li>xmlWriter bugfix (Alfred Mickautsch)</li>
<li>chvalid.[ch]: couple of fixes from Stephane Bidoul</li>
<li>context reset: error state reset, push parser reset (GrahamBennett)</li>
<li>context reuse: generate errors if file is not readable</li>
<li>defaulted attributes for element coming from internal entities(Stephane
Bidoul)</li>
<li>Python: tab and spaces mix (William Brack)</li>
<li>Error handler could crash in DTD validation in 2.6.0</li>
<li>xmlReader: do not use the document or element _private field</li>
<li>testSAX.c: avoid a problem with some PIs (Massimo Morara)</li>
<li>general bug fixes: mandatory encoding in text decl, serializingDocument
Fragment nodes, xmlSearchNs 2.6.0 problem (Kasimier Buchcik),XPath errors
not reported, slow HTML parsing of large documents.</li>
</ul>
<h3>2.6.0: Oct 20 2003</h3>
<ul>
<li>Major revision release: should be API and ABI compatible but got a
lotof change</li>
<li>Increased the library modularity, far more options can be stripped
out,a --with-minimum configuration will weight around 160KBytes</li>
<li>Use per parser and per document dictionnary, allocate names and
smalltext nodes from the dictionnary</li>
<li>Switch to a SAX2 like parser rewrote most of the XML parser
core,provides namespace resolution and defaulted attributes, minimize
memoryallocations and copies, namespace checking and specific error
handling,immutable buffers, make predefined entities static structures,
etc...</li>
<li>rewrote all the error handling in the library, all errors can
beintercepted at a structured level, with precise
informationavailable.</li>
<li>New simpler and more generic XML and HTML parser APIs, allowing
toeasilly modify the parsing options and reuse parser context for
multipleconsecutive documents.</li>
<li>Similar new APIs for the xmlReader, for options and reuse, provided
newfunctions to access content as const strings, use them for
Pythonbindings</li>
<li>a lot of other smaller API improvements: xmlStrPrintf (Aleksey
Sanin),Walker i.e. reader on a document tree based on Alfred Mickautsch
code,make room in nodes for line numbers, reference counting and future
PSVIextensions, generation of character ranges to be checked with
fasteralgorithm (William), xmlParserMaxDepth (Crutcher Dunnavant),
bufferaccess</li>
<li>New xmlWriter API provided by Alfred Mickautsch</li>
<li>Schemas: base64 support by Anthony Carrico</li>
<li>Parser<->HTTP integration fix, proper processing of the
Mime-Typeand charset informations if available.</li>
<li>Relax-NG: bug fixes including the one reported by Martijn Faassen
andzeroOrMore, better error reporting.</li>
<li>Python bindings (Stéphane Bidoul), never use stdout for
errorsoutput</li>
<li>Portability: all the headers have macros for export and
callingconvention definitions (Igor Zlatkovic), VMS update (Craig A.
Berry),Windows: threads (Jesse Pelton), Borland compiler (Eric Zurcher,
Igor),Mingw (Igor), typos (Mark Vakoc), beta version (Stephane
Bidoul),warning cleanups on AIX and MIPS compilers (William Brack), BeOS
(Marcin'Shard' Konicki)</li>
<li>Documentation fixes and README (William Brack), search fix
(William),tutorial updates (John Fleck), namespace docs (Stefan Kost)</li>
<li>Bug fixes: xmlCleanupParser (Dave Beckett), threading
uninitializedmutexes, HTML doctype lowercase, SAX/IO (William),
compression detectionand restore (William), attribute declaration in DTDs
(William), namespaceon attribute in HTML output (William), input filename
(Rob Richards),namespace DTD validation, xmlReplaceNode (Chris Ryland),
I/O callbacks(Markus Keim), CDATA serialization (Shaun McCance),
xmlReader (PeterDerr), high codepoint charref like &#x10FFFF;, buffer
access in pushmode (Justin Fletcher), TLS threads on Windows (Jesse
Pelton), XPath bug(William), xmlCleanupParser (Marc Liyanage), CDATA
output (William), HTTPerror handling.</li>
<li>xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for
compattesting, --nodict for building without tree dictionnary, --nocdata
toreplace CDATA by text, --nsclean to remove surperfluous
namespacedeclarations</li>
<li>added xml2-config --libtool-libs option from Kevin P. Fleming</li>
<li>a lot of profiling and tuning of the code, speedup patch
forxmlSearchNs() by Luca Padovani. The xmlReader should do far
lessallocation and it speed should get closer to SAX. Chris Anderson
workedon speeding and cleaning up repetitive checking code.</li>
<li>cleanup of "make tests"</li>
<li>libxml-2.0-uninstalled.pc from Malcolm Tredinnick</li>
<li>deactivated the broken docBook SGML parser code and plugged the
XMLparser instead.</li>
</ul>
<h3>2.5.11: Sep 9 2003</h3>
<p>A bugfix only release:</p>
<ul>
<li>risk of crash in Relax-NG</li>
<li>risk of crash when using multithreaded programs</li>
</ul>
<h3>2.5.10: Aug 15 2003</h3>
<p>A bugfixes only release</p>
<ul>
<li>Windows Makefiles (William Brack)</li>
<li>UTF-16 support fixes (Mark Itzcovitz)</li>
<li>Makefile and portability (William Brack) automake, Linux alpha, Mingwon
Windows (Mikhail Grushinskiy)</li>
<li>HTML parser (Oliver Stoeneberg)</li>
<li>XInclude performance problem reported by Kevin Ruscoe</li>
<li>XML parser performance problem reported by Grant Goodale</li>
<li>xmlSAXParseDTD() bug fix from Malcolm Tredinnick</li>
<li>and a couple other cleanup</li>
</ul>
<h3>2.5.9: Aug 9 2003</h3>
<ul>
<li>bugfixes: IPv6 portability, xmlHasNsProp (Markus Keim), Windows
build(Wiliam Brake, Jesse Pelton, Igor), Schemas (Peter Sobisch),
threading(Rob Richards), hexBinary type (), UTF-16 BOM (Dodji
Seketeli),xmlReader, Relax-NG schemas compilation, namespace handling,
EXSLT (SeanGriffin), HTML parsing problem (William Brack), DTD validation
for mixedcontent + namespaces, HTML serialization, library
initialization,progressive HTML parser</li>
<li>better interfaces for Relax-NG error handling (Joachim Bauch, )</li>
<li>adding xmlXIncludeProcessTree() for XInclud'ing in a subtree</li>
<li>doc fixes and improvements (John Fleck)</li>
<li>configure flag for -with-fexceptions when embedding in C++</li>
<li>couple of new UTF-8 helper functions (William Brack)</li>
<li>general encoding cleanup + ISO-8859-x without iconv (Peter Jacobi)</li>
<li>xmlTextReader cleanup + enum for node types (Bjorn Reese)</li>
<li>general compilation/warning cleanup Solaris/HP-UX/...
(WilliamBrack)</li>
</ul>
<h3>2.5.8: Jul 6 2003</h3>
<ul>
<li>bugfixes: XPath, XInclude, file/URI mapping, UTF-16 save
(MarkItzcovitz), UTF-8 checking, URI saving, error printing (William
Brack),PI related memleak, compilation without schemas or without xpath
(JoergSchmitz-Linneweber/Garry Pennington), xmlUnlinkNode problem with
DTDs,rpm problem on , i86_64, removed a few compilation problems from
2.5.7,xmlIOParseDTD, and xmlSAXParseDTD (Malcolm Tredinnick)</li>
<li>portability: DJGPP (MsDos) , OpenVMS (Craig A. Berry)</li>
<li>William Brack fixed multithreading lock problems</li>
<li>IPv6 patch for FTP and HTTP accesses (Archana Shah/Wipro)</li>
<li>Windows fixes (Igor Zlatkovic, Eric Zurcher), threading
(StéphaneBidoul)</li>
<li>A few W3C Schemas Structure improvements</li>
<li>W3C Schemas Datatype improvements (Charlie Bozeman)</li>
<li>Python bindings for thread globals (Stéphane Bidoul), and
method/classgenerator</li>
<li>added --nonet option to xmllint</li>
<li>documentation improvements (John Fleck)</li>
</ul>
<h3>2.5.7: Apr 25 2003</h3>
<ul>
<li>Relax-NG: Compiling to regexp and streaming validation on top of
thexmlReader interface, added to xmllint --stream</li>
<li>xmlReader: Expand(), Next() and DOM access glue, bug fixes</li>
<li>Support for large files: RGN validated a 4.5GB instance</li>
<li>Thread support is now configured in by default</li>
<li>Fixes: update of the Trio code (Bjorn), WXS Date and Duration
fixes(Charles Bozeman), DTD and namespaces (Brent Hendricks), HTML push
parserand zero bytes handling, some missing Windows file path
conversions,behaviour of the parser and validator in the presence of "out
of memory"error conditions</li>
<li>extended the API to be able to plug a garbage collecting
memoryallocator, added xmlMallocAtomic() and modified the
allocationsaccordingly.</li>
<li>Performances: removed excessive malloc() calls, speedup of the push
andxmlReader interfaces, removed excessive thread locking</li>
<li>Documentation: man page (John Fleck), xmlReader documentation</li>
<li>Python: adding binding for xmlCatalogAddLocal (Brent M Hendricks)</li>
</ul>
<h3>2.5.6: Apr 1 2003</h3>
<ul>
<li>Fixed W3C XML Schemas datatype, should be compliant now except
forbinHex and base64 which are not supported yet.</li>
<li>bug fixes: non-ASCII IDs, HTML output, XInclude on large docs
andXInclude entities handling, encoding detection on external subsets,
XMLSchemas bugs and memory leaks, HTML parser (James Bursa)</li>
<li>portability: python/trio (Albert Chin), Sun compiler warnings</li>
<li>documentation: added --relaxng option to xmllint man page (John)</li>
<li>improved error reporting: xml:space, start/end tag mismatches, Relax
NGerrors</li>
</ul>
<h3>2.5.5: Mar 24 2003</h3>
<ul>
<li>Lot of fixes on the Relax NG implementation. More testing
includingDocBook and TEI examples.</li>
<li>Increased the support for W3C XML Schemas datatype</li>
<li>Several bug fixes in the URI handling layer</li>
<li>Bug fixes: HTML parser, xmlReader, DTD validation, XPath,
encodingconversion, line counting in the parser.</li>
<li>Added support for $XMLLINT_INDENT environment variable, FTP delete</li>
<li>Fixed the RPM spec file name</li>
</ul>
<h3>2.5.4: Feb 20 2003</h3>
<ul>
<li>Conformance testing and lot of fixes on Relax NG and
XIncludeimplementation</li>
<li>Implementation of XPointer element() scheme</li>
<li>Bug fixes: XML parser, XInclude entities merge, validity checking
onnamespaces,
<p>2 serialization bugs, node info generation problems, a DTD
regexpgeneration problem.</p>
</li>
<li>Portability: windows updates and path canonicalization (Igor)</li>
<li>A few typo fixes (Kjartan Maraas)</li>
<li>Python bindings generator fixes (Stephane Bidoul)</li>
</ul>
<h3>2.5.3: Feb 10 2003</h3>
<ul>
<li>RelaxNG and XML Schemas datatypes improvements, and added a
firstversion of RelaxNG Python bindings</li>
<li>Fixes: XLink (Sean Chittenden), XInclude (Sean Chittenden), API fix
forserializing namespace nodes, encoding conversion bug,
XHTML1serialization</li>
<li>Portability fixes: Windows (Igor), AMD 64bits RPM spec file</li>
</ul>
<h3>2.5.2: Feb 5 2003</h3>
<ul>
<li>First implementation of RelaxNG, added --relaxng flag to xmllint</li>
<li>Schemas support now compiled in by default.</li>
<li>Bug fixes: DTD validation, namespace checking, XInclude and
entities,delegateURI in XML Catalogs, HTML parser, XML reader (Stéphane
Bidoul),XPath parser and evaluation, UTF8ToUTF8 serialization, XML
reader memoryconsumption, HTML parser, HTML serialization in the presence
ofnamespaces</li>
<li>added an HTML API to check elements and attributes.</li>
<li>Documentation improvement, PDF for the tutorial (John Fleck),
docpatches (Stefan Kost)</li>
<li>Portability fixes: NetBSD (Julio Merino), Windows (Igor Zlatkovic)</li>
<li>Added python bindings for XPointer, contextual error reporting(Stéphane
Bidoul)</li>
<li>URI/file escaping problems (Stefano Zacchiroli)</li>
</ul>
<h3>2.5.1: Jan 8 2003</h3>
<ul>
<li>Fixes a memory leak and configuration/compilation problems in 2.5.0</li>
<li>documentation updates (John)</li>
<li>a couple of XmlTextReader fixes</li>
</ul>
<h3>2.5.0: Jan 6 2003</h3>
<ul>
<li>New <a href="xmlreader.html">XmltextReader interface</a>based on C#API
(with help of Stéphane Bidoul)</li>
<li>Windows: more exports, including the new API (Igor)</li>
<li>XInclude fallback fix</li>
<li>Python: bindings for the new API, packaging (Stéphane
Bidoul),drv_libxml2.py Python xml.sax driver (Stéphane Bidoul), fixes,
speedupand iterators for Python-2.2 (Hannu Krosing)</li>
<li>Tutorial fixes (john Fleck and Niraj Tolia) xmllint man
update(John)</li>
<li>Fix an XML parser bug raised by Vyacheslav Pindyura</li>
<li>Fix for VMS serialization (Nigel Hall) and config (Craig A. Berry)</li>
<li>Entities handling fixes</li>
<li>new API to optionally track node creation and deletion
(LukasSchroeder)</li>
<li>Added documentation for the XmltextReader interface and some <a
href="guidelines.html">XML guidelines</a></li>
</ul>
<h3>2.4.30: Dec 12 2002</h3>
<ul>
<li>2.4.29 broke the python bindings, rereleasing</li>
<li>Improvement/fixes of the XML API generator, and couple of minor
codefixes.</li>
</ul>
<h3>2.4.29: Dec 11 2002</h3>
<ul>
<li>Windows fixes (Igor): Windows CE port, pthread linking, python
bindings(Stéphane Bidoul), Mingw (Magnus Henoch), and export list
updates</li>
<li>Fix for prev in python bindings (ERDI Gergo)</li>
<li>Fix for entities handling (Marcus Clarke)</li>
<li>Refactored the XML and HTML dumps to a single code path, fixed
XHTML1dump</li>
<li>Fix for URI parsing when handling URNs with fragment identifiers</li>
<li>Fix for HTTP URL escaping problem</li>
<li>added an TextXmlReader (C#) like API (work in progress)</li>
<li>Rewrote the API in XML generation script, includes a C parser and
savesmore informations needed for C# bindings</li>
</ul>
<h3>2.4.28: Nov 22 2002</h3>
<ul>
<li>a couple of python binding fixes</li>
<li>2 bug fixes in the XML push parser</li>
<li>potential memory leak removed (Martin Stoilov)</li>
<li>fix to the configure script for Unix (Dimitri Papadopoulos)</li>
<li>added encoding support for XInclude parse="text"</li>
<li>autodetection of XHTML1 and specific serialization rules added</li>
<li>nasty threading bug fixed (William Brack)</li>
</ul>
<h3>2.4.27: Nov 17 2002</h3>
<ul>
<li>fixes for the Python bindings</li>
<li>a number of bug fixes: SGML catalogs,
xmlParseBalancedChunkMemory(),HTML parser, Schemas (Charles Bozeman),
document fragment support(Christian Glahn), xmlReconciliateNs (Brian
Stafford), XPointer,xmlFreeNode(), xmlSAXParseMemory (Peter Jones),
xmlGetNodePath (PetrPajas), entities processing</li>
<li>added grep to xmllint --shell</li>
<li>VMS update patch from Craig A. Berry</li>
<li>cleanup of the Windows build with support for more compilers
(Igor),better thread support on Windows</li>
<li>cleanup of Unix Makefiles and spec file</li>
<li>Improvements to the documentation (John Fleck)</li>
</ul>
<h3>2.4.26: Oct 18 2002</h3>
<ul>
<li>Patches for Windows CE port, improvements on Windows paths handling</li>
<li>Fixes to the validation code (DTD and Schemas), xmlNodeGetPath() ,HTML
serialization, Namespace compliance, and a number of smallproblems</li>
</ul>
<h3>2.4.25: Sep 26 2002</h3>
<ul>
<li>A number of bug fixes: XPath, validation, Python bindings, DOM andtree,
xmlI/O, Html</li>
<li>Serious rewrite of XInclude</li>
<li>Made XML Schemas regexp part of the default build and APIs, small
fixand improvement of the regexp core</li>
<li>Changed the validation code to reuse XML Schemas regexp APIs</li>
<li>Better handling of Windows file paths, improvement of Makefiles
(Igor,Daniel Gehriger, Mark Vakoc)</li>
<li>Improved the python I/O bindings, the tests, added resolver and
regexpAPIs</li>
<li>New logos from Marc Liyanage</li>
<li>Tutorial improvements: John Fleck, Christopher Harris</li>
<li>Makefile: Fixes for AMD x86_64 (Mandrake), DESTDIR
(ChristopheMerlet)</li>
<li>removal of all stderr/perror use for error reporting</li>
<li>Better error reporting: XPath and DTD validation</li>
<li>update of the trio portability layer (Bjorn Reese)</li>
</ul>
<p><strong>2.4.24: Aug 22 2002</strong></p>
<ul>
<li>XPath fixes (William), xf:escape-uri() (Wesley Terpstra)</li>
<li>Python binding fixes: makefiles (William), generator, rpm build,
x86-64(fcrozat)</li>
<li>HTML <style> and boolean attributes serializer fixes</li>
<li>C14N improvements by Aleksey</li>
<li>doc cleanups: Rick Jones</li>
<li>Windows compiler makefile updates: Igor and Elizabeth Barham</li>
<li>XInclude: implementation of fallback and xml:base fixup added</li>
</ul>
<h3>2.4.23: July 6 2002</h3>
<ul>
<li>performances patches: Peter Jacobi</li>
<li>c14n fixes, testsuite and performances: Aleksey Sanin</li>
<li>added xmlDocFormatDump: Chema Celorio</li>
<li>new tutorial: John Fleck</li>
<li>new hash functions and performances: Sander Vesik, portability fix
fromPeter Jacobi</li>
<li>a number of bug fixes: XPath (William Brack, Richard Jinks), XML
andHTML parsers, ID lookup function</li>
<li>removal of all remaining sprintf: Aleksey Sanin</li>
</ul>
<h3>2.4.22: May 27 2002</h3>
<ul>
<li>a number of bug fixes: configure scripts, base handling, parser,
memoryusage, HTML parser, XPath, documentation (Christian
Cornelssen),indentation, URI parsing</li>
<li>Optimizations for XMLSec, fixing and making public some of the
networkprotocol handlers (Aleksey)</li>
<li>performance patch from Gary Pennington</li>
<li>Charles Bozeman provided date and time support for XML
Schemasdatatypes</li>
</ul>
<h3>2.4.21: Apr 29 2002</h3>
<p>This release is both a bug fix release and also contains the early
XMLSchemas <a href="http://www.w3.org/TR/xmlschema-1/">structures</a>and <a
href="http://www.w3.org/TR/xmlschema-2/">datatypes</a>code, beware,
allinterfaces are likely to change, there is huge holes, it is clearly a work
inprogress and don't even think of putting this code in a production
system,it's actually not compiled in by default. The real fixes are:</p>
<ul>
<li>a couple of bugs or limitations introduced in 2.4.20</li>
<li>patches for Borland C++ and MSC by Igor</li>
<li>some fixes on XPath strings and conformance patches by RichardJinks</li>
<li>patch from Aleksey for the ExcC14N specification</li>
<li>OSF/1 bug fix by Bjorn</li>
</ul>
<h3>2.4.20: Apr 15 2002</h3>
<ul>
<li>bug fixes: file descriptor leak, XPath, HTML output, DTD validation</li>
<li>XPath conformance testing by Richard Jinks</li>
<li>Portability fixes: Solaris, MPE/iX, Windows, OSF/1, python
bindings,libxml.m4</li>
</ul>
<h3>2.4.19: Mar 25 2002</h3>
<ul>
<li>bug fixes: half a dozen XPath bugs, Validation, ISO-Latin to
UTF8encoder</li>
<li>portability fixes in the HTTP code</li>
<li>memory allocation checks using valgrind, and profiling tests</li>
<li>revamp of the Windows build and Makefiles</li>
</ul>
<h3>2.4.18: Mar 18 2002</h3>
<ul>
<li>bug fixes: tree, SAX, canonicalization, validation,
portability,XPath</li>
<li>removed the --with-buffer option it was becoming unmaintainable</li>
<li>serious cleanup of the Python makefiles</li>
<li>speedup patch to XPath very effective for DocBook stylesheets</li>
<li>Fixes for Windows build, cleanup of the documentation</li>
</ul>
<h3>2.4.17: Mar 8 2002</h3>
<ul>
<li>a lot of bug fixes, including "namespace nodes have no parents
inXPath"</li>
<li>fixed/improved the Python wrappers, added more examples and
moreregression tests, XPath extension functions can now return
node-sets</li>
<li>added the XML Canonicalization support from Aleksey Sanin</li>
</ul>
<h3>2.4.16: Feb 20 2002</h3>
<ul>
<li>a lot of bug fixes, most of them were triggered by the XML
Testsuitefrom OASIS and W3C. Compliance has been significantly
improved.</li>
<li>a couple of portability fixes too.</li>
</ul>
<h3>2.4.15: Feb 11 2002</h3>
<ul>
<li>Fixed the Makefiles, especially the python module ones</li>
<li>A few bug fixes and cleanup</li>
<li>Includes cleanup</li>
</ul>
<h3>2.4.14: Feb 8 2002</h3>
<ul>
<li>Change of License to the <a
href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>basically
for integration in XFree86 codebase, and removingconfusion around the
previous dual-licensing</li>
<li>added Python bindings, beta software but should already be
quitecomplete</li>
<li>a large number of fixes and cleanups, especially for all
treemanipulations</li>
<li>cleanup of the headers, generation of a reference API definition
inXML</li>
</ul>
<h3>2.4.13: Jan 14 2002</h3>
<ul>
<li>update of the documentation: John Fleck and Charlie Bozeman</li>
<li>cleanup of timing code from Justin Fletcher</li>
<li>fixes for Windows and initial thread support on Win32: Igor and
SergueiNarojnyi</li>
<li>Cygwin patch from Robert Collins</li>
<li>added xmlSetEntityReferenceFunc() for Keith Isdale work on xsldbg</li>
</ul>
<h3>2.4.12: Dec 7 2001</h3>
<ul>
<li>a few bug fixes: thread (Gary Pennington), xmllint (Geert
Kloosterman),XML parser (Robin Berjon), XPointer (Danny Jamshy), I/O
cleanups(robert)</li>
<li>Eric Lavigne contributed project files for MacOS</li>
<li>some makefiles cleanups</li>
</ul>
<h3>2.4.11: Nov 26 2001</h3>
<ul>
<li>fixed a couple of errors in the includes, fixed a few bugs, some
codecleanups</li>
<li>xmllint man pages improvement by Heiko Rupp</li>
<li>updated VMS build instructions from John A Fotheringham</li>
<li>Windows Makefiles updates from Igor</li>
</ul>
<h3>2.4.10: Nov 10 2001</h3>
<ul>
<li>URI escaping fix (Joel Young)</li>
<li>added xmlGetNodePath() (for paths or XPointers generation)</li>
<li>Fixes namespace handling problems when using DTD and validation</li>
<li>improvements on xmllint: Morus Walter patches for --format and--encode,
Stefan Kost and Heiko Rupp improvements on the --shell</li>
<li>fixes for xmlcatalog linking pointed by Weiqi Gao</li>
<li>fixes to the HTML parser</li>
</ul>
<h3>2.4.9: Nov 6 2001</h3>
<ul>
<li>fixes more catalog bugs</li>
<li>avoid a compilation problem, improve xmlGetLineNo()</li>
</ul>
<h3>2.4.8: Nov 4 2001</h3>
<ul>
<li>fixed SGML catalogs broken in previous release, updated
xmlcatalogtool</li>
<li>fixed a compile errors and some includes troubles.</li>
</ul>
<h3>2.4.7: Oct 30 2001</h3>
<ul>
<li>exported some debugging interfaces</li>
<li>serious rewrite of the catalog code</li>
<li>integrated Gary Pennington thread safety patch, added configure
optionand regression tests</li>
<li>removed an HTML parser bug</li>
<li>fixed a couple of potentially serious validation bugs</li>
<li>integrated the SGML DocBook support in xmllint</li>
<li>changed the nanoftp anonymous login passwd</li>
<li>some I/O cleanup and a couple of interfaces for Perl wrapper</li>
<li>general bug fixes</li>
<li>updated xmllint man page by John Fleck</li>
<li>some VMS and Windows updates</li>
</ul>
<h3>2.4.6: Oct 10 2001</h3>
<ul>
<li>added an updated man pages by John Fleck</li>
<li>portability and configure fixes</li>
<li>an infinite loop on the HTML parser was removed (William)</li>
<li>Windows makefile patches from Igor</li>
<li>fixed half a dozen bugs reported for libxml or libxslt</li>
<li>updated xmlcatalog to be able to modify SGML super catalogs</li>
</ul>
<h3>2.4.5: Sep 14 2001</h3>
<ul>
<li>Remove a few annoying bugs in 2.4.4</li>
<li>forces the HTML serializer to output decimal charrefs since someversion
of Netscape can't handle hexadecimal ones</li>
</ul>
<h3>1.8.16: Sep 14 2001</h3>
<ul>
<li>maintenance release of the old libxml1 branch, couple of bug
andportability fixes</li>
</ul>
<h3>2.4.4: Sep 12 2001</h3>
<ul>
<li>added --convert to xmlcatalog, bug fixes and cleanups of XMLCatalog</li>
<li>a few bug fixes and some portability changes</li>
<li>some documentation cleanups</li>
</ul>
<h3>2.4.3: Aug 23 2001</h3>
<ul>
<li>XML Catalog support see the doc</li>
<li>New NaN/Infinity floating point code</li>
<li>A few bug fixes</li>
</ul>
<h3>2.4.2: Aug 15 2001</h3>
<ul>
<li>adds xmlLineNumbersDefault() to control line number generation</li>
<li>lot of bug fixes</li>
<li>the Microsoft MSC projects files should now be up to date</li>
<li>inheritance of namespaces from DTD defaulted attributes</li>
<li>fixes a serious potential security bug</li>
<li>added a --format option to xmllint</li>
</ul>
<h3>2.4.1: July 24 2001</h3>
<ul>
<li>possibility to keep line numbers in the tree</li>
<li>some computation NaN fixes</li>
<li>extension of the XPath API</li>
<li>cleanup for alpha and ia64 targets</li>
<li>patch to allow saving through HTTP PUT or POST</li>
</ul>
<h3>2.4.0: July 10 2001</h3>
<ul>
<li>Fixed a few bugs in XPath, validation, and tree handling.</li>
<li>Fixed XML Base implementation, added a couple of examples to
theregression tests</li>
<li>A bit of cleanup</li>
</ul>
<h3>2.3.14: July 5 2001</h3>
<ul>
<li>fixed some entities problems and reduce memory requirement
whensubstituting them</li>
<li>lots of improvements in the XPath queries interpreter can
besubstantially faster</li>
<li>Makefiles and configure cleanups</li>
<li>Fixes to XPath variable eval, and compare on empty node set</li>
<li>HTML tag closing bug fixed</li>
<li>Fixed an URI reference computation problem when validating</li>
</ul>
<h3>2.3.13: June 28 2001</h3>
<ul>
<li>2.3.12 configure.in was broken as well as the push mode XML parser</li>
<li>a few more fixes for compilation on Windows MSC by Yon Derek</li>
</ul>
<h3>1.8.14: June 28 2001</h3>
<ul>
<li>Zbigniew Chyla gave a patch to use the old XML parser in push mode</li>
<li>Small Makefile fix</li>
</ul>
<h3>2.3.12: June 26 2001</h3>
<ul>
<li>lots of cleanup</li>
<li>a couple of validation fix</li>
<li>fixed line number counting</li>
<li>fixed serious problems in the XInclude processing</li>
<li>added support for UTF8 BOM at beginning of entities</li>
<li>fixed a strange gcc optimizer bugs in xpath handling of float,
gcc-3.0miscompile uri.c (William), Thomas Leitner provided a fix for
theoptimizer on Tru64</li>
<li>incorporated Yon Derek and Igor Zlatkovic fixes and improvements
forcompilation on Windows MSC</li>
<li>update of libxml-doc.el (Felix Natter)</li>
<li>fixed 2 bugs in URI normalization code</li>
</ul>
<h3>2.3.11: June 17 2001</h3>
<ul>
<li>updates to trio, Makefiles and configure should fix some
portabilityproblems (alpha)</li>
<li>fixed some HTML serialization problems (pre, script, and
block/inlinehandling), added encoding aware APIs, cleanup of this
code</li>
<li>added xmlHasNsProp()</li>
<li>implemented a specific PI for encoding support in the DocBook
SGMLparser</li>
<li>some XPath fixes (-Infinity, / as a function parameter and
namespacesnode selection)</li>
<li>fixed a performance problem and an error in the validation code</li>
<li>fixed XInclude routine to implement the recursive behaviour</li>
<li>fixed xmlFreeNode problem when libxml is included statically twice</li>
<li>added --version to xmllint for bug reports</li>
</ul>
<h3>2.3.10: June 1 2001</h3>
<ul>
<li>fixed the SGML catalog support</li>
<li>a number of reported bugs got fixed, in XPath, iconv detection,XInclude
processing</li>
<li>XPath string function should now handle unicode correctly</li>
</ul>
<h3>2.3.9: May 19 2001</h3>
<p>Lots of bugfixes, and added a basic SGML catalog support:</p>
<ul>
<li>HTML push bugfix #54891 and another patch from Jonas Borgström</li>
<li>some serious speed optimization again</li>
<li>some documentation cleanups</li>
<li>trying to get better linking on Solaris (-R)</li>
<li>XPath API cleanup from Thomas Broyer</li>
<li>Validation bug fixed #54631, added a patch from Gary Pennington,
fixedxmlValidGetValidElements()</li>
<li>Added an INSTALL file</li>
<li>Attribute removal added to API: #54433</li>
<li>added a basic support for SGML catalogs</li>
<li>fixed xmlKeepBlanksDefault(0) API</li>
<li>bugfix in xmlNodeGetLang()</li>
<li>fixed a small configure portability problem</li>
<li>fixed an inversion of SYSTEM and PUBLIC identifier in HTML document</li>
</ul>
<h3>1.8.13: May 14 2001</h3>
<ul>
<li>bugfixes release of the old libxml1 branch used by Gnome</li>
</ul>
<h3>2.3.8: May 3 2001</h3>
<ul>
<li>Integrated an SGML DocBook parser for the Gnome project</li>
<li>Fixed a few things in the HTML parser</li>
<li>Fixed some XPath bugs raised by XSLT use, tried to fix the
floatingpoint portability issue</li>
<li>Speed improvement (8M/s for SAX, 3M/s for DOM, 1.5M/s forDOM+validation
using the XML REC as input and a 700MHz celeron).</li>
<li>incorporated more Windows cleanup</li>
<li>added xmlSaveFormatFile()</li>
<li>fixed problems in copying nodes with entities references (gdome)</li>
<li>removed some troubles surrounding the new validation module</li>
</ul>
<h3>2.3.7: April 22 2001</h3>
<ul>
<li>lots of small bug fixes, corrected XPointer</li>
<li>Non deterministic content model validation support</li>
<li>added xmlDocCopyNode for gdome2</li>
<li>revamped the way the HTML parser handles end of tags</li>
<li>XPath: corrections of namespaces support and number formatting</li>
<li>Windows: Igor Zlatkovic patches for MSC compilation</li>
<li>HTML output fixes from P C Chow and William M. Brack</li>
<li>Improved validation speed sensible for DocBook</li>
<li>fixed a big bug with ID declared in external parsed entities</li>
<li>portability fixes, update of Trio from Bjorn Reese</li>
</ul>
<h3>2.3.6: April 8 2001</h3>
<ul>
<li>Code cleanup using extreme gcc compiler warning options, found
andcleared half a dozen potential problem</li>
<li>the Eazel team found an XML parser bug</li>
<li>cleaned up the user of some of the string formatting function. used
thetrio library code to provide the one needed when the platform is
missingthem</li>
<li>xpath: removed a memory leak and fixed the predicate evaluationproblem,
extended the testsuite and cleaned up the result. XPointer seemsbroken
...</li>
</ul>
<h3>2.3.5: Mar 23 2001</h3>
<ul>
<li>Biggest change is separate parsing and evaluation of XPath
expressions,there is some new APIs for this too</li>
<li>included a number of bug fixes(XML push parser, 51876,
notations,52299)</li>
<li>Fixed some portability issues</li>
</ul>
<h3>2.3.4: Mar 10 2001</h3>
<ul>
<li>Fixed bugs #51860 and #51861</li>
<li>Added a global variable xmlDefaultBufferSize to allow default
buffersize to be application tunable.</li>
<li>Some cleanup in the validation code, still a bug left and this
partshould probably be rewritten to support ambiguous content model
:-\</li>
<li>Fix a couple of serious bugs introduced or raised by changes in
2.3.3parser</li>
<li>Fixed another bug in xmlNodeGetContent()</li>
<li>Bjorn fixed XPath node collection and Number formatting</li>
<li>Fixed a loop reported in the HTML parsing</li>
<li>blank space are reported even if the Dtd content model proves that
theyare formatting spaces, this is for XML conformance</li>
</ul>
<h3>2.3.3: Mar 1 2001</h3>
<ul>
<li>small change in XPath for XSLT</li>
<li>documentation cleanups</li>
<li>fix in validation by Gary Pennington</li>
<li>serious parsing performances improvements</li>
</ul>
<h3>2.3.2: Feb 24 2001</h3>
<ul>
<li>chasing XPath bugs, found a bunch, completed some TODO</li>
<li>fixed a Dtd parsing bug</li>
<li>fixed a bug in xmlNodeGetContent</li>
<li>ID/IDREF support partly rewritten by Gary Pennington</li>
</ul>
<h3>2.3.1: Feb 15 2001</h3>
<ul>
<li>some XPath and HTML bug fixes for XSLT</li>
<li>small extension of the hash table interfaces for DOM
gdome2implementation</li>
<li>A few bug fixes</li>
</ul>
<h3>2.3.0: Feb 8 2001 (2.2.12 was on 25 Jan but I didn't kept track)</h3>
<ul>
<li>Lots of XPath bug fixes</li>
<li>Add a mode with Dtd lookup but without validation error reporting
forXSLT</li>
<li>Add support for text node without escaping (XSLT)</li>
<li>bug fixes for xmlCheckFilename</li>
<li>validation code bug fixes from Gary Pennington</li>
<li>Patch from Paul D. Smith correcting URI path normalization</li>
<li>Patch to allow simultaneous install of libxml-devel
andlibxml2-devel</li>
<li>the example Makefile is now fixed</li>
<li>added HTML to the RPM packages</li>
<li>tree copying bugfixes</li>
<li>updates to Windows makefiles</li>
<li>optimization patch from Bjorn Reese</li>
</ul>
<h3>2.2.11: Jan 4 2001</h3>
<ul>
<li>bunch of bug fixes (memory I/O, xpath, ftp/http, ...)</li>
<li>added htmlHandleOmittedElem()</li>
<li>Applied Bjorn Reese's IPV6 first patch</li>
<li>Applied Paul D. Smith patches for validation of XInclude results</li>
<li>added XPointer xmlns() new scheme support</li>
</ul>
<h3>2.2.10: Nov 25 2000</h3>
<ul>
<li>Fix the Windows problems of 2.2.8</li>
<li>integrate OpenVMS patches</li>
<li>better handling of some nasty HTML input</li>
<li>Improved the XPointer implementation</li>
<li>integrate a number of provided patches</li>
</ul>
<h3>2.2.9: Nov 25 2000</h3>
<ul>
<li>erroneous release :-(</li>
</ul>
<h3>2.2.8: Nov 13 2000</h3>
<ul>
<li>First version of <a
href="http://www.w3.org/TR/xinclude">XInclude</a>support</li>
<li>Patch in conditional section handling</li>
<li>updated MS compiler project</li>
<li>fixed some XPath problems</li>
<li>added an URI escaping function</li>
<li>some other bug fixes</li>
</ul>
<h3>2.2.7: Oct 31 2000</h3>
<ul>
<li>added message redirection</li>
<li>XPath improvements (thanks TOM !)</li>
<li>xmlIOParseDTD() added</li>
<li>various small fixes in the HTML, URI, HTTP and XPointer support</li>
<li>some cleanup of the Makefile, autoconf and the distribution content</li>
</ul>
<h3>2.2.6: Oct 25 2000:</h3>
<ul>
<li>Added an hash table module, migrated a number of internal structure
tothose</li>
<li>Fixed a posteriori validation problems</li>
<li>HTTP module cleanups</li>
<li>HTML parser improvements (tag errors, script/style handling,
attributenormalization)</li>
<li>coalescing of adjacent text nodes</li>
<li>couple of XPath bug fixes, exported the internal API</li>
</ul>
<h3>2.2.5: Oct 15 2000:</h3>
<ul>
<li>XPointer implementation and testsuite</li>
<li>Lot of XPath fixes, added variable and functions registration,
moretests</li>
<li>Portability fixes, lots of enhancements toward an easy Windows buildand
release</li>
<li>Late validation fixes</li>
<li>Integrated a lot of contributed patches</li>
<li>added memory management docs</li>
<li>a performance problem when using large buffer seems fixed</li>
</ul>
<h3>2.2.4: Oct 1 2000:</h3>
<ul>
<li>main XPath problem fixed</li>
<li>Integrated portability patches for Windows</li>
<li>Serious bug fixes on the URI and HTML code</li>
</ul>
<h3>2.2.3: Sep 17 2000</h3>
<ul>
<li>bug fixes</li>
<li>cleanup of entity handling code</li>
<li>overall review of all loops in the parsers, all sprintf usage has
beenchecked too</li>
<li>Far better handling of larges Dtd. Validating against DocBook XML
Dtdworks smoothly now.</li>
</ul>
<h3>1.8.10: Sep 6 2000</h3>
<ul>
<li>bug fix release for some Gnome projects</li>
</ul>
<h3>2.2.2: August 12 2000</h3>
<ul>
<li>mostly bug fixes</li>
<li>started adding routines to access xml parser context options</li>
</ul>
<h3>2.2.1: July 21 2000</h3>
<ul>
<li>a purely bug fixes release</li>
<li>fixed an encoding support problem when parsing from a memory block</li>
<li>fixed a DOCTYPE parsing problem</li>
<li>removed a bug in the function allowing to override the memoryallocation
routines</li>
</ul>
<h3>2.2.0: July 14 2000</h3>
<ul>
<li>applied a lot of portability fixes</li>
<li>better encoding support/cleanup and saving (content is now
alwaysencoded in UTF-8)</li>
<li>the HTML parser now correctly handles encodings</li>
<li>added xmlHasProp()</li>
<li>fixed a serious problem with &#38;</li>
<li>propagated the fix to FTP client</li>
<li>cleanup, bugfixes, etc ...</li>
<li>Added a page about <a href="encoding.html">libxml
Internationalizationsupport</a></li>
</ul>
<h3>1.8.9: July 9 2000</h3>
<ul>
<li>fixed the spec the RPMs should be better</li>
<li>fixed a serious bug in the FTP implementation, released 1.8.9 to
solverpmfind users problem</li>
</ul>
<h3>2.1.1: July 1 2000</h3>
<ul>
<li>fixes a couple of bugs in the 2.1.0 packaging</li>
<li>improvements on the HTML parser</li>
</ul>
<h3>2.1.0 and 1.8.8: June 29 2000</h3>
<ul>
<li>1.8.8 is mostly a commodity package for upgrading to libxml2
accordingto <a href="upgrade.html">new instructions</a>. It fixes a nasty
problemabout &#38; charref parsing</li>
<li>2.1.0 also ease the upgrade from libxml v1 to the recent version.
italso contains numerous fixes and enhancements:
<ul>
<li>added xmlStopParser() to stop parsing</li>
<li>improved a lot parsing speed when there is large CDATA blocs</li>
<li>includes XPath patches provided by Picdar Technology</li>
<li>tried to fix as much as possible DTD validation and
namespacerelated problems</li>
<li>output to a given encoding has been added/tested</li>
<li>lot of various fixes</li>
</ul>
</li>
</ul>
<h3>2.0.0: Apr 12 2000</h3>
<ul>
<li>First public release of libxml2. If you are using libxml, it's a
goodidea to check the 1.x to 2.x upgrade instructions. NOTE: while
initiallyscheduled for Apr 3 the release occurred only on Apr 12 due to
massiveworkload.</li>
<li>The include are now located under $prefix/include/libxml (instead
of$prefix/include/gnome-xml), they also are referenced by
<pre>#include <libxml/xxx.h></pre>
<p>instead of</p>
<pre>#include "xxx.h"</pre>
</li>
<li>a new URI module for parsing URIs and following strictly RFC 2396</li>
<li>the memory allocation routines used by libxml can now be
overloadeddynamically by using xmlMemSetup()</li>
<li>The previously CVS only tool tester has been
renamed<strong>xmllint</strong>and is now installed as part of the
libxml2package</li>
<li>The I/O interface has been revamped. There is now ways to plug
inspecific I/O modules, either at the URI scheme detection level
usingxmlRegisterInputCallbacks() or by passing I/O functions when
creating aparser context using xmlCreateIOParserCtxt()</li>
<li>there is a C preprocessor macro LIBXML_VERSION providing the
versionnumber of the libxml module in use</li>
<li>a number of optional features of libxml can now be excluded atconfigure
time (FTP/HTTP/HTML/XPath/Debug)</li>
</ul>
<h3>2.0.0beta: Mar 14 2000</h3>
<ul>
<li>This is a first Beta release of libxml version 2</li>
<li>It's available only from<a
href="ftp://xmlsoft.org/libxml2/">xmlsoft.orgFTP</a>, it's packaged as
libxml2-2.0.0beta and available as tar andRPMs</li>
<li>This version is now the head in the Gnome CVS base, the old one
isavailable under the tag LIB_XML_1_X</li>
<li>This includes a very large set of changes. From a programmatic pointof
view applications should not have to be modified too much, check the<a
href="upgrade.html">upgrade page</a></li>
<li>Some interfaces may changes (especially a bit about encoding).</li>
<li>the updates includes:
<ul>
<li>fix I18N support. ISO-Latin-x/UTF-8/UTF-16 (nearly) seems
correctlyhandled now</li>
<li>Better handling of entities, especially well-formedness checkingand
proper PEref extensions in external subsets</li>
<li>DTD conditional sections</li>
<li>Validation now correctly handle entities content</li>
<li><a
href="http://rpmfind.net/tools/gdome/messages/0039.html">changestructures
to accommodate DOM</a></li>
</ul>
</li>
<li>Serious progress were made toward compliance, <a
href="conf/result.html">here are the result of the test</a>against
theOASIS testsuite (except the Japanese tests since I don't support
thatencoding yet). This URL is rebuilt every couple of hours using the
CVShead version.</li>
</ul>
<h3>1.8.7: Mar 6 2000</h3>
<ul>
<li>This is a bug fix release:</li>
<li>It is possible to disable the ignorable blanks heuristic used
bylibxml-1.x, a new function xmlKeepBlanksDefault(0) will allow this.
Notethat for adherence to XML spec, this behaviour will be disabled
bydefault in 2.x . The same function will allow to keep compatibility
forold code.</li>
<li>Blanks in <a> </a> constructs are not ignored
anymore,avoiding heuristic is really the Right Way :-\</li>
<li>The unchecked use of snprintf which was breaking
libxml-1.8.6compilation on some platforms has been fixed</li>
<li>nanoftp.c nanohttp.c: Fixed '#' and '?' stripping when
processingURIs</li>
</ul>
<h3>1.8.6: Jan 31 2000</h3>
<ul>
<li>added a nanoFTP transport module, debugged until the new version of <a
href="http://rpmfind.net/linux/rpm2html/rpmfind.html">rpmfind</a>can
useit without troubles</li>
</ul>
<h3>1.8.5: Jan 21 2000</h3>
<ul>
<li>adding APIs to parse a well balanced chunk of XML (production <a
href="http://www.w3.org/TR/REC-xml#NT-content">[43] content</a>of theXML
spec)</li>
<li>fixed a hideous bug in xmlGetProp pointed by Rune.Djurhuus@fast.no</li>
<li>Jody Goldberg <jgoldberg@home.com> provided another patch
tryingto solve the zlib checks problems</li>
<li>The current state in gnome CVS base is expected to ship as 1.8.5
withgnumeric soon</li>
</ul>
<h3>1.8.4: Jan 13 2000</h3>
<ul>
<li>bug fixes, reintroduced xmlNewGlobalNs(), fixed xmlNewNs()</li>
<li>all exit() call should have been removed from libxml</li>
<li>fixed a problem with INCLUDE_WINSOCK on WIN32 platform</li>
<li>added newDocFragment()</li>
</ul>
<h3>1.8.3: Jan 5 2000</h3>
<ul>
<li>a Push interface for the XML and HTML parsers</li>
<li>a shell-like interface to the document tree (try tester --shell :-)</li>
<li>lots of bug fixes and improvement added over XMas holidays</li>
<li>fixed the DTD parsing code to work with the xhtml DTD</li>
<li>added xmlRemoveProp(), xmlRemoveID() and xmlRemoveRef()</li>
<li>Fixed bugs in xmlNewNs()</li>
<li>External entity loading code has been revamped, now it
usesxmlLoadExternalEntity(), some fix on entities processing were
added</li>
<li>cleaned up WIN32 includes of socket stuff</li>
</ul>
<h3>1.8.2: Dec 21 1999</h3>
<ul>
<li>I got another problem with includes and C++, I hope this issue is
fixedfor good this time</li>
<li>Added a few tree modification functions:
xmlReplaceNode,xmlAddPrevSibling, xmlAddNextSibling, xmlNodeSetName
andxmlDocSetRootElement</li>
<li>Tried to improve the HTML output with help from <a
href="mailto:clahey@umich.edu">Chris Lahey</a></li>
</ul>
<h3>1.8.1: Dec 18 1999</h3>
<ul>
<li>various patches to avoid troubles when using libxml with C++
compilersthe "namespace" keyword and C escaping in include files</li>
<li>a problem in one of the core macros IS_CHAR was corrected</li>
<li>fixed a bug introduced in 1.8.0 breaking default namespace
processing,and more specifically the Dia application</li>
<li>fixed a posteriori validation (validation after parsing, or by using
aDtd not specified in the original document)</li>
<li>fixed a bug in</li>
</ul>
<h3>1.8.0: Dec 12 1999</h3>
<ul>
<li>cleanup, especially memory wise</li>
<li>the parser should be more reliable, especially the HTML one, it
shouldnot crash, whatever the input !</li>
<li>Integrated various patches, especially a speedup improvement for
largedataset from <a href="mailto:cnygard@bellatlantic.net">Carl
Nygard</a>,configure with --with-buffers to enable them.</li>
<li>attribute normalization, oops should have been added long ago !</li>
<li>attributes defaulted from DTDs should be available, xmlSetProp()
nowdoes entities escaping by default.</li>
</ul>
<h3>1.7.4: Oct 25 1999</h3>
<ul>
<li>Lots of HTML improvement</li>
<li>Fixed some errors when saving both XML and HTML</li>
<li>More examples, the regression tests should now look clean</li>
<li>Fixed a bug with contiguous charref</li>
</ul>
<h3>1.7.3: Sep 29 1999</h3>
<ul>
<li>portability problems fixed</li>
<li>snprintf was used unconditionally, leading to link problems on
systemwere it's not available, fixed</li>
</ul>
<h3>1.7.1: Sep 24 1999</h3>
<ul>
<li>The basic type for strings manipulated by libxml has been renamed
in1.7.1 from <strong>CHAR</strong>to <strong>xmlChar</strong>. The
reasonis that CHAR was conflicting with a predefined type on Windows.
Howeveron non WIN32 environment, compatibility is provided by the way of
a<strong>#define </strong>.</li>
<li>Changed another error : the use of a structure field called errno,
andleading to troubles on platforms where it's a macro</li>
</ul>
<h3>1.7.0: Sep 23 1999</h3>
<ul>
<li>Added the ability to fetch remote DTD or parsed entities, see the <a
href="html/libxml-nanohttp.html">nanohttp</a>module.</li>
<li>Added an errno to report errors by another mean than a simple
printflike callback</li>
<li>Finished ID/IDREF support and checking when validation</li>
<li>Serious memory leaks fixed (there is now a <a
href="html/libxml-xmlmemory.html">memory wrapper</a>module)</li>
<li>Improvement of <a
href="http://www.w3.org/TR/xpath">XPath</a>implementation</li>
<li>Added an HTML parser front-end</li>
</ul>
<h2><a name="XML">XML</a></h2>
<p><a href="http://www.w3.org/TR/REC-xml">XML is a
standard</a>formarkup-based structured documents. Here is <a
name="example">an example XMLdocument</a>:</p>
<pre><?xml version="1.0"?>
<EXAMPLE prop1="gnome is great" prop2="&amp; linux too">
<head>
<title>Welcome to Gnome</title>
</head>
<chapter>
<title>The Linux adventure</title>
<p>bla bla bla ...</p>
<image href="linus.gif"/>
<p>...</p>
</chapter>
</EXAMPLE></pre>
<p>The first line specifies that it is an XML document and gives
usefulinformation about its encoding. Then the rest of the document is a
textformat whose structure is specified by tags between brackets.
<strong>Eachtag opened has to be closed</strong>. XML is pedantic about this.
However, ifa tag is empty (no content), a single tag can serve as both the
opening andclosing tag if it ends with <code>/></code>rather than
with<code>></code>. Note that, for example, the image tag has no content
(justan attribute) and is closed by ending the tag with
<code>/></code>.</p>
<p>XML can be applied successfully to a wide range of tasks, ranging fromlong
term structured document maintenance (where it follows the steps ofSGML) to
simple data encoding mechanisms like configuration file formatting(glade),
spreadsheets (gnumeric), or even shorter lived documents such asWebDAV where
it is used to encode remote calls between a client and aserver.</p>
<h2><a name="XSLT">XSLT</a></h2>
<p>Check <a href="http://xmlsoft.org/XSLT">the separate libxslt page</a></p>
<p><a href="http://www.w3.org/TR/xslt">XSL Transformations</a>, is alanguage
for transforming XML documents into other XML documents (orHTML/textual
output).</p>
<p>A separate library called libxslt is available implementing XSLT-1.0
forlibxml2. This module "libxslt" too can be found in the Gnome CVS base.</p>
<p>You can check the progresses on the libxslt <a
href="http://xmlsoft.org/XSLT/ChangeLog.html">Changelog</a>.</p>
<h2><a name="Python">Python and bindings</a></h2>
<p>There are a number of language bindings and wrappers available forlibxml2,
the list below is not exhaustive. Please contact the <a
href="http://mail.gnome.org/mailman/listinfo/xml-bindings">xml-bindings@gnome.org</a>(<a
href="http://mail.gnome.org/archives/xml-bindings/">archives</a>) inorder to
get updates to this list or to discuss the specific topic of libxml2or
libxslt wrappers or bindings:</p>
<ul>
<li><a href="http://libxmlplusplus.sourceforge.net/">Libxml++</a>seems
themost up-to-date C++ bindings for libxml2, check the <a
href="http://libxmlplusplus.sourceforge.net/reference/html/hierarchy.html">documentation</a>and
the <a
href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/libxmlplusplus/libxml%2b%2b/examples/">examples</a>.</li>
<li>There is another <a href="http://libgdome-cpp.berlios.de/">C++
wrapperbased on the gdome2 bindings</a>maintained by Tobias Peters.</li>
<li>and a third C++ wrapper by Peter Jones <pjones@pmade.org>
<p>Website: <a
href="http://pmade.org/pjones/software/xmlwrapp/">http://pmade.org/pjones/software/xmlwrapp/</a></p>
</li>
<li><a
href="http://mail.gnome.org/archives/xml/2001-March/msg00014.html">MattSergeant</a>developed
<a href="http://axkit.org/download/">XML::LibXSLT</a>, a Perl wrapper
forlibxml2/libxslt as part of the <a href="http://axkit.com/">AxKit
XMLapplication server</a>.</li>
<li>If you're interested into scripting XML processing, have a look at <a
href="http://xsh.sourceforge.net/">XSH</a>an XML editing shell based
onLibxml2 Perl bindings.</li>
<li><a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>provides
anearlier version of the libxml/libxslt <a
href="http://www.rexx.com/~dkuhlman">wrappers for Python</a>.</li>
<li>Gopal.V and Peter Minten develop <a
href="http://savannah.gnu.org/projects/libxmlsharp">libxml#</a>, a set
ofC# libxml2 bindings.</li>
<li>Petr Kozelka provides <a
href="http://sourceforge.net/projects/libxml2-pas">Pascal units to
gluelibxml2</a>with Kylix, Delphi and other Pascal compilers.</li>
<li>Uwe Fechner also provides <a
href="http://sourceforge.net/projects/idom2-pas/">idom2</a>, a
DOM2implementation for Kylix2/D5/D6 from Borland.</li>
<li>There is <a href="http://libxml.rubyforge.org/">bindings for
Ruby</a>and libxml2 bindings are also available in Ruby through the <a
href="http://libgdome-ruby.berlios.de/">libgdome-ruby</a>modulemaintained
by Tobias Peters.</li>
<li>Steve Ball and contributors maintains <a
href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings
forTcl</a>.</li>
<li>libxml2 and libxslt is the default XML library for PHP5.</li>
<li><a href="http://savannah.gnu.org/projects/classpathx/">LibxmlJ</a>isan
effort to create a 100% JAXP-compatible Java wrapper for libxml2
andlibxslt as part of GNU ClasspathX project.</li>
<li>Patrick McPhee provides Rexx bindings fof libxml2 and libxslt, look
for<a href="http://www.interlog.com/~ptjm/software.html">RexxXML</a>.</li>
<li><a
href="http://www.satimage.fr/software/en/xml_suite.html">Satimage</a>provides
<a
href="http://www.satimage.fr/software/en/downloads_osaxen.html">XMLLibosax</a>.
This is an osax for Mac OS X with a set of commands toimplement in
AppleScript the XML DOM, XPATH and XSLT. Also includescommands for
Property-lists (Apple's fast lookup table XML format.)</li>
<li>Francesco Montorsi developped <a
href="https://sourceforge.net/project/showfiles.php?group_id=51305&package_id=45182">wxXml2</a>wrappers
that interface libxml2, allowing wxWidgets applications toload/save/edit
XML instances.</li>
</ul>
<p>The distribution includes a set of Python bindings, which are guaranteedto
be maintained as part of the library in the future, though the
Pythoninterface have not yet reached the completeness of the C API.</p>
<p>Note that some of the Python purist dislike the default set of
Pythonbindings, rather than complaining I suggest they have a look at <a
href="http://codespeak.net/lxml/">lxml the more pythonic bindings for
libxml2and libxslt</a>and <a
href="http://codespeak.net/mailman/listinfo/lxml-dev">help
MartijnFaassen</a>complete those.</p>
<p><a href="mailto:stephane.bidoul@softwareag.com">Stéphane
Bidoul</a>maintains <a href="http://users.skynet.be/sbi/libxml-python/">a
Windows portof the Python bindings</a>.</p>
<p>Note to people interested in building bindings, the API is formalized as<a
href="libxml2-api.xml">an XML API description file</a>which allows toautomate
a large part of the Python bindings, this includes functiondescriptions,
enums, structures, typedefs, etc... The Python script used tobuild the
bindings is python/generator.py in the source distribution.</p>
<p>To install the Python bindings there are 2 options:</p>
<ul>
<li>If you use an RPM based distribution, simply install the <a
href="http://rpmfind.net/linux/rpm2html/search.php?query=libxml2-python">libxml2-pythonRPM</a>(and
if needed the <a
href="http://rpmfind.net/linux/rpm2html/search.php?query=libxslt-python">libxslt-pythonRPM</a>).</li>
<li>Otherwise use the <a
href="ftp://xmlsoft.org/libxml2/python/">libxml2-pythonmodule
distribution</a>corresponding to your installed version oflibxml2 and
libxslt. Note that to install it you will need both libxml2and libxslt
installed and run "python setup.py build install" in themodule tree.</li>
</ul>
<p>The distribution includes a set of examples and regression tests for
thepython bindings in the <code>python/tests</code>directory. Here are
someexcerpts from those tests:</p>
<h3>tst.py:</h3>
<p>This is a basic test of the file interface and DOM navigation:</p>
<pre>import libxml2, sys
doc = libxml2.parseFile("tst.xml")
if doc.name != "tst.xml":
print "doc.name failed"
sys.exit(1)
root = doc.children
if root.name != "doc":
print "root.name failed"
sys.exit(1)
child = root.children
if child.name != "foo":
print "child.name failed"
sys.exit(1)
doc.freeDoc()</pre>
<p>The Python module is called libxml2; parseFile is the equivalent
ofxmlParseFile (most of the bindings are automatically generated, and the
xmlprefix is removed and the casing convention are kept). All node seen at
thebinding level share the same subset of accessors:</p>
<ul>
<li><code>name</code>: returns the node name</li>
<li><code>type</code>: returns a string indicating the node type</li>
<li><code>content</code>: returns the content of the node, it is based
onxmlNodeGetContent() and hence is recursive.</li>
<li><code>parent</code>, <code>children</code>,
<code>last</code>,<code>next</code>, <code>prev</code>,
<code>doc</code>,<code>properties</code>: pointing to the associated
element in the tree,those may return None in case no such link
exists.</li>
</ul>
<p>Also note the need to explicitly deallocate documents with freeDoc()
.Reference counting for libxml2 trees would need quite a lot of work
tofunction properly, and rather than risk memory leaks if not
implementedcorrectly it sounds safer to have an explicit function to free a
tree. Thewrapper python objects like doc, root or child are them
automatically garbagecollected.</p>
<h3>validate.py:</h3>
<p>This test check the validation interfaces and redirection of
errormessages:</p>
<pre>import libxml2
#deactivate error messages from the validation
def noerr(ctx, str):
pass
libxml2.registerErrorHandler(noerr, None)
ctxt = libxml2.createFileParserCtxt("invalid.xml")
ctxt.validate(1)
ctxt.parseDocument()
doc = ctxt.doc()
valid = ctxt.isValid()
doc.freeDoc()
if valid != 0:
print "validity check failed"</pre>
<p>The first thing to notice is the call to registerErrorHandler(), itdefines
a new error handler global to the library. It is used to avoid seeingthe
error messages when trying to validate the invalid document.</p>
<p>The main interest of that test is the creation of a parser context
withcreateFileParserCtxt() and how the behaviour can be changed before
callingparseDocument() . Similarly the informations resulting from the
parsing phaseare also available using context methods.</p>
<p>Contexts like nodes are defined as class and the libxml2 wrappers maps
theC function interfaces in terms of objects method as much as possible.
Thebest to get a complete view of what methods are supported is to look at
thelibxml2.py module containing all the wrappers.</p>
<h3>push.py:</h3>
<p>This test show how to activate the push parser interface:</p>
<pre>import libxml2
ctxt = libxml2.createPushParser(None, "<foo", 4, "test.xml")
ctxt.parseChunk("/>", 2, 1)
doc = ctxt.doc()
doc.freeDoc()</pre>
<p>The context is created with a special call based on
thexmlCreatePushParser() from the C library. The first argument is an
optionalSAX callback object, then the initial set of data, the length and the
name ofthe resource in case URI-References need to be computed by the
parser.</p>
<p>Then the data are pushed using the parseChunk() method, the last
callsetting the third argument terminate to 1.</p>
<h3>pushSAX.py:</h3>
<p>this test show the use of the event based parsing interfaces. In this
casethe parser does not build a document, but provides callback information
asthe parser makes progresses analyzing the data being provided:</p>
<pre>import libxml2
log = ""
class callback:
def startDocument(self):
global log
log = log + "startDocument:"
def endDocument(self):
global log
log = log + "endDocument:"
def startElement(self, tag, attrs):
global log
log = log + "startElement %s %s:" % (tag, attrs)
def endElement(self, tag):
global log
log = log + "endElement %s:" % (tag)
def characters(self, data):
global log
log = log + "characters: %s:" % (data)
def warning(self, msg):
global log
log = log + "warning: %s:" % (msg)
def error(self, msg):
global log
log = log + "error: %s:" % (msg)
def fatalError(self, msg):
global log
log = log + "fatalError: %s:" % (msg)
handler = callback()
ctxt = libxml2.createPushParser(handler, "<foo", 4, "test.xml")
chunk = " url='tst'>b"
ctxt.parseChunk(chunk, len(chunk), 0)
chunk = "ar</foo>"
ctxt.parseChunk(chunk, len(chunk), 1)
reference = "startDocument:startElement foo {'url': 'tst'}:" + \
"characters: bar:endElement foo:endDocument:"
if log != reference:
print "Error got: %s" % log
print "Expected: %s" % reference</pre>
<p>The key object in that test is the handler, it provides a number of
entrypoints which can be called by the parser as it makes progresses to
indicatethe information set obtained. The full set of callback is larger than
whatthe callback class in that specific example implements (see the
SAXdefinition for a complete list). The wrapper will only call those supplied
bythe object when activated. The startElement receives the names of the
elementand a dictionary containing the attributes carried by this element.</p>
<p>Also note that the reference string generated from the callback shows
asingle character call even though the string "bar" is passed to the
parserfrom 2 different call to parseChunk()</p>
<h3>xpath.py:</h3>
<p>This is a basic test of XPath wrappers support</p>
<pre>import libxml2
doc = libxml2.parseFile("tst.xml")
ctxt = doc.xpathNewContext()
res = ctxt.xpathEval("//*")
if len(res) != 2:
print "xpath query: wrong node set size"
sys.exit(1)
if res[0].name != "doc" or res[1].name != "foo":
print "xpath query: wrong node set value"
sys.exit(1)
doc.freeDoc()
ctxt.xpathFreeContext()</pre>
<p>This test parses a file, then create an XPath context to evaluate
XPathexpression on it. The xpathEval() method execute an XPath query and
returnsthe result mapped in a Python way. String and numbers are natively
converted,and node sets are returned as a tuple of libxml2 Python nodes
wrappers. Likethe document, the XPath context need to be freed explicitly,
also not thatthe result of the XPath query may point back to the document
tree and hencethe document must be freed after the result of the query is
used.</p>
<h3>xpathext.py:</h3>
<p>This test shows how to extend the XPath engine with functions written
inpython:</p>
<pre>import libxml2
def foo(ctx, x):
return x + 1
doc = libxml2.parseFile("tst.xml")
ctxt = doc.xpathNewContext()
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
res = ctxt.xpathEval("foo(1)")
if res != 2:
print "xpath extension failure"
doc.freeDoc()
ctxt.xpathFreeContext()</pre>
<p>Note how the extension function is registered with the context (but
thatpart is not yet finalized, this may change slightly in the future).</p>
<h3>tstxpath.py:</h3>
<p>This test is similar to the previous one but shows how the
extensionfunction can access the XPath evaluation context:</p>
<pre>def foo(ctx, x):
global called
#
# test that access to the XPath evaluation contexts
#
pctxt = libxml2.xpathParserContext(_obj=ctx)
ctxt = pctxt.context()
called = ctxt.function()
return x + 1</pre>
<p>All the interfaces around the XPath parser(or rather evaluation)
contextare not finalized, but it should be sufficient to do contextual work
at theevaluation point.</p>
<h3>Memory debugging:</h3>
<p>last but not least, all tests starts with the following prologue:</p>
<pre>#memory debug specific
libxml2.debugMemory(1)</pre>
<p>and ends with the following epilogue:</p>
<pre>#memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()</pre>
<p>Those activate the memory debugging interface of libxml2 where
allallocated block in the library are tracked. The prologue then cleans up
thelibrary state and checks that all allocated memory has been freed. If not
itcalls dumpMemory() which saves that list in a <code>.memdump</code>file.</p>
<h2><a name="architecture">libxml2 architecture</a></h2>
<p>Libxml2 is made of multiple components; some of them are optional, andmost
of the block interfaces are public. The main components are:</p>
<ul>
<li>an Input/Output layer</li>
<li>FTP and HTTP client layers (optional)</li>
<li>an Internationalization layer managing the encodings support</li>
<li>a URI module</li>
<li>the XML parser and its basic SAX interface</li>
<li>an HTML parser using the same SAX interface (optional)</li>
<li>a SAX tree module to build an in-memory DOM representation</li>
<li>a tree module to manipulate the DOM representation</li>
<li>a validation module using the DOM representation (optional)</li>
<li>an XPath module for global lookup in a DOM representation(optional)</li>
<li>a debug module (optional)</li>
</ul>
<p>Graphically this gives the following:</p>
<p><img src="libxml.gif" alt="a graphical view of the various"></p>
<p></p>
<h2><a name="tree">The tree output</a></h2>
<p>The parser returns a tree built during the document analysis. The
valuereturned is an <strong>xmlDocPtr</strong>(i.e., a pointer to
an<strong>xmlDoc</strong>structure). This structure contains information
suchas the file name, the document type, and a
<strong>children</strong>pointerwhich is the root of the document (or more
exactly the first child under theroot which is the document). The tree is
made of <strong>xmlNode</strong>s,chained in double-linked lists of siblings
and with a children<->parentrelationship. An xmlNode can also carry
properties (a chain of xmlAttrstructures). An attribute may have a value
which is a list of TEXT orENTITY_REF nodes.</p>
<p>Here is an example (erroneous with respect to the XML spec since
thereshould be only one ELEMENT under the root):</p>
<p><img src="structure.gif" alt=" structure.gif "></p>
<p>In the source package there is a small program (not installed by
default)called <strong>xmllint</strong>which parses XML files given as
argument andprints them back as parsed. This is useful for detecting errors
both in XMLcode and in the XML parser itself. It has an option
<strong>--debug</strong>which prints the actual in-memory structure of the
document; here is theresult with the <a href="#example">example</a>given
before:</p>
<pre>DOCUMENT
version=1.0
standalone=true
ELEMENT EXAMPLE
ATTRIBUTE prop1
TEXT
content=gnome is great
ATTRIBUTE prop2
ENTITY_REF
TEXT
content= linux too
ELEMENT head
ELEMENT title
TEXT
content=Welcome to Gnome
ELEMENT chapter
ELEMENT title
TEXT
content=The Linux adventure
ELEMENT p
TEXT
content=bla bla bla ...
ELEMENT image
ATTRIBUTE href
TEXT
content=linus.gif
ELEMENT p
TEXT
content=...</pre>
<p>This should be useful for learning the internal representation model.</p>
<h2><a name="interface">The SAX interface</a></h2>
<p>Sometimes the DOM tree output is just too large to fit reasonably
intomemory. In that case (and if you don't expect to save back the XML
documentloaded using libxml), it's better to use the SAX interface of libxml.
SAX isa <strong>callback-based interface</strong>to the parser. Before
parsing,the application layer registers a customized set of callbacks which
arecalled by the library as it progresses through the XML input.</p>
<p>To get more detailed step-by-step guidance on using the SAX interface
oflibxml, see the <a
href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">nicedocumentation</a>.written
by <a href="mailto:james@daa.com.au">JamesHenstridge</a>.</p>
<p>You can debug the SAX behaviour by using the
<strong>testSAX</strong>program located in the gnome-xml module (it's usually
not shipped in thebinary packages of libxml, but you can find it in the tar
sourcedistribution). Here is the sequence of callbacks that would be reported
bytestSAX when parsing the example XML document shown earlier:</p>
<pre>SAX.setDocumentLocator()
SAX.startDocument()
SAX.getEntity(amp)
SAX.startElement(EXAMPLE, prop1='gnome is great', prop2='&amp; linux too')
SAX.characters( , 3)
SAX.startElement(head)
SAX.characters( , 4)
SAX.startElement(title)
SAX.characters(Welcome to Gnome, 16)
SAX.endElement(title)
SAX.characters( , 3)
SAX.endElement(head)
SAX.characters( , 3)
SAX.startElement(chapter)
SAX.characters( , 4)
SAX.startElement(title)
SAX.characters(The Linux adventure, 19)
SAX.endElement(title)
SAX.characters( , 4)
SAX.startElement(p)
SAX.characters(bla bla bla ..., 15)
SAX.endElement(p)
SAX.characters( , 4)
SAX.startElement(image, href='linus.gif')
SAX.endElement(image)
SAX.characters( , 4)
SAX.startElement(p)
SAX.characters(..., 3)
SAX.endElement(p)
SAX.characters( , 3)
SAX.endElement(chapter)
SAX.characters( , 1)
SAX.endElement(EXAMPLE)
SAX.endDocument()</pre>
<p>Most of the other interfaces of libxml2 are based on the DOM
tree-buildingfacility, so nearly everything up to the end of this document
presupposes theuse of the standard DOM tree build. Note that the DOM tree
itself is built bya set of registered default callbacks, without internal
specificinterface.</p>
<h2><a name="Validation">Validation & DTDs</a></h2>
<p>Table of Content:</p>
<ol>
<li><a href="#General5">General overview</a></li>
<li><a href="#definition">The definition</a></li>
<li><a href="#Simple">Simple rules</a>
<ol>
<li><a href="#reference">How to reference a DTD from a document</a></li>
<li><a href="#Declaring">Declaring elements</a></li>
<li><a href="#Declaring1">Declaring attributes</a></li>
</ol>
</li>
<li><a href="#Some">Some examples</a></li>
<li><a href="#validate">How to validate</a></li>
<li><a href="#Other">Other resources</a></li>
</ol>
<h3><a name="General5">General overview</a></h3>
<p>Well what is validation and what is a DTD ?</p>
<p>DTD is the acronym for Document Type Definition. This is a description
ofthe content for a family of XML files. This is part of the XML
1.0specification, and allows one to describe and verify that a given
documentinstance conforms to the set of rules detailing its structure and
content.</p>
<p>Validation is the process of checking a document against a DTD
(moregenerally against a set of construction rules).</p>
<p>The validation process and building DTDs are the two most difficult
partsof the XML life cycle. Briefly a DTD defines all the possible elements
to befound within your document, what is the formal shape of your document
tree(by defining the allowed content of an element; either text, a
regularexpression for the allowed list of children, or mixed content i.e.
both textand children). The DTD also defines the valid attributes for all
elements andthe types of those attributes.</p>
<h3><a name="definition1">The definition</a></h3>
<p>The <a href="http://www.w3.org/TR/REC-xml">W3C XML Recommendation</a>(<a
href="http://www.xml.com/axml/axml.html">Tim Bray's annotated version
ofRev1</a>):</p>
<ul>
<li><a
href="http://www.w3.org/TR/REC-xml#elemdecls">Declaringelements</a></li>
<li><a
href="http://www.w3.org/TR/REC-xml#attdecls">Declaringattributes</a></li>
</ul>
<p>(unfortunately) all this is inherited from the SGML world, the syntax
isancient...</p>
<h3><a name="Simple1">Simple rules</a></h3>
<p>Writing DTDs can be done in many ways. The rules to build them if you
needsomething permanent or something which can evolve over time can be
radicallydifferent. Really complex DTDs like DocBook ones are flexible but
quiteharder to design. I will just focus on DTDs for a formats with a fixed
simplestructure. It is just a set of basic rules, and definitely not
exhaustive norusable for complex DTD design.</p>
<h4><a name="reference1">How to reference a DTD from a document</a>:</h4>
<p>Assuming the top element of the document is <code>spec</code>and the dtdis
placed in the file <code>mydtd</code>in the subdirectory<code>dtds</code>of
the directory from where the document were loaded:</p>
<p><code><!DOCTYPE spec SYSTEM "dtds/mydtd"></code></p>
<p>Notes:</p>
<ul>
<li>The system string is actually an URI-Reference (as defined in <a
href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>) so you can use
afull URL string indicating the location of your DTD on the Web. This is
areally good thing to do if you want others to validate your
document.</li>
<li>It is also possible to associate a <code>PUBLIC</code>identifier
(amagic string) so that the DTD is looked up in catalogs on the client
sidewithout having to locate it on the web.</li>
<li>A DTD contains a set of element and attribute declarations, but
theydon't define what the root of the document should be. This is
explicitlytold to the parser/validator as the first element of
the<code>DOCTYPE</code>declaration.</li>
</ul>
<h4><a name="Declaring2">Declaring elements</a>:</h4>
<p>The following declares an element <code>spec</code>:</p>
<p><code><!ELEMENT spec (front, body, back?)></code></p>
<p>It also expresses that the spec element contains one
<code>front</code>,one <code>body</code>and one optional
<code>back</code>children elements inthis order. The declaration of one
element of the structure and its contentare done in a single declaration.
Similarly the following declares<code>div1</code>elements:</p>
<p><code><!ELEMENT div1 (head, (p | list | note)*, div2?)></code></p>
<p>which means div1 contains one <code>head</code>then a series of
optional<code>p</code>, <code>list</code>s and <code>note</code>s and then
anoptional <code>div2</code>. And last but not least an element can
containtext:</p>
<p><code><!ELEMENT b (#PCDATA)></code></p>
<p><code>b</code>contains text or being of mixed content (text and elementsin
no particular order):</p>
<p><code><!ELEMENT p (#PCDATA|a|ul|b|i|em)*></code></p>
<p><code>p </code>can contain text or <code>a</code>,
<code>ul</code>,<code>b</code>, <code>i </code>or <code>em</code>elements in
no particularorder.</p>
<h4><a name="Declaring1">Declaring attributes</a>:</h4>
<p>Again the attributes declaration includes their content definition:</p>
<p><code><!ATTLIST termdef name CDATA #IMPLIED></code></p>
<p>means that the element <code>termdef</code>can have a
<code>name</code>attribute containing text (<code>CDATA</code>) and which is
optional(<code>#IMPLIED</code>). The attribute value can also be defined
within aset:</p>
<p><code><!ATTLIST list type
(bullets|ordered|glossary)"ordered"></code></p>
<p>means <code>list</code>element have a <code>type</code>attribute with
3allowed values "bullets", "ordered" or "glossary" and which default
to"ordered" if the attribute is not explicitly specified.</p>
<p>The content type of an attribute can be text
(<code>CDATA</code>),anchor/reference/references(<code>ID</code>/<code>IDREF</code>/<code>IDREFS</code>),
entity(ies)(<code>ENTITY</code>/<code>ENTITIES</code>) or
name(s)(<code>NMTOKEN</code>/<code>NMTOKENS</code>). The following defines
that a<code>chapter</code>element can have an optional
<code>id</code>attributeof type <code>ID</code>, usable for reference from
attribute of typeIDREF:</p>
<p><code><!ATTLIST chapter id ID #IMPLIED></code></p>
<p>The last value of an attribute definition can be
<code>#REQUIRED</code>meaning that the attribute has to be given,
<code>#IMPLIED</code>meaning that it is optional, or the default value
(possibly prefixed by<code>#FIXED</code>if it is the only allowed).</p>
<p>Notes:</p>
<ul>
<li>Usually the attributes pertaining to a given element are declared in
asingle expression, but it is just a convention adopted by a lot of
DTDwriters:
<pre><!ATTLIST termdef
id ID #REQUIRED
name CDATA #IMPLIED></pre>
<p>The previous construct defines both
<code>id</code>and<code>name</code>attributes for the element
<code>termdef</code>.</p>
</li>
</ul>
<h3><a name="Some1">Some examples</a></h3>
<p>The directory <code>test/valid/dtds/</code>in the libxml2
distributioncontains some complex DTD examples. The example in the
file<code>test/valid/dia.xml</code>shows an XML file where the simple DTD
isdirectly included within the document.</p>
<h3><a name="validate1">How to validate</a></h3>
<p>The simplest way is to use the xmllint program included with libxml.
The<code>--valid</code>option turns-on validation of the files given as
input.For example the following validates a copy of the first revision of the
XML1.0 specification:</p>
<p><code>xmllint --valid --noout test/valid/REC-xml-19980210.xml</code></p>
<p>the -- noout is used to disable output of the resulting tree.</p>
<p>The <code>--dtdvalid dtd</code>allows validation of the document(s)against
a given DTD.</p>
<p>Libxml2 exports an API to handle DTDs and validation, check the <a
href="http://xmlsoft.org/html/libxml-valid.html">associateddescription</a>.</p>
<h3><a name="Other1">Other resources</a></h3>
<p>DTDs are as old as SGML. So there may be a number of examples on-line,
Iwill just list one for now, others pointers welcome:</p>
<ul>
<li><a href="http://www.xml101.com:8081/dtd/">XML-101 DTD</a></li>
</ul>
<p>I suggest looking at the examples found under test/valid/dtd and any ofthe
large number of books available on XML. The dia example in test/validshould
be both simple and complete enough to allow you to build your own.</p>
<p></p>
<h2><a name="Memory">Memory Management</a></h2>
<p>Table of Content:</p>
<ol>
<li><a href="#General3">General overview</a></li>
<li><a href="#setting">Setting libxml2 set of memory routines</a></li>
<li><a href="#cleanup">Cleaning up after parsing</a></li>
<li><a href="#Debugging">Debugging routines</a></li>
<li><a href="#General4">General memory requirements</a></li>
</ol>
<h3><a name="General3">General overview</a></h3>
<p>The module <code><a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlmemory.h</a></code>provides
the interfaces to the libxml2 memory system:</p>
<ul>
<li>libxml2 does not use the libc memory allocator directly but
xmlFree(),xmlMalloc() and xmlRealloc()</li>
<li>those routines can be reallocated to a specific set of routine,
bydefault the libc ones i.e. free(), malloc() and realloc()</li>
<li>the xmlmemory.c module includes a set of debugging routine</li>
</ul>
<h3><a name="setting">Setting libxml2 set of memory routines</a></h3>
<p>It is sometimes useful to not use the default memory allocator, either
fordebugging, analysis or to implement a specific behaviour on memory
management(like on embedded systems). Two function calls are available to do
so:</p>
<ul>
<li><a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemGet()</a>which
return the current set of functions in use by the parser</li>
<li><a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemSetup()</a>which
allow to set up a new set of memory allocation functions</li>
</ul>
<p>Of course a call to xmlMemSetup() should probably be done before
callingany other libxml2 routines (unless you are sure your allocations
routines arecompatibles).</p>
<h3><a name="cleanup">Cleaning up after parsing</a></h3>
<p>Libxml2 is not stateless, there is a few set of memory structures
needingallocation before the parser is fully functional (some encoding
structuresfor example). This also mean that once parsing is finished there is
a tinyamount of memory (a few hundred bytes) which can be recollected if you
don'treuse the parser immediately:</p>
<ul>
<li><a
href="http://xmlsoft.org/html/libxml-parser.html">xmlCleanupParser()</a>is
a centralized routine to free the parsing states. Note that itwon't
deallocate any produced tree if any (use the xmlFreeDoc() andrelated
routines for this).</li>
<li><a
href="http://xmlsoft.org/html/libxml-parser.html">xmlInitParser()</a>is
the dual routine allowing to preallocate the parsing statewhich can be
useful for example to avoid initialization reentrancyproblems when using
libxml2 in multithreaded applications</li>
</ul>
<p>Generally xmlCleanupParser() is safe, if needed the state will be
rebuildat the next invocation of parser routines, but be careful of the
consequencesin multithreaded applications.</p>
<h3><a name="Debugging">Debugging routines</a></h3>
<p>When configured using --with-mem-debug flag (off by default), libxml2
usesa set of memory allocation debugging routines keeping track of all
allocatedblocks and the location in the code where the routine was called. A
couple ofother debugging routines allow to dump the memory allocated infos to
a fileor call a specific routine when a given block number is allocated:</p>
<ul>
<li><a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMallocLoc()</a><a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlReallocLoc()</a>and
<a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemStrdupLoc()</a>are
the memory debugging replacement allocation routines</li>
<li><a
href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemoryDump()</a>dumps
all the informations about the allocated memory block leftsin the
<code>.memdump</code>file</li>
</ul>
<p>When developing libxml2 memory debug is enabled, the tests programs
callxmlMemoryDump () and the "make test" regression tests will check for
anymemory leak during the full regression test sequence, this helps a
lotensuring that libxml2 does not leak memory and bullet proof
memoryallocations use (some libc implementations are known to be far too
permissiveresulting in major portability problems!).</p>
<p>If the .memdump reports a leak, it displays the allocation function
andalso tries to give some informations about the content and structure of
theallocated blocks left. This is sufficient in most cases to find the
culprit,but not always. Assuming the allocation problem is reproducible, it
ispossible to find more easily:</p>
<ol>
<li>write down the block number xxxx not allocated</li>
<li>export the environment variable XML_MEM_BREAKPOINT=xxxx , the
easiestwhen using GDB is to simply give the command
<p><code>set environment XML_MEM_BREAKPOINT xxxx</code></p>
<p>before running the program.</p>
</li>
<li>run the program under a debugger and set a breakpoint
onxmlMallocBreakpoint() a specific function called when this precise
blockis allocated</li>
<li>when the breakpoint is reached you can then do a fine analysis of
theallocation an step to see the condition resulting in the
missingdeallocation.</li>
</ol>
<p>I used to use a commercial tool to debug libxml2 memory problems but
afternoticing that it was not detecting memory leaks that simple mechanism
wasused and proved extremely efficient until now. Lately I have also used <a
href="http://developer.kde.org/~sewardj/">valgrind</a>with quite somesuccess,
it is tied to the i386 architecture since it works by emulating theprocessor
and instruction set, it is slow but extremely efficient, i.e. itspot memory
usage errors in a very precise way.</p>
<h3><a name="General4">General memory requirements</a></h3>
<p>How much libxml2 memory require ? It's hard to tell in average it
dependsof a number of things:</p>
<ul>
<li>the parser itself should work in a fixed amount of memory, except
forinformation maintained about the stacks of names and entities
locations.The I/O and encoding handlers will probably account for a few
KBytes.This is true for both the XML and HTML parser (though the HTML
parserneed more state).</li>
<li>If you are generating the DOM tree then memory requirements will
grownearly linear with the size of the data. In general for a
balancedtextual document the internal memory requirement is about 4 times
thesize of the UTF8 serialization of this document (example the
XML-1.0recommendation is a bit more of 150KBytes and takes 650KBytes of
mainmemory when parsed). Validation will add a amount of memory required
formaintaining the external Dtd state which should be linear with
thecomplexity of the content model defined by the Dtd</li>
<li>If you need to work with fixed memory requirements or don't need
thefull DOM tree then using the <a
href="xmlreader.html">xmlReaderinterface</a>is probably the best way to
proceed, it still allows tovalidate or operate on subset of the tree if
needed.</li>
<li>If you don't care about the advanced features of libxml2
likevalidation, DOM, XPath or XPointer, don't use entities, need to work
withfixed memory requirements, and try to get the fastest parsing
possiblethen the SAX interface should be used, but it has known
restrictions.</li>
</ul>
<p></p>
<h2><a name="Encodings">Encodings support</a></h2>
<p>If you are not really familiar with Internationalization (usual shortcutis
I18N) , Unicode, characters and glyphs, I suggest you read a <a
href="http://www.tbray.org/ongoing/When/200x/2003/04/06/Unicode">presentation</a>by
Tim Bray on Unicode and why you should care about it.</p>
<p>If you don't understand why <b>it does not make sense to have a
stringwithout knowing what encoding it uses</b>, then as Joel Spolsky said <a
href="http://www.joelonsoftware.com/articles/Unicode.html">please do notwrite
another line of code until you finish reading that article.</a>. It isa
prerequisite to understand this page, and avoid a lot of problems
withlibxml2, XML or text processing in general.</p>
<p>Table of Content:</p>
<ol>
<li><a href="encoding.html#What">What does internationalization supportmean
?</a></li>
<li><a href="encoding.html#internal">The internal encoding, how
andwhy</a></li>
<li><a href="encoding.html#implemente">How is it implemented ?</a></li>
<li><a href="encoding.html#Default">Default supported encodings</a></li>
<li><a href="encoding.html#extend">How to extend the
existingsupport</a></li>
</ol>
<h3><a name="What">What does internationalization support mean ?</a></h3>
<p>XML was designed from the start to allow the support of any character
setby using Unicode. Any conformant XML parser has to support the UTF-8
andUTF-16 default encodings which can both express the full unicode ranges.
UTF8is a variable length encoding whose greatest points are to reuse the
sameencoding for ASCII and to save space for Western encodings, but it is a
bitmore complex to handle in practice. UTF-16 use 2 bytes per character
(andsometimes combines two pairs), it makes implementation easier, but looks
abit overkill for Western languages encoding. Moreover the XML
specificationallows the document to be encoded in other encodings at the
condition thatthey are clearly labeled as such. For example the following is
a wellformedXML document encoded in ISO-8859-1 and using accentuated letters
that weFrench like for both markup and content:</p>
<pre><?xml version="1.0" encoding="ISO-8859-1"?>
<très>là</très></pre>
<p>Having internationalization support in libxml2 means the following:</p>
<ul>
<li>the document is properly parsed</li>
<li>informations about it's encoding are saved</li>
<li>it can be modified</li>
<li>it can be saved in its original encoding</li>
<li>it can also be saved in another encoding supported by libxml2
(forexample straight UTF8 or even an ASCII form)</li>
</ul>
<p>Another very important point is that the whole libxml2 API, with
theexception of a few routines to read with a specific encoding or save to
aspecific encoding, is completely agnostic about the original encoding of
thedocument.</p>
<p>It should be noted too that the HTML parser embedded in libxml2 now
obeythe same rules too, the following document will be (as of 2.2.2) handled
inan internationalized fashion by libxml2 too:</p>
<pre><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="fr">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
</head>
<body>
<p>W3C crée des standards pour le Web.</body>
</html></pre>
<h3><a name="internal">The internal encoding, how and why</a></h3>
<p>One of the core decisions was to force all documents to be converted to
adefault internal encoding, and that encoding to be UTF-8, here are
therationales for those choices:</p>
<ul>
<li>keeping the native encoding in the internal form would force the
libxmlusers (or the code associated) to be fully aware of the encoding of
theoriginal document, for examples when adding a text node to a
document,the content would have to be provided in the document encoding,
i.e. theclient code would have to check it before hand, make sure it's
conformantto the encoding, etc ... Very hard in practice, though in some
specificcases this may make sense.</li>
<li>the second decision was which encoding. From the XML spec only UTF8
andUTF16 really makes sense as being the two only encodings for which
thereis mandatory support. UCS-4 (32 bits fixed size encoding) could
beconsidered an intelligent choice too since it's a direct Unicode
mappingsupport. I selected UTF-8 on the basis of efficiency and
compatibilitywith surrounding software:
<ul>
<li>UTF-8 while a bit more complex to convert from/to (i.e.
slightlymore costly to import and export CPU wise) is also far more
compactthan UTF-16 (and UCS-4) for a majority of the documents I see
it usedfor right now (RPM RDF catalogs, advogato data, various
configurationfile formats, etc.) and the key point for today's
computerarchitecture is efficient uses of caches. If one nearly
double thememory requirement to store the same amount of data, this
will trashcaches (main memory/external caches/internal caches) and my
take isthat this harms the system far more than the CPU requirements
neededfor the conversion to UTF-8</li>
<li>Most of libxml2 version 1 users were using it with straight
ASCIImost of the time, doing the conversion with an internal
encodingrequiring all their code to be rewritten was a serious
show-stopperfor using UTF-16 or UCS-4.</li>
<li>UTF-8 is being used as the de-facto internal encoding standard
forrelated code like the <a
href="http://www.pango.org/">pango</a>upcoming Gnome text widget, and
a lot of Unix code (yet another placewhere Unix programmer base takes
a different approach from Microsoft- they are using UTF-16)</li>
</ul>
</li>
</ul>
<p>What does this mean in practice for the libxml2 user:</p>
<ul>
<li>xmlChar, the libxml2 data type is a byte, those bytes must be
assembledas UTF-8 valid strings. The proper way to terminate an xmlChar *
stringis simply to append 0 byte, as usual.</li>
<li>One just need to make sure that when using chars outside the ASCII
set,the values has been properly converted to UTF-8</li>
</ul>
<h3><a name="implemente">How is it implemented ?</a></h3>
<p>Let's describe how all this works within libxml, basically the
I18N(internationalization) support get triggered only during I/O operation,
i.e.when reading a document or saving one. Let's look first at the
readingsequence:</p>
<ol>
<li>when a document is processed, we usually don't know the encoding,
asimple heuristic allows to detect UTF-16 and UCS-4 from encodings
wherethe ASCII range (0-0x7F) maps with ASCII</li>
<li>the xml declaration if available is parsed, including the
encodingdeclaration. At that point, if the autodetected encoding is
differentfrom the one declared a call to xmlSwitchEncoding() is
issued.</li>
<li>If there is no encoding declaration, then the input has to be in
eitherUTF-8 or UTF-16, if it is not then at some point when processing
theinput, the converter/checker of UTF-8 form will raise an encoding
error.You may end-up with a garbled document, or no document at all !
Example:
<pre>~/XML -> ./xmllint err.xml
err.xml:1: error: Input is not proper UTF-8, indicate encoding !
<très>là</très>
^
err.xml:1: error: Bytes: 0xE8 0x73 0x3E 0x6C
<très>là</très>
^</pre>
</li>
<li>xmlSwitchEncoding() does an encoding name lookup, canonicalize it,
andthen search the default registered encoding converters for that
encoding.If it's not within the default set and iconv() support has been
compiledit, it will ask iconv for such an encoder. If this fails then the
parserwill report an error and stops processing:
<pre>~/XML -> ./xmllint err2.xml
err2.xml:1: error: Unsupported encoding UnsupportedEnc
<?xml version="1.0" encoding="UnsupportedEnc"?>
^</pre>
</li>
<li>From that point the encoder processes progressively the input (it
isplugged as a front-end to the I/O module) for that entity. It
capturesand converts on-the-fly the document to be parsed to UTF-8. The
parseritself just does UTF-8 checking of this input and process
ittransparently. The only difference is that the encoding information
hasbeen added to the parsing context (more precisely to the
inputcorresponding to this entity).</li>
<li>The result (when using DOM) is an internal form completely in UTF-8with
just an encoding information on the document node.</li>
</ol>
<p>Ok then what happens when saving the document (assuming youcollected/built
an xmlDoc DOM like structure) ? It depends on the functioncalled,
xmlSaveFile() will just try to save in the original encoding,
whilexmlSaveFileTo() and xmlSaveFileEnc() can optionally save to a
givenencoding:</p>
<ol>
<li>if no encoding is given, libxml2 will look for an encoding
valueassociated to the document and if it exists will try to save to
thatencoding,
<p>otherwise everything is written in the internal form, i.e. UTF-8</p>
</li>
<li>so if an encoding was specified, either at the API level or on
thedocument, libxml2 will again canonicalize the encoding name, lookup
for aconverter in the registered set or through iconv. If not found
thefunction will return an error code</li>
<li>the converter is placed before the I/O buffer layer, as another kind
ofbuffer, then libxml2 will simply push the UTF-8 serialization to
throughthat buffer, which will then progressively be converted and pushed
ontothe I/O layer.</li>
<li>It is possible that the converter code fails on some input, for
exampletrying to push an UTF-8 encoded Chinese character through the
UTF-8 toISO-8859-1 converter won't work. Since the encoders are
progressive theywill just report the error and the number of bytes
converted, at thatpoint libxml2 will decode the offending character,
remove it from thebuffer and replace it with the associated charRef
encoding &#123; andresume the conversion. This guarantees that any
document will be savedwithout losses (except for markup names where this
is not legal, this isa problem in the current version, in practice avoid
using non-asciicharacters for tag or attribute names). A special "ascii"
encoding nameis used to save documents to a pure ascii form can be used
whenportability is really crucial</li>
</ol>
<p>Here are a few examples based on the same test document:</p>
<pre>~/XML -> ./xmllint isolat1
<?xml version="1.0" encoding="ISO-8859-1"?>
<très>là</très>
~/XML -> ./xmllint --encode UTF-8 isolat1
<?xml version="1.0" encoding="UTF-8"?>
<très>là </très>
~/XML -> </pre>
<p>The same processing is applied (and reuse most of the code) for HTML
I18Nprocessing. Looking up and modifying the content encoding is a bit
moredifficult since it is located in a <meta> tag under the
<head>,so a couple of functions htmlGetMetaEncoding() and
htmlSetMetaEncoding() havebeen provided. The parser also attempts to switch
encoding on the fly whendetecting such a tag on input. Except for that the
processing is the same(and again reuses the same code).</p>
<h3><a name="Default">Default supported encodings</a></h3>
<p>libxml2 has a set of default converters for the following
encodings(located in encoding.c):</p>
<ol>
<li>UTF-8 is supported by default (null handlers)</li>
<li>UTF-16, both little and big endian</li>
<li>ISO-Latin-1 (ISO-8859-1) covering most western languages</li>
<li>ASCII, useful mostly for saving</li>
<li>HTML, a specific handler for the conversion of UTF-8 to ASCII with
HTMLpredefined entities like &copy; for the Copyright sign.</li>
</ol>
<p>More over when compiled on an Unix platform with iconv support the fullset
of encodings supported by iconv can be instantly be used by libxml. On alinux
machine with glibc-2.1 the list of supported encodings and aliases fill3 full
pages, and include UCS-4, the full set of ISO-Latin encodings, and thevarious
Japanese ones.</p>
<p>To convert from the UTF-8 values returned from the API to another
encodingthen it is possible to use the function provided from <a
href="html/libxml-encoding.html">the encoding module</a>like <a
href="html/libxml-encoding.html#UTF8Toisolat1">UTF8Toisolat1</a>, or use
thePOSIX <a
href="http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html">iconv()</a>API
directly.</p>
<h4>Encoding aliases</h4>
<p>From 2.2.3, libxml2 has support to register encoding names aliases.
Thegoal is to be able to parse document whose encoding is supported but
wherethe name differs (for example from the default set of names accepted
byiconv). The following functions allow to register and handle new aliases
forexisting encodings. Once registered libxml2 will automatically lookup
thealiases when handling a document:</p>
<ul>
<li>int xmlAddEncodingAlias(const char *name, const char *alias);</li>
<li>int xmlDelEncodingAlias(const char *alias);</li>
<li>const char * xmlGetEncodingAlias(const char *alias);</li>
<li>void xmlCleanupEncodingAliases(void);</li>
</ul>
<h3><a name="extend">How to extend the existing support</a></h3>
<p>Well adding support for new encoding, or overriding one of the
encoders(assuming it is buggy) should not be hard, just write input and
outputconversion routines to/from UTF-8, and register them
usingxmlNewCharEncodingHandler(name, xxxToUTF8, UTF8Toxxx), and they will
becalled automatically if the parser(s) encounter such an encoding
name(register it uppercase, this will help). The description of the
encoders,their arguments and expected return values are described in the
encoding.hheader.</p>
<h2><a name="IO">I/O Interfaces</a></h2>
<p>Table of Content:</p>
<ol>
<li><a href="#General1">General overview</a></li>
<li><a href="#basic">The basic buffer type</a></li>
<li><a href="#Input">Input I/O handlers</a></li>
<li><a href="#Output">Output I/O handlers</a></li>
<li><a href="#entities">The entities loader</a></li>
<li><a href="#Example2">Example of customized I/O</a></li>
</ol>
<h3><a name="General1">General overview</a></h3>
<p>The module <code><a
href="http://xmlsoft.org/html/libxml-xmlio.html">xmlIO.h</a></code>providesthe
interfaces to the libxml2 I/O system. This consists of 4 main parts:</p>
<ul>
<li>Entities loader, this is a routine which tries to fetch the
entities(files) based on their PUBLIC and SYSTEM identifiers. The default
loaderdon't look at the public identifier since libxml2 do not maintain
acatalog. You can redefine you own entity loader by
using<code>xmlGetExternalEntityLoader()</code>and<code>xmlSetExternalEntityLoader()</code>.
<a href="#entities">Check theexample</a>.</li>
<li>Input I/O buffers which are a commodity structure used by the
parser(s)input layer to handle fetching the informations to feed the
parser. Thisprovides buffering and is also a placeholder where the
encodingconverters to UTF8 are piggy-backed.</li>
<li>Output I/O buffers are similar to the Input ones and fulfill
similartask but when generating a serialization from a tree.</li>
<li>A mechanism to register sets of I/O callbacks and associate them
withspecific naming schemes like the protocol part of the URIs.
<p>This affect the default I/O operations and allows to use specific
I/Ohandlers for certain names.</p>
</li>
</ul>
<p>The general mechanism used when loading http://rpmfind.net/xml.html
forexample in the HTML parser is the following:</p>
<ol>
<li>The default entity loader calls
<code>xmlNewInputFromFile()</code>withthe parsing context and the URI
string.</li>
<li>the URI string is checked against the existing registered handlersusing
their match() callback function, if the HTTP module was compiledin, it is
registered and its match() function will succeeds</li>
<li>the open() function of the handler is called and if successful
willreturn an I/O Input buffer</li>
<li>the parser will the start reading from this buffer and
progressivelyfetch information from the resource, calling the read()
function of thehandler until the resource is exhausted</li>
<li>if an encoding change is detected it will be installed on the
inputbuffer, providing buffering and efficient use of the
conversionroutines</li>
<li>once the parser has finished, the close() function of the handler
iscalled once and the Input buffer and associated resources
aredeallocated.</li>
</ol>
<p>The user defined callbacks are checked first to allow overriding of
thedefault libxml2 I/O routines.</p>
<h3><a name="basic">The basic buffer type</a></h3>
<p>All the buffer manipulation handling is done using
the<code>xmlBuffer</code>type define in <code><a
href="http://xmlsoft.org/html/libxml-tree.html">tree.h</a></code>which is
aresizable memory buffer. The buffer allocation strategy can be selected to
beeither best-fit or use an exponential doubling one (CPU vs. memory
usetrade-off). The values are
<code>XML_BUFFER_ALLOC_EXACT</code>and<code>XML_BUFFER_ALLOC_DOUBLEIT</code>,
and can be set individually or on asystem wide basis using
<code>xmlBufferSetAllocationScheme()</code>. A numberof functions allows to
manipulate buffers with names starting with
the<code>xmlBuffer...</code>prefix.</p>
<h3><a name="Input">Input I/O handlers</a></h3>
<p>An Input I/O handler is a simple
structure<code>xmlParserInputBuffer</code>containing a context associated to
theresource (file descriptor, or pointer to a protocol handler), the read()
andclose() callbacks to use and an xmlBuffer. And extra xmlBuffer and a
charsetencoding handler are also present to support charset conversion
whenneeded.</p>
<h3><a name="Output">Output I/O handlers</a></h3>
<p>An Output handler <code>xmlOutputBuffer</code>is completely similar to
anInput one except the callbacks are write() and close().</p>
<h3><a name="entities">The entities loader</a></h3>
<p>The entity loader resolves requests for new entities and create inputs
forthe parser. Creating an input from a filename or an URI string is
donethrough the xmlNewInputFromFile() routine. The default entity loader do
nothandle the PUBLIC identifier associated with an entity (if any). So it
justcalls xmlNewInputFromFile() with the SYSTEM identifier (which is
mandatory inXML).</p>
<p>If you want to hook up a catalog mechanism then you simply need tooverride
the default entity loader, here is an example:</p>
<pre>#include <libxml/xmlIO.h>
xmlExternalEntityLoader defaultLoader = NULL;
xmlParserInputPtr
xmlMyExternalEntityLoader(const char *URL, const char *ID,
xmlParserCtxtPtr ctxt) {
xmlParserInputPtr ret;
const char *fileID = NULL;
/* lookup for the fileID depending on ID */
ret = xmlNewInputFromFile(ctxt, fileID);
if (ret != NULL)
return(ret);
if (defaultLoader != NULL)
ret = defaultLoader(URL, ID, ctxt);
return(ret);
}
int main(..) {
...
/*
* Install our own entity loader
*/
defaultLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(xmlMyExternalEntityLoader);
...
}</pre>
<h3><a name="Example2">Example of customized I/O</a></h3>
<p>This example come from <a
href="http://xmlsoft.org/messages/0708.html">areal use case</a>,
xmlDocDump() closes the FILE * passed by the applicationand this was a
problem. The <a href="http://xmlsoft.org/messages/0711.html">solution</a>was
to redefine anew output handler with the closing call deactivated:</p>
<ol>
<li>First define a new I/O output allocator where the output don't closethe
file:
<pre>xmlOutputBufferPtr
xmlOutputBufferCreateOwn(FILE *file, xmlCharEncodingHandlerPtr encoder) {
xmlOutputBufferPtr ret;
if (xmlOutputCallbackInitialized == 0)
xmlRegisterDefaultOutputCallbacks();
if (file == NULL) return(NULL);
ret = xmlAllocOutputBuffer(encoder);
if (ret != NULL) {
ret->context = file;
ret->writecallback = xmlFileWrite;
ret->closecallback = NULL; /* No close callback */
}
return(ret);
} </pre>
</li>
<li>And then use it to save the document:
<pre>FILE *f;
xmlOutputBufferPtr output;
xmlDocPtr doc;
int res;
f = ...
doc = ....
output = xmlOutputBufferCreateOwn(f, NULL);
res = xmlSaveFileTo(output, doc, NULL);
</pre>
</li>
</ol>
<h2><a name="Catalog">Catalog support</a></h2>
<p>Table of Content:</p>
<ol>
<li><a href="General2">General overview</a></li>
<li><a href="#definition">The definition</a></li>
<li><a href="#Simple">Using catalogs</a></li>
<li><a href="#Some">Some examples</a></li>
<li><a href="#reference">How to tune catalog usage</a></li>
<li><a href="#validate">How to debug catalog processing</a></li>
<li><a href="#Declaring">How to create and maintain catalogs</a></li>
<li><a href="#implemento">The implementor corner quick review of
theAPI</a></li>
<li><a href="#Other">Other resources</a></li>
</ol>
<h3><a name="General2">General overview</a></h3>
<p>What is a catalog? Basically it's a lookup mechanism used when an entity(a
file or a remote resource) references another entity. The catalog lookupis
inserted between the moment the reference is recognized by the software(XML
parser, stylesheet processing, or even images referenced for inclusionin a
rendering) and the time where loading that resource is actuallystarted.</p>
<p>It is basically used for 3 things:</p>
<ul>
<li>mapping from "logical" names, the public identifiers and a moreconcrete
name usable for download (and URI). For example it can associatethe
logical name
<p>"-//OASIS//DTD DocBook XML V4.1.2//EN"</p>
<p>of the DocBook 4.1.2 XML DTD with the actual URL where it can
bedownloaded</p>
<p>http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd</p>
</li>
<li>remapping from a given URL to another one, like an HTTP
indirectionsaying that
<p>"http://www.oasis-open.org/committes/tr.xsl"</p>
<p>should really be looked at</p>
<p>"http://www.oasis-open.org/committes/entity/stylesheets/base/tr.xsl"</p>
</li>
<li>providing a local cache mechanism allowing to load the
entitiesassociated to public identifiers or remote resources, this is a
reallyimportant feature for any significant deployment of XML or SGML
since itallows to avoid the aleas and delays associated to fetching
remoteresources.</li>
</ul>
<h3><a name="definition">The definitions</a></h3>
<p>Libxml, as of 2.4.3 implements 2 kind of catalogs:</p>
<ul>
<li>the older SGML catalogs, the official spec is SGML Open
TechnicalResolution TR9401:1997, but is better understood by reading <a
href="http://www.jclark.com/sp/catalog.htm">the SP Catalog
page</a>fromJames Clark. This is relatively old and not the preferred
mode ofoperation of libxml.</li>
<li><a
href="http://www.oasis-open.org/committees/entity/spec.html">XMLCatalogs</a>is
far more flexible, more recent, uses an XML syntax andshould scale quite
better. This is the default option of libxml.</li>
</ul>
<p></p>
<h3><a name="Simple">Using catalog</a></h3>
<p>In a normal environment libxml2 will by default check the presence of
acatalog in /etc/xml/catalog, and assuming it has been correctly
populated,the processing is completely transparent to the document user. To
take aconcrete example, suppose you are authoring a DocBook document, this
onestarts with the following DOCTYPE definition:</p>
<pre><?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
"http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"></pre>
<p>When validating the document with libxml, the catalog will beautomatically
consulted to lookup the public identifier "-//Norman Walsh//DTDDocBk XML
V3.1.4//EN" and the system
identifier"http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd", and if these
entities havebeen installed on your system and the catalogs actually point to
them, libxmlwill fetch them from the local disk.</p>
<p style="font-size: 10pt"><strong>Note</strong>: Really don't use
thisDOCTYPE example it's a really old version, but is fine as an example.</p>
<p>Libxml2 will check the catalog each time that it is requested to load
anentity, this includes DTD, external parsed entities, stylesheets, etc ...
Ifyour system is correctly configured all the authoring phase and
processingshould use only local files, even if your document stays portable
because ituses the canonical public and system ID, referencing the remote
document.</p>
<h3><a name="Some">Some examples:</a></h3>
<p>Here is a couple of fragments from XML Catalogs used in libxml2
earlyregression tests in <code>test/catalogs</code>:</p>
<pre><?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC
"-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/>
...</pre>
<p>This is the beginning of a catalog for DocBook 4.1.2, XML Catalogs
arewritten in XML, there is a specific namespace for catalog
elements"urn:oasis:names:tc:entity:xmlns:xml:catalog". The first entry in
thiscatalog is a <code>public</code>mapping it allows to associate a
PublicIdentifier with an URI.</p>
<pre>...
<rewriteSystem systemIdStartString="http://www.oasis-open.org/docbook/"
rewritePrefix="file:///usr/share/xml/docbook/"/>
...</pre>
<p>A <code>rewriteSystem</code>is a very powerful instruction, it says
thatany URI starting with a given prefix should be looked at another
URIconstructed by replacing the prefix with an new one. In effect this acts
likea cache system for a full area of the Web. In practice it is extremely
usefulwith a file prefix if you have installed a copy of those resources on
yourlocal system.</p>
<pre>...
<delegatePublic publicIdStartString="-//OASIS//DTD XML Catalog //"
catalog="file:///usr/share/xml/docbook.xml"/>
<delegatePublic publicIdStartString="-//OASIS//ENTITIES DocBook XML"
catalog="file:///usr/share/xml/docbook.xml"/>
<delegatePublic publicIdStartString="-//OASIS//DTD DocBook XML"
catalog="file:///usr/share/xml/docbook.xml"/>
<delegateSystem systemIdStartString="http://www.oasis-open.org/docbook/"
catalog="file:///usr/share/xml/docbook.xml"/>
<delegateURI uriStartString="http://www.oasis-open.org/docbook/"
catalog="file:///usr/share/xml/docbook.xml"/>
...</pre>
<p>Delegation is the core features which allows to build a tree of
catalogs,easier to maintain than a single catalog, based on Public
Identifier, SystemIdentifier or URI prefixes it instructs the catalog
software to look upentries in another resource. This feature allow to build
hierarchies ofcatalogs, the set of entries presented should be sufficient to
redirect theresolution of all DocBook references to the specific catalog
in<code>/usr/share/xml/docbook.xml</code>this one in turn could delegate
allreferences for DocBook 4.2.1 to a specific catalog installed at the same
timeas the DocBook resources on the local machine.</p>
<h3><a name="reference">How to tune catalog usage:</a></h3>
<p>The user can change the default catalog behaviour by redirecting queriesto
its own set of catalogs, this can be done by setting
the<code>XML_CATALOG_FILES</code>environment variable to a list of catalogs,
anempty one should deactivate loading the default
<code>/etc/xml/catalog</code>default catalog</p>
<h3><a name="validate">How to debug catalog processing:</a></h3>
<p>Setting up the <code>XML_DEBUG_CATALOG</code>environment variable willmake
libxml2 output debugging informations for each catalog operations,
forexample:</p>
<pre>orchis:~/XML -> xmllint --memory --noout test/ent2
warning: failed to load external entity "title.xml"
orchis:~/XML -> export XML_DEBUG_CATALOG=
orchis:~/XML -> xmllint --memory --noout test/ent2
Failed to parse catalog /etc/xml/catalog
Failed to parse catalog /etc/xml/catalog
warning: failed to load external entity "title.xml"
Catalogs cleanup
orchis:~/XML -> </pre>
<p>The test/ent2 references an entity, running the parser from memory
makesthe base URI unavailable and the the "title.xml" entity cannot be
loaded.Setting up the debug environment variable allows to detect that an
attempt ismade to load the <code>/etc/xml/catalog</code>but since it's not
present theresolution fails.</p>
<p>But the most advanced way to debug XML catalog processing is to use
the<strong>xmlcatalog</strong>command shipped with libxml2, it allows to
loadcatalogs and make resolution queries to see what is going on. This is
alsoused for the regression tests:</p>
<pre>orchis:~/XML -> ./xmlcatalog test/catalogs/docbook.xml \
"-//OASIS//DTD DocBook XML V4.1.2//EN"
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
orchis:~/XML -> </pre>
<p>For debugging what is going on, adding one -v flags increase the
verbositylevel to indicate the processing done (adding a second flag also
indicatewhat elements are recognized at parsing):</p>
<pre>orchis:~/XML -> ./xmlcatalog -v test/catalogs/docbook.xml \
"-//OASIS//DTD DocBook XML V4.1.2//EN"
Parsing catalog test/catalogs/docbook.xml's content
Found public match -//OASIS//DTD DocBook XML V4.1.2//EN
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
Catalogs cleanup
orchis:~/XML -> </pre>
<p>A shell interface is also available to debug and process multiple
queries(and for regression tests):</p>
<pre>orchis:~/XML -> ./xmlcatalog -shell test/catalogs/docbook.xml \
"-//OASIS//DTD DocBook XML V4.1.2//EN"
> help
Commands available:
public PublicID: make a PUBLIC identifier lookup
system SystemID: make a SYSTEM identifier lookup
resolve PublicID SystemID: do a full resolver lookup
add 'type' 'orig' 'replace' : add an entry
del 'values' : remove values
dump: print the current catalog state
debug: increase the verbosity level
quiet: decrease the verbosity level
exit: quit the shell
> public "-//OASIS//DTD DocBook XML V4.1.2//EN"
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
> quit
orchis:~/XML -> </pre>
<p>This should be sufficient for most debugging purpose, this was
actuallyused heavily to debug the XML Catalog implementation itself.</p>
<h3><a name="Declaring">How to create and maintain</a>catalogs:</h3>
<p>Basically XML Catalogs are XML files, you can either use XML tools
tomanage them or use <strong>xmlcatalog</strong>for this. The basic step
isto create a catalog the -create option provide this facility:</p>
<pre>orchis:~/XML -> ./xmlcatalog --create tst.xml
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/>
orchis:~/XML -> </pre>
<p>By default xmlcatalog does not overwrite the original catalog and save
theresult on the standard output, this can be overridden using the
-nooutoption. The <code>-add</code>command allows to add entries in
thecatalog:</p>
<pre>orchis:~/XML -> ./xmlcatalog --noout --create --add "public" \
"-//OASIS//DTD DocBook XML V4.1.2//EN" \
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd tst.xml
orchis:~/XML -> cat tst.xml
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" \
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/>
</catalog>
orchis:~/XML -> </pre>
<p>The <code>-add</code>option will always take 3 parameters even if some
ofthe XML Catalog constructs (like nextCatalog) will have only a
singleargument, just pass a third empty string, it will be ignored.</p>
<p>Similarly the <code>-del</code>option remove matching entries from
thecatalog:</p>
<pre>orchis:~/XML -> ./xmlcatalog --del \
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" tst.xml
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/>
orchis:~/XML -> </pre>
<p>The catalog is now empty. Note that the matching of
<code>-del</code>isexact and would have worked in a similar fashion with the
Public IDstring.</p>
<p>This is rudimentary but should be sufficient to manage a not too
complexcatalog tree of resources.</p>
<h3><a name="implemento">The implementor corner quick review of
theAPI:</a></h3>
<p>First, and like for every other module of libxml, there is anautomatically
generated <a href="html/libxml-catalog.html">API page forcatalog
support</a>.</p>
<p>The header for the catalog interfaces should be included as:</p>
<pre>#include <libxml/catalog.h></pre>
<p>The API is voluntarily kept very simple. First it is not obvious
thatapplications really need access to it since it is the default behaviour
oflibxml2 (Note: it is possible to completely override libxml2 default
catalogby using <a
href="html/libxml-parser.html">xmlSetExternalEntityLoader</a>toplug an
application specific resolver).</p>
<p>Basically libxml2 support 2 catalog lists:</p>
<ul>
<li>the default one, global shared by all the application</li>
<li>a per-document catalog, this one is built if the document uses
the<code>oasis-xml-catalog</code>PIs to specify its own catalog list, it
isassociated to the parser context and destroyed when the parsing
contextis destroyed.</li>
</ul>
<p>the document one will be used first if it exists.</p>
<h4>Initialization routines:</h4>
<p>xmlInitializeCatalog(), xmlLoadCatalog() and xmlLoadCatalogs() should
beused at startup to initialize the catalog, if the catalog should
beinitialized with specific values xmlLoadCatalog() or
xmlLoadCatalogs()should be called before xmlInitializeCatalog() which would
otherwise do adefault initialization first.</p>
<p>The xmlCatalogAddLocal() call is used by the parser to grow the
documentown catalog list if needed.</p>
<h4>Preferences setup:</h4>
<p>The XML Catalog spec requires the possibility to select defaultpreferences
between public and system delegation,xmlCatalogSetDefaultPrefer() allows
this, xmlCatalogSetDefaults() andxmlCatalogGetDefaults() allow to control if
XML Catalogs resolution shouldbe forbidden, allowed for global catalog, for
document catalog or both, thedefault is to allow both.</p>
<p>And of course xmlCatalogSetDebug() allows to generate debug
messages(through the xmlGenericError() mechanism).</p>
<h4>Querying routines:</h4>
<p>xmlCatalogResolve(), xmlCatalogResolveSystem(),
xmlCatalogResolvePublic()and xmlCatalogResolveURI() are relatively explicit
if you read the XMLCatalog specification they correspond to section 7
algorithms, they shouldalso work if you have loaded an SGML catalog with a
simplified semantic.</p>
<p>xmlCatalogLocalResolve() and xmlCatalogLocalResolveURI() are the same
butoperate on the document catalog list</p>
<h4>Cleanup and Miscellaneous:</h4>
<p>xmlCatalogCleanup() free-up the global catalog, xmlCatalogFreeLocal()
isthe per-document equivalent.</p>
<p>xmlCatalogAdd() and xmlCatalogRemove() are used to dynamically modify
thefirst catalog in the global list, and xmlCatalogDump() allows to dump
acatalog state, those routines are primarily designed for xmlcatalog, I'm
notsure that exposing more complex interfaces (like navigation ones) would
bereally useful.</p>
<p>The xmlParseCatalogFile() is a function used to load XML Catalog
files,it's similar as xmlParseFile() except it bypass all catalog lookups,
it'sprovided because this functionality may be useful for client tools.</p>
<h4>threaded environments:</h4>
<p>Since the catalog tree is built progressively, some care has been taken
totry to avoid troubles in multithreaded environments. The code is now
threadsafe assuming that the libxml2 library has been compiled with
threadssupport.</p>
<p></p>
<h3><a name="Other">Other resources</a></h3>
<p>The XML Catalog specification is relatively recent so there isn't
muchliterature to point at:</p>
<ul>
<li>You can find a good rant from Norm Walsh about <a
href="http://www.arbortext.com/Think_Tank/XML_Resources/Issue_Three/issue_three.html">theneed
for catalogs</a>, it provides a lot of context informations even ifI
don't agree with everything presented. Norm also wrote a more
recentarticle <a
href="http://wwws.sun.com/software/xml/developers/resolver/article/">XMLentities
and URI resolvers</a>describing them.</li>
<li>An <a href="http://home.ccil.org/~cowan/XML/XCatalog.html">old
XMLcatalog proposal</a>from John Cowan</li>
<li>The <a href="http://www.rddl.org/">Resource Directory
DescriptionLanguage</a>(RDDL) another catalog system but more oriented
towardproviding metadata for XML namespaces.</li>
<li>the page from the OASIS Technical <a
href="http://www.oasis-open.org/committees/entity/">Committee on
EntityResolution</a>who maintains XML Catalog, you will find pointers to
thespecification update, some background and pointers to others
toolsproviding XML Catalog support</li>
<li>There is a <a href="buildDocBookCatalog">shell script</a>to generateXML
Catalogs for DocBook 4.1.2 . If it can write to the /etc/xml/directory,
it will set-up /etc/xml/catalog and /etc/xml/docbook based onthe
resources found on the system. Otherwise it will just create~/xmlcatalog
and ~/dbkxmlcatalog and doing:
<p><code>export XML_CATALOG_FILES=$HOME/xmlcatalog</code></p>
<p>should allow to process DocBook documentations without
requiringnetwork accesses for the DTD or stylesheets</p>
</li>
<li>I have uploaded <a
href="ftp://xmlsoft.org/libxml2/test/dbk412catalog.tar.gz">asmall
tarball</a>containing XML Catalogs for DocBook 4.1.2 which seemsto work
fine for me too</li>
<li>The <a
href="http://www.xmlsoft.org/xmlcatalog_man.html">xmlcatalogmanual
page</a></li>
</ul>
<p>If you have suggestions for corrections or additions, simply contactme:</p>
<h2><a name="library">The parser interfaces</a></h2>
<p>This section is directly intended to help programmers getting
bootstrappedusing the XML tollkit from the C language. It is not intended to
beextensive. I hope the automatically generated documents will provide
thecompleteness required, but as a separate set of documents. The interfaces
ofthe XML parser are by principle low level, Those interested in a higher
levelAPI should <a href="#DOM">look at DOM</a>.</p>
<p>The <a href="html/libxml-parser.html">parser interfaces for
XML</a>areseparated from the <a href="html/libxml-htmlparser.html">HTML
parserinterfaces</a>. Let's have a look at how the XML parser can be
called:</p>
<h3><a name="Invoking">Invoking the parser : the pull method</a></h3>
<p>Usually, the first thing to do is to read an XML input. The parser
acceptsdocuments either from in-memory strings or from files. The functions
aredefined in "parser.h":</p>
<dl>
<dt><code>xmlDocPtr xmlParseMemory(char *buffer, int size);</code></dt>
<dd><p>Parse a null-terminated string containing the document.</p>
</dd>
</dl>
<dl>
<dt><code>xmlDocPtr xmlParseFile(const char *filename);</code></dt>
<dd><p>Parse an XML document contained in a (possibly compressed)file.</p>
</dd>
</dl>
<p>The parser returns a pointer to the document structure (or NULL in case
offailure).</p>
<h3 id="Invoking1">Invoking the parser: the push method</h3>
<p>In order for the application to keep the control when the document isbeing
fetched (which is common for GUI based programs) libxml2 provides apush
interface, too, as of version 1.8.3. Here are the interfacefunctions:</p>
<pre>xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
void *user_data,
const char *chunk,
int size,
const char *filename);
int xmlParseChunk (xmlParserCtxtPtr ctxt,
const char *chunk,
int size,
int terminate);</pre>
<p>and here is a simple example showing how to use the interface:</p>
<pre> FILE *f;
f = fopen(filename, "r");
if (f != NULL) {
int res, size = 1024;
char chars[1024];
xmlParserCtxtPtr ctxt;
res = fread(chars, 1, 4, f);
if (res > 0) {
ctxt = xmlCreatePushParserCtxt(NULL, NULL,
chars, res, filename);
while ((res = fread(chars, 1, size, f)) > 0) {
xmlParseChunk(ctxt, chars, res, 0);
}
xmlParseChunk(ctxt, chars, 0, 1);
doc = ctxt->myDoc;
xmlFreeParserCtxt(ctxt);
}
}</pre>
<p>The HTML parser embedded into libxml2 also has a push interface;
thefunctions are just prefixed by "html" rather than "xml".</p>
<h3 id="Invoking2">Invoking the parser: the SAX interface</h3>
<p>The tree-building interface makes the parser memory-hungry, first
loadingthe document in memory and then building the tree itself. Reading a
documentwithout building the tree is possible using the SAX interfaces (see
SAX.h and<a
href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">JamesHenstridge's
documentation</a>). Note also that the push interface can belimited to SAX:
just use the two first arguments of<code>xmlCreatePushParserCtxt()</code>.</p>
<h3><a name="Building">Building a tree from scratch</a></h3>
<p>The other way to get an XML tree in memory is by building it.
Basicallythere is a set of functions dedicated to building new elements.
(These arealso described in <libxml/tree.h>.) For example, here is a
piece ofcode that produces the XML document used in the previous examples:</p>
<pre> #include <libxml/tree.h>
xmlDocPtr doc;
xmlNodePtr tree, subtree;
doc = xmlNewDoc("1.0");
doc->children = xmlNewDocNode(doc, NULL, "EXAMPLE", NULL);
xmlSetProp(doc->children, "prop1", "gnome is great");
xmlSetProp(doc->children, "prop2", "& linux too");
tree = xmlNewChild(doc->children, NULL, "head", NULL);
subtree = xmlNewChild(tree, NULL, "title", "Welcome to Gnome");
tree = xmlNewChild(doc->children, NULL, "chapter", NULL);
subtree = xmlNewChild(tree, NULL, "title", "The Linux adventure");
subtree = xmlNewChild(tree, NULL, "p", "bla bla bla ...");
subtree = xmlNewChild(tree, NULL, "image", NULL);
xmlSetProp(subtree, "href", "linus.gif");</pre>
<p>Not really rocket science ...</p>
<h3><a name="Traversing">Traversing the tree</a></h3>
<p>Basically by <a href="html/libxml-tree.html">including
"tree.h"</a>yourcode has access to the internal structure of all the elements
of the tree.The names should be somewhat simple like
<strong>parent</strong>,<strong>children</strong>, <strong>next</strong>,
<strong>prev</strong>,<strong>properties</strong>, etc... For example, still
with the previousexample:</p>
<pre><code>doc->children->children->children</code></pre>
<p>points to the title element,</p>
<pre>doc->children->children->next->children->children</pre>
<p>points to the text node containing the chapter title "The
Linuxadventure".</p>
<p><strong>NOTE</strong>: XML allows <em>PI</em>s and <em>comments</em>to
bepresent before the document root, so <code>doc->children</code>may
pointto an element which is not the document Root Element; a
function<code>xmlDocGetRootElement()</code>was added for this purpose.</p>
<h3><a name="Modifying">Modifying the tree</a></h3>
<p>Functions are provided for reading and writing the document content.
Hereis an excerpt from the <a href="html/libxml-tree.html">tree API</a>:</p>
<dl>
<dt><code>xmlAttrPtr xmlSetProp(xmlNodePtr node, const xmlChar *name,
constxmlChar *value);</code></dt>
<dd><p>This sets (or changes) an attribute carried by an ELEMENT node.The
value can be NULL.</p>
</dd>
</dl>
<dl>
<dt><code>const xmlChar *xmlGetProp(xmlNodePtr node, const
xmlChar*name);</code></dt>
<dd><p>This function returns a pointer to new copy of the
propertycontent. Note that the user must deallocate the result.</p>
</dd>
</dl>
<p>Two functions are provided for reading and writing the text associatedwith
elements:</p>
<dl>
<dt><code>xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const
xmlChar*value);</code></dt>
<dd><p>This function takes an "external" string and converts it to
onetext node or possibly to a list of entity and text nodes.
Allnon-predefined entity references like &Gnome; will be
storedinternally as entity nodes, hence the result of the function may
not bea single node.</p>
</dd>
</dl>
<dl>
<dt><code>xmlChar *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list,
intinLine);</code></dt>
<dd><p>This function is the inverse
of<code>xmlStringGetNodeList()</code>. It generates a new
stringcontaining the content of the text and entity nodes. Note the
extraargument inLine. If this argument is set to 1, the function will
expandentity references. For example, instead of returning the
&Gnome;XML encoding in the string, it will substitute it with its
value (say,"GNU Network Object Model Environment").</p>
</dd>
</dl>
<h3><a name="Saving">Saving a tree</a></h3>
<p>Basically 3 options are possible:</p>
<dl>
<dt><code>void xmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem,
int*size);</code></dt>
<dd><p>Returns a buffer into which the document has been saved.</p>
</dd>
</dl>
<dl>
<dt><code>extern void xmlDocDump(FILE *f, xmlDocPtr doc);</code></dt>
<dd><p>Dumps a document to an open file descriptor.</p>
</dd>
</dl>
<dl>
<dt><code>int xmlSaveFile(const char *filename, xmlDocPtr cur);</code></dt>
<dd><p>Saves the document to a file. In this case, the
compressioninterface is triggered if it has been turned on.</p>
</dd>
</dl>
<h3><a name="Compressio">Compression</a></h3>
<p>The library transparently handles compression when doing
file-basedaccesses. The level of compression on saves can be turned on either
globallyor individually for one file:</p>
<dl>
<dt><code>int xmlGetDocCompressMode (xmlDocPtr doc);</code></dt>
<dd><p>Gets the document compression ratio (0-9).</p>
</dd>
</dl>
<dl>
<dt><code>void xmlSetDocCompressMode (xmlDocPtr doc, int mode);</code></dt>
<dd><p>Sets the document compression ratio.</p>
</dd>
</dl>
<dl>
<dt><code>int xmlGetCompressMode(void);</code></dt>
<dd><p>Gets the default compression ratio.</p>
</dd>
</dl>
<dl>
<dt><code>void xmlSetCompressMode(int mode);</code></dt>
<dd><p>Sets the default compression ratio.</p>
</dd>
</dl>
<h2><a name="Entities">Entities or no entities</a></h2>
<p>Entities in principle are similar to simple C macros. An entity defines
anabbreviation for a given string that you can reuse many times throughout
thecontent of your document. Entities are especially useful when a given
stringmay occur frequently within a document, or to confine the change needed
to adocument to a restricted area in the internal subset of the document (at
thebeginning). Example:</p>
<pre>1 <?xml version="1.0"?>
2 <!DOCTYPE EXAMPLE SYSTEM "example.dtd" [
3 <!ENTITY xml "Extensible Markup Language">
4 ]>
5 <EXAMPLE>
6 &xml;
7 </EXAMPLE></pre>
<p>Line 3 declares the xml entity. Line 6 uses the xml entity, by
prefixingits name with '&' and following it by ';' without any spaces
added. Thereare 5 predefined entities in libxml2 allowing you to escape
characters withpredefined meaning in some parts of the xml document
content:<strong>&lt;</strong>for the character '<',
<strong>&gt;</strong>for the character '>',
<strong>&apos;</strong>for the character
''',<strong>&quot;</strong>for the character '"',
and<strong>&amp;</strong>for the character '&'.</p>
<p>One of the problems related to entities is that you may want the parser
tosubstitute an entity's content so that you can see the replacement text
inyour application. Or you may prefer to keep entity references as such in
thecontent to be able to save the document back without losing this
usuallyprecious information (if the user went through the pain of
explicitlydefining entities, he may have a a rather negative attitude if you
blindlysubstitute them as saving time). The <a
href="html/libxml-parser.html#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault()</a>function
allows you to check and change the behaviour, which is to notsubstitute
entities by default.</p>
<p>Here is the DOM tree built by libxml2 for the previous document in
thedefault case:</p>
<pre>/gnome/src/gnome-xml -> ./xmllint --debug test/ent1
DOCUMENT
version=1.0
ELEMENT EXAMPLE
TEXT
content=
ENTITY_REF
INTERNAL_GENERAL_ENTITY xml
content=Extensible Markup Language
TEXT
content=</pre>
<p>And here is the result when substituting entities:</p>
<pre>/gnome/src/gnome-xml -> ./tester --debug --noent test/ent1
DOCUMENT
version=1.0
ELEMENT EXAMPLE
TEXT
content= Extensible Markup Language</pre>
<p>So, entities or no entities? Basically, it depends on your use case.
Isuggest that you keep the non-substituting default behaviour and avoid
usingentities in your XML document or data if you are not willing to handle
theentity references elements in the DOM tree.</p>
<p>Note that at save time libxml2 enforces the conversion of the
predefinedentities where necessary to prevent well-formedness problems, and
will alsotransparently replace those with chars (i.e. it will not generate
entityreference elements in the DOM tree or call the reference() SAX callback
whenfinding them in the input).</p>
<p><span style="background-color: #FF0000">WARNING</span>: handling
entitieson top of the libxml2 SAX interface is difficult!!! If you plan to
usenon-predefined entities in your documents, then the learning curve to
handlethen using the SAX API may be long. If you plan to use complex
documents, Istrongly suggest you consider using the DOM interface instead and
let libxmldeal with the complexity rather than trying to do it yourself.</p>
<h2><a name="Namespaces">Namespaces</a></h2>
<p>The libxml2 library implements <a
href="http://www.w3.org/TR/REC-xml-names/">XML namespaces</a>support
byrecognizing namespace constructs in the input, and does namespace
lookupautomatically when building the DOM tree. A namespace declaration
isassociated with an in-memory structure and all elements or attributes
withinthat namespace point to it. Hence testing the namespace is a simple and
fastequality operation at the user level.</p>
<p>I suggest that people using libxml2 use a namespace, and declare it in
theroot element of their document as the default namespace. Then they don't
needto use the prefix in the content but we will have a basis for future
semanticrefinement and merging of data from different sources. This doesn't
increasethe size of the XML output significantly, but significantly increases
itsvalue in the long-term. Example:</p>
<pre><mydoc xmlns="http://mydoc.example.org/schemas/">
<elem1>...</elem1>
<elem2>...</elem2>
</mydoc></pre>
<p>The namespace value has to be an absolute URL, but the URL doesn't have
topoint to any existing resource on the Web. It will bind all the element
andattributes with that URL. I suggest to use an URL within a domain
youcontrol, and that the URL should contain some kind of version information
ifpossible. For example, <code>"http://www.gnome.org/gnumeric/1.0/"</code>is
agood namespace scheme.</p>
<p>Then when you load a file, make sure that a namespace carrying
theversion-independent prefix is installed on the root element of your
document,and if the version information don't match something you know, warn
the userand be liberal in what you accept as the input. Also do *not* try to
basenamespace checking on the prefix value. <foo:text> may be exactly
thesame as <bar:text> in another document. What really matters is the
URIassociated with the element or the attribute, not the prefix string (which
isjust a shortcut for the full URI). In libxml, element and attributes have
an<code>ns</code>field pointing to an xmlNs structure detailing the
namespaceprefix and its URI.</p>
<p>@@Interfaces@@</p>
<pre>xmlNodePtr node;
if(!strncmp(node->name,"mytag",5)
&& node->ns
&& !strcmp(node->ns->href,"http://www.mysite.com/myns/1.0")) {
...
}</pre>
<p>Usually people object to using namespaces together with validity
checking.I will try to make sure that using namespaces won't break validity
checking,so even if you plan to use or currently are using validation I
stronglysuggest adding namespaces to your document. A default namespace
scheme<code>xmlns="http://...."</code>should not break validity even on
lessflexible parsers. Using namespaces to mix and differentiate content
comingfrom multiple DTDs will certainly break current validation schemes. To
checksuch documents one needs to use schema-validation, which is supported
inlibxml2 as well. See <a href="http://www.relaxng.org/">relagx-ng</a>and <a
href="http://www.w3c.org/XML/Schema">w3c-schema</a>.</p>
<h2><a name="Upgrading">Upgrading 1.x code</a></h2>
<p>Incompatible changes:</p>
<p>Version 2 of libxml2 is the first version introducing serious
backwardincompatible changes. The main goals were:</p>
<ul>
<li>a general cleanup. A number of mistakes inherited from the very
earlyversions couldn't be changed due to compatibility constraints.
Examplethe "childs" element in the nodes.</li>
<li>Uniformization of the various nodes, at least for their header and
linkparts (doc, parent, children, prev, next), the goal is a
simplerprogramming model and simplifying the task of the DOM
implementors.</li>
<li>better conformances to the XML specification, for example version
1.xhad an heuristic to try to detect ignorable white spaces. As a result
theSAX event generated were ignorableWhitespace() while the spec
requirescharacter() in that case. This also mean that a number of DOM
nodecontaining blank text may populate the DOM tree which were not
presentbefore.</li>
</ul>
<h3>How to fix libxml-1.x code:</h3>
<p>So client code of libxml designed to run with version 1.x may have to
bechanged to compile against version 2.x of libxml. Here is a list of
changesthat I have collected, they may not be sufficient, so in case you find
otherchange which are required, <a href="mailto:Daniel.Veillard@w3.org">drop
me amail</a>:</p>
<ol>
<li>The package name have changed from libxml to libxml2, the library
nameis now -lxml2 . There is a new xml2-config script which should be
used toselect the right parameters libxml2</li>
<li>Node <strong>childs</strong>field has been
renamed<strong>children</strong>so s/childs/children/g should be
applied(probability of having "childs" anywhere else is close to 0+</li>
<li>The document don't have anymore a <strong>root</strong>element it
hasbeen replaced by <strong>children</strong>and usually you will get
alist of element here. For example a Dtd element for the internal
subsetand it's declaration may be found in that list, as well as
processinginstructions or comments found before or after the document
root element.Use <strong>xmlDocGetRootElement(doc)</strong>to get the
root element ofa document. Alternatively if you are sure to not reference
DTDs nor havePIs or comments before or after the root
elements/->root/->children/g will probably do it.</li>
<li>The white space issue, this one is more complex, unless special case
ofvalidating parsing, the line breaks and spaces usually used for
indentingand formatting the document content becomes significant. So they
arereported by SAX and if your using the DOM tree, corresponding nodes
aregenerated. Too approach can be taken:
<ol>
<li>lazy one, use the compatibility
call<strong>xmlKeepBlanksDefault(0)</strong>but be aware that you
arerelying on a special (and possibly broken) set of heuristics
oflibxml to detect ignorable blanks. Don't complain if it breaks
ormake your application not 100% clean w.r.t. to it's input.</li>
<li>the Right Way: change you code to accept possibly
insignificantblanks characters, or have your tree populated with
weird blank textnodes. You can spot them using the commodity
function<strong>xmlIsBlankNode(node)</strong>returning 1 for such
blanknodes.</li>
</ol>
<p>Note also that with the new default the output functions don't add
anyextra indentation when saving a tree in order to be able to round
trip(read and save) without inflating the document with extra
formattingchars.</p>
</li>
<li>The include path has changed to $prefix/libxml/ and the
includesthemselves uses this new prefix in includes instructions... If
you areusing (as expected) the
<pre>xml2-config --cflags</pre>
<p>output to generate you compile commands this will probably work out
ofthe box</p>
</li>
<li>xmlDetectCharEncoding takes an extra argument indicating the length
inbyte of the head of the document available for character detection.</li>
</ol>
<h3>Ensuring both libxml-1.x and libxml-2.x compatibility</h3>
<p>Two new version of libxml (1.8.11) and libxml2 (2.3.4) have been
releasedto allow smooth upgrade of existing libxml v1code while
retainingcompatibility. They offers the following:</p>
<ol>
<li>similar include naming, one should
use<strong>#include<libxml/...></strong>in both cases.</li>
<li>similar identifiers defined via macros for the child and root
fields:respectively
<strong>xmlChildrenNode</strong>and<strong>xmlRootNode</strong></li>
<li>a new macro <strong>LIBXML_TEST_VERSION</strong>which should beinserted
once in the client code</li>
</ol>
<p>So the roadmap to upgrade your existing libxml applications is
thefollowing:</p>
<ol>
<li>install the libxml-1.8.8 (and libxml-devel-1.8.8) packages</li>
<li>find all occurrences where the xmlDoc <strong>root</strong>field isused
and change it to <strong>xmlRootNode</strong></li>
<li>similarly find all occurrences where the
xmlNode<strong>childs</strong>field is used and change it
to<strong>xmlChildrenNode</strong></li>
<li>add a <strong>LIBXML_TEST_VERSION</strong>macro somewhere in
your<strong>main()</strong>or in the library init entry point</li>
<li>Recompile, check compatibility, it should still work</li>
<li>Change your configure script to look first for xml2-config and fallback
using xml-config . Use the --cflags and --libs output of the commandas
the Include and Linking parameters needed to use libxml.</li>
<li>install libxml2-2.3.x and libxml2-devel-2.3.x (libxml-1.8.y
andlibxml-devel-1.8.y can be kept simultaneously)</li>
<li>remove your config.cache, relaunch your configuration mechanism,
andrecompile, if steps 2 and 3 were done right it should compile
as-is</li>
<li>Test that your application is still running correctly, if not this
maybe due to extra empty nodes due to formating spaces being kept in
libxml2contrary to libxml1, in that case insert xmlKeepBlanksDefault(1)
in yourcode before calling the parser (next
to<strong>LIBXML_TEST_VERSION</strong>is a fine place).</li>
</ol>
<p>Following those steps should work. It worked for some of my own code.</p>
<p>Let me put some emphasis on the fact that there is far more changes
fromlibxml 1.x to 2.x than the ones you may have to patch for. The overall
codehas been considerably cleaned up and the conformance to the XML
specificationhas been drastically improved too. Don't take those changes as
an excuse tonot upgrade, it may cost a lot on the long term ...</p>
<h2><a name="Thread">Thread safety</a></h2>
<p>Starting with 2.4.7, libxml2 makes provisions to ensure that
concurrentthreads can safely work in parallel parsing different documents.
There ishowever a couple of things to do to ensure it:</p>
<ul>
<li>configure the library accordingly using the --with-threads options</li>
<li>call xmlInitParser() in the "main" thread before using any of
thelibxml2 API (except possibly selecting a different memory
allocator)</li>
</ul>
<p>Note that the thread safety cannot be ensured for multiple threads
sharingthe same document, the locking must be done at the application level,
libxmlexports a basic mutex and reentrant mutexes API in
<libxml/threads.h>.The parts of the library checked for thread safety
are:</p>
<ul>
<li>concurrent loading</li>
<li>file access resolution</li>
<li>catalog access</li>
<li>catalog building</li>
<li>entities lookup/accesses</li>
<li>validation</li>
<li>global variables per-thread override</li>
<li>memory handling</li>
</ul>
<p>XPath is supposed to be thread safe now, but this wasn't
testedseriously.</p>
<h2><a name="DOM"></a><a name="Principles">DOM Principles</a></h2>
<p><a href="http://www.w3.org/DOM/">DOM</a>stands for the <em>DocumentObject
Model</em>; this is an API for accessing XML or HTML structureddocuments.
Native support for DOM in Gnome is on the way (module gnome-dom),and will be
based on gnome-xml. This will be a far cleaner interface tomanipulate XML
files within Gnome since it won't expose the internalstructure.</p>
<p>The current DOM implementation on top of libxml2 is the <a
href="http://cvs.gnome.org/lxr/source/gdome2/">gdome2 Gnome module</a>,
thisis a full DOM interface, thanks to Paolo Casarini, check the <a
href="http://www.cs.unibo.it/~casarini/gdome2/">Gdome2 homepage</a>for
moreinformations.</p>
<h2><a name="Example"></a><a name="real">A real example</a></h2>
<p>Here is a real size example, where the actual content of the
applicationdata is not kept in the DOM tree but uses internal structures. It
is based ona proposal to keep a database of jobs related to Gnome, with an
XML basedstorage structure. Here is an <a href="gjobs.xml">XML encoded
jobsbase</a>:</p>
<pre><?xml version="1.0"?>
<gjob:Helping xmlns:gjob="http://www.gnome.org/some-location">
<gjob:Jobs>
<gjob:Job>
<gjob:Project ID="3"/>
<gjob:Application>GBackup</gjob:Application>
<gjob:Category>Development</gjob:Category>
<gjob:Update>
<gjob:Status>Open</gjob:Status>
<gjob:Modified>Mon, 07 Jun 1999 20:27:45 -0400 MET DST</gjob:Modified>
<gjob:Salary>USD 0.00</gjob:Salary>
</gjob:Update>
<gjob:Developers>
<gjob:Developer>
</gjob:Developer>
</gjob:Developers>
<gjob:Contact>
<gjob:Person>Nathan Clemons</gjob:Person>
<gjob:Email>nathan@windsofstorm.net</gjob:Email>
<gjob:Company>
</gjob:Company>
<gjob:Organisation>
</gjob:Organisation>
<gjob:Webpage>
</gjob:Webpage>
<gjob:Snailmail>
</gjob:Snailmail>
<gjob:Phone>
</gjob:Phone>
</gjob:Contact>
<gjob:Requirements>
The program should be released as free software, under the GPL.
</gjob:Requirements>
<gjob:Skills>
</gjob:Skills>
<gjob:Details>
A GNOME based system that will allow a superuser to configure
compressed and uncompressed files and/or file systems to be backed
up with a supported media in the system. This should be able to
perform via find commands generating a list of files that are passed
to tar, dd, cpio, cp, gzip, etc., to be directed to the tape machine
or via operations performed on the filesystem itself. Email
notification and GUI status display very important.
</gjob:Details>
</gjob:Job>
</gjob:Jobs>
</gjob:Helping></pre>
<p>While loading the XML file into an internal DOM tree is a matter ofcalling
only a couple of functions, browsing the tree to gather the data andgenerate
the internal structures is harder, and more error prone.</p>
<p>The suggested principle is to be tolerant with respect to the
inputstructure. For example, the ordering of the attributes is not
significant,the XML specification is clear about it. It's also usually a good
idea not todepend on the order of the children of a given node, unless it
really makesthings harder. Here is some code to parse the information for a
person:</p>
<pre>/*
* A person record
*/
typedef struct person {
char *name;
char *email;
char *company;
char *organisation;
char *smail;
char *webPage;
char *phone;
} person, *personPtr;
/*
* And the code needed to parse it
*/
personPtr parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
personPtr ret = NULL;
DEBUG("parsePerson\n");
/*
* allocate the struct
*/
ret = (personPtr) malloc(sizeof(person));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
return(NULL);
}
memset(ret, 0, sizeof(person));
/* We don't care what the top level element name is */
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!strcmp(cur->name, "Person")) && (cur->ns == ns))
ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!strcmp(cur->name, "Email")) && (cur->ns == ns))
ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
cur = cur->next;
}
return(ret);
}</pre>
<p>Here are a couple of things to notice:</p>
<ul>
<li>Usually a recursive parsing style is the more convenient one: XML
datais by nature subject to repetitive constructs and usually exhibits
highlystructured patterns.</li>
<li>The two arguments of type <em>xmlDocPtr</em>and <em>xmlNsPtr</em>,i.e.
the pointer to the global XML document and the namespace reserved tothe
application. Document wide information are needed for example todecode
entities and it's a good coding practice to define a namespace foryour
application set of data and test that the element and attributesyou're
analyzing actually pertains to your application space. This isdone by a
simple equality test (cur->ns == ns).</li>
<li>To retrieve text and attributes value, you can use the
function<em>xmlNodeListGetString</em>to gather all the text and entity
referencenodes generated by the DOM output and produce an single text
string.</li>
</ul>
<p>Here is another piece of code used to parse another level of
thestructure:</p>
<pre>#include <libxml/tree.h>
/*
* a Description for a Job
*/
typedef struct job {
char *projectID;
char *application;
char *category;
personPtr contact;
int nbDevelopers;
personPtr developers[100]; /* using dynamic alloc is left as an exercise */
} job, *jobPtr;
/*
* And the code needed to parse it
*/
jobPtr parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
jobPtr ret = NULL;
DEBUG("parseJob\n");
/*
* allocate the struct
*/
ret = (jobPtr) malloc(sizeof(job));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
return(NULL);
}
memset(ret, 0, sizeof(job));
/* We don't care what the top level element name is */
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!strcmp(cur->name, "Project")) && (cur->ns == ns)) {
ret->projectID = xmlGetProp(cur, "ID");
if (ret->projectID == NULL) {
fprintf(stderr, "Project has no ID\n");
}
}
if ((!strcmp(cur->name, "Application")) && (cur->ns == ns))
ret->application = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!strcmp(cur->name, "Category")) && (cur->ns == ns))
ret->category = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!strcmp(cur->name, "Contact")) && (cur->ns == ns))
ret->contact = parsePerson(doc, ns, cur);
cur = cur->next;
}
return(ret);
}</pre>
<p>Once you are used to it, writing this kind of code is quite simple,
butboring. Ultimately, it could be possible to write stubbers taking either
Cdata structure definitions, a set of XML examples or an XML DTD and
producethe code needed to import and export the content between C data and
XMLstorage. This is left as an exercise to the reader :-)</p>
<p>Feel free to use <a href="example/gjobread.c">the code for the full
Cparsing example</a>as a template, it is also available with Makefile in
theGnome CVS base under gnome-xml/example</p>
<h2><a name="Contributi">Contributions</a></h2>
<ul>
<li>Bjorn Reese, William Brack and Thomas Broyer have provided a number
ofpatches, Gary Pennington worked on the validation API, threading
supportand Solaris port.</li>
<li>John Fleck helps maintaining the documentation and man pages.</li>
<li><a href="mailto:igor@zlatkovic.com">Igor Zlatkovic</a>is now
themaintainer of the Windows port, <a
href="http://www.zlatkovic.com/projects/libxml/index.html">he
providesbinaries</a></li>
<li><a href="mailto:Gary.Pennington@sun.com">Gary Pennington</a>provides<a
href="http://garypennington.net/libxml2/">Solaris binaries</a></li>
<li><a
href="http://mail.gnome.org/archives/xml/2001-March/msg00014.html">MattSergeant</a>developed
<a href="http://axkit.org/download/">XML::LibXSLT</a>, a Perl wrapper
forlibxml2/libxslt as part of the <a href="http://axkit.com/">AxKit
XMLapplication server</a></li>
<li><a href="mailto:fnatter@gmx.net">Felix Natter</a>and <a
href="mailto:geertk@ai.rug.nl">Geert Kloosterman</a>provide <a
href="libxml-doc.el">an emacs module</a>to lookup libxml(2)
functionsdocumentation</li>
<li><a href="mailto:sherwin@nlm.nih.gov">Ziying Sherwin</a>provided <a
href="http://xmlsoft.org/messages/0488.html">man pages</a></li>
<li>there is a module for <a
href="http://acs-misc.sourceforge.net/nsxml.html">libxml/libxslt
supportin OpenNSD/AOLServer</a></li>
<li><a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>provided
thefirst version of libxml/libxslt <a
href="http://www.rexx.com/~dkuhlman">wrappers for Python</a></li>
<li>Petr Kozelka provides <a
href="http://sourceforge.net/projects/libxml2-pas">Pascal units to
gluelibxml2</a>with Kylix and Delphi and other Pascal compilers</li>
<li><a href="mailto:aleksey@aleksey.com">Aleksey Sanin</a>implemented the<a
href="http://www.w3.org/Signature/">XML Canonicalization and XMLDigital
Signature</a><a href="http://www.aleksey.com/xmlsec/">implementations for
libxml2</a></li>
<li><a href="mailto:Steve.Ball@explain.com.au">Steve
Ball</a>andcontributors maintain <a
href="http://tclxml.sourceforge.net/">tclbindings for libxml2 and
libxslt</a>, as well as <a
href="http://tclxml.sf.net/tkxmllint.html">tkxmllint</a>a GUI forxmllint
and <a href="http://tclxml.sf.net/tkxsltproc.html">tkxsltproc</a>a GUI
for xsltproc.</li>
</ul>
<p></p>
</body>
</html>
|