Kitxuuu commited on
Commit
d843a8a
·
verified ·
1 Parent(s): 3f1d7ac

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. local-test-libxml2-full-01/afc-libxml2/doc/Makefile.am +28 -0
  2. local-test-libxml2-full-01/afc-libxml2/doc/apibuild.py +1930 -0
  3. local-test-libxml2-full-01/afc-libxml2/doc/libxml2-api.xml +0 -0
  4. local-test-libxml2-full-01/afc-libxml2/doc/meson.build +12 -0
  5. local-test-libxml2-full-01/afc-libxml2/doc/xml2-config.1 +32 -0
  6. local-test-libxml2-full-01/afc-libxml2/doc/xmlcatalog.1 +356 -0
  7. local-test-libxml2-full-01/afc-libxml2/doc/xmlcatalog.html +144 -0
  8. local-test-libxml2-full-01/afc-libxml2/doc/xmlcatalog.xml +475 -0
  9. local-test-libxml2-full-01/afc-libxml2/doc/xmllint.1 +686 -0
  10. local-test-libxml2-full-01/afc-libxml2/doc/xmllint.html +188 -0
  11. local-test-libxml2-full-01/afc-libxml2/doc/xmllint.xml +1045 -0
  12. local-test-libxml2-full-01/afc-libxml2/example/.gitignore +16 -0
  13. local-test-libxml2-full-01/afc-libxml2/example/Makefile.am +44 -0
  14. local-test-libxml2-full-01/afc-libxml2/example/gjobread.c +301 -0
  15. local-test-libxml2-full-01/afc-libxml2/example/gjobs.xml +57 -0
  16. local-test-libxml2-full-01/afc-libxml2/example/icu.c +241 -0
  17. local-test-libxml2-full-01/afc-libxml2/example/io1.c +159 -0
  18. local-test-libxml2-full-01/afc-libxml2/example/io2.c +58 -0
  19. local-test-libxml2-full-01/afc-libxml2/example/meson.build +27 -0
  20. local-test-libxml2-full-01/afc-libxml2/example/parse1.c +48 -0
  21. local-test-libxml2-full-01/afc-libxml2/example/parse2.c +64 -0
  22. local-test-libxml2-full-01/afc-libxml2/example/parse3.c +52 -0
  23. local-test-libxml2-full-01/afc-libxml2/example/parse4.c +135 -0
  24. local-test-libxml2-full-01/afc-libxml2/example/reader1.c +99 -0
  25. local-test-libxml2-full-01/afc-libxml2/example/reader2.c +115 -0
  26. local-test-libxml2-full-01/afc-libxml2/example/reader3.c +111 -0
  27. local-test-libxml2-full-01/afc-libxml2/example/reader4.c +114 -0
  28. local-test-libxml2-full-01/afc-libxml2/example/test1.xml +1 -0
  29. local-test-libxml2-full-01/afc-libxml2/example/test2.xml +13 -0
  30. local-test-libxml2-full-01/afc-libxml2/example/test3.xml +39 -0
  31. local-test-libxml2-full-01/afc-libxml2/example/testWriter.c +1068 -0
  32. local-test-libxml2-full-01/afc-libxml2/example/tree1.c +80 -0
  33. local-test-libxml2-full-01/afc-libxml2/example/tree2.c +107 -0
  34. local-test-libxml2-full-01/afc-libxml2/example/xpath1.c +243 -0
  35. local-test-libxml2-full-01/afc-libxml2/example/xpath2.c +183 -0
  36. local-test-libxml2-full-01/afc-libxml2/include/Makefile.am +5 -0
  37. local-test-libxml2-full-01/afc-libxml2/include/meson.build +2 -0
  38. local-test-libxml2-full-01/afc-libxml2/include/wsockcompat.h +49 -0
  39. local-test-libxml2-full-01/afc-libxml2/m4/ax_append_flag.m4 +50 -0
  40. local-test-libxml2-full-01/afc-libxml2/m4/ax_append_link_flags.m4 +44 -0
  41. local-test-libxml2-full-01/afc-libxml2/m4/ax_check_link_flag.m4 +53 -0
  42. local-test-libxml2-full-01/afc-libxml2/m4/ax_gcc_func_attribute.m4 +242 -0
  43. local-test-libxml2-full-01/afc-libxml2/m4/ax_recursive_eval.m4 +56 -0
  44. local-test-libxml2-full-01/afc-libxml2/m4/ax_require_defined.m4 +37 -0
  45. local-test-libxml2-full-01/afc-libxml2/os400/README400 +226 -0
  46. local-test-libxml2-full-01/afc-libxml2/os400/initscript.sh +315 -0
  47. local-test-libxml2-full-01/afc-libxml2/os400/libxmlmain.c +102 -0
  48. local-test-libxml2-full-01/afc-libxml2/os400/make-bldcsndfa.sh +43 -0
  49. local-test-libxml2-full-01/afc-libxml2/os400/make-include.sh +78 -0
  50. local-test-libxml2-full-01/afc-libxml2/os400/make-rpg.sh +100 -0
local-test-libxml2-full-01/afc-libxml2/doc/Makefile.am ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Process this file with automake to produce Makefile.in
2
+ SUBDIRS = . devhelp
3
+
4
+ nobase_dist_doc_DATA = \
5
+ xmlcatalog.html \
6
+ xmllint.html
7
+
8
+ dist_man_MANS = xml2-config.1 xmllint.1 xmlcatalog.1
9
+
10
+ EXTRA_DIST = \
11
+ apibuild.py \
12
+ libxml2-api.xml \
13
+ xmlcatalog.xml \
14
+ xmllint.xml \
15
+ meson.build
16
+
17
+ DOCBOOK_HTML = http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
18
+
19
+ rebuild:
20
+ cd $(srcdir) && ./apibuild.py
21
+ cd $(srcdir) && $(XSLTPROC) --nonet xmllint.xml
22
+ cd $(srcdir) && $(XSLTPROC) --nonet -o xmllint.html $(DOCBOOK_HTML) xmllint.xml
23
+ cd $(srcdir) && $(XSLTPROC) --nonet xmlcatalog.xml
24
+ cd $(srcdir) && $(XSLTPROC) --nonet -o xmlcatalog.html $(DOCBOOK_HTML) xmlcatalog.xml
25
+ cd devhelp && $(MAKE) rebuild
26
+ cd .. && $(MAKE) rebuild_testapi
27
+
28
+ .PHONY: rebuild
local-test-libxml2-full-01/afc-libxml2/doc/apibuild.py ADDED
@@ -0,0 +1,1930 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ #
3
+ # This is the API builder, it parses the C sources and build the
4
+ # API formal description in XML.
5
+ #
6
+ # See Copyright for the status of this software.
7
+ #
8
9
+ #
10
+ import os, sys
11
+ import string
12
+ import glob
13
+
14
+ debug=0
15
+ #debugsym='ignorableWhitespaceSAXFunc'
16
+ debugsym=None
17
+
18
+ #
19
+ # C parser analysis code
20
+ #
21
+ ignored_files = {
22
+ "config.h": "generated portability layer",
23
+ "libxml.h": "internal only",
24
+ "legacy.c": "legacy code",
25
+ "testModule.c": "test tool",
26
+ "testapi.c": "generated regression tests",
27
+ "runtest.c": "regression tests program",
28
+ "runsuite.c": "regression tests program",
29
+ "tst.c": "not part of the library",
30
+ "test.c": "not part of the library",
31
+ "testdso.c": "test for dynamid shared libraries",
32
+ "testrecurse.c": "test for entities recursions",
33
+ "timsort.h": "Internal header only for xpath.c 2.9.0",
34
+ "nanoftp.h": "empty",
35
+ "SAX.h": "empty",
36
+ }
37
+
38
+ ignored_words = {
39
+ "WINAPI": (0, "Windows keyword"),
40
+ "LIBXML_DLL_IMPORT": (0, "Special macro to flag external keywords"),
41
+ "XMLPUBVAR": (0, "Special macro for extern vars for win32"),
42
+ "XSLTPUBVAR": (0, "Special macro for extern vars for win32"),
43
+ "EXSLTPUBVAR": (0, "Special macro for extern vars for win32"),
44
+ "XMLPUBFUN": (0, "Special macro for extern funcs for win32"),
45
+ "XSLTPUBFUN": (0, "Special macro for extern funcs for win32"),
46
+ "EXSLTPUBFUN": (0, "Special macro for extern funcs for win32"),
47
+ "XSLTCALL": (0, "Special macro for win32 calls"),
48
+ "EXSLTCALL": (0, "Special macro for win32 calls"),
49
+ "__declspec": (3, "Windows keyword"),
50
+ "__stdcall": (0, "Windows keyword"),
51
+ "ATTRIBUTE_UNUSED": (0, "macro keyword"),
52
+ "ATTRIBUTE_DESTRUCTOR": (0, "macro keyword"),
53
+ "LIBEXSLT_PUBLIC": (0, "macro keyword"),
54
+ "X_IN_Y": (5, "macro function builder"),
55
+ "ATTRIBUTE_ALLOC_SIZE": (3, "macro for gcc checking extension"),
56
+ "ATTRIBUTE_PRINTF": (5, "macro for gcc printf args checking extension"),
57
+ "LIBXML_ATTR_FORMAT": (5, "macro for gcc printf args checking extension"),
58
+ "LIBXML_ATTR_ALLOC_SIZE": (3, "macro for gcc checking extension"),
59
+ "ATTRIBUTE_NO_SANITIZE": (3, "macro keyword"),
60
+ "ATTRIBUTE_NO_SANITIZE_INTEGER": (0, "macro keyword"),
61
+ "ATTRIBUTE_COUNTED_BY": (3, "macro keyword"),
62
+ "XML_DEPRECATED": (0, "macro keyword"),
63
+ "XML_DEPRECATED_MEMBER": (0, "macro keyword"),
64
+ "XML_GLOBALS_ALLOC": (0, "macro keyword"),
65
+ "XML_GLOBALS_ERROR": (0, "macro keyword"),
66
+ "XML_GLOBALS_IO": (0, "macro keyword"),
67
+ "XML_GLOBALS_PARSER": (0, "macro keyword"),
68
+ "XML_GLOBALS_TREE": (0, "macro keyword"),
69
+ "XML_THREAD_LOCAL": (0, "macro keyword"),
70
+ }
71
+
72
+ def escape(raw):
73
+ raw = raw.replace('&', '&')
74
+ raw = raw.replace('<', '&lt;')
75
+ raw = raw.replace('>', '&gt;')
76
+ raw = raw.replace("'", '&apos;')
77
+ raw = raw.replace('"', '&quot;')
78
+ return raw
79
+
80
+ class identifier:
81
+ def __init__(self, name, header=None, module=None, type=None, lineno = 0,
82
+ info=None, extra=None, conditionals = None):
83
+ self.name = name
84
+ self.header = header
85
+ self.module = module
86
+ self.type = type
87
+ self.info = info
88
+ self.extra = extra
89
+ self.lineno = lineno
90
+ self.static = 0
91
+ if conditionals == None or len(conditionals) == 0:
92
+ self.conditionals = None
93
+ else:
94
+ self.conditionals = conditionals[:]
95
+ if self.name == debugsym:
96
+ print("=> define %s : %s" % (debugsym, (module, type, info,
97
+ extra, conditionals)))
98
+
99
+ def __repr__(self):
100
+ r = "%s %s:" % (self.type, self.name)
101
+ if self.static:
102
+ r = r + " static"
103
+ if self.module != None:
104
+ r = r + " from %s" % (self.module)
105
+ if self.info != None:
106
+ r = r + " " + repr(self.info)
107
+ if self.extra != None:
108
+ r = r + " " + repr(self.extra)
109
+ if self.conditionals != None:
110
+ r = r + " " + repr(self.conditionals)
111
+ return r
112
+
113
+
114
+ def set_header(self, header):
115
+ self.header = header
116
+ def set_module(self, module):
117
+ self.module = module
118
+ def set_type(self, type):
119
+ self.type = type
120
+ def set_info(self, info):
121
+ self.info = info
122
+ def set_extra(self, extra):
123
+ self.extra = extra
124
+ def set_lineno(self, lineno):
125
+ self.lineno = lineno
126
+ def set_static(self, static):
127
+ self.static = static
128
+ def set_conditionals(self, conditionals):
129
+ if conditionals == None or len(conditionals) == 0:
130
+ self.conditionals = None
131
+ else:
132
+ self.conditionals = conditionals[:]
133
+
134
+ def get_name(self):
135
+ return self.name
136
+ def get_header(self):
137
+ return self.module
138
+ def get_module(self):
139
+ return self.module
140
+ def get_type(self):
141
+ return self.type
142
+ def get_info(self):
143
+ return self.info
144
+ def get_lineno(self):
145
+ return self.lineno
146
+ def get_extra(self):
147
+ return self.extra
148
+ def get_static(self):
149
+ return self.static
150
+ def get_conditionals(self):
151
+ return self.conditionals
152
+
153
+ def update(self, header, module, type = None, info = None, extra=None,
154
+ conditionals=None):
155
+ if self.name == debugsym:
156
+ print("=> update %s : %s" % (debugsym, (module, type, info,
157
+ extra, conditionals)))
158
+ if header != None and self.header == None:
159
+ self.set_header(module)
160
+ if module != None and (self.module == None or self.header == self.module):
161
+ self.set_module(module)
162
+ if type != None and self.type == None:
163
+ self.set_type(type)
164
+ if info != None:
165
+ self.set_info(info)
166
+ if extra != None:
167
+ self.set_extra(extra)
168
+ if conditionals != None:
169
+ self.set_conditionals(conditionals)
170
+
171
+ class index:
172
+ def __init__(self, name = "noname"):
173
+ self.name = name
174
+ self.identifiers = {}
175
+ self.functions = {}
176
+ self.variables = {}
177
+ self.includes = {}
178
+ self.structs = {}
179
+ self.enums = {}
180
+ self.typedefs = {}
181
+ self.macros = {}
182
+ self.references = {}
183
+ self.info = {}
184
+
185
+ def add_ref(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals = None):
186
+ if name[0:2] == '__':
187
+ return None
188
+ d = None
189
+ if name in self.identifiers:
190
+ d = self.identifiers[name]
191
+ d.update(header, module, type, info, extra, conditionals)
192
+ else:
193
+ d = identifier(name, header, module, type, lineno, info, extra, conditionals)
194
+ self.identifiers[name] = d
195
+
196
+ if d != None and static == 1:
197
+ d.set_static(1)
198
+
199
+ if d != None and name != None and type != None:
200
+ self.references[name] = d
201
+
202
+ if name == debugsym:
203
+ print("New ref: %s" % (d))
204
+
205
+ return d
206
+
207
+ def add(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals = None):
208
+ if name[0:2] == '__':
209
+ return None
210
+ d = None
211
+ if name in self.identifiers:
212
+ d = self.identifiers[name]
213
+ d.update(header, module, type, info, extra, conditionals)
214
+ else:
215
+ d = identifier(name, header, module, type, lineno, info, extra, conditionals)
216
+ self.identifiers[name] = d
217
+
218
+ if d != None and static == 1:
219
+ d.set_static(1)
220
+
221
+ if d != None and name != None and type != None:
222
+ if type == "function":
223
+ self.functions[name] = d
224
+ elif type == "functype":
225
+ self.functions[name] = d
226
+ elif type == "variable":
227
+ self.variables[name] = d
228
+ elif type == "include":
229
+ self.includes[name] = d
230
+ elif type == "struct":
231
+ self.structs[name] = d
232
+ elif type == "enum":
233
+ self.enums[name] = d
234
+ elif type == "typedef":
235
+ self.typedefs[name] = d
236
+ elif type == "macro":
237
+ self.macros[name] = d
238
+ else:
239
+ print("Unable to register type ", type)
240
+
241
+ if name == debugsym:
242
+ print("New symbol: %s" % (d))
243
+
244
+ return d
245
+
246
+ def merge(self, idx):
247
+ for id in list(idx.functions.keys()):
248
+ #
249
+ # macro might be used to override functions or variables
250
+ # definitions
251
+ #
252
+ if id in self.macros:
253
+ del self.macros[id]
254
+ if id in self.functions:
255
+ print("function %s from %s redeclared in %s" % (
256
+ id, self.functions[id].header, idx.functions[id].header))
257
+ else:
258
+ self.functions[id] = idx.functions[id]
259
+ self.identifiers[id] = idx.functions[id]
260
+ for id in list(idx.variables.keys()):
261
+ #
262
+ # macro might be used to override functions or variables
263
+ # definitions
264
+ #
265
+ if id in self.macros:
266
+ del self.macros[id]
267
+ if id in self.variables:
268
+ print("variable %s from %s redeclared in %s" % (
269
+ id, self.variables[id].header, idx.variables[id].header))
270
+ else:
271
+ self.variables[id] = idx.variables[id]
272
+ self.identifiers[id] = idx.variables[id]
273
+ for id in list(idx.structs.keys()):
274
+ if id in self.structs:
275
+ print("struct %s from %s redeclared in %s" % (
276
+ id, self.structs[id].header, idx.structs[id].header))
277
+ else:
278
+ self.structs[id] = idx.structs[id]
279
+ self.identifiers[id] = idx.structs[id]
280
+ for id in list(idx.typedefs.keys()):
281
+ if id in self.typedefs:
282
+ print("typedef %s from %s redeclared in %s" % (
283
+ id, self.typedefs[id].header, idx.typedefs[id].header))
284
+ else:
285
+ self.typedefs[id] = idx.typedefs[id]
286
+ self.identifiers[id] = idx.typedefs[id]
287
+ for id in list(idx.macros.keys()):
288
+ #
289
+ # macro might be used to override functions or variables
290
+ # definitions
291
+ #
292
+ if id in self.variables:
293
+ continue
294
+ if id in self.functions:
295
+ continue
296
+ if id in self.enums:
297
+ continue
298
+ if id in self.macros and id != 'XML_OP':
299
+ print("macro %s from %s redeclared in %s" % (
300
+ id, self.macros[id].header, idx.macros[id].header))
301
+ else:
302
+ self.macros[id] = idx.macros[id]
303
+ self.identifiers[id] = idx.macros[id]
304
+ for id in list(idx.enums.keys()):
305
+ if id in self.enums:
306
+ print("enum %s from %s redeclared in %s" % (
307
+ id, self.enums[id].header, idx.enums[id].header))
308
+ else:
309
+ self.enums[id] = idx.enums[id]
310
+ self.identifiers[id] = idx.enums[id]
311
+
312
+ def merge_public(self, idx):
313
+ for id in list(idx.functions.keys()):
314
+ if id in self.functions:
315
+ # check that function condition agrees with header
316
+ if idx.functions[id].conditionals != \
317
+ self.functions[id].conditionals:
318
+ print("Header condition differs from Function for %s:" \
319
+ % id)
320
+ print(" H: %s" % self.functions[id].conditionals)
321
+ print(" C: %s" % idx.functions[id].conditionals)
322
+ up = idx.functions[id]
323
+ self.functions[id].update(None, up.module, up.type, up.info, up.extra)
324
+ # else:
325
+ # print "Function %s from %s is not declared in headers" % (
326
+ # id, idx.functions[id].module)
327
+
328
+ for id in list(idx.variables.keys()):
329
+ if id in self.variables:
330
+ # check that variable condition agrees with header
331
+ # TODO: produces many false positives
332
+ #if idx.variables[id].conditionals != \
333
+ # self.variables[id].conditionals:
334
+ # print("Header condition differs from Variable for %s:" \
335
+ # % id)
336
+ # print(" H: %s" % self.variables[id].conditionals)
337
+ # print(" C: %s" % idx.variables[id].conditionals)
338
+ up = idx.variables[id]
339
+ self.variables[id].update(None, up.module, up.type, up.info, up.extra)
340
+
341
+ def analyze_dict(self, type, dict):
342
+ count = 0
343
+ public = 0
344
+ for name in list(dict.keys()):
345
+ id = dict[name]
346
+ count = count + 1
347
+ if id.static == 0:
348
+ public = public + 1
349
+ if count != public:
350
+ print(" %d %s , %d public" % (count, type, public))
351
+ elif count != 0:
352
+ print(" %d public %s" % (count, type))
353
+
354
+
355
+ def analyze(self):
356
+ self.analyze_dict("functions", self.functions)
357
+ self.analyze_dict("variables", self.variables)
358
+ self.analyze_dict("structs", self.structs)
359
+ self.analyze_dict("typedefs", self.typedefs)
360
+ self.analyze_dict("macros", self.macros)
361
+
362
+ class CLexer:
363
+ """A lexer for the C language, tokenize the input by reading and
364
+ analyzing it line by line"""
365
+ def __init__(self, input):
366
+ self.input = input
367
+ self.tokens = []
368
+ self.line = ""
369
+ self.lineno = 0
370
+
371
+ def getline(self):
372
+ line = ''
373
+ while line == '':
374
+ line = self.input.readline()
375
+ if not line:
376
+ return None
377
+ self.lineno = self.lineno + 1
378
+ line = line.lstrip()
379
+ line = line.rstrip()
380
+ if line == '':
381
+ continue
382
+ while line[-1] == '\\':
383
+ line = line[:-1]
384
+ n = self.input.readline()
385
+ self.lineno = self.lineno + 1
386
+ n = n.lstrip()
387
+ n = n.rstrip()
388
+ if not n:
389
+ break
390
+ else:
391
+ line = line + n
392
+ return line
393
+
394
+ def getlineno(self):
395
+ return self.lineno
396
+
397
+ def push(self, token):
398
+ self.tokens.insert(0, token);
399
+
400
+ def debug(self):
401
+ print("Last token: ", self.last)
402
+ print("Token queue: ", self.tokens)
403
+ print("Line %d end: " % (self.lineno), self.line)
404
+
405
+ def token(self):
406
+ while self.tokens == []:
407
+ if self.line == "":
408
+ line = self.getline()
409
+ else:
410
+ line = self.line
411
+ self.line = ""
412
+ if line == None:
413
+ return None
414
+
415
+ if line[0] == '#':
416
+ self.tokens = list(map((lambda x: ('preproc', x)),
417
+ line.split()))
418
+ break;
419
+ l = len(line)
420
+ if line[0] == '"' or line[0] == "'":
421
+ end = line[0]
422
+ line = line[1:]
423
+ found = 0
424
+ tok = ""
425
+ while found == 0:
426
+ i = 0
427
+ l = len(line)
428
+ while i < l:
429
+ if line[i] == end:
430
+ self.line = line[i+1:]
431
+ line = line[:i]
432
+ l = i
433
+ found = 1
434
+ break
435
+ if line[i] == '\\':
436
+ i = i + 1
437
+ i = i + 1
438
+ tok = tok + line
439
+ if found == 0:
440
+ line = self.getline()
441
+ if line == None:
442
+ return None
443
+ self.last = ('string', tok)
444
+ return self.last
445
+
446
+ if l >= 2 and line[0] == '/' and line[1] == '*':
447
+ line = line[2:]
448
+ found = 0
449
+ tok = ""
450
+ while found == 0:
451
+ i = 0
452
+ l = len(line)
453
+ while i < l:
454
+ if line[i] == '*' and i+1 < l and line[i+1] == '/':
455
+ self.line = line[i+2:]
456
+ line = line[:i-1]
457
+ l = i
458
+ found = 1
459
+ break
460
+ i = i + 1
461
+ if tok != "":
462
+ tok = tok + "\n"
463
+ tok = tok + line
464
+ if found == 0:
465
+ line = self.getline()
466
+ if line == None:
467
+ return None
468
+ self.last = ('comment', tok)
469
+ return self.last
470
+ if l >= 2 and line[0] == '/' and line[1] == '/':
471
+ line = line[2:]
472
+ self.last = ('comment', line)
473
+ return self.last
474
+ i = 0
475
+ while i < l:
476
+ if line[i] == '/' and i+1 < l and line[i+1] == '/':
477
+ self.line = line[i:]
478
+ line = line[:i]
479
+ break
480
+ if line[i] == '/' and i+1 < l and line[i+1] == '*':
481
+ self.line = line[i:]
482
+ line = line[:i]
483
+ break
484
+ if line[i] == '"' or line[i] == "'":
485
+ self.line = line[i:]
486
+ line = line[:i]
487
+ break
488
+ i = i + 1
489
+ l = len(line)
490
+ i = 0
491
+ while i < l:
492
+ if line[i] == ' ' or line[i] == '\t':
493
+ i = i + 1
494
+ continue
495
+ o = ord(line[i])
496
+ if (o >= 97 and o <= 122) or (o >= 65 and o <= 90) or \
497
+ (o >= 48 and o <= 57):
498
+ s = i
499
+ while i < l:
500
+ o = ord(line[i])
501
+ if (o >= 97 and o <= 122) or (o >= 65 and o <= 90) or \
502
+ (o >= 48 and o <= 57) or \
503
+ (" \t(){}:;,+-*/%&!|[]=><".find(line[i])) == -1:
504
+ i = i + 1
505
+ else:
506
+ break
507
+ self.tokens.append(('name', line[s:i]))
508
+ continue
509
+ if "(){}:;,[]".find(line[i]) != -1:
510
+ # if line[i] == '(' or line[i] == ')' or line[i] == '{' or \
511
+ # line[i] == '}' or line[i] == ':' or line[i] == ';' or \
512
+ # line[i] == ',' or line[i] == '[' or line[i] == ']':
513
+ self.tokens.append(('sep', line[i]))
514
+ i = i + 1
515
+ continue
516
+ if "+-*><=/%&!|.".find(line[i]) != -1:
517
+ # if line[i] == '+' or line[i] == '-' or line[i] == '*' or \
518
+ # line[i] == '>' or line[i] == '<' or line[i] == '=' or \
519
+ # line[i] == '/' or line[i] == '%' or line[i] == '&' or \
520
+ # line[i] == '!' or line[i] == '|' or line[i] == '.':
521
+ if line[i] == '.' and i + 2 < l and \
522
+ line[i+1] == '.' and line[i+2] == '.':
523
+ self.tokens.append(('name', '...'))
524
+ i = i + 3
525
+ continue
526
+
527
+ j = i + 1
528
+ if j < l and (
529
+ "+-*><=/%&!|".find(line[j]) != -1):
530
+ # line[j] == '+' or line[j] == '-' or line[j] == '*' or \
531
+ # line[j] == '>' or line[j] == '<' or line[j] == '=' or \
532
+ # line[j] == '/' or line[j] == '%' or line[j] == '&' or \
533
+ # line[j] == '!' or line[j] == '|'):
534
+ self.tokens.append(('op', line[i:j+1]))
535
+ i = j + 1
536
+ else:
537
+ self.tokens.append(('op', line[i]))
538
+ i = i + 1
539
+ continue
540
+ s = i
541
+ while i < l:
542
+ o = ord(line[i])
543
+ if (o >= 97 and o <= 122) or (o >= 65 and o <= 90) or \
544
+ (o >= 48 and o <= 57) or (
545
+ " \t(){}:;,+-*/%&!|[]=><".find(line[i]) == -1):
546
+ # line[i] != ' ' and line[i] != '\t' and
547
+ # line[i] != '(' and line[i] != ')' and
548
+ # line[i] != '{' and line[i] != '}' and
549
+ # line[i] != ':' and line[i] != ';' and
550
+ # line[i] != ',' and line[i] != '+' and
551
+ # line[i] != '-' and line[i] != '*' and
552
+ # line[i] != '/' and line[i] != '%' and
553
+ # line[i] != '&' and line[i] != '!' and
554
+ # line[i] != '|' and line[i] != '[' and
555
+ # line[i] != ']' and line[i] != '=' and
556
+ # line[i] != '*' and line[i] != '>' and
557
+ # line[i] != '<'):
558
+ i = i + 1
559
+ else:
560
+ break
561
+ self.tokens.append(('name', line[s:i]))
562
+
563
+ tok = self.tokens[0]
564
+ self.tokens = self.tokens[1:]
565
+ self.last = tok
566
+ return tok
567
+
568
+ class CParser:
569
+ """The C module parser"""
570
+ def __init__(self, filename, idx = None):
571
+ self.filename = filename
572
+ if len(filename) > 2 and filename[-2:] == '.h':
573
+ self.is_header = 1
574
+ else:
575
+ self.is_header = 0
576
+ self.input = open(filename)
577
+ self.lexer = CLexer(self.input)
578
+ if idx == None:
579
+ self.index = index()
580
+ else:
581
+ self.index = idx
582
+ self.top_comment = ""
583
+ self.last_comment = ""
584
+ self.comment = None
585
+ self.collect_ref = 0
586
+ self.doc_disable = 0
587
+ self.conditionals = []
588
+ self.defines = []
589
+
590
+ def collect_references(self):
591
+ self.collect_ref = 1
592
+
593
+ def disable(self):
594
+ self.doc_disable = 1
595
+
596
+ def enable(self):
597
+ self.doc_disable = 0
598
+
599
+ def lineno(self):
600
+ return self.lexer.getlineno()
601
+
602
+ def index_add(self, name, module, static, type, info=None, extra = None):
603
+ if self.doc_disable:
604
+ return
605
+ if self.is_header == 1:
606
+ self.index.add(name, module, module, static, type, self.lineno(),
607
+ info, extra, self.conditionals)
608
+ else:
609
+ self.index.add(name, None, module, static, type, self.lineno(),
610
+ info, extra, self.conditionals)
611
+
612
+ def index_add_ref(self, name, module, static, type, info=None,
613
+ extra = None):
614
+ if self.is_header == 1:
615
+ self.index.add_ref(name, module, module, static, type,
616
+ self.lineno(), info, extra, self.conditionals)
617
+ else:
618
+ self.index.add_ref(name, None, module, static, type, self.lineno(),
619
+ info, extra, self.conditionals)
620
+
621
+ def warning(self, msg):
622
+ if self.doc_disable:
623
+ return
624
+ print(msg)
625
+
626
+ def error(self, msg, token=-1):
627
+ if self.doc_disable:
628
+ return
629
+
630
+ print("Parse Error: " + msg)
631
+ if token != -1:
632
+ print("Got token ", token)
633
+ self.lexer.debug()
634
+ sys.exit(1)
635
+
636
+ def debug(self, msg, token=-1):
637
+ print("Debug: " + msg)
638
+ if token != -1:
639
+ print("Got token ", token)
640
+ self.lexer.debug()
641
+
642
+ def parseTopComment(self, comment):
643
+ res = {}
644
+ lines = comment.split("\n")
645
+ item = None
646
+ for line in lines:
647
+ while line != "" and (line[0] == ' ' or line[0] == '\t'):
648
+ line = line[1:]
649
+ while line != "" and line[0] == '*':
650
+ line = line[1:]
651
+ while line != "" and (line[0] == ' ' or line[0] == '\t'):
652
+ line = line[1:]
653
+ try:
654
+ (it, line) = line.split(":", 1)
655
+ item = it
656
+ while line != "" and (line[0] == ' ' or line[0] == '\t'):
657
+ line = line[1:]
658
+ if item in res:
659
+ res[item] = res[item] + " " + line
660
+ else:
661
+ res[item] = line
662
+ except:
663
+ if item != None:
664
+ if item in res:
665
+ res[item] = res[item] + " " + line
666
+ else:
667
+ res[item] = line
668
+ self.index.info = res
669
+
670
+ def parseComment(self, token):
671
+ if self.top_comment == "":
672
+ self.top_comment = token[1]
673
+ if self.comment == None or token[1][0] == '*':
674
+ self.comment = token[1];
675
+ else:
676
+ self.comment = self.comment + token[1]
677
+ token = self.lexer.token()
678
+
679
+ if self.comment.find("DOC_DISABLE") != -1:
680
+ self.disable()
681
+
682
+ if self.comment.find("DOC_ENABLE") != -1:
683
+ self.enable()
684
+
685
+ return token
686
+
687
+ #
688
+ # Parse a simple comment block for typedefs or global variables
689
+ #
690
+ def parseSimpleComment(self, name, quiet = False):
691
+ if name[0:2] == '__':
692
+ quiet = 1
693
+
694
+ args = []
695
+ desc = ""
696
+
697
+ if self.comment == None:
698
+ if not quiet:
699
+ self.warning("Missing comment for %s" % (name))
700
+ return(None)
701
+ if self.comment[0] != '*':
702
+ if not quiet:
703
+ self.warning("Missing * in comment for %s" % (name))
704
+ return(None)
705
+ lines = self.comment.split('\n')
706
+ if lines[0] == '*':
707
+ del lines[0]
708
+ if lines[0] != "* %s:" % (name):
709
+ if not quiet:
710
+ self.warning("Misformatted comment for %s" % (name))
711
+ self.warning(" Expecting '* %s:' got '%s'" % (name, lines[0]))
712
+ return(None)
713
+ del lines[0]
714
+ while len(lines) > 0 and lines[0] == '*':
715
+ del lines[0]
716
+ desc = ""
717
+ while len(lines) > 0:
718
+ l = lines[0]
719
+ while len(l) > 0 and l[0] == '*':
720
+ l = l[1:]
721
+ l = l.strip()
722
+ desc = desc + " " + l
723
+ del lines[0]
724
+
725
+ desc = desc.strip()
726
+
727
+ if quiet == 0:
728
+ if desc == "":
729
+ self.warning("Comment for %s lacks description" % (name))
730
+
731
+ return(desc)
732
+ #
733
+ # Parse a comment block associate to a macro
734
+ #
735
+ def parseMacroComment(self, name, quiet = 0):
736
+ if name[0:2] == '__':
737
+ quiet = 1
738
+
739
+ args = []
740
+ desc = ""
741
+
742
+ if self.comment == None:
743
+ if not quiet:
744
+ self.warning("Missing comment for macro %s" % (name))
745
+ return((args, desc))
746
+ if self.comment[0] != '*':
747
+ if not quiet:
748
+ self.warning("Missing * in macro comment for %s" % (name))
749
+ return((args, desc))
750
+ lines = self.comment.split('\n')
751
+ if lines[0] == '*':
752
+ del lines[0]
753
+ if lines[0] != "* %s:" % (name):
754
+ if not quiet:
755
+ self.warning("Misformatted macro comment for %s" % (name))
756
+ self.warning(" Expecting '* %s:' got '%s'" % (name, lines[0]))
757
+ return((args, desc))
758
+ del lines[0]
759
+ while lines[0] == '*':
760
+ del lines[0]
761
+ while len(lines) > 0 and lines[0][0:3] == '* @':
762
+ l = lines[0][3:]
763
+ try:
764
+ (arg, desc) = l.split(':', 1)
765
+ desc=desc.strip()
766
+ arg=arg.strip()
767
+ except:
768
+ if not quiet:
769
+ self.warning("Misformatted macro comment for %s" % (name))
770
+ self.warning(" problem with '%s'" % (lines[0]))
771
+ del lines[0]
772
+ continue
773
+ del lines[0]
774
+ l = lines[0].strip()
775
+ while len(l) > 2 and l[0:3] != '* @':
776
+ while l[0] == '*':
777
+ l = l[1:]
778
+ desc = desc + ' ' + l.strip()
779
+ del lines[0]
780
+ if len(lines) == 0:
781
+ break
782
+ l = lines[0]
783
+ args.append((arg, desc))
784
+ while len(lines) > 0 and lines[0] == '*':
785
+ del lines[0]
786
+ desc = ""
787
+ while len(lines) > 0:
788
+ l = lines[0]
789
+ while len(l) > 0 and l[0] == '*':
790
+ l = l[1:]
791
+ l = l.strip()
792
+ desc = desc + " " + l
793
+ del lines[0]
794
+
795
+ desc = desc.strip()
796
+
797
+ if quiet == 0:
798
+ if desc == "":
799
+ self.warning("Macro comment for %s lack description of the macro" % (name))
800
+
801
+ return((args, desc))
802
+
803
+ #
804
+ # Parse a comment block and merge the information found in the
805
+ # parameters descriptions, finally returns a block as complete
806
+ # as possible
807
+ #
808
+ def mergeFunctionComment(self, name, description, quiet = 0):
809
+ if name == 'main':
810
+ quiet = 1
811
+ if name[0:2] == '__':
812
+ quiet = 1
813
+
814
+ (ret, args) = description
815
+ desc = ""
816
+ retdesc = ""
817
+
818
+ if self.comment == None:
819
+ if not quiet:
820
+ self.warning("Missing comment for function %s" % (name))
821
+ return(((ret[0], retdesc), args, desc))
822
+ if self.comment[0] != '*':
823
+ if not quiet:
824
+ self.warning("Missing * in function comment for %s" % (name))
825
+ return(((ret[0], retdesc), args, desc))
826
+ lines = self.comment.split('\n')
827
+ if lines[0] == '*':
828
+ del lines[0]
829
+ if lines[0] != "* %s:" % (name):
830
+ if not quiet:
831
+ self.warning("Misformatted function comment for %s" % (name))
832
+ self.warning(" Expecting '* %s:' got '%s'" % (name, lines[0]))
833
+ return(((ret[0], retdesc), args, desc))
834
+ del lines[0]
835
+ while lines[0] == '*':
836
+ del lines[0]
837
+ nbargs = len(args)
838
+ while len(lines) > 0 and lines[0][0:3] == '* @':
839
+ l = lines[0][3:]
840
+ try:
841
+ (arg, desc) = l.split(':', 1)
842
+ desc=desc.strip()
843
+ arg=arg.strip()
844
+ except:
845
+ if not quiet:
846
+ self.warning("Misformatted function comment for %s" % (name))
847
+ self.warning(" problem with '%s'" % (lines[0]))
848
+ del lines[0]
849
+ continue
850
+ del lines[0]
851
+ l = lines[0].strip()
852
+ while len(l) > 2 and l[0:3] != '* @':
853
+ while l[0] == '*':
854
+ l = l[1:]
855
+ desc = desc + ' ' + l.strip()
856
+ del lines[0]
857
+ if len(lines) == 0:
858
+ break
859
+ l = lines[0]
860
+ i = 0
861
+ while i < nbargs:
862
+ if args[i][1] == arg:
863
+ args[i] = (args[i][0], arg, desc)
864
+ break;
865
+ i = i + 1
866
+ if i >= nbargs:
867
+ if not quiet:
868
+ self.warning("Unable to find arg %s from function comment for %s" % (
869
+ arg, name))
870
+ while len(lines) > 0 and lines[0] == '*':
871
+ del lines[0]
872
+ desc = ""
873
+ while len(lines) > 0:
874
+ l = lines[0]
875
+ while len(l) > 0 and l[0] == '*':
876
+ l = l[1:]
877
+ l = l.strip()
878
+ if len(l) >= 6 and l[0:6] == "return" or l[0:6] == "Return":
879
+ try:
880
+ l = l.split(' ', 1)[1]
881
+ except:
882
+ l = ""
883
+ retdesc = l.strip()
884
+ del lines[0]
885
+ while len(lines) > 0:
886
+ l = lines[0]
887
+ while len(l) > 0 and l[0] == '*':
888
+ l = l[1:]
889
+ l = l.strip()
890
+ retdesc = retdesc + " " + l
891
+ del lines[0]
892
+ else:
893
+ desc = desc + " " + l
894
+ del lines[0]
895
+
896
+ retdesc = retdesc.strip()
897
+ desc = desc.strip()
898
+
899
+ if quiet == 0:
900
+ #
901
+ # report missing comments
902
+ #
903
+ i = 0
904
+ while i < nbargs:
905
+ if args[i][2] == None and args[i][0] != "void" and \
906
+ ((args[i][1] != None) or (args[i][1] == '')):
907
+ self.warning("Function comment for %s lacks description of arg %s" % (name, args[i][1]))
908
+ i = i + 1
909
+ if retdesc == "" and ret[0] != "void":
910
+ self.warning("Function comment for %s lacks description of return value" % (name))
911
+ if desc == "" and retdesc == "":
912
+ self.warning("Function comment for %s lacks description of the function" % (name))
913
+
914
+ return(((ret[0], retdesc), args, desc))
915
+
916
+ def parsePreproc(self, token):
917
+ if debug:
918
+ print("=> preproc ", token, self.lexer.tokens)
919
+ name = token[1]
920
+ if name == "#include":
921
+ token = self.lexer.token()
922
+ if token == None:
923
+ return None
924
+ if token[0] == 'preproc':
925
+ self.index_add(token[1], self.filename, not self.is_header,
926
+ "include")
927
+ return self.lexer.token()
928
+ return token
929
+ if name == "#define":
930
+ token = self.lexer.token()
931
+ if token == None:
932
+ return None
933
+ if token[0] == 'preproc':
934
+ # TODO macros with arguments
935
+ name = token[1]
936
+ lst = []
937
+ token = self.lexer.token()
938
+ while token != None and token[0] == 'preproc' and \
939
+ token[1][0] != '#':
940
+ lst.append(token[1])
941
+ token = self.lexer.token()
942
+ try:
943
+ name = name.split('(') [0]
944
+ except:
945
+ pass
946
+ info = self.parseMacroComment(name, True)
947
+ self.index_add(name, self.filename, not self.is_header,
948
+ "macro", info)
949
+ return token
950
+
951
+ #
952
+ # Processing of conditionals modified by Bill 1/1/05
953
+ #
954
+ # We process conditionals (i.e. tokens from #ifdef, #ifndef,
955
+ # #if, #else and #endif) for headers and mainline code,
956
+ # store the ones from the header in libxml2-api.xml, and later
957
+ # (in the routine merge_public) verify that the two (header and
958
+ # mainline code) agree.
959
+ #
960
+ # There is a small problem with processing the headers. Some of
961
+ # the variables are not concerned with enabling / disabling of
962
+ # library functions (e.g. '__XML_PARSER_H__'), and we don't want
963
+ # them to be included in libxml2-api.xml, or involved in
964
+ # the check between the header and the mainline code. To
965
+ # accomplish this, we ignore any conditional which doesn't include
966
+ # the string 'ENABLED'
967
+ #
968
+ if name == "#ifdef":
969
+ apstr = self.lexer.tokens[0][1]
970
+ try:
971
+ self.defines.append(apstr)
972
+ if apstr.find('ENABLED') != -1:
973
+ self.conditionals.append("defined(%s)" % apstr)
974
+ except:
975
+ pass
976
+ elif name == "#ifndef":
977
+ apstr = self.lexer.tokens[0][1]
978
+ try:
979
+ self.defines.append(apstr)
980
+ if apstr.find('ENABLED') != -1:
981
+ self.conditionals.append("!defined(%s)" % apstr)
982
+ except:
983
+ pass
984
+ elif name == "#if":
985
+ apstr = ""
986
+ for tok in self.lexer.tokens:
987
+ if apstr != "":
988
+ apstr = apstr + " "
989
+ apstr = apstr + tok[1]
990
+ try:
991
+ self.defines.append(apstr)
992
+ if apstr.find('ENABLED') != -1:
993
+ self.conditionals.append(apstr)
994
+ except:
995
+ pass
996
+ elif name == "#else":
997
+ if self.conditionals != [] and \
998
+ self.defines[-1].find('ENABLED') != -1:
999
+ self.conditionals[-1] = "!(%s)" % self.conditionals[-1]
1000
+ elif name == "#endif":
1001
+ if self.conditionals != [] and \
1002
+ self.defines[-1].find('ENABLED') != -1:
1003
+ self.conditionals = self.conditionals[:-1]
1004
+ self.defines = self.defines[:-1]
1005
+ token = self.lexer.token()
1006
+ while token != None and token[0] == 'preproc' and \
1007
+ token[1][0] != '#':
1008
+ token = self.lexer.token()
1009
+ return token
1010
+
1011
+ #
1012
+ # token acquisition on top of the lexer, it handle internally
1013
+ # preprocessor and comments since they are logically not part of
1014
+ # the program structure.
1015
+ #
1016
+ def token(self):
1017
+ global ignored_words
1018
+
1019
+ token = self.lexer.token()
1020
+ while token != None:
1021
+ if token[0] == 'comment':
1022
+ token = self.parseComment(token)
1023
+ continue
1024
+ elif token[0] == 'preproc':
1025
+ token = self.parsePreproc(token)
1026
+ continue
1027
+ elif token[0] == "name" and token[1] == "__const":
1028
+ token = ("name", "const")
1029
+ return token
1030
+ elif token[0] == "name" and token[1] == "__attribute":
1031
+ token = self.lexer.token()
1032
+ while token != None and token[1] != ";":
1033
+ token = self.lexer.token()
1034
+ return token
1035
+ elif token[0] == "name" and token[1] in ignored_words:
1036
+ (n, info) = ignored_words[token[1]]
1037
+ i = 0
1038
+ while i < n:
1039
+ token = self.lexer.token()
1040
+ i = i + 1
1041
+ token = self.lexer.token()
1042
+ continue
1043
+ else:
1044
+ if debug:
1045
+ print("=> ", token)
1046
+ return token
1047
+ return None
1048
+
1049
+ #
1050
+ # Parse a typedef, it records the type and its name.
1051
+ #
1052
+ def parseTypedef(self, token):
1053
+ if token == None:
1054
+ return None
1055
+ token = self.parseType(token)
1056
+ if token == None:
1057
+ self.error("parsing typedef")
1058
+ return None
1059
+ base_type = self.type
1060
+ type = base_type
1061
+ #self.debug("end typedef type", token)
1062
+ while token != None:
1063
+ if token[0] == "name":
1064
+ name = token[1]
1065
+ signature = self.signature
1066
+ if signature != None:
1067
+ type = type.split('(')[0]
1068
+ d = self.mergeFunctionComment(name,
1069
+ ((type, None), signature), 1)
1070
+ self.index_add(name, self.filename, not self.is_header,
1071
+ "functype", d)
1072
+ else:
1073
+ if base_type == "struct":
1074
+ self.index_add(name, self.filename, not self.is_header,
1075
+ "struct", type)
1076
+ base_type = "struct " + name
1077
+ else:
1078
+ # TODO report missing or misformatted comments
1079
+ info = self.parseSimpleComment(name, True)
1080
+ self.index_add(name, self.filename, not self.is_header,
1081
+ "typedef", type, info)
1082
+ token = self.token()
1083
+ else:
1084
+ self.error("parsing typedef: expecting a name")
1085
+ return token
1086
+ #self.debug("end typedef", token)
1087
+ if token != None and token[0] == 'sep' and token[1] == ',':
1088
+ type = base_type
1089
+ token = self.token()
1090
+ while token != None and token[0] == "op":
1091
+ type = type + token[1]
1092
+ token = self.token()
1093
+ elif token != None and token[0] == 'sep' and token[1] == ';':
1094
+ break;
1095
+ elif token != None and token[0] == 'name':
1096
+ type = base_type
1097
+ continue;
1098
+ else:
1099
+ self.error("parsing typedef: expecting ';'", token)
1100
+ return token
1101
+ token = self.token()
1102
+ return token
1103
+
1104
+ #
1105
+ # Parse a C code block, used for functions it parse till
1106
+ # the balancing } included
1107
+ #
1108
+ def parseBlock(self, token):
1109
+ while token != None:
1110
+ if token[0] == "sep" and token[1] == "{":
1111
+ token = self.token()
1112
+ token = self.parseBlock(token)
1113
+ elif token[0] == "sep" and token[1] == "}":
1114
+ token = self.token()
1115
+ return token
1116
+ else:
1117
+ if self.collect_ref == 1:
1118
+ oldtok = token
1119
+ token = self.token()
1120
+ if oldtok[0] == "name" and oldtok[1][0:3] == "xml":
1121
+ if token[0] == "sep" and token[1] == "(":
1122
+ self.index_add_ref(oldtok[1], self.filename,
1123
+ 0, "function")
1124
+ token = self.token()
1125
+ elif token[0] == "name":
1126
+ token = self.token()
1127
+ if token[0] == "sep" and (token[1] == ";" or
1128
+ token[1] == "," or token[1] == "="):
1129
+ self.index_add_ref(oldtok[1], self.filename,
1130
+ 0, "type")
1131
+ elif oldtok[0] == "name" and oldtok[1][0:4] == "XML_":
1132
+ self.index_add_ref(oldtok[1], self.filename,
1133
+ 0, "typedef")
1134
+ elif oldtok[0] == "name" and oldtok[1][0:7] == "LIBXML_":
1135
+ self.index_add_ref(oldtok[1], self.filename,
1136
+ 0, "typedef")
1137
+
1138
+ else:
1139
+ token = self.token()
1140
+ return token
1141
+
1142
+ #
1143
+ # Parse a C struct definition till the balancing }
1144
+ #
1145
+ def parseStruct(self, token):
1146
+ fields = []
1147
+ #self.debug("start parseStruct", token)
1148
+ while token != None:
1149
+ if token[0] == "sep" and token[1] == "{":
1150
+ token = self.token()
1151
+ token = self.parseTypeBlock(token)
1152
+ elif token[0] == "sep" and token[1] == "}":
1153
+ self.struct_fields = fields
1154
+ #self.debug("end parseStruct", token)
1155
+ #print fields
1156
+ token = self.token()
1157
+ return token
1158
+ else:
1159
+ base_type = self.type
1160
+ #self.debug("before parseType", token)
1161
+ token = self.parseType(token)
1162
+ #self.debug("after parseType", token)
1163
+ if token != None and token[0] == "name":
1164
+ fname = token[1]
1165
+ token = self.token()
1166
+ if token[0] == "sep" and token[1] == ";":
1167
+ token = self.token()
1168
+ fields.append((self.type, fname))
1169
+ else:
1170
+ self.error("parseStruct: expecting ;", token)
1171
+ elif token != None and token[0] == "sep" and token[1] == "{":
1172
+ token = self.token()
1173
+ token = self.parseTypeBlock(token)
1174
+ if token != None and token[0] == "name":
1175
+ token = self.token()
1176
+ if token != None and token[0] == "sep" and token[1] == ";":
1177
+ token = self.token()
1178
+ else:
1179
+ self.error("parseStruct: expecting ;", token)
1180
+ else:
1181
+ self.error("parseStruct: name", token)
1182
+ token = self.token()
1183
+ self.type = base_type;
1184
+ self.struct_fields = fields
1185
+ #self.debug("end parseStruct", token)
1186
+ #print fields
1187
+ return token
1188
+
1189
+ #
1190
+ # Parse a C enum block, parse till the balancing }
1191
+ #
1192
+ def parseEnumBlock(self, token):
1193
+ self.enums = []
1194
+ name = None
1195
+ self.comment = None
1196
+ comment = ""
1197
+ value = "0"
1198
+ while token != None:
1199
+ if token[0] == "sep" and token[1] == "{":
1200
+ token = self.token()
1201
+ token = self.parseTypeBlock(token)
1202
+ elif token[0] == "sep" and token[1] == "}":
1203
+ if name != None:
1204
+ if self.comment != None:
1205
+ comment = self.comment
1206
+ self.comment = None
1207
+ self.enums.append((name, value, comment))
1208
+ token = self.token()
1209
+ return token
1210
+ elif token[0] == "name":
1211
+ if name != None:
1212
+ if self.comment != None:
1213
+ comment = self.comment.strip()
1214
+ self.comment = None
1215
+ self.enums.append((name, value, comment))
1216
+ name = token[1]
1217
+ comment = ""
1218
+ token = self.token()
1219
+ if token[0] == "op" and token[1][0] == "=":
1220
+ value = ""
1221
+ if len(token[1]) > 1:
1222
+ value = token[1][1:]
1223
+ token = self.token()
1224
+ while token[0] != "sep" or (token[1] != ',' and
1225
+ token[1] != '}'):
1226
+ value = value + token[1]
1227
+ token = self.token()
1228
+ else:
1229
+ try:
1230
+ value = "%d" % (int(value) + 1)
1231
+ except:
1232
+ self.warning("Failed to compute value of enum %s" % (name))
1233
+ value=""
1234
+ if token[0] == "sep" and token[1] == ",":
1235
+ token = self.token()
1236
+ else:
1237
+ token = self.token()
1238
+ return token
1239
+
1240
+ #
1241
+ # Parse a C definition block, used for structs it parse till
1242
+ # the balancing }
1243
+ #
1244
+ def parseTypeBlock(self, token):
1245
+ while token != None:
1246
+ if token[0] == "sep" and token[1] == "{":
1247
+ token = self.token()
1248
+ token = self.parseTypeBlock(token)
1249
+ elif token[0] == "sep" and token[1] == "}":
1250
+ token = self.token()
1251
+ return token
1252
+ else:
1253
+ token = self.token()
1254
+ return token
1255
+
1256
+ #
1257
+ # Parse a type: the fact that the type name can either occur after
1258
+ # the definition or within the definition makes it a little harder
1259
+ # if inside, the name token is pushed back before returning
1260
+ #
1261
+ def parseType(self, token):
1262
+ self.type = ""
1263
+ self.struct_fields = []
1264
+ self.signature = None
1265
+ if token == None:
1266
+ return token
1267
+
1268
+ have_sign = 0
1269
+ done = 0
1270
+
1271
+ while token[0] == "name" and (
1272
+ token[1] == "const" or \
1273
+ token[1] == "unsigned" or \
1274
+ token[1] == "signed"):
1275
+ if token[1] == "unsigned" or token[1] == "signed":
1276
+ have_sign = 1
1277
+ if self.type == "":
1278
+ self.type = token[1]
1279
+ else:
1280
+ self.type = self.type + " " + token[1]
1281
+ token = self.token()
1282
+
1283
+ if token[0] == "name" and token[1] in ("char", "short", "int", "long"):
1284
+ if self.type == "":
1285
+ self.type = token[1]
1286
+ else:
1287
+ self.type = self.type + " " + token[1]
1288
+
1289
+ elif have_sign:
1290
+ done = 1
1291
+
1292
+ elif token[0] == "name" and token[1] == "struct":
1293
+ if self.type == "":
1294
+ self.type = token[1]
1295
+ else:
1296
+ self.type = self.type + " " + token[1]
1297
+ token = self.token()
1298
+ nametok = None
1299
+ if token[0] == "name":
1300
+ nametok = token
1301
+ token = self.token()
1302
+ if token != None and token[0] == "sep" and token[1] == "{":
1303
+ token = self.token()
1304
+ token = self.parseStruct(token)
1305
+ elif token != None and token[0] == "op" and token[1] == "*":
1306
+ self.type = self.type + " " + nametok[1] + " *"
1307
+ token = self.token()
1308
+ while token != None and token[0] == "op" and token[1] == "*":
1309
+ self.type = self.type + " *"
1310
+ token = self.token()
1311
+ if token[0] == "name":
1312
+ nametok = token
1313
+ token = self.token()
1314
+ else:
1315
+ self.error("struct : expecting name", token)
1316
+ return token
1317
+ elif token != None and token[0] == "name" and nametok != None:
1318
+ self.type = self.type + " " + nametok[1]
1319
+ return token
1320
+
1321
+ if nametok != None:
1322
+ self.lexer.push(token)
1323
+ token = nametok
1324
+ return token
1325
+
1326
+ elif token[0] == "name" and token[1] == "enum":
1327
+ if self.type == "":
1328
+ self.type = token[1]
1329
+ else:
1330
+ self.type = self.type + " " + token[1]
1331
+ self.enums = []
1332
+ token = self.token()
1333
+ if token != None and token[0] == "sep" and token[1] == "{":
1334
+ token = self.token()
1335
+ token = self.parseEnumBlock(token)
1336
+ else:
1337
+ self.error("parsing enum: expecting '{'", token)
1338
+ enum_type = None
1339
+ if token != None and token[0] != "name":
1340
+ self.lexer.push(token)
1341
+ token = ("name", "enum")
1342
+ else:
1343
+ enum_type = token[1]
1344
+ for enum in self.enums:
1345
+ self.index_add(enum[0], self.filename,
1346
+ not self.is_header, "enum",
1347
+ (enum[1], enum[2], enum_type))
1348
+ return token
1349
+
1350
+ elif token[0] == "name":
1351
+ if self.type == "":
1352
+ self.type = token[1]
1353
+ else:
1354
+ self.type = self.type + " " + token[1]
1355
+ else:
1356
+ self.error("parsing type %s: expecting a name" % (self.type),
1357
+ token)
1358
+ return token
1359
+ if not done:
1360
+ token = self.token()
1361
+ while token != None and (token[0] == "op" or
1362
+ token[0] == "name" and token[1] == "const"):
1363
+ self.type = self.type + " " + token[1]
1364
+ token = self.token()
1365
+
1366
+ #
1367
+ # if there is a parenthesis here, this means a function type
1368
+ #
1369
+ if token != None and token[0] == "sep" and token[1] == '(':
1370
+ self.type = self.type + token[1]
1371
+ token = self.token()
1372
+ while token != None and token[0] == "op" and token[1] == '*':
1373
+ self.type = self.type + token[1]
1374
+ token = self.token()
1375
+ if token == None or token[0] != "name" :
1376
+ self.error("parsing function type, name expected", token);
1377
+ return token
1378
+ self.type = self.type + token[1]
1379
+ nametok = token
1380
+ token = self.token()
1381
+ if token != None and token[0] == "sep" and token[1] == ')':
1382
+ self.type = self.type + token[1]
1383
+ token = self.token()
1384
+ if token != None and token[0] == "sep" and token[1] == '(':
1385
+ token = self.token()
1386
+ type = self.type;
1387
+ token = self.parseSignature(token);
1388
+ self.type = type;
1389
+ else:
1390
+ self.error("parsing function type, '(' expected", token);
1391
+ return token
1392
+ else:
1393
+ self.error("parsing function type, ')' expected", token);
1394
+ return token
1395
+ self.lexer.push(token)
1396
+ token = nametok
1397
+ return token
1398
+
1399
+ #
1400
+ # do some lookahead for arrays
1401
+ #
1402
+ if token != None and token[0] == "name":
1403
+ nametok = token
1404
+ token = self.token()
1405
+ if token != None and token[0] == "sep" and token[1] == '[':
1406
+ self.type = self.type + nametok[1]
1407
+ while token != None and token[0] == "sep" and token[1] == '[':
1408
+ self.type = self.type + token[1]
1409
+ token = self.token()
1410
+ while token != None and token[0] != 'sep' and \
1411
+ token[1] != ']' and token[1] != ';':
1412
+ self.type = self.type + token[1]
1413
+ token = self.token()
1414
+ if token != None and token[0] == 'sep' and token[1] == ']':
1415
+ self.type = self.type + token[1]
1416
+ token = self.token()
1417
+ else:
1418
+ self.error("parsing array type, ']' expected", token);
1419
+ return token
1420
+ elif token != None and token[0] == "sep" and token[1] == ':':
1421
+ # remove :12 in case it's a limited int size
1422
+ token = self.token()
1423
+ token = self.token()
1424
+ self.lexer.push(token)
1425
+ token = nametok
1426
+
1427
+ return token
1428
+
1429
+ #
1430
+ # Parse a signature: '(' has been parsed and we scan the type definition
1431
+ # up to the ')' included
1432
+ def parseSignature(self, token):
1433
+ signature = []
1434
+ if token != None and token[0] == "sep" and token[1] == ')':
1435
+ self.signature = []
1436
+ token = self.token()
1437
+ return token
1438
+ while token != None:
1439
+ token = self.parseType(token)
1440
+ if token != None and token[0] == "name":
1441
+ signature.append((self.type, token[1], None))
1442
+ token = self.token()
1443
+ elif token != None and token[0] == "sep" and token[1] == ',':
1444
+ token = self.token()
1445
+ continue
1446
+ elif token != None and token[0] == "sep" and token[1] == ')':
1447
+ # only the type was provided
1448
+ if self.type == "...":
1449
+ signature.append((self.type, "...", None))
1450
+ else:
1451
+ signature.append((self.type, None, None))
1452
+ if token != None and token[0] == "sep":
1453
+ if token[1] == ',':
1454
+ token = self.token()
1455
+ continue
1456
+ elif token[1] == ')':
1457
+ token = self.token()
1458
+ break
1459
+ self.signature = signature
1460
+ return token
1461
+
1462
+ #
1463
+ # Parse a global definition, be it a type, variable or function
1464
+ # the extern "C" blocks are a bit nasty and require it to recurse.
1465
+ #
1466
+ def parseGlobal(self, token):
1467
+ static = 0
1468
+ if token[1] == 'extern':
1469
+ token = self.token()
1470
+ if token == None:
1471
+ return token
1472
+ if token[0] == 'string':
1473
+ if token[1] == 'C':
1474
+ token = self.token()
1475
+ if token == None:
1476
+ return token
1477
+ if token[0] == 'sep' and token[1] == "{":
1478
+ token = self.token()
1479
+ # print 'Entering extern "C line ', self.lineno()
1480
+ while token != None and (token[0] != 'sep' or
1481
+ token[1] != "}"):
1482
+ if token[0] == 'name':
1483
+ token = self.parseGlobal(token)
1484
+ else:
1485
+ self.error(
1486
+ "token %s %s unexpected at the top level" % (
1487
+ token[0], token[1]))
1488
+ token = self.parseGlobal(token)
1489
+ # print 'Exiting extern "C" line', self.lineno()
1490
+ token = self.token()
1491
+ return token
1492
+ else:
1493
+ return token
1494
+ elif token[1] == 'static':
1495
+ static = 1
1496
+ token = self.token()
1497
+ if token == None or token[0] != 'name':
1498
+ return token
1499
+
1500
+ if token[1] == 'typedef':
1501
+ token = self.token()
1502
+ return self.parseTypedef(token)
1503
+ else:
1504
+ token = self.parseType(token)
1505
+ type_orig = self.type
1506
+ if token == None or token[0] != "name":
1507
+ return token
1508
+ type = type_orig
1509
+ self.name = token[1]
1510
+ token = self.token()
1511
+ while token != None and (token[0] == "sep" or token[0] == "op"):
1512
+ if token[0] == "sep":
1513
+ if token[1] == "[":
1514
+ type = type + token[1]
1515
+ token = self.token()
1516
+ while token != None and (token[0] != "sep" or \
1517
+ token[1] != ";"):
1518
+ type = type + token[1]
1519
+ token = self.token()
1520
+
1521
+ if token != None and token[0] == "op" and token[1] == "=":
1522
+ #
1523
+ # Skip the initialization of the variable
1524
+ #
1525
+ token = self.token()
1526
+ if token[0] == 'sep' and token[1] == '{':
1527
+ token = self.token()
1528
+ token = self.parseBlock(token)
1529
+ else:
1530
+ while token != None and (token[0] != "sep" or \
1531
+ (token[1] != ';' and token[1] != ',')):
1532
+ token = self.token()
1533
+ if token == None or token[0] != "sep" or (token[1] != ';' and
1534
+ token[1] != ','):
1535
+ self.error("missing ';' or ',' after value")
1536
+
1537
+ if token != None and token[0] == "sep":
1538
+ if token[1] == ";":
1539
+ if type == "struct":
1540
+ self.index_add(self.name, self.filename,
1541
+ not self.is_header, "struct", self.struct_fields)
1542
+ else:
1543
+ info = self.parseSimpleComment(self.name, True)
1544
+ self.index_add(self.name, self.filename,
1545
+ not self.is_header, "variable", type, info)
1546
+ self.comment = None
1547
+ token = self.token()
1548
+ break
1549
+ elif token[1] == "(":
1550
+ token = self.token()
1551
+ token = self.parseSignature(token)
1552
+ if token == None:
1553
+ return None
1554
+ if token[0] == "sep" and token[1] == ";":
1555
+ d = self.mergeFunctionComment(self.name,
1556
+ ((type, None), self.signature), 1)
1557
+ self.index_add(self.name, self.filename, static,
1558
+ "function", d)
1559
+ self.comment = None
1560
+ token = self.token()
1561
+ elif token[0] == "sep" and token[1] == "{":
1562
+ d = self.mergeFunctionComment(self.name,
1563
+ ((type, None), self.signature), static)
1564
+ self.index_add(self.name, self.filename, static,
1565
+ "function", d)
1566
+ self.comment = None
1567
+ token = self.token()
1568
+ token = self.parseBlock(token);
1569
+ elif token[1] == ',':
1570
+ self.index_add(self.name, self.filename, static,
1571
+ "variable", type)
1572
+ self.comment = None
1573
+ type = type_orig
1574
+ token = self.token()
1575
+ while token != None and token[0] == "sep":
1576
+ type = type + token[1]
1577
+ token = self.token()
1578
+ if token != None and token[0] == "name":
1579
+ self.name = token[1]
1580
+ token = self.token()
1581
+ else:
1582
+ break
1583
+
1584
+ return token
1585
+
1586
+ def parse(self):
1587
+ self.warning("Parsing %s" % (self.filename))
1588
+ token = self.token()
1589
+ while token != None:
1590
+ if token[0] == 'name':
1591
+ token = self.parseGlobal(token)
1592
+ else:
1593
+ self.error("token %s %s unexpected at the top level" % (
1594
+ token[0], token[1]))
1595
+ token = self.parseGlobal(token)
1596
+ return
1597
+ self.parseTopComment(self.top_comment)
1598
+ return self.index
1599
+
1600
+
1601
+ class docBuilder:
1602
+ """A documentation builder"""
1603
+ def __init__(self, name, directories=['.'], excludes=[]):
1604
+ self.name = name
1605
+ self.directories = directories
1606
+ self.excludes = excludes + list(ignored_files.keys())
1607
+ self.modules = {}
1608
+ self.headers = {}
1609
+ self.idx = index()
1610
+ self.index = {}
1611
+ if name == 'libxml2':
1612
+ self.basename = 'libxml'
1613
+ else:
1614
+ self.basename = name
1615
+
1616
+ def analyze(self):
1617
+ print("Project %s : %d headers, %d modules" % (self.name, len(list(self.headers.keys())), len(list(self.modules.keys()))))
1618
+ self.idx.analyze()
1619
+
1620
+ def scanHeaders(self):
1621
+ for header in list(self.headers.keys()):
1622
+ parser = CParser(header)
1623
+ idx = parser.parse()
1624
+ self.headers[header] = idx;
1625
+ self.idx.merge(idx)
1626
+
1627
+ def scanModules(self):
1628
+ for module in list(self.modules.keys()):
1629
+ parser = CParser(module)
1630
+ idx = parser.parse()
1631
+ # idx.analyze()
1632
+ self.modules[module] = idx
1633
+ self.idx.merge_public(idx)
1634
+
1635
+ def scan(self):
1636
+ for directory in self.directories:
1637
+ files = glob.glob(directory + "/*.c")
1638
+ for file in files:
1639
+ skip = 0
1640
+ for excl in self.excludes:
1641
+ if file.find(excl) != -1:
1642
+ print("Skipping %s" % file)
1643
+ skip = 1
1644
+ break
1645
+ if skip == 0:
1646
+ self.modules[file] = None;
1647
+ files = glob.glob(directory + "/*.h")
1648
+ for file in files:
1649
+ skip = 0
1650
+ for excl in self.excludes:
1651
+ if file.find(excl) != -1:
1652
+ print("Skipping %s" % file)
1653
+ skip = 1
1654
+ break
1655
+ if skip == 0:
1656
+ self.headers[file] = None;
1657
+ self.scanHeaders()
1658
+ self.scanModules()
1659
+
1660
+ def modulename_file(self, file):
1661
+ module = os.path.basename(file)
1662
+ if module[-2:] == '.h':
1663
+ module = module[:-2]
1664
+ elif module[-2:] == '.c':
1665
+ module = module[:-2]
1666
+ return module
1667
+
1668
+ def serialize_enum(self, output, name):
1669
+ id = self.idx.enums[name]
1670
+ output.write(" <enum name='%s' file='%s'" % (name,
1671
+ self.modulename_file(id.header)))
1672
+ if id.info != None:
1673
+ info = id.info
1674
+ if info[0] != None and info[0] != '':
1675
+ try:
1676
+ val = eval(info[0])
1677
+ except:
1678
+ val = info[0]
1679
+ output.write(" value='%s'" % (val));
1680
+ if info[2] != None and info[2] != '':
1681
+ output.write(" type='%s'" % info[2]);
1682
+ if info[1] != None and info[1] != '':
1683
+ output.write(" info='%s'" % escape(info[1]));
1684
+ output.write("/>\n")
1685
+
1686
+ def serialize_macro(self, output, name):
1687
+ id = self.idx.macros[name]
1688
+ output.write(" <macro name='%s' file='%s'>\n" % (name,
1689
+ self.modulename_file(id.header)))
1690
+ if id.info != None:
1691
+ try:
1692
+ (args, desc) = id.info
1693
+ if desc != None and desc != "":
1694
+ output.write(" <info>%s</info>\n" % (escape(desc)))
1695
+ for arg in args:
1696
+ (name, desc) = arg
1697
+ if desc != None and desc != "":
1698
+ output.write(" <arg name='%s' info='%s'/>\n" % (
1699
+ name, escape(desc)))
1700
+ else:
1701
+ output.write(" <arg name='%s'/>\n" % (name))
1702
+ except:
1703
+ pass
1704
+ output.write(" </macro>\n")
1705
+
1706
+ def serialize_typedef(self, output, name):
1707
+ id = self.idx.typedefs[name]
1708
+ if id.info[0:7] == 'struct ':
1709
+ output.write(" <struct name='%s' file='%s' type='%s'" % (
1710
+ name, self.modulename_file(id.header), id.info))
1711
+ name = id.info[7:]
1712
+ if name in self.idx.structs and ( \
1713
+ type(self.idx.structs[name].info) == type(()) or
1714
+ type(self.idx.structs[name].info) == type([])):
1715
+ output.write(">\n");
1716
+ try:
1717
+ for field in self.idx.structs[name].info:
1718
+ output.write(" <field name='%s' type='%s'/>\n" % (field[1] , field[0]))
1719
+ except:
1720
+ print("Failed to serialize struct %s" % (name))
1721
+ output.write(" </struct>\n")
1722
+ else:
1723
+ output.write("/>\n");
1724
+ else :
1725
+ output.write(" <typedef name='%s' file='%s' type='%s'" % (
1726
+ name, self.modulename_file(id.header), id.info))
1727
+ try:
1728
+ desc = id.extra
1729
+ if desc != None and desc != "":
1730
+ output.write(">\n <info>%s</info>\n" % (escape(desc)))
1731
+ output.write(" </typedef>\n")
1732
+ else:
1733
+ output.write("/>\n")
1734
+ except:
1735
+ output.write("/>\n")
1736
+
1737
+ def serialize_variable(self, output, name):
1738
+ id = self.idx.variables[name]
1739
+ if id.info != None:
1740
+ output.write(" <variable name='%s' file='%s' type='%s'" % (
1741
+ name, self.modulename_file(id.header), id.info))
1742
+ else:
1743
+ output.write(" <variable name='%s' file='%s'" % (
1744
+ name, self.modulename_file(id.header)))
1745
+ desc = id.extra
1746
+ if desc != None and desc != "":
1747
+ output.write(">\n <info>%s</info>\n" % (escape(desc)))
1748
+ output.write(" </variable>\n")
1749
+ else:
1750
+ output.write("/>\n")
1751
+
1752
+ def serialize_function(self, output, name):
1753
+ id = self.idx.functions[name]
1754
+ if name == debugsym:
1755
+ print("=>", id)
1756
+
1757
+ output.write(" <%s name='%s' file='%s' module='%s'>\n" % (id.type,
1758
+ name, self.modulename_file(id.header),
1759
+ self.modulename_file(id.module)))
1760
+ #
1761
+ # Processing of conditionals modified by Bill 1/1/05
1762
+ #
1763
+ if id.conditionals != None:
1764
+ apstr = ""
1765
+ for cond in id.conditionals:
1766
+ if apstr != "":
1767
+ apstr = apstr + " &amp;&amp; "
1768
+ apstr = apstr + cond
1769
+ output.write(" <cond>%s</cond>\n"% (apstr));
1770
+ try:
1771
+ (ret, params, desc) = id.info
1772
+ if (desc == None or desc == '') and \
1773
+ name[0:9] != "xmlThrDef" and name != "xmlDllMain" and \
1774
+ ret[1] == '':
1775
+ print("%s %s from %s has no description" % (id.type, name,
1776
+ self.modulename_file(id.module)))
1777
+
1778
+ output.write(" <info>%s</info>\n" % (escape(desc)))
1779
+ if ret[0] != None:
1780
+ if ret[0] == "void":
1781
+ output.write(" <return type='void'/>\n")
1782
+ else:
1783
+ output.write(" <return type='%s' info='%s'/>\n" % (
1784
+ ret[0], escape(ret[1])))
1785
+ for param in params:
1786
+ if param[0] == 'void':
1787
+ continue
1788
+ if param[2] == None:
1789
+ output.write(" <arg name='%s' type='%s' info=''/>\n" % (param[1], param[0]))
1790
+ else:
1791
+ output.write(" <arg name='%s' type='%s' info='%s'/>\n" % (param[1], param[0], escape(param[2])))
1792
+ except:
1793
+ print("Failed to save function %s info: " % name, repr(id.info))
1794
+ output.write(" </%s>\n" % (id.type))
1795
+
1796
+ def serialize_exports(self, output, file):
1797
+ module = self.modulename_file(file)
1798
+ output.write(" <file name='%s'>\n" % (module))
1799
+ dict = self.headers[file]
1800
+ if dict.info != None:
1801
+ for data in ('Summary', 'Description', 'Author'):
1802
+ try:
1803
+ output.write(" <%s>%s</%s>\n" % (
1804
+ data.lower(),
1805
+ escape(dict.info[data]),
1806
+ data.lower()))
1807
+ except:
1808
+ if data != 'Author':
1809
+ print("Header %s lacks a %s description" % (module, data))
1810
+ if 'Description' in dict.info:
1811
+ desc = dict.info['Description']
1812
+ if desc.find("DEPRECATED") != -1:
1813
+ output.write(" <deprecated/>\n")
1814
+
1815
+ ids = list(dict.macros.keys())
1816
+ ids.sort()
1817
+ for id in ids:
1818
+ # Macros are sometime used to masquerade other types.
1819
+ if id in dict.functions:
1820
+ continue
1821
+ if id in dict.variables:
1822
+ continue
1823
+ if id in dict.typedefs:
1824
+ continue
1825
+ if id in dict.structs:
1826
+ continue
1827
+ if id in dict.enums:
1828
+ continue
1829
+ output.write(" <exports symbol='%s' type='macro'/>\n" % (id))
1830
+ ids = list(dict.enums.keys())
1831
+ ids.sort()
1832
+ for id in ids:
1833
+ output.write(" <exports symbol='%s' type='enum'/>\n" % (id))
1834
+ ids = list(dict.typedefs.keys())
1835
+ ids.sort()
1836
+ for id in ids:
1837
+ output.write(" <exports symbol='%s' type='typedef'/>\n" % (id))
1838
+ ids = list(dict.structs.keys())
1839
+ ids.sort()
1840
+ for id in ids:
1841
+ output.write(" <exports symbol='%s' type='struct'/>\n" % (id))
1842
+ ids = list(dict.variables.keys())
1843
+ ids.sort()
1844
+ for id in ids:
1845
+ output.write(" <exports symbol='%s' type='variable'/>\n" % (id))
1846
+ ids = list(dict.functions.keys())
1847
+ ids.sort()
1848
+ for id in ids:
1849
+ output.write(" <exports symbol='%s' type='function'/>\n" % (id))
1850
+ output.write(" </file>\n")
1851
+
1852
+ def serialize(self):
1853
+ filename = "%s-api.xml" % self.name
1854
+ print("Saving XML description %s" % (filename))
1855
+ output = open(filename, "w")
1856
+ output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
1857
+ output.write("<api name='%s'>\n" % self.name)
1858
+ output.write(" <files>\n")
1859
+ headers = list(self.headers.keys())
1860
+ headers.sort()
1861
+ for file in headers:
1862
+ self.serialize_exports(output, file)
1863
+ output.write(" </files>\n")
1864
+ output.write(" <symbols>\n")
1865
+ macros = list(self.idx.macros.keys())
1866
+ macros.sort()
1867
+ for macro in macros:
1868
+ self.serialize_macro(output, macro)
1869
+ enums = list(self.idx.enums.keys())
1870
+ enums.sort()
1871
+ for enum in enums:
1872
+ self.serialize_enum(output, enum)
1873
+ typedefs = list(self.idx.typedefs.keys())
1874
+ typedefs.sort()
1875
+ for typedef in typedefs:
1876
+ self.serialize_typedef(output, typedef)
1877
+ variables = list(self.idx.variables.keys())
1878
+ variables.sort()
1879
+ for variable in variables:
1880
+ self.serialize_variable(output, variable)
1881
+ functions = list(self.idx.functions.keys())
1882
+ functions.sort()
1883
+ for function in functions:
1884
+ self.serialize_function(output, function)
1885
+ output.write(" </symbols>\n")
1886
+ output.write("</api>\n")
1887
+ output.close()
1888
+
1889
+
1890
+ def rebuild():
1891
+ builder = None
1892
+ if glob.glob("parser.c") != [] :
1893
+ print("Rebuilding API description for libxml2")
1894
+ builder = docBuilder("libxml2", [".", "."],
1895
+ ["tst.c"])
1896
+ elif glob.glob("../parser.c") != [] :
1897
+ print("Rebuilding API description for libxml2")
1898
+ builder = docBuilder("libxml2", ["..", "../include/libxml"],
1899
+ ["tst.c"])
1900
+ elif glob.glob("../libxslt/transform.c") != [] :
1901
+ print("Rebuilding API description for libxslt")
1902
+ builder = docBuilder("libxslt", ["../libxslt"],
1903
+ ["win32config.h", "libxslt.h", "tst.c"])
1904
+ else:
1905
+ print("rebuild() failed, unable to guess the module")
1906
+ return None
1907
+ builder.scan()
1908
+ builder.analyze()
1909
+ builder.serialize()
1910
+ if glob.glob("../libexslt/exslt.c") != [] :
1911
+ extra = docBuilder("libexslt", ["../libexslt"], ["libexslt.h"])
1912
+ extra.scan()
1913
+ extra.analyze()
1914
+ extra.serialize()
1915
+ return builder
1916
+
1917
+ #
1918
+ # for debugging the parser
1919
+ #
1920
+ def parse(filename):
1921
+ parser = CParser(filename)
1922
+ idx = parser.parse()
1923
+ return idx
1924
+
1925
+ if __name__ == "__main__":
1926
+ if len(sys.argv) > 1:
1927
+ debug = 1
1928
+ parse(sys.argv[1])
1929
+ else:
1930
+ rebuild()
local-test-libxml2-full-01/afc-libxml2/doc/libxml2-api.xml ADDED
The diff for this file is too large to render. See raw diff
 
local-test-libxml2-full-01/afc-libxml2/doc/meson.build ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ install_man(files(['xml2-config.1', 'xmlcatalog.1', 'xmllint.1']))
3
+
4
+
5
+ tutorial_files = files(
6
+ 'xmlcatalog.html',
7
+ 'xmllint.html',
8
+ )
9
+
10
+ install_data(tutorial_files, install_dir: dir_doc)
11
+
12
+ subdir('devhelp')
local-test-libxml2-full-01/afc-libxml2/doc/xml2-config.1 ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .TH xml2-config 1 "3 April 2022" Version 1.2.0
2
+ .SH NAME
3
+ xml2-config - script to get information about the installed version of libxml2
4
+ .SH SYNOPSIS
5
+ .B xml2-config
6
+ [\-\-prefix\fI[=DIR]\fP] [\-\-libs] [\-\-cflags] [\-\-version] [\-\-help]
7
+ .SH DESCRIPTION
8
+ \fIxml2-config\fP is a tool that is used to determine the compile and
9
+ linker flags that should be used to compile and link programs that use
10
+ \fIlibxml2\fP.
11
+ .SH OPTIONS
12
+ \fIxml2-config\fP accepts the following options:
13
+ .TP 8
14
+ .B \-\-version
15
+ Print the currently installed version of \fIlibxml2\fP on the standard output.
16
+ .TP 8
17
+ .B \-\-libs
18
+ Print the linker flags that are necessary to link a \fIlibxml2\fP program.
19
+ Add \-\-dynamic after \-\-libs to print only shared library linking
20
+ information.
21
+ .TP 8
22
+ .B \-\-cflags
23
+ Print the compiler flags that are necessary to compile a \fIlibxml2\fP program.
24
+ .TP 8
25
+ .B \-\-prefix=PREFIX
26
+ If specified, use PREFIX instead of the installation prefix that
27
+ \fIlibxml2\fP was built with when computing the output for the
28
+ \-\-cflags and \-\-libs options. This option must be specified before
29
+ any \-\-libs or \-\-cflags options.
30
+ .SH AUTHOR
31
+ This manual page was written by Fredrik Hallenberg <[email protected]>,
32
+ for the Debian GNU/linux system (but may be used by others).
local-test-libxml2-full-01/afc-libxml2/doc/xmlcatalog.1 ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '\" t
2
+ .\" Title: xmlcatalog
3
+ .\" Author: John Fleck <[email protected]>
4
+ .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5
+ .\" Date: 06/12/2024
6
+ .\" Manual: xmlcatalog Manual
7
+ .\" Source: libxml2
8
+ .\" Language: English
9
+ .\"
10
+ .TH "XMLCATALOG" "1" "06/12/2024" "libxml2" "xmlcatalog Manual"
11
+ .\" -----------------------------------------------------------------
12
+ .\" * Define some portability stuff
13
+ .\" -----------------------------------------------------------------
14
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+ .\" http://bugs.debian.org/507673
16
+ .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
+ .ie \n(.g .ds Aq \(aq
19
+ .el .ds Aq '
20
+ .\" -----------------------------------------------------------------
21
+ .\" * set default formatting
22
+ .\" -----------------------------------------------------------------
23
+ .\" disable hyphenation
24
+ .nh
25
+ .\" disable justification (adjust text to left margin only)
26
+ .ad l
27
+ .\" -----------------------------------------------------------------
28
+ .\" * MAIN CONTENT STARTS HERE *
29
+ .\" -----------------------------------------------------------------
30
+ .SH "NAME"
31
+ xmlcatalog \- Command line tool to parse and manipulate XML or SGML catalog files\&.
32
+ .SH "SYNOPSIS"
33
+ .HP \w'\fBxmlcatalog\fR\ 'u
34
+ \fBxmlcatalog\fR [\fB\-\-sgml\fR | \fB\-\-shell\fR | \fB\-\-convert\fR | \fB\-\-create\fR | \fB\-\-del\ \fR\fB\fIVALUE(S)\fR\fR | [\ \fB\-\-add\ \fR\fB\fITYPE\fR\fR\fB\ \fR\fB\fIORIG\fR\fR\fB\ \fR\fB\fIREPLACE\fR\fR\fB\ \fR\ |\ \fB\-\-add\ \fR\fB\fIFILENAME\fR\fR] | \fB\-\-noout\fR | \fB\-\-no\-super\-update\fR | [\fB\-v\fR\ |\ \fB\-\-verbose\fR]] {\fICATALOGFILE\fR} {\fIENTITIES\fR...}
35
+ .SH "DESCRIPTION"
36
+ .PP
37
+ \fBxmlcatalog\fR
38
+ is a command line application allowing users to monitor and manipulate
39
+ XML
40
+ and
41
+ SGML
42
+ catalogs\&. It is included in
43
+ \fBlibxml\fR(3)\&.
44
+ .PP
45
+ Its functions can be invoked from a single command from the command line, or it can perform multiple functions in interactive mode\&. It can operate on both
46
+ XML
47
+ and
48
+ SGML
49
+ files\&.
50
+ .SH "OPTIONS"
51
+ .PP
52
+ \fBxmlcatalog\fR
53
+ accepts the following options (in alphabetical order):
54
+ .PP
55
+ \fB\-\-add \fR\fB\fITYPE\fR\fR\fB \fR\fB\fIORIG\fR\fR\fB \fR\fB\fIREPLACE\fR\fR\fB \fR
56
+ .RS 4
57
+ Add an entry to
58
+ CATALOGFILE\&.
59
+ \fITYPE\fR
60
+ indicates the type of entry\&. Possible types are:
61
+ \fIpublic\fR, \fIsystem\fR, \fIuri\fR, \fIrewriteSystem\fR, \fIrewriteURI\fR, \fIdelegatePublic\fR, \fIdelegateSystem\fR, \fIdelegateURI\fR, \fInextCatalog\fR\&.
62
+ \fIORIG\fR
63
+ is the original reference to be replaced, and
64
+ \fIREPLACE\fR
65
+ is the
66
+ URI
67
+ of the replacement entity to be used\&. The
68
+ \fB\-\-add\fR
69
+ option will not overwrite
70
+ CATALOGFILE, outputting to
71
+ stdout, unless
72
+ \fB\-\-noout\fR
73
+ is used\&. The
74
+ \fB\-\-add\fR
75
+ will always take three parameters even if some of the
76
+ XML
77
+ catalog constructs will have only a single argument\&.
78
+ .RE
79
+ .PP
80
+ \fB\-\-add \fR\fB\fIFILENAME\fR\fR
81
+ .RS 4
82
+ If the
83
+ \fB\-\-add\fR
84
+ option is used following the
85
+ \fB\-\-sgml\fR
86
+ option, only a single argument, a
87
+ \fIFILENAME\fR, is used\&. This is used to add the name of a catalog file to an
88
+ SGML
89
+ supercatalog, a file that contains references to other included
90
+ SGML
91
+ catalog files\&.
92
+ .RE
93
+ .PP
94
+ \fB\-\-convert\fR
95
+ .RS 4
96
+ Convert SGML catalog to XML\&.
97
+ .RE
98
+ .PP
99
+ \fB\-\-create\fR
100
+ .RS 4
101
+ Create a new
102
+ XML
103
+ catalog\&. Outputs to
104
+ stdout, ignoring
105
+ \fIfilename\fR
106
+ unless
107
+ \fB\-\-noout\fR
108
+ is used, in which case it creates a new catalog file
109
+ \fIfilename\fR\&.
110
+ .RE
111
+ .PP
112
+ \fB\-\-del \fR\fB\fIVALUE(S)\fR\fR
113
+ .RS 4
114
+ Remove entries from
115
+ \fICATALOGFILE\fR
116
+ matching
117
+ \fIVALUE(S)\fR\&. The
118
+ \fB\-\-del\fR
119
+ option will not overwrite
120
+ \fICATALOGFILE\fR, outputting to
121
+ stdout, unless
122
+ \fB\-\-noout\fR
123
+ is used\&.
124
+ .RE
125
+ .PP
126
+ \fB\-\-noout\fR
127
+ .RS 4
128
+ Save output to the named file rather than outputting to
129
+ stdout\&.
130
+ .RE
131
+ .PP
132
+ \fB\-\-no\-super\-update\fR
133
+ .RS 4
134
+ Do not update the
135
+ SGML
136
+ super catalog\&.
137
+ .RE
138
+ .PP
139
+ \fB\-\-shell\fR
140
+ .RS 4
141
+ Run a shell allowing interactive queries on catalog file
142
+ \fICATALOGFILE\fR\&. For the set of available commands see
143
+ the section called \(lqSHELL COMMANDS\(rq\&.
144
+ .RE
145
+ .PP
146
+ \fB\-\-sgml\fR
147
+ .RS 4
148
+ Uses
149
+ SGML
150
+ super catalogs for
151
+ \fB\-\-add\fR
152
+ and
153
+ \fB\-\-del\fR
154
+ options\&.
155
+ .RE
156
+ .PP
157
+ \fB\-v\fR, \fB\-\-verbose\fR
158
+ .RS 4
159
+ Output debugging information\&.
160
+ .RE
161
+ .PP
162
+ Invoking
163
+ \fBxmlcatalog\fR
164
+ non\-interactively without a designated action (imposed with options like
165
+ \fB\-\-add\fR) will result in a lookup of the catalog entry for
166
+ \fIENTITIES\fR
167
+ in the catalog denoted with
168
+ \fICATALOGFILE\fR\&. The corresponding entries will be output to the command line\&. This mode of operation, together with
169
+ \fB\-\-shell\fR
170
+ mode and non\-modifying (i\&.e\&. without
171
+ \fB\-\-noout\fR) direct actions, allows for a special shortcut of the void
172
+ \fICATALOGFILE\fR
173
+ specification (possibly expressed as "" in the shell environment) appointing the default system catalog\&. That simplifies the handling when its exact location is irrelevant but the respective built\-in still needs to be consulted\&.
174
+ .SH "SHELL COMMANDS"
175
+ .PP
176
+ Invoking
177
+ \fBxmlcatalog\fR
178
+ with the
179
+ \fB\-\-shell \fR\fB\fICATALOGFILE\fR\fR
180
+ option opens a command line shell allowing interactive access to the catalog file identified by
181
+ \fICATALOGFILE\fR\&. Invoking the shell provides a command line prompt after which the following commands (described in alphabetical order) can be entered\&.
182
+ .PP
183
+ \fBadd \fR\fB\fITYPE\fR\fR\fB \fR\fB\fIORIG\fR\fR\fB \fR\fB\fIREPLACE\fR\fR\fB \fR
184
+ .RS 4
185
+ Add an entry to the catalog file\&.
186
+ \fITYPE\fR
187
+ indicates the type of entry\&. Possible types are:
188
+ \fIpublic\fR, \fIsystem\fR, \fIuri\fR, \fIrewriteSystem\fR, \fIrewriteURI\fR, \fIdelegatePublic\fR, \fIdelegateSystem\fR, \fIdelegateURI\fR, \fInextCatalog\fR\&.
189
+ \fIORIG\fR
190
+ is the original reference to be replaced, and
191
+ \fIREPLACE\fR
192
+ is the
193
+ URI
194
+ of the replacement entity to be used\&. The
195
+ \fB\-\-add\fR
196
+ option will not overwrite
197
+ CATALOGFILE, outputting to
198
+ stdout, unless
199
+ \fB\-\-noout\fR
200
+ is used\&. The
201
+ \fB\-\-add\fR
202
+ will always take three parameters even if some of the
203
+ XML
204
+ catalog constructs will have only a single argument\&.
205
+ .RE
206
+ .PP
207
+ \fBdebug\fR
208
+ .RS 4
209
+ Print debugging statements showing the steps
210
+ \fBxmlcatalog\fR
211
+ is executing\&.
212
+ .RE
213
+ .PP
214
+ \fBdel \fR\fB\fIVALUE(S)\fR\fR
215
+ .RS 4
216
+ Remove the catalog entry corresponding to
217
+ \fIVALUE(S)\fR\&.
218
+ .RE
219
+ .PP
220
+ \fBdump\fR
221
+ .RS 4
222
+ Print the current catalog\&.
223
+ .RE
224
+ .PP
225
+ \fBexit\fR
226
+ .RS 4
227
+ Quit the shell\&.
228
+ .RE
229
+ .PP
230
+ \fBpublic \fR\fB\fIPUBLIC\-ID\fR\fR
231
+ .RS 4
232
+ Execute a Formal Public Identifier lookup of the catalog entry for
233
+ \fIPUBLIC\-ID\fR\&. The corresponding entry will be output to the command line\&.
234
+ .RE
235
+ .PP
236
+ \fBquiet\fR
237
+ .RS 4
238
+ Stop printing debugging statements\&.
239
+ .RE
240
+ .PP
241
+ \fBsystem \fR\fB\fISYSTEM\-ID\fR\fR
242
+ .RS 4
243
+ Execute a Formal Public Identifier lookup of the catalog entry for
244
+ \fISYSTEM\-ID\fR\&. The corresponding entry will be output to the command line\&.
245
+ .RE
246
+ .SH "ENVIRONMENT"
247
+ .PP
248
+ \fBXML_CATALOG_FILES\fR
249
+ .RS 4
250
+ XML
251
+ catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
252
+ \fBXML_CATALOG_FILES\fR
253
+ environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default catalog from
254
+ /etc/xml/catalog
255
+ or, more specifically,
256
+ ${sysconfdir}/xml/catalog\&.
257
+ .RE
258
+ .SH "DIAGNOSTICS"
259
+ .PP
260
+ \fBxmlcatalog\fR
261
+ return codes provide information that can be used when calling it from scripts\&.
262
+ .PP
263
+ \fB0\fR
264
+ .RS 4
265
+ No error
266
+ .RE
267
+ .PP
268
+ \fB1\fR
269
+ .RS 4
270
+ Failed to remove an entry from the catalog
271
+ .RE
272
+ .PP
273
+ \fB2\fR
274
+ .RS 4
275
+ Failed to save to the catalog, check file permissions
276
+ .RE
277
+ .PP
278
+ \fB3\fR
279
+ .RS 4
280
+ Failed to add an entry to the catalog
281
+ .RE
282
+ .PP
283
+ \fB4\fR
284
+ .RS 4
285
+ Failed to look up an entry in the catalog
286
+ .RE
287
+ .SH "SEE ALSO"
288
+ .PP
289
+ \fBlibxml\fR(3)
290
+ .PP
291
+ More information can be found at
292
+ .sp
293
+ .RS 4
294
+ .ie n \{\
295
+ \h'-04'\(bu\h'+03'\c
296
+ .\}
297
+ .el \{\
298
+ .sp -1
299
+ .IP \(bu 2.3
300
+ .\}
301
+ \fBlibxml\fR(3)
302
+ web page
303
+ \m[blue]\fB\%https://gitlab.gnome.org/GNOME/libxml2\fR\m[]
304
+ .RE
305
+ .sp
306
+ .RS 4
307
+ .ie n \{\
308
+ \h'-04'\(bu\h'+03'\c
309
+ .\}
310
+ .el \{\
311
+ .sp -1
312
+ .IP \(bu 2.3
313
+ .\}
314
+ \fBlibxml\fR(3)
315
+ catalog support web page at
316
+ \m[blue]\fB\%https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support\fR\m[]
317
+ .RE
318
+ .sp
319
+ .RS 4
320
+ .ie n \{\
321
+ \h'-04'\(bu\h'+03'\c
322
+ .\}
323
+ .el \{\
324
+ .sp -1
325
+ .IP \(bu 2.3
326
+ .\}
327
+ James Clark\*(Aqs
328
+ SGML
329
+ catalog page
330
+ \m[blue]\fB\%http://www.jclark.com/sp/catalog.htm\fR\m[]
331
+ .RE
332
+ .sp
333
+ .RS 4
334
+ .ie n \{\
335
+ \h'-04'\(bu\h'+03'\c
336
+ .\}
337
+ .el \{\
338
+ .sp -1
339
+ .IP \(bu 2.3
340
+ .\}
341
+ OASIS
342
+ XML
343
+ catalog specification
344
+ \m[blue]\fB\%http://www.oasis-open.org/committees/entity/spec.html\fR\m[]
345
+ .RE
346
+ .sp
347
+ .SH "AUTHOR"
348
+ .PP
349
+ \fBJohn Fleck\fR <\&jfleck@inkstain\&.net\&>
350
+ .RS 4
351
+ Author.
352
+ .RE
353
+ .SH "COPYRIGHT"
354
+ .br
355
+ Copyright \(co 2001, 2004
356
+ .br
local-test-libxml2-full-01/afc-libxml2/doc/xmlcatalog.html ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmlcatalog</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmlcatalog &#8212;
2
+ Command line tool to parse and manipulate <acronym class="acronym">XML</acronym>
3
+ or <acronym class="acronym">SGML</acronym> catalog files.
4
+ </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmlcatalog</code> [ <code class="option">--sgml</code> | <code class="option">--shell</code> | <code class="option">--convert</code> | <code class="option">--create</code> | <code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code> |
5
+ [
6
+ <code class="option">--add
7
+ <em class="replaceable"><code>TYPE</code></em>
8
+ <em class="replaceable"><code>ORIG</code></em>
9
+ <em class="replaceable"><code>REPLACE</code></em>
10
+ </code>
11
+ | <code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code> ]
12
+ | <code class="option">--noout</code> | <code class="option">--no-super-update</code> |
13
+ [ <code class="option">-v</code> | <code class="option">--verbose</code> ]
14
+ ] {<em class="replaceable"><code>CATALOGFILE</code></em>} {<em class="replaceable"><code>ENTITIES</code></em>...}</p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
15
+ <span class="command"><strong>xmlcatalog</strong></span> is a command line application allowing users to monitor and
16
+ manipulate <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> catalogs. It
17
+ is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.
18
+ </p><p>
19
+ Its functions can be invoked from a single command from the command line,
20
+ or it can perform multiple functions in interactive mode. It can operate
21
+ on both <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> files.
22
+ </p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
23
+ <span class="command"><strong>xmlcatalog</strong></span> accepts the following options (in alphabetical order):
24
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
25
+ <code class="option">--add
26
+ <em class="replaceable"><code>TYPE</code></em>
27
+ <em class="replaceable"><code>ORIG</code></em>
28
+ <em class="replaceable"><code>REPLACE</code></em>
29
+ </code>
30
+ </span></dt><dd><p>
31
+ Add an entry to <code class="filename">CATALOGFILE</code>. <em class="replaceable"><code>TYPE</code></em>
32
+ indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
33
+ reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
34
+ is the <acronym class="acronym">URI</acronym> of the replacement entity to be
35
+ used. The <code class="option">--add</code> option will not overwrite
36
+ <code class="filename">CATALOGFILE</code>, outputting
37
+ to <code class="filename">stdout</code>, unless
38
+ <code class="option">--noout</code> is used. The <code class="option">--add</code> will
39
+ always take three parameters even if some of the <acronym class="acronym">XML</acronym>
40
+ catalog constructs will have only a single argument.
41
+ </p></dd><dt><span class="term"><code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code></span></dt><dd><p>
42
+ If the <code class="option">--add</code> option is used following
43
+ the <code class="option">--sgml</code> option, only a single argument,
44
+ a <em class="replaceable"><code>FILENAME</code></em>, is used. This is used to add
45
+ the name of a catalog file to an <acronym class="acronym">SGML</acronym> supercatalog,
46
+ a file that contains references to other included <acronym class="acronym">SGML</acronym>
47
+ catalog files.
48
+ </p></dd><dt><span class="term"><code class="option">--convert</code></span></dt><dd><p>
49
+ Convert SGML catalog to XML.
50
+ </p></dd><dt><span class="term"><code class="option">--create</code></span></dt><dd><p>
51
+ Create a new <acronym class="acronym">XML</acronym> catalog. Outputs
52
+ to <code class="filename">stdout</code>,
53
+ ignoring <em class="replaceable"><code>filename</code></em> unless <code class="option">--noout</code> is
54
+ used, in which case it creates a new catalog
55
+ file <em class="replaceable"><code>filename</code></em>.
56
+ </p></dd><dt><span class="term"><code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
57
+ Remove entries from <em class="replaceable"><code>CATALOGFILE</code></em>
58
+ matching <em class="replaceable"><code>VALUE(S)</code></em>. The <code class="option">--del</code>
59
+ option will not overwrite <em class="replaceable"><code>CATALOGFILE</code></em>,
60
+ outputting to <code class="filename">stdout</code>,
61
+ unless <code class="option">--noout</code> is used.
62
+ </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
63
+ Save output to the named file rather than outputting
64
+ to <code class="filename">stdout</code>.
65
+ </p></dd><dt><span class="term"><code class="option">--no-super-update</code></span></dt><dd><p>
66
+ Do not update the <acronym class="acronym">SGML</acronym> super catalog.
67
+ </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
68
+ Run a shell allowing interactive queries on catalog
69
+ file <em class="replaceable"><code>CATALOGFILE</code></em>. For the set of available
70
+ commands see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>.
71
+ </p></dd><dt><span class="term"><code class="option">--sgml</code></span></dt><dd><p>
72
+ Uses <acronym class="acronym">SGML</acronym> super catalogs for <code class="option">--add</code>
73
+ and <code class="option">--del</code> options.
74
+ </p></dd><dt><span class="term"><code class="option">-v</code>, </span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>Output debugging information.</p></dd></dl></div><p>
75
+ Invoking <span class="command"><strong>xmlcatalog</strong></span> non-interactively without a designated action
76
+ (imposed with options like <code class="option">--add</code>) will result in a lookup
77
+ of the catalog entry for <em class="replaceable"><code>ENTITIES</code></em> in the
78
+ catalog denoted with <em class="replaceable"><code>CATALOGFILE</code></em>. The
79
+ corresponding entries will be output to the command line. This mode of
80
+ operation, together with <code class="option">--shell</code> mode and non-modifying
81
+ (i.e. without <code class="option">--noout</code>) direct actions, allows for
82
+ a special shortcut of the void <em class="replaceable"><code>CATALOGFILE</code></em>
83
+ specification (possibly expressed as "" in the shell
84
+ environment) appointing the default system catalog. That simplifies the
85
+ handling when its exact location is irrelevant but the respective built-in
86
+ still needs to be consulted.
87
+ </p></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
88
+ Invoking <span class="command"><strong>xmlcatalog</strong></span> with
89
+ the <code class="option">--shell <em class="replaceable"><code>CATALOGFILE</code></em></code> option opens
90
+ a command line shell allowing interactive access to the catalog file
91
+ identified by <em class="replaceable"><code>CATALOGFILE</code></em>. Invoking the shell
92
+ provides a command line prompt after which the following commands (described in
93
+ alphabetical order) can be entered.
94
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
95
+ <code class="option">add
96
+ <em class="replaceable"><code>TYPE</code></em>
97
+ <em class="replaceable"><code>ORIG</code></em>
98
+ <em class="replaceable"><code>REPLACE</code></em>
99
+ </code>
100
+ </span></dt><dd><p>
101
+ Add an entry to the catalog file. <em class="replaceable"><code>TYPE</code></em>
102
+ indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
103
+ reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
104
+ is the <acronym class="acronym">URI</acronym> of the replacement entity to be
105
+ used. The <code class="option">--add</code> option will not overwrite
106
+ <code class="filename">CATALOGFILE</code>, outputting
107
+ to <code class="filename">stdout</code>, unless
108
+ <code class="option">--noout</code> is used. The <code class="option">--add</code> will
109
+ always take three parameters even if some of the <acronym class="acronym">XML</acronym>
110
+ catalog constructs will have only a single argument.
111
+ </p></dd><dt><span class="term"><code class="option">debug</code></span></dt><dd><p>
112
+ Print debugging statements showing the steps <span class="command"><strong>xmlcatalog</strong></span> is executing.
113
+ </p></dd><dt><span class="term"><code class="option">del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
114
+ Remove the catalog entry corresponding to <em class="replaceable"><code>VALUE(S)</code></em>.
115
+ </p></dd><dt><span class="term"><code class="option">dump</code></span></dt><dd><p>Print the current catalog.</p></dd><dt><span class="term"><code class="option">exit</code></span></dt><dd><p>Quit the shell.</p></dd><dt><span class="term"><code class="option">public <em class="replaceable"><code>PUBLIC-ID</code></em></code></span></dt><dd><p>
116
+ Execute a Formal Public Identifier lookup of the catalog entry
117
+ for <em class="replaceable"><code>PUBLIC-ID</code></em>. The corresponding entry will be
118
+ output to the command line.
119
+ </p></dd><dt><span class="term"><code class="option">quiet</code></span></dt><dd><p>Stop printing debugging statements.</p></dd><dt><span class="term"><code class="option">system <em class="replaceable"><code>SYSTEM-ID</code></em></code></span></dt><dd><p>
120
+ Execute a Formal Public Identifier lookup of the catalog entry
121
+ for <em class="replaceable"><code>SYSTEM-ID</code></em>. The corresponding entry will be
122
+ output to the command line.
123
+ </p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
124
+ queries to the user's own set of catalogs. This can be done by setting
125
+ the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
126
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
127
+ An empty variable should deactivate loading the default catalog from
128
+ <code class="filename">/etc/xml/catalog</code> or, more specifically,
129
+ <code class="filename">${sysconfdir}/xml/catalog</code>.
130
+ </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
131
+ <span class="command"><strong>xmlcatalog</strong></span> return codes provide information that can be used when
132
+ calling it from scripts.
133
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Failed to remove an entry from the catalog</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Failed to save to the catalog, check file permissions</p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Failed to add an entry to the catalog</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Failed to look up an entry in the catalog</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
134
+ </p><p>
135
+ More information can be found at
136
+ </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
137
+ </p></li><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> catalog support web page
138
+ at <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support" target="_top">https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support</a>
139
+ </p></li><li class="listitem"><p>James Clark's <acronym class="acronym">SGML</acronym> catalog
140
+ page <a class="ulink" href="http://www.jclark.com/sp/catalog.htm" target="_top">http://www.jclark.com/sp/catalog.htm</a>
141
+ </p></li><li class="listitem"><p><acronym class="acronym">OASIS</acronym> <acronym class="acronym">XML</acronym> catalog specification
142
+ <a class="ulink" href="http://www.oasis-open.org/committees/entity/spec.html" target="_top">http://www.oasis-open.org/committees/entity/spec.html</a>
143
+ </p></li></ul></div><p>
144
+ </p></div></div></body></html>
local-test-libxml2-full-01/afc-libxml2/doc/xmlcatalog.xml ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet type="text/xsl"
3
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
4
+ <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
5
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
6
+
7
+ <!ENTITY xmlcatalog "<command>xmlcatalog</command>">
8
+ ]>
9
+
10
+ <refentry>
11
+
12
+ <refentryinfo>
13
+ <title>xmlcatalog Manual</title>
14
+ <productname>libxml2</productname>
15
+ <copyright>
16
+ <year>2001</year>
17
+ <year>2004</year>
18
+ </copyright>
19
+ <author>
20
+ <firstname>John</firstname>
21
+ <surname>Fleck</surname>
22
+ <affiliation>
23
+ <address>
24
+ <email>[email protected]</email>
25
+ </address>
26
+ </affiliation>
27
+ </author>
28
+ <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
29
+ <!-- <releaseinfo>This is release 0.3 of the xmlcatalog Manual.</releaseinfo> -->
30
+ <!-- <edition>0.3</edition> -->
31
+ </refentryinfo>
32
+
33
+ <refmeta>
34
+ <refentrytitle>xmlcatalog</refentrytitle>
35
+ <manvolnum>1</manvolnum>
36
+ </refmeta>
37
+
38
+ <refnamediv>
39
+ <refname>xmlcatalog</refname>
40
+ <refpurpose>
41
+ Command line tool to parse and manipulate <acronym>XML</acronym>
42
+ or <acronym>SGML</acronym> catalog files.
43
+ </refpurpose>
44
+ </refnamediv>
45
+
46
+ <refsynopsisdiv>
47
+ <cmdsynopsis>
48
+ <command>xmlcatalog</command>
49
+ <group choice="opt">
50
+ <arg choice="plain"><option>--sgml</option></arg>
51
+ <arg choice="plain"><option>--shell</option></arg>
52
+ <arg choice="plain"><option>--convert</option></arg>
53
+ <arg choice="plain"><option>--create</option></arg>
54
+ <arg choice="plain"><option>--del <replaceable>VALUE(S)</replaceable></option></arg>
55
+ <arg choice="plain">
56
+ <group choice="opt">
57
+ <arg choice="plain">
58
+ <option>--add
59
+ <replaceable>TYPE</replaceable>
60
+ <replaceable>ORIG</replaceable>
61
+ <replaceable>REPLACE</replaceable>
62
+ </option>
63
+ </arg>
64
+ <arg choice="plain"><option>--add <replaceable>FILENAME</replaceable></option></arg>
65
+ </group>
66
+ </arg>
67
+ <arg choice="plain"><option>--noout</option></arg>
68
+ <arg choice="plain"><option>--no-super-update</option></arg>
69
+ <arg choice="plain">
70
+ <group choice="opt">
71
+ <arg choice="plain"><option>-v</option></arg>
72
+ <arg choice="plain"><option>--verbose</option></arg>
73
+ </group>
74
+ </arg>
75
+ </group>
76
+ <arg choice="req" rep="norepeat"><replaceable>CATALOGFILE</replaceable></arg>
77
+ <arg choice="req" rep="repeat"><replaceable>ENTITIES</replaceable></arg>
78
+ </cmdsynopsis>
79
+ </refsynopsisdiv>
80
+
81
+ <refsect1 id="description">
82
+ <title>DESCRIPTION</title>
83
+ <para>
84
+ &xmlcatalog; is a command line application allowing users to monitor and
85
+ manipulate <acronym>XML</acronym> and <acronym>SGML</acronym> catalogs. It
86
+ is included in <citerefentry>
87
+ <refentrytitle>libxml</refentrytitle>
88
+ <manvolnum>3</manvolnum>
89
+ </citerefentry>.
90
+ </para>
91
+ <para>
92
+ Its functions can be invoked from a single command from the command line,
93
+ or it can perform multiple functions in interactive mode. It can operate
94
+ on both <acronym>XML</acronym> and <acronym>SGML</acronym> files.
95
+ </para>
96
+ </refsect1>
97
+
98
+ <refsect1 id="options">
99
+ <title>OPTIONS</title>
100
+ <para>
101
+ &xmlcatalog; accepts the following options (in alphabetical order):
102
+ </para>
103
+
104
+ <variablelist>
105
+
106
+ <varlistentry>
107
+ <term>
108
+ <option>--add
109
+ <replaceable>TYPE</replaceable>
110
+ <replaceable>ORIG</replaceable>
111
+ <replaceable>REPLACE</replaceable>
112
+ </option>
113
+ </term>
114
+ <listitem>
115
+ <para>
116
+ Add an entry to <filename>CATALOGFILE</filename>. <replaceable>TYPE</replaceable>
117
+ indicates the type of entry. Possible types are: <simplelist type="inline">
118
+ <member><parameter>public</parameter></member>
119
+ <member><parameter>system</parameter></member>
120
+ <member><parameter>uri</parameter></member>
121
+ <member><parameter>rewriteSystem</parameter></member>
122
+ <member><parameter>rewriteURI</parameter></member>
123
+ <member><parameter>delegatePublic</parameter></member>
124
+ <member><parameter>delegateSystem</parameter></member>
125
+ <member><parameter>delegateURI</parameter></member>
126
+ <member><parameter>nextCatalog</parameter></member>
127
+ </simplelist>. <replaceable>ORIG</replaceable> is the original
128
+ reference to be replaced, and <replaceable>REPLACE</replaceable>
129
+ is the <acronym>URI</acronym> of the replacement entity to be
130
+ used. The <option>--add</option> option will not overwrite
131
+ <filename>CATALOGFILE</filename>, outputting
132
+ to <filename class="devicefile">stdout</filename>, unless
133
+ <option>--noout</option> is used. The <option>--add</option> will
134
+ always take three parameters even if some of the <acronym>XML</acronym>
135
+ catalog constructs will have only a single argument.
136
+ </para>
137
+ <!--
138
+ FIXME - Is my list of possible types correct? Are SGML types the same?
139
+ -->
140
+ </listitem>
141
+ </varlistentry>
142
+
143
+ <varlistentry>
144
+ <term><option>--add <replaceable>FILENAME</replaceable></option></term>
145
+ <listitem>
146
+ <para>
147
+ If the <option>--add</option> option is used following
148
+ the <option>--sgml</option> option, only a single argument,
149
+ a <replaceable>FILENAME</replaceable>, is used. This is used to add
150
+ the name of a catalog file to an <acronym>SGML</acronym> supercatalog,
151
+ a file that contains references to other included <acronym>SGML</acronym>
152
+ catalog files.
153
+ </para>
154
+ </listitem>
155
+ </varlistentry>
156
+
157
+ <varlistentry>
158
+ <term><option>--convert</option></term>
159
+ <listitem>
160
+ <para>
161
+ Convert SGML catalog to XML.
162
+ </para>
163
+ </listitem>
164
+ </varlistentry>
165
+
166
+ <varlistentry>
167
+ <term><option>--create</option></term>
168
+ <listitem>
169
+ <para>
170
+ Create a new <acronym>XML</acronym> catalog. Outputs
171
+ to <filename class="devicefile">stdout</filename>,
172
+ ignoring <replaceable>filename</replaceable> unless <option>--noout</option> is
173
+ used, in which case it creates a new catalog
174
+ file <replaceable>filename</replaceable>.
175
+ </para>
176
+ </listitem>
177
+ </varlistentry>
178
+
179
+ <varlistentry>
180
+ <term><option>--del <replaceable>VALUE(S)</replaceable></option></term>
181
+ <listitem>
182
+ <para>
183
+ Remove entries from <replaceable>CATALOGFILE</replaceable>
184
+ matching <replaceable>VALUE(S)</replaceable>. The <option>--del</option>
185
+ option will not overwrite <replaceable>CATALOGFILE</replaceable>,
186
+ outputting to <filename class="devicefile">stdout</filename>,
187
+ unless <option>--noout</option> is used.
188
+ </para>
189
+ </listitem>
190
+ </varlistentry>
191
+
192
+ <varlistentry>
193
+ <term><option>--noout</option></term>
194
+ <listitem>
195
+ <para>
196
+ Save output to the named file rather than outputting
197
+ to <filename class="devicefile">stdout</filename>.
198
+ </para>
199
+ </listitem>
200
+ </varlistentry>
201
+
202
+ <varlistentry>
203
+ <term><option>--no-super-update</option></term>
204
+ <listitem>
205
+ <para>
206
+ Do not update the <acronym>SGML</acronym> super catalog.
207
+ </para>
208
+ </listitem>
209
+ </varlistentry>
210
+
211
+ <varlistentry>
212
+ <term><option>--shell</option></term>
213
+ <listitem>
214
+ <para>
215
+ Run a shell allowing interactive queries on catalog
216
+ file <replaceable>CATALOGFILE</replaceable>. For the set of available
217
+ commands see <xref linkend="shell"/>.
218
+ </para>
219
+ </listitem>
220
+ </varlistentry>
221
+
222
+ <varlistentry>
223
+ <term><option>--sgml</option></term>
224
+ <listitem>
225
+ <para>
226
+ Uses <acronym>SGML</acronym> super catalogs for <option>--add</option>
227
+ and <option>--del</option> options.
228
+ </para>
229
+ </listitem>
230
+ </varlistentry>
231
+
232
+ <varlistentry>
233
+ <term><option>-v</option></term>
234
+ <term><option>--verbose</option></term>
235
+ <listitem>
236
+ <para>Output debugging information.</para>
237
+ </listitem>
238
+ </varlistentry>
239
+
240
+ </variablelist>
241
+
242
+ <para>
243
+ Invoking &xmlcatalog; non-interactively without a designated action
244
+ (imposed with options like <option>--add</option>) will result in a lookup
245
+ of the catalog entry for <replaceable>ENTITIES</replaceable> in the
246
+ catalog denoted with <replaceable>CATALOGFILE</replaceable>. The
247
+ corresponding entries will be output to the command line. This mode of
248
+ operation, together with <option>--shell</option> mode and non-modifying
249
+ (i.e. without <option>--noout</option>) direct actions, allows for
250
+ a special shortcut of the void <replaceable>CATALOGFILE</replaceable>
251
+ specification (possibly expressed as &quot;&quot; in the shell
252
+ environment) appointing the default system catalog. That simplifies the
253
+ handling when its exact location is irrelevant but the respective built-in
254
+ still needs to be consulted.
255
+ </para>
256
+ </refsect1>
257
+
258
+ <refsect1 id="shell">
259
+ <title>SHELL COMMANDS</title>
260
+ <para>
261
+ Invoking &xmlcatalog; with
262
+ the <option>--shell <replaceable>CATALOGFILE</replaceable></option> option opens
263
+ a command line shell allowing interactive access to the catalog file
264
+ identified by <replaceable>CATALOGFILE</replaceable>. Invoking the shell
265
+ provides a command line prompt after which the following commands (described in
266
+ alphabetical order) can be entered.
267
+ </para>
268
+
269
+ <variablelist>
270
+
271
+ <varlistentry>
272
+ <term>
273
+ <option>add
274
+ <replaceable>TYPE</replaceable>
275
+ <replaceable>ORIG</replaceable>
276
+ <replaceable>REPLACE</replaceable>
277
+ </option>
278
+ </term>
279
+ <listitem>
280
+ <para>
281
+ Add an entry to the catalog file. <replaceable>TYPE</replaceable>
282
+ indicates the type of entry. Possible types are: <simplelist type="inline">
283
+ <member><parameter>public</parameter></member>
284
+ <member><parameter>system</parameter></member>
285
+ <member><parameter>uri</parameter></member>
286
+ <member><parameter>rewriteSystem</parameter></member>
287
+ <member><parameter>rewriteURI</parameter></member>
288
+ <member><parameter>delegatePublic</parameter></member>
289
+ <member><parameter>delegateSystem</parameter></member>
290
+ <member><parameter>delegateURI</parameter></member>
291
+ <member><parameter>nextCatalog</parameter></member>
292
+ </simplelist>. <replaceable>ORIG</replaceable> is the original
293
+ reference to be replaced, and <replaceable>REPLACE</replaceable>
294
+ is the <acronym>URI</acronym> of the replacement entity to be
295
+ used. The <option>--add</option> option will not overwrite
296
+ <filename>CATALOGFILE</filename>, outputting
297
+ to <filename class="devicefile">stdout</filename>, unless
298
+ <option>--noout</option> is used. The <option>--add</option> will
299
+ always take three parameters even if some of the <acronym>XML</acronym>
300
+ catalog constructs will have only a single argument.
301
+ </para>
302
+ </listitem>
303
+ </varlistentry>
304
+
305
+ <varlistentry>
306
+ <term><option>debug</option></term>
307
+ <listitem>
308
+ <para>
309
+ Print debugging statements showing the steps &xmlcatalog; is executing.
310
+ </para>
311
+ </listitem>
312
+ </varlistentry>
313
+
314
+ <varlistentry>
315
+ <term><option>del <replaceable>VALUE(S)</replaceable></option></term>
316
+ <listitem>
317
+ <para>
318
+ Remove the catalog entry corresponding to <replaceable>VALUE(S)</replaceable>.
319
+ </para>
320
+ </listitem>
321
+ </varlistentry>
322
+
323
+ <varlistentry>
324
+ <term><option>dump</option></term>
325
+ <listitem>
326
+ <para>Print the current catalog.</para>
327
+ </listitem>
328
+ </varlistentry>
329
+
330
+ <varlistentry>
331
+ <term><option>exit</option></term>
332
+ <listitem>
333
+ <para>Quit the shell.</para>
334
+ </listitem>
335
+ </varlistentry>
336
+
337
+ <varlistentry>
338
+ <term><option>public <replaceable>PUBLIC-ID</replaceable></option></term>
339
+ <listitem>
340
+ <para>
341
+ Execute a Formal Public Identifier lookup of the catalog entry
342
+ for <replaceable>PUBLIC-ID</replaceable>. The corresponding entry will be
343
+ output to the command line.
344
+ </para>
345
+ </listitem>
346
+ </varlistentry>
347
+
348
+ <varlistentry>
349
+ <term><option>quiet</option></term>
350
+ <listitem>
351
+ <para>Stop printing debugging statements.</para>
352
+ </listitem>
353
+ </varlistentry>
354
+
355
+ <varlistentry>
356
+ <term><option>system <replaceable>SYSTEM-ID</replaceable></option></term>
357
+ <listitem>
358
+ <para>
359
+ Execute a Formal Public Identifier lookup of the catalog entry
360
+ for <replaceable>SYSTEM-ID</replaceable>. The corresponding entry will be
361
+ output to the command line.
362
+ </para>
363
+ </listitem>
364
+ </varlistentry>
365
+
366
+ </variablelist>
367
+ </refsect1>
368
+
369
+ <refsect1 id="environment">
370
+ <title>ENVIRONMENT</title>
371
+ <variablelist>
372
+
373
+ <varlistentry>
374
+ <term><envar>XML_CATALOG_FILES</envar></term>
375
+ <listitem>
376
+ <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
377
+ queries to the user's own set of catalogs. This can be done by setting
378
+ the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
379
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
380
+ An empty variable should deactivate loading the default catalog from
381
+ <filename>/etc/xml/catalog</filename> or, more specifically,
382
+ <filename>${sysconfdir}/xml/catalog</filename>.
383
+ </para>
384
+ </listitem>
385
+ </varlistentry>
386
+
387
+ </variablelist>
388
+ </refsect1>
389
+
390
+ <refsect1 id="diagnostics">
391
+ <title>DIAGNOSTICS</title>
392
+ <para>
393
+ &xmlcatalog; return codes provide information that can be used when
394
+ calling it from scripts.
395
+ </para>
396
+ <variablelist>
397
+
398
+ <varlistentry>
399
+ <term><errorcode>0</errorcode></term>
400
+ <listitem>
401
+ <para>No error</para>
402
+ </listitem>
403
+ </varlistentry>
404
+
405
+ <varlistentry>
406
+ <term><errorcode>1</errorcode></term>
407
+ <listitem>
408
+ <para>Failed to remove an entry from the catalog</para>
409
+ </listitem>
410
+ </varlistentry>
411
+
412
+ <varlistentry>
413
+ <term><errorcode>2</errorcode></term>
414
+ <listitem>
415
+ <para>Failed to save to the catalog, check file permissions</para>
416
+ </listitem>
417
+ </varlistentry>
418
+
419
+ <varlistentry>
420
+ <term><errorcode>3</errorcode></term>
421
+ <listitem>
422
+ <para>Failed to add an entry to the catalog</para>
423
+ </listitem>
424
+ </varlistentry>
425
+
426
+ <varlistentry>
427
+ <term><errorcode>4</errorcode></term>
428
+ <listitem>
429
+ <para>Failed to look up an entry in the catalog</para>
430
+ </listitem>
431
+ </varlistentry>
432
+
433
+ </variablelist>
434
+ </refsect1>
435
+
436
+ <refsect1 id="seealso">
437
+ <title>SEE ALSO</title>
438
+ <para><citerefentry>
439
+ <refentrytitle>libxml</refentrytitle>
440
+ <manvolnum>3</manvolnum>
441
+ </citerefentry>
442
+ </para>
443
+ <para>
444
+ More information can be found at
445
+ <itemizedlist>
446
+ <listitem>
447
+ <para><citerefentry>
448
+ <refentrytitle>libxml</refentrytitle>
449
+ <manvolnum>3</manvolnum>
450
+ </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
451
+ </para>
452
+ </listitem>
453
+ <listitem>
454
+ <para><citerefentry>
455
+ <refentrytitle>libxml</refentrytitle>
456
+ <manvolnum>3</manvolnum>
457
+ </citerefentry> catalog support web page
458
+ at <ulink url="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support"/>
459
+ </para>
460
+ </listitem>
461
+ <listitem>
462
+ <para>James Clark's <acronym>SGML</acronym> catalog
463
+ page <ulink url="http://www.jclark.com/sp/catalog.htm"/>
464
+ </para>
465
+ </listitem>
466
+ <listitem>
467
+ <para><acronym>OASIS</acronym> <acronym>XML</acronym> catalog specification
468
+ <ulink url="http://www.oasis-open.org/committees/entity/spec.html"/>
469
+ </para>
470
+ </listitem>
471
+ </itemizedlist>
472
+ </para>
473
+ </refsect1>
474
+
475
+ </refentry>
local-test-libxml2-full-01/afc-libxml2/doc/xmllint.1 ADDED
@@ -0,0 +1,686 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '\" t
2
+ .\" Title: xmllint
3
+ .\" Author: John Fleck <[email protected]>
4
+ .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5
+ .\" Date: 12/26/2024
6
+ .\" Manual: xmllint Manual
7
+ .\" Source: libxml2
8
+ .\" Language: English
9
+ .\"
10
+ .TH "XMLLINT" "1" "12/26/2024" "libxml2" "xmllint Manual"
11
+ .\" -----------------------------------------------------------------
12
+ .\" * Define some portability stuff
13
+ .\" -----------------------------------------------------------------
14
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+ .\" http://bugs.debian.org/507673
16
+ .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
+ .ie \n(.g .ds Aq \(aq
19
+ .el .ds Aq '
20
+ .\" -----------------------------------------------------------------
21
+ .\" * set default formatting
22
+ .\" -----------------------------------------------------------------
23
+ .\" disable hyphenation
24
+ .nh
25
+ .\" disable justification (adjust text to left margin only)
26
+ .ad l
27
+ .\" -----------------------------------------------------------------
28
+ .\" * MAIN CONTENT STARTS HERE *
29
+ .\" -----------------------------------------------------------------
30
+ .SH "NAME"
31
+ xmllint \- command line XML tool
32
+ .SH "SYNOPSIS"
33
+ .HP \w'\fBxmllint\fR\ 'u
34
+ \fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-quiet\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-huge\fR | \fB\-\-nocompact\fR | \fB\-\-nodefdtd\fR | \fB\-\-nodict\fR | \fB\-\-noenc\fR | \fB\-\-noent\fR | \fB\-\-nofixup\-base\-uris\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-max\-ampl\ \fR\fB\fIINTEGER\fR\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-pretty\ \fR\fB\fIINTEGER\fR\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schematron\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR | \fB\-\-c14n11\fR | \fB\-\-exc\-c14n\fR | \fB\-\-pedantic\fR | \fB\-\-sax\fR | \fB\-\-sax1\fR | \fB\-\-oldxml10\fR] {\fIXML\-FILE(S)\fR... | \-}
35
+ .SH "DESCRIPTION"
36
+ .PP
37
+ The
38
+ \fBxmllint\fR
39
+ program parses one or more
40
+ XML
41
+ files, specified on the command line as
42
+ \fIXML\-FILE\fR
43
+ (or the standard input if the filename provided is
44
+ \fB\-\fR
45
+ )\&. It prints various types of output, depending upon the options selected\&. It is useful for detecting errors both in
46
+ XML
47
+ code and in the
48
+ XML
49
+ parser itself\&.
50
+ .PP
51
+ \fBxmllint\fR
52
+ is included in
53
+ \fBlibxml\fR(3)\&.
54
+ .SH "OPTIONS"
55
+ .PP
56
+ \fBxmllint\fR
57
+ accepts the following options (in alphabetical order):
58
+ .PP
59
+ \fB\-\-auto\fR
60
+ .RS 4
61
+ Generate a small document for testing purposes\&.
62
+ .RE
63
+ .PP
64
+ \fB\-\-catalogs\fR
65
+ .RS 4
66
+ Use the
67
+ SGML
68
+ catalog(s) from
69
+ \fBSGML_CATALOG_FILES\fR\&. Otherwise
70
+ XML
71
+ catalogs starting from
72
+ /etc/xml/catalog
73
+ or, more specifically,
74
+ ${sysconfdir}/xml/catalog
75
+ are used by default\&.
76
+ .RE
77
+ .PP
78
+ \fB\-\-compress\fR
79
+ .RS 4
80
+ Turn on
81
+ \fBgzip\fR(1)
82
+ compression of output\&.
83
+ .RE
84
+ .PP
85
+ \fB\-\-copy\fR
86
+ .RS 4
87
+ Test the internal copy implementation\&.
88
+ .RE
89
+ .PP
90
+ \fB\-\-c14n\fR, \fB\-\-c14n11\fR, \fB\-\-exc\-c14n\fR
91
+ .RS 4
92
+ Use the W3C
93
+ XML
94
+ Canonicalisation (C14N) to serialize the result of parsing to
95
+ stdout\&. It keeps comments in the result\&.
96
+ .RE
97
+ .PP
98
+ \fB\-\-dtdvalid \fR\fB\fIURL\fR\fR
99
+ .RS 4
100
+ Use the
101
+ DTD
102
+ specified by an
103
+ \fIURL\fR
104
+ for validation\&.
105
+ .RE
106
+ .PP
107
+ \fB\-\-dtdvalidfpi \fR\fB\fIFPI\fR\fR
108
+ .RS 4
109
+ Use the
110
+ DTD
111
+ specified by a Formal Public Identifier
112
+ \fIFPI\fR
113
+ for validation, note that this will require a catalog exporting that Formal Public Identifier to work\&.
114
+ .RE
115
+ .PP
116
+ \fB\-\-debug\fR
117
+ .RS 4
118
+ Parse a file and output an annotated tree of the in\-memory version of the document\&.
119
+ .RE
120
+ .PP
121
+ \fB\-\-debugent\fR
122
+ .RS 4
123
+ Debug the entities defined in the document\&.
124
+ .RE
125
+ .PP
126
+ \fB\-\-dropdtd\fR
127
+ .RS 4
128
+ Remove
129
+ DTD
130
+ from output\&.
131
+ .RE
132
+ .PP
133
+ \fB\-\-dtdattr\fR
134
+ .RS 4
135
+ Fetch external
136
+ DTD
137
+ and populate the tree with inherited attributes\&.
138
+ .RE
139
+ .PP
140
+ \fB\-\-encode \fR\fB\fIENCODING\fR\fR
141
+ .RS 4
142
+ Output in the given encoding\&. Note that this works for full document not fragments or result from XPath queries\&.
143
+ .RE
144
+ .PP
145
+ \fB\-\-format\fR
146
+ .RS 4
147
+ Reformat and reindent the output\&. The
148
+ \fBXMLLINT_INDENT\fR
149
+ environment variable controls the indentation\&. The default value is two spaces " ")\&.
150
+ .RE
151
+ .PP
152
+ \fB\-\-html\fR
153
+ .RS 4
154
+ Use the
155
+ HTML
156
+ parser\&.
157
+ .RE
158
+ .PP
159
+ \fB\-\-htmlout\fR
160
+ .RS 4
161
+ Output results as an
162
+ HTML
163
+ file\&. This causes
164
+ \fBxmllint\fR
165
+ to output the necessary
166
+ HTML
167
+ tags surrounding the result tree output so the results can be displayed/viewed in a browser\&.
168
+ .RE
169
+ .PP
170
+ \fB\-\-huge\fR
171
+ .RS 4
172
+ Ignore some hardcoded parser limits\&.
173
+ .RE
174
+ .PP
175
+ \fB\-\-insert\fR
176
+ .RS 4
177
+ Test for valid insertions\&.
178
+ .RE
179
+ .PP
180
+ \fB\-\-loaddtd\fR
181
+ .RS 4
182
+ Fetch an external
183
+ DTD\&.
184
+ .RE
185
+ .PP
186
+ \fB\-\-load\-trace\fR
187
+ .RS 4
188
+ Display all the documents loaded during the processing to
189
+ stderr\&.
190
+ .RE
191
+ .PP
192
+ \fB\-\-max\-ampl \fR\fB\fIINTEGER\fR\fR
193
+ .RS 4
194
+ Set the maximum amplification factor which protects against exponential entity expansion ("billion laughs")\&. The default value is 5\&. Documents making heavy use of entity expansion may require a higher value\&.
195
+ .RE
196
+ .PP
197
+ \fB\-\-maxmem \fR\fB\fINNBYTES\fR\fR
198
+ .RS 4
199
+ Test the parser memory support\&.
200
+ \fINNBYTES\fR
201
+ is the maximum number of bytes the library is allowed to allocate\&. This can also be used to make sure batch processing of
202
+ XML
203
+ files will not exhaust the virtual memory of the server running them\&.
204
+ .RE
205
+ .PP
206
+ \fB\-\-memory\fR
207
+ .RS 4
208
+ Parse from memory\&.
209
+ .RE
210
+ .PP
211
+ \fB\-\-noblanks\fR
212
+ .RS 4
213
+ Drop ignorable blank spaces\&.
214
+ .RE
215
+ .PP
216
+ \fB\-\-nocatalogs\fR
217
+ .RS 4
218
+ Do not use any catalogs\&.
219
+ .RE
220
+ .PP
221
+ \fB\-\-nocdata\fR
222
+ .RS 4
223
+ Substitute CDATA section by equivalent text nodes\&.
224
+ .RE
225
+ .PP
226
+ \fB\-\-nocompact\fR
227
+ .RS 4
228
+ Do not generate compact text nodes (parser option XML_PARSE_COMPACT)\&. Only for debugging\&.
229
+ .RE
230
+ .PP
231
+ \fB\-\-nodefdtd\fR
232
+ .RS 4
233
+ Do not set default HTML doctype (parser option HTML_PARSE_NODEFDTD)\&.
234
+ .RE
235
+ .PP
236
+ \fB\-\-nodict\fR
237
+ .RS 4
238
+ Don\*(Aqt use dictionaries (parser option XML_PARSE_NODICT)\&. Only for debugging\&.
239
+ .RE
240
+ .PP
241
+ \fB\-\-noenc\fR
242
+ .RS 4
243
+ Ignore encoding declaration (parser option XML_PARSE_IGNORE_ENC)\&.
244
+ .RE
245
+ .PP
246
+ \fB\-\-noent\fR
247
+ .RS 4
248
+ Substitute entity values for entity references\&. By default,
249
+ \fBxmllint\fR
250
+ leaves entity references in place\&.
251
+ .RE
252
+ .PP
253
+ \fB\-\-nofixup\-base\-uris\fR
254
+ .RS 4
255
+ Don\*(Aqt fix xml:base URIs when processing XIncludes (parser option XML_PARSE_NOBASEFIX)\&.
256
+ .RE
257
+ .PP
258
+ \fB\-\-nonet\fR
259
+ .RS 4
260
+ Do not use the Internet to fetch
261
+ DTDs or entities\&.
262
+ .RE
263
+ .PP
264
+ \fB\-\-noout\fR
265
+ .RS 4
266
+ Suppress output\&. By default,
267
+ \fBxmllint\fR
268
+ outputs the result tree\&.
269
+ .RE
270
+ .PP
271
+ \fB\-\-nowarning\fR
272
+ .RS 4
273
+ Do not emit warnings from the parser and/or validator\&.
274
+ .RE
275
+ .PP
276
+ \fB\-\-nowrap\fR
277
+ .RS 4
278
+ Do not output
279
+ HTML
280
+ doc wrapper\&.
281
+ .RE
282
+ .PP
283
+ \fB\-\-noxincludenode\fR
284
+ .RS 4
285
+ Do XInclude processing but do not generate XInclude start and end nodes\&.
286
+ .RE
287
+ .PP
288
+ \fB\-\-nsclean\fR
289
+ .RS 4
290
+ Remove redundant namespace declarations\&.
291
+ .RE
292
+ .PP
293
+ \fB\-\-oldxml10\fR
294
+ .RS 4
295
+ Use deprecated parsing rules before XML 1\&.0, 5th edition\&.
296
+ .RE
297
+ .PP
298
+ \fB\-\-output \fR\fB\fIFILE\fR\fR
299
+ .RS 4
300
+ Define a file path where
301
+ \fBxmllint\fR
302
+ will save the result of parsing\&. Usually the programs build a tree and save it on
303
+ stdout, with this option the result
304
+ XML
305
+ instance will be saved onto a file\&.
306
+ .RE
307
+ .PP
308
+ \fB\-\-path "\fR\fB\fIPATH(S)\fR\fR\fB"\fR
309
+ .RS 4
310
+ Use the (space\- or colon\-separated) list of filesystem paths specified by
311
+ \fIPATHS\fR
312
+ to load
313
+ DTDs or entities\&. Enclose space\-separated lists by quotation marks\&.
314
+ .RE
315
+ .PP
316
+ \fB\-\-pattern \fR\fB\fIPATTERNVALUE\fR\fR
317
+ .RS 4
318
+ Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser\&. It allows to select some nodes in the document based on an XPath (subset) expression\&. Used for debugging\&.
319
+ .RE
320
+ .PP
321
+ \fB\-\-pedantic\fR
322
+ .RS 4
323
+ Enable additional warnings\&.
324
+ .RE
325
+ .PP
326
+ \fB\-\-postvalid\fR
327
+ .RS 4
328
+ Validate after parsing has completed\&.
329
+ .RE
330
+ .PP
331
+ \fB\-\-pretty \fR\fB\fIINTEGER\fR\fR
332
+ .RS 4
333
+ Value 0 means no formatting, 1 means XML_SAVE_FORMAT (same as \-\-format), 2 means XML_SAVE_WSNONSIG\&.
334
+ .RE
335
+ .PP
336
+ \fB\-\-push\fR
337
+ .RS 4
338
+ Use the push mode of the parser\&.
339
+ .RE
340
+ .PP
341
+ \fB\-\-quiet\fR
342
+ .RS 4
343
+ Don\*(Aqt print informational messages to stderr\&.
344
+ .RE
345
+ .PP
346
+ \fB\-\-recover\fR
347
+ .RS 4
348
+ Output any parsable portions of an invalid document\&.
349
+ .RE
350
+ .PP
351
+ \fB\-\-relaxng \fR\fB\fISCHEMA\fR\fR
352
+ .RS 4
353
+ Use RelaxNG file named
354
+ \fISCHEMA\fR
355
+ for validation\&.
356
+ .RE
357
+ .PP
358
+ \fB\-\-repeat\fR
359
+ .RS 4
360
+ Repeat 100 times, for timing or profiling\&.
361
+ .RE
362
+ .PP
363
+ \fB\-\-sax\fR
364
+ .RS 4
365
+ Print SAX callbacks (only for debugging)\&.
366
+ .RE
367
+ .PP
368
+ \fB\-\-sax1\fR
369
+ .RS 4
370
+ Use deprecated SAX1 interface (only for debugging)\&.
371
+ .RE
372
+ .PP
373
+ \fB\-\-schema \fR\fB\fISCHEMA\fR\fR
374
+ .RS 4
375
+ Use a W3C
376
+ XML
377
+ Schema file named
378
+ \fISCHEMA\fR
379
+ for validation\&.
380
+ .RE
381
+ .PP
382
+ \fB\-\-schematron \fR\fB\fISCHEMA\fR\fR
383
+ .RS 4
384
+ Use a Schematron file named
385
+ \fISCHEMA\fR
386
+ for validation\&.
387
+ .RE
388
+ .PP
389
+ \fB\-\-shell\fR
390
+ .RS 4
391
+ Run a navigating shell\&. Details on available commands in shell mode are below (see
392
+ the section called \(lqSHELL COMMANDS\(rq)\&.
393
+ .RE
394
+ .PP
395
+ \fB\-\-xpath "\fR\fB\fIXPath_expression\fR\fR\fB"\fR
396
+ .RS 4
397
+ Run an XPath expression given as argument and print the result\&. In case of a nodeset result, each node in the node set is serialized in full in the output\&. In case of an empty node set the "XPath set is empty" result will be shown and exit code 11 will be returned\&.\&. This feature is EXPERIMENTAL\&. Implementation details can change without futher notice\&.
398
+ .RE
399
+ .PP
400
+ \fB\-\-stream\fR
401
+ .RS 4
402
+ Use streaming
403
+ API
404
+ \- useful when used in combination with
405
+ \fB\-\-relaxng\fR
406
+ or
407
+ \fB\-\-valid\fR
408
+ options for validation of files that are too large to be held in memory\&.
409
+ .RE
410
+ .PP
411
+ \fB\-\-testIO\fR
412
+ .RS 4
413
+ Test user input/output support\&.
414
+ .RE
415
+ .PP
416
+ \fB\-\-timing\fR
417
+ .RS 4
418
+ Output information about the time it takes
419
+ \fBxmllint\fR
420
+ to perform the various steps\&.
421
+ .RE
422
+ .PP
423
+ \fB\-\-valid\fR
424
+ .RS 4
425
+ Determine if the document is a valid instance of the included Document Type Definition (DTD)\&. A
426
+ DTD
427
+ to be validated against also can be specified at the command line using the
428
+ \fB\-\-dtdvalid\fR
429
+ option\&. By default,
430
+ \fBxmllint\fR
431
+ also checks to determine if the document is well\-formed\&.
432
+ .RE
433
+ .PP
434
+ \fB\-\-version\fR
435
+ .RS 4
436
+ Display the version of
437
+ \fBlibxml\fR(3)
438
+ used\&.
439
+ .RE
440
+ .PP
441
+ \fB\-\-walker\fR
442
+ .RS 4
443
+ Test the walker module, which is a reader interface but for a document tree, instead of using the reader
444
+ API
445
+ on an unparsed document it works on an existing in\-memory tree\&. Used for debugging\&.
446
+ .RE
447
+ .PP
448
+ \fB\-\-xinclude\fR
449
+ .RS 4
450
+ Do XInclude processing\&.
451
+ .RE
452
+ .PP
453
+ \fB\-\-xmlout\fR
454
+ .RS 4
455
+ Used in conjunction with
456
+ \fB\-\-html\fR\&. Usually when
457
+ HTML
458
+ is parsed the document is saved with the
459
+ HTML
460
+ serializer\&. But with this option the resulting document is saved with the
461
+ XML
462
+ serializer\&. This is primarily used to generate
463
+ XHTML
464
+ from
465
+ HTML
466
+ input\&.
467
+ .RE
468
+ .SH "SHELL COMMANDS"
469
+ .PP
470
+ \fBxmllint\fR
471
+ offers an interactive shell mode invoked with the
472
+ \fB\-\-shell\fR
473
+ command\&. Available commands in shell mode include (in alphabetical order):
474
+ .PP
475
+ \fBbase\fR
476
+ .RS 4
477
+ Display
478
+ XML
479
+ base of the node\&.
480
+ .RE
481
+ .PP
482
+ \fBbye\fR
483
+ .RS 4
484
+ Leave the shell\&.
485
+ .RE
486
+ .PP
487
+ \fBcat \fR\fB\fINODE\fR\fR
488
+ .RS 4
489
+ Display the given node or the current one\&.
490
+ .RE
491
+ .PP
492
+ \fBcd \fR\fB\fIPATH\fR\fR
493
+ .RS 4
494
+ Change the current node to the given path (if unique) or root if no argument is given\&.
495
+ .RE
496
+ .PP
497
+ \fBdir \fR\fB\fIPATH\fR\fR
498
+ .RS 4
499
+ Dumps information about the node (namespace, attributes, content)\&.
500
+ .RE
501
+ .PP
502
+ \fBdu \fR\fB\fIPATH\fR\fR
503
+ .RS 4
504
+ Show the structure of the subtree under the given path or the current node\&.
505
+ .RE
506
+ .PP
507
+ \fBexit\fR
508
+ .RS 4
509
+ Leave the shell\&.
510
+ .RE
511
+ .PP
512
+ \fBhelp\fR
513
+ .RS 4
514
+ Show this help\&.
515
+ .RE
516
+ .PP
517
+ \fBload \fR\fB\fIFILENAME\fR\fR
518
+ .RS 4
519
+ Load a new document with the given filename\&.
520
+ .RE
521
+ .PP
522
+ \fBls \fR\fB\fIPATH\fR\fR
523
+ .RS 4
524
+ List contents of the given path or the current directory\&.
525
+ .RE
526
+ .PP
527
+ \fBpwd\fR
528
+ .RS 4
529
+ Display the path to the current node\&.
530
+ .RE
531
+ .PP
532
+ \fBquit\fR
533
+ .RS 4
534
+ Leave the shell\&.
535
+ .RE
536
+ .PP
537
+ \fBsave \fR\fB\fIFILENAME\fR\fR
538
+ .RS 4
539
+ Save the current document to the given filename or to the original name\&.
540
+ .RE
541
+ .PP
542
+ \fBvalidate\fR
543
+ .RS 4
544
+ Check the document for errors\&.
545
+ .RE
546
+ .PP
547
+ \fBwrite \fR\fB\fIFILENAME\fR\fR
548
+ .RS 4
549
+ Write the current node to the given filename\&.
550
+ .RE
551
+ .SH "ENVIRONMENT"
552
+ .PP
553
+ \fBSGML_CATALOG_FILES\fR
554
+ .RS 4
555
+ SGML
556
+ catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
557
+ \fBSGML_CATALOG_FILES\fR
558
+ environment variable to a list of catalogs\&. An empty one should deactivate loading the default catalog\&.
559
+ .RE
560
+ .PP
561
+ \fBXML_CATALOG_FILES\fR
562
+ .RS 4
563
+ XML
564
+ catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
565
+ \fBXML_CATALOG_FILES\fR
566
+ environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default catalog\&.
567
+ .RE
568
+ .PP
569
+ \fBXML_DEBUG_CATALOG\fR
570
+ .RS 4
571
+ Setting the environment variable
572
+ \fBXML_DEBUG_CATALOG\fR
573
+ to
574
+ \fInon\-zero\fR
575
+ using the
576
+ \fBexport\fR
577
+ command outputs debugging information related to catalog operations\&.
578
+ .RE
579
+ .PP
580
+ \fBXMLLINT_INDENT\fR
581
+ .RS 4
582
+ Setting the environment variable
583
+ \fBXMLLINT_INDENT\fR
584
+ controls the indentation\&. The default value is two spaces " "\&.
585
+ .RE
586
+ .SH "DIAGNOSTICS"
587
+ .PP
588
+ \fBxmllint\fR
589
+ return codes provide information that can be used when calling it from scripts\&.
590
+ .PP
591
+ \fB0\fR
592
+ .RS 4
593
+ No error
594
+ .RE
595
+ .PP
596
+ \fB1\fR
597
+ .RS 4
598
+ Unclassified
599
+ .RE
600
+ .PP
601
+ \fB2\fR
602
+ .RS 4
603
+ Error in
604
+ DTD
605
+ .RE
606
+ .PP
607
+ \fB3\fR
608
+ .RS 4
609
+ Validation error
610
+ .RE
611
+ .PP
612
+ \fB4\fR
613
+ .RS 4
614
+ Validation error
615
+ .RE
616
+ .PP
617
+ \fB5\fR
618
+ .RS 4
619
+ Error in schema compilation
620
+ .RE
621
+ .PP
622
+ \fB6\fR
623
+ .RS 4
624
+ Error writing output
625
+ .RE
626
+ .PP
627
+ \fB7\fR
628
+ .RS 4
629
+ Error in pattern (generated when
630
+ \fB\-\-pattern\fR
631
+ option is used)
632
+ .RE
633
+ .PP
634
+ \fB9\fR
635
+ .RS 4
636
+ Out of memory error
637
+ .RE
638
+ .PP
639
+ \fB10\fR
640
+ .RS 4
641
+ XPath evaluation error
642
+ .RE
643
+ .PP
644
+ \fB11\fR
645
+ .RS 4
646
+ XPath result is empty
647
+ .RE
648
+ .SH "SEE ALSO"
649
+ .PP
650
+ \fBlibxml\fR(3)
651
+ .PP
652
+ More information can be found at
653
+ .sp
654
+ .RS 4
655
+ .ie n \{\
656
+ \h'-04'\(bu\h'+03'\c
657
+ .\}
658
+ .el \{\
659
+ .sp -1
660
+ .IP \(bu 2.3
661
+ .\}
662
+ \fBlibxml\fR(3)
663
+ web page
664
+ \m[blue]\fB\%https://gitlab.gnome.org/GNOME/libxml2\fR\m[]
665
+ .RE
666
+ .sp
667
+ .SH "AUTHORS"
668
+ .PP
669
+ \fBJohn Fleck\fR <\&jfleck@inkstain\&.net\&>
670
+ .RS 4
671
+ Author.
672
+ .RE
673
+ .PP
674
+ \fBZiying Sherwin\fR <\&sherwin@nlm\&.nih\&.gov\&>
675
+ .RS 4
676
+ Author.
677
+ .RE
678
+ .PP
679
+ \fBHeiko Rupp\fR <\&hwr@pilhuhn\&.de\&>
680
+ .RS 4
681
+ Author.
682
+ .RE
683
+ .SH "COPYRIGHT"
684
+ .br
685
+ Copyright \(co 2001, 2004
686
+ .br
local-test-libxml2-full-01/afc-libxml2/doc/xmllint.html ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="id1337"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmllint &#8212; command line <acronym class="acronym">XML</acronym> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmllint</code> [ <code class="option">--version</code> | <code class="option">--debug</code> | <code class="option">--quiet</code> | <code class="option">--shell</code> | <code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code> | <code class="option">--debugent</code> | <code class="option">--copy</code> | <code class="option">--recover</code> | <code class="option">--huge</code> | <code class="option">--nocompact</code> | <code class="option">--nodefdtd</code> | <code class="option">--nodict</code> | <code class="option">--noenc</code> | <code class="option">--noent</code> | <code class="option">--nofixup-base-uris</code> | <code class="option">--noout</code> | <code class="option">--nonet</code> | <code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code> | <code class="option">--load-trace</code> | <code class="option">--htmlout</code> | <code class="option">--nowrap</code> | <code class="option">--valid</code> | <code class="option">--postvalid</code> | <code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code> | <code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code> | <code class="option">--timing</code> | <code class="option">--output <em class="replaceable"><code>FILE</code></em></code> | <code class="option">--repeat</code> | <code class="option">--insert</code> | <code class="option">--compress</code> | <code class="option">--html</code> | <code class="option">--xmlout</code> | <code class="option">--push</code> | <code class="option">--memory</code> | <code class="option">--max-ampl <em class="replaceable"><code>INTEGER</code></em></code> | <code class="option">--maxmem <em class="replaceable"><code>NBBYTES</code></em></code> | <code class="option">--nowarning</code> | <code class="option">--noblanks</code> | <code class="option">--nocdata</code> | <code class="option">--format</code> | <code class="option">--pretty <em class="replaceable"><code>INTEGER</code></em></code> | <code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code> | <code class="option">--dropdtd</code> | <code class="option">--nsclean</code> | <code class="option">--testIO</code> | <code class="option">--catalogs</code> | <code class="option">--nocatalogs</code> | <code class="option">--auto</code> | <code class="option">--xinclude</code> | <code class="option">--noxincludenode</code> | <code class="option">--loaddtd</code> | <code class="option">--dtdattr</code> | <code class="option">--stream</code> | <code class="option">--walker</code> | <code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code> | <code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--schematron <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--c14n</code> | <code class="option">--c14n11</code> | <code class="option">--exc-c14n</code> | <code class="option">--pedantic</code> | <code class="option">--sax</code> | <code class="option">--sax1</code> | <code class="option">--oldxml10</code> ] { <em class="replaceable"><code>XML-FILE(S)</code></em>... | - }</p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
2
+ The <span class="command"><strong>xmllint</strong></span> program parses one or more <acronym class="acronym">XML</acronym> files,
3
+ specified on the command line as <em class="replaceable"><code>XML-FILE</code></em>
4
+ (or the standard input if the filename provided
5
+ is <span class="bold"><strong>-</strong></span> ). It prints various types of
6
+ output, depending upon the options selected. It is useful for detecting
7
+ errors both in <acronym class="acronym">XML</acronym> code and in
8
+ the <acronym class="acronym">XML</acronym> parser itself.
9
+ </p><p><span class="command"><strong>xmllint</strong></span> is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
10
+ <span class="command"><strong>xmllint</strong></span> accepts the following options (in alphabetical order):
11
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--auto</code></span></dt><dd><p>Generate a small document for testing purposes.</p></dd><dt><span class="term"><code class="option">--catalogs</code></span></dt><dd><p>
12
+ Use the <acronym class="acronym">SGML</acronym> catalog(s) from <code class="envar">SGML_CATALOG_FILES</code>.
13
+ Otherwise <acronym class="acronym">XML</acronym> catalogs starting
14
+ from <code class="filename">/etc/xml/catalog</code> or, more specifically,
15
+ <code class="filename">${sysconfdir}/xml/catalog</code> are used by default.
16
+ </p></dd><dt><span class="term"><code class="option">--compress</code></span></dt><dd><p>
17
+ Turn on <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> compression of output.
18
+ </p></dd><dt><span class="term"><code class="option">--copy</code></span></dt><dd><p>Test the internal copy implementation.</p></dd><dt><span class="term"><code class="option">--c14n</code>, </span><span class="term"><code class="option">--c14n11</code>, </span><span class="term"><code class="option">--exc-c14n</code></span></dt><dd><p>
19
+ Use the W3C <acronym class="acronym">XML</acronym> Canonicalisation (<acronym class="acronym">C14N</acronym>) to
20
+ serialize the result of parsing to <code class="filename">stdout</code>.
21
+ It keeps comments in the result.
22
+ </p></dd><dt><span class="term"><code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code></span></dt><dd><p>
23
+ Use the <acronym class="acronym">DTD</acronym> specified by
24
+ an <em class="replaceable"><code>URL</code></em> for validation.
25
+ </p></dd><dt><span class="term"><code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code></span></dt><dd><p>
26
+ Use the <acronym class="acronym">DTD</acronym> specified by a Formal Public
27
+ Identifier <em class="replaceable"><code>FPI</code></em> for validation, note that this
28
+ will require a catalog exporting that Formal Public Identifier to work.
29
+ </p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
30
+ Parse a file and output an annotated tree of the
31
+ in-memory version of the document.
32
+ </p></dd><dt><span class="term"><code class="option">--debugent</code></span></dt><dd><p>Debug the entities defined in the document.</p></dd><dt><span class="term"><code class="option">--dropdtd</code></span></dt><dd><p>Remove <acronym class="acronym">DTD</acronym> from output.</p></dd><dt><span class="term"><code class="option">--dtdattr</code></span></dt><dd><p>
33
+ Fetch external <acronym class="acronym">DTD</acronym> and populate the tree with
34
+ inherited attributes.
35
+ </p></dd><dt><span class="term"><code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code></span></dt><dd><p>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</p></dd><dt><span class="term"><code class="option">--format</code></span></dt><dd><p>
36
+ Reformat and reindent the output. The <code class="envar">XMLLINT_INDENT</code>
37
+ environment variable controls the indentation. The default value is two
38
+ spaces " ").
39
+ </p></dd><dt><span class="term"><code class="option">--html</code></span></dt><dd><p>Use the <acronym class="acronym">HTML</acronym> parser.</p></dd><dt><span class="term"><code class="option">--htmlout</code></span></dt><dd><p>
40
+ Output results as an <acronym class="acronym">HTML</acronym> file. This
41
+ causes <span class="command"><strong>xmllint</strong></span> to output the necessary <acronym class="acronym">HTML</acronym>
42
+ tags surrounding the result tree output so the results can be
43
+ displayed/viewed in a browser.
44
+ </p></dd><dt><span class="term"><code class="option">--huge</code></span></dt><dd><p>Ignore some hardcoded parser limits.</p></dd><dt><span class="term"><code class="option">--insert</code></span></dt><dd><p>Test for valid insertions.</p></dd><dt><span class="term"><code class="option">--loaddtd</code></span></dt><dd><p>Fetch an external <acronym class="acronym">DTD</acronym>.</p></dd><dt><span class="term"><code class="option">--load-trace</code></span></dt><dd><p>
45
+ Display all the documents loaded during the processing
46
+ to <code class="filename">stderr</code>.
47
+ </p></dd><dt><span class="term"><code class="option">--max-ampl <em class="replaceable"><code>INTEGER</code></em></code></span></dt><dd><p>
48
+ Set the maximum amplification factor which protects against
49
+ exponential entity expansion ("billion laughs"). The default value
50
+ is 5. Documents making heavy use of entity expansion may require a
51
+ higher value.
52
+ </p></dd><dt><span class="term"><code class="option">--maxmem <em class="replaceable"><code>NNBYTES</code></em></code></span></dt><dd><p>
53
+ Test the parser memory support. <em class="replaceable"><code>NNBYTES</code></em>
54
+ is the maximum number of bytes the library is allowed to allocate.
55
+ This can also be used to make sure batch processing
56
+ of <acronym class="acronym">XML</acronym> files will not exhaust the virtual memory
57
+ of the server running them.
58
+ </p></dd><dt><span class="term"><code class="option">--memory</code></span></dt><dd><p>Parse from memory.</p></dd><dt><span class="term"><code class="option">--noblanks</code></span></dt><dd><p>Drop ignorable blank spaces.</p></dd><dt><span class="term"><code class="option">--nocatalogs</code></span></dt><dd><p>Do not use any catalogs.</p></dd><dt><span class="term"><code class="option">--nocdata</code></span></dt><dd><p>Substitute CDATA section by equivalent text nodes.</p></dd><dt><span class="term"><code class="option">--nocompact</code></span></dt><dd><p>
59
+ Do not generate compact text nodes (parser option
60
+ XML_PARSE_COMPACT). Only for debugging.
61
+ </p></dd><dt><span class="term"><code class="option">--nodefdtd</code></span></dt><dd><p>
62
+ Do not set default HTML doctype (parser option
63
+ HTML_PARSE_NODEFDTD).
64
+ </p></dd><dt><span class="term"><code class="option">--nodict</code></span></dt><dd><p>
65
+ Don't use dictionaries (parser option XML_PARSE_NODICT).
66
+ Only for debugging.
67
+ </p></dd><dt><span class="term"><code class="option">--noenc</code></span></dt><dd><p>
68
+ Ignore encoding declaration (parser option
69
+ XML_PARSE_IGNORE_ENC).
70
+ </p></dd><dt><span class="term"><code class="option">--noent</code></span></dt><dd><p>
71
+ Substitute entity values for entity references. By default, <span class="command"><strong>xmllint</strong></span>
72
+ leaves entity references in place.
73
+ </p></dd><dt><span class="term"><code class="option">--nofixup-base-uris</code></span></dt><dd><p>
74
+ Don't fix xml:base URIs when processing XIncludes
75
+ (parser option XML_PARSE_NOBASEFIX).
76
+ </p></dd><dt><span class="term"><code class="option">--nonet</code></span></dt><dd><p>
77
+ Do not use the Internet to fetch <acronym class="acronym">DTD</acronym>s or entities.
78
+ </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
79
+ Suppress output. By default, <span class="command"><strong>xmllint</strong></span> outputs the result tree.
80
+ </p></dd><dt><span class="term"><code class="option">--nowarning</code></span></dt><dd><p>Do not emit warnings from the parser and/or validator.</p></dd><dt><span class="term"><code class="option">--nowrap</code></span></dt><dd><p>Do not output <acronym class="acronym">HTML</acronym> doc wrapper.</p></dd><dt><span class="term"><code class="option">--noxincludenode</code></span></dt><dd><p>
81
+ Do XInclude processing but do not generate XInclude start and end nodes.
82
+ </p></dd><dt><span class="term"><code class="option">--nsclean</code></span></dt><dd><p>Remove redundant namespace declarations.</p></dd><dt><span class="term"><code class="option">--oldxml10</code></span></dt><dd><p>
83
+ Use deprecated parsing rules before XML 1.0,
84
+ 5th edition.
85
+ </p></dd><dt><span class="term"><code class="option">--output <em class="replaceable"><code>FILE</code></em></code></span></dt><dd><p>
86
+ Define a file path where <span class="command"><strong>xmllint</strong></span> will save the result of parsing.
87
+ Usually the programs build a tree and save it
88
+ on <code class="filename">stdout</code>, with this option
89
+ the result <acronym class="acronym">XML</acronym> instance will be saved onto a file.
90
+ </p></dd><dt><span class="term"><code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code></span></dt><dd><p>
91
+ Use the (space- or colon-separated) list of filesystem paths specified
92
+ by <em class="replaceable"><code>PATHS</code></em> to load <acronym class="acronym">DTD</acronym>s or
93
+ entities. Enclose space-separated lists by quotation marks.
94
+ </p></dd><dt><span class="term"><code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code></span></dt><dd><p>
95
+ Used to exercise the pattern recognition engine, which can be used
96
+ with the reader interface to the parser. It allows to select some
97
+ nodes in the document based on an XPath (subset) expression. Used
98
+ for debugging.
99
+ </p></dd><dt><span class="term"><code class="option">--pedantic</code></span></dt><dd><p>Enable additional warnings.</p></dd><dt><span class="term"><code class="option">--postvalid</code></span></dt><dd><p>Validate after parsing has completed.</p></dd><dt><span class="term"><code class="option">--pretty <em class="replaceable"><code>INTEGER</code></em></code></span></dt><dd><p>
100
+ Value 0 means no formatting, 1 means XML_SAVE_FORMAT
101
+ (same as --format), 2 means XML_SAVE_WSNONSIG.
102
+ </p></dd><dt><span class="term"><code class="option">--push</code></span></dt><dd><p>Use the push mode of the parser.</p></dd><dt><span class="term"><code class="option">--quiet</code></span></dt><dd><p>Don't print informational messages to stderr.</p></dd><dt><span class="term"><code class="option">--recover</code></span></dt><dd><p>Output any parsable portions of an invalid document.</p></dd><dt><span class="term"><code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
103
+ Use RelaxNG file named <em class="replaceable"><code>SCHEMA</code></em>
104
+ for validation.
105
+ </p></dd><dt><span class="term"><code class="option">--repeat</code></span></dt><dd><p>Repeat 100 times, for timing or profiling.</p></dd><dt><span class="term"><code class="option">--sax</code></span></dt><dd><p>Print SAX callbacks (only for debugging).</p></dd><dt><span class="term"><code class="option">--sax1</code></span></dt><dd><p>Use deprecated SAX1 interface (only for debugging).</p></dd><dt><span class="term"><code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
106
+ Use a W3C <acronym class="acronym">XML</acronym> Schema file
107
+ named <em class="replaceable"><code>SCHEMA</code></em> for validation.
108
+ </p></dd><dt><span class="term"><code class="option">--schematron <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
109
+ Use a Schematron file
110
+ named <em class="replaceable"><code>SCHEMA</code></em> for validation.
111
+ </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
112
+ Run a navigating shell. Details on available commands in shell mode
113
+ are below (see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>).
114
+ </p></dd><dt><span class="term"><code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code></span></dt><dd><p>
115
+ Run an XPath expression given as argument and print the
116
+ result. In case of a nodeset result, each node in the
117
+ node set is serialized in full in the output. In case
118
+ of an empty node set the "XPath set is empty" result
119
+ will be shown and exit code 11 will be returned..
120
+ This feature is EXPERIMENTAL. Implementation details can
121
+ change without futher notice.
122
+ </p></dd><dt><span class="term"><code class="option">--stream</code></span></dt><dd><p>
123
+ Use streaming <acronym class="acronym">API</acronym> - useful when used in combination
124
+ with <code class="option">--relaxng</code> or <code class="option">--valid</code> options
125
+ for validation of files that are too large to be held in memory.
126
+ </p></dd><dt><span class="term"><code class="option">--testIO</code></span></dt><dd><p>Test user input/output support.</p></dd><dt><span class="term"><code class="option">--timing</code></span></dt><dd><p>
127
+ Output information about the time it takes <span class="command"><strong>xmllint</strong></span> to perform the
128
+ various steps.
129
+ </p></dd><dt><span class="term"><code class="option">--valid</code></span></dt><dd><p>
130
+ Determine if the document is a valid instance of the included
131
+ Document Type Definition (<acronym class="acronym">DTD</acronym>).
132
+ A <acronym class="acronym">DTD</acronym> to be validated against also can be
133
+ specified at the command line using the <code class="option">--dtdvalid</code>
134
+ option. By default, <span class="command"><strong>xmllint</strong></span> also checks to determine if the
135
+ document is well-formed.
136
+ </p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
137
+ Display the version of <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> used.
138
+ </p></dd><dt><span class="term"><code class="option">--walker</code></span></dt><dd><p>
139
+ Test the walker module, which is a reader interface but for a
140
+ document tree, instead of using the reader <acronym class="acronym">API</acronym> on
141
+ an unparsed document it works on an existing in-memory tree. Used for
142
+ debugging.
143
+ </p></dd><dt><span class="term"><code class="option">--xinclude</code></span></dt><dd><p>Do XInclude processing.</p></dd><dt><span class="term"><code class="option">--xmlout</code></span></dt><dd><p>
144
+ Used in conjunction with <code class="option">--html</code>. Usually
145
+ when <acronym class="acronym">HTML</acronym> is parsed the document is saved with
146
+ the <acronym class="acronym">HTML</acronym> serializer. But with this option the
147
+ resulting document is saved with the <acronym class="acronym">XML</acronym>
148
+ serializer. This is primarily used to
149
+ generate <acronym class="acronym">XHTML</acronym> from <acronym class="acronym">HTML</acronym> input.
150
+ </p></dd></dl></div></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
151
+ <span class="command"><strong>xmllint</strong></span> offers an interactive shell mode invoked with
152
+ the <code class="option">--shell</code> command. Available commands in shell mode
153
+ include (in alphabetical order):
154
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>base</strong></span></span></dt><dd><p>Display <acronym class="acronym">XML</acronym> base of the node.</p></dd><dt><span class="term"><span class="command"><strong>bye</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>cat <em class="replaceable"><code>NODE</code></em></strong></span></span></dt><dd><p>Display the given node or the current one.</p></dd><dt><span class="term"><span class="command"><strong>cd <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
155
+ Change the current node to the given path (if unique) or root if no
156
+ argument is given.
157
+ </p></dd><dt><span class="term"><span class="command"><strong>dir <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
158
+ Dumps information about the node (namespace, attributes, content).
159
+ </p></dd><dt><span class="term"><span class="command"><strong>du <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
160
+ Show the structure of the subtree under the given path or the current node.
161
+ </p></dd><dt><span class="term"><span class="command"><strong>exit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>help</strong></span></span></dt><dd><p>Show this help.</p></dd><dt><span class="term"><span class="command"><strong>load <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Load a new document with the given filename.</p></dd><dt><span class="term"><span class="command"><strong>ls <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>List contents of the given path or the current directory.</p></dd><dt><span class="term"><span class="command"><strong>pwd</strong></span></span></dt><dd><p>Display the path to the current node.</p></dd><dt><span class="term"><span class="command"><strong>quit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>save <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>
162
+ Save the current document to the given filename or to the original name.
163
+ </p></dd><dt><span class="term"><code class="option">validate</code></span></dt><dd><p>Check the document for errors.</p></dd><dt><span class="term"><span class="command"><strong>write <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Write the current node to the given filename.</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">SGML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">SGML</acronym> catalog behavior can be changed by redirecting
164
+ queries to the user's own set of catalogs. This can be done by setting
165
+ the <code class="envar">SGML_CATALOG_FILES</code> environment variable to a list
166
+ of catalogs. An empty one should deactivate loading the
167
+ default catalog.
168
+ </p></dd><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
169
+ queries to the user's own set of catalogs. This can be done by setting
170
+ the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
171
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
172
+ An empty variable should deactivate loading the default catalog.
173
+ </p></dd><dt><span class="term"><code class="envar">XML_DEBUG_CATALOG</code></span></dt><dd><p>Setting the environment variable <code class="envar">XML_DEBUG_CATALOG</code>
174
+ to <em class="parameter"><code>non-zero</code></em> using the <span class="command"><strong>export</strong></span>
175
+ command outputs debugging information related to catalog operations.
176
+ </p></dd><dt><span class="term"><code class="envar">XMLLINT_INDENT</code></span></dt><dd><p>Setting the environment variable <code class="envar">XMLLINT_INDENT</code>
177
+ controls the indentation. The default value is two spaces " ".
178
+ </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
179
+ <span class="command"><strong>xmllint</strong></span> return codes provide information that can be used when
180
+ calling it from scripts.
181
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Unclassified</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Error in <acronym class="acronym">DTD</acronym></p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">5</span></span></dt><dd><p>Error in schema compilation</p></dd><dt><span class="term"><span class="errorcode">6</span></span></dt><dd><p>Error writing output</p></dd><dt><span class="term"><span class="errorcode">7</span></span></dt><dd><p>
182
+ Error in pattern (generated when <code class="option">--pattern</code> option is used)
183
+ </p></dd><dt><span class="term"><span class="errorcode">9</span></span></dt><dd><p>Out of memory error</p></dd><dt><span class="term"><span class="errorcode">10</span></span></dt><dd><p>XPath evaluation error</p></dd><dt><span class="term"><span class="errorcode">11</span></span></dt><dd><p>XPath result is empty</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
184
+ </p><p>
185
+ More information can be found at
186
+ </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
187
+ </p></li></ul></div><p>
188
+ </p></div></div></body></html>
local-test-libxml2-full-01/afc-libxml2/doc/xmllint.xml ADDED
@@ -0,0 +1,1045 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet type="text/xsl"
3
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
4
+ <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
5
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
6
+
7
+ <!ENTITY xmllint "<command>xmllint</command>">
8
+ ]>
9
+
10
+ <refentry>
11
+
12
+ <refentryinfo>
13
+ <title>xmllint Manual</title>
14
+ <productname>libxml2</productname>
15
+ <copyright>
16
+ <year>2001</year>
17
+ <year>2004</year>
18
+ </copyright>
19
+ <authorgroup>
20
+ <author>
21
+ <firstname>John</firstname>
22
+ <surname>Fleck</surname>
23
+ <affiliation>
24
+ <address>
25
+ <email>[email protected]</email>
26
+ </address>
27
+ </affiliation>
28
+ </author>
29
+ <author>
30
+ <firstname>Ziying</firstname>
31
+ <surname>Sherwin</surname>
32
+ <affiliation>
33
+ <address>
34
+ <email>[email protected]</email>
35
+ </address>
36
+ </affiliation>
37
+ </author>
38
+ <author>
39
+ <firstname>Heiko</firstname>
40
+ <surname>Rupp</surname>
41
+ <affiliation>
42
+ <address>
43
+ <email>[email protected]</email>
44
+ </address>
45
+ </affiliation>
46
+ </author>
47
+ </authorgroup>
48
+ <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
49
+ <!-- <releaseinfo>This is release 0.5 of the xmllint Manual.</releaseinfo> -->
50
+ <!-- <edition>0.5</edition> -->
51
+ </refentryinfo>
52
+
53
+ <refmeta>
54
+ <refentrytitle>xmllint</refentrytitle>
55
+ <manvolnum>1</manvolnum>
56
+ </refmeta>
57
+
58
+ <refnamediv>
59
+ <refname>xmllint</refname>
60
+ <refpurpose>command line <acronym>XML</acronym> tool</refpurpose>
61
+ </refnamediv>
62
+
63
+ <refsynopsisdiv>
64
+ <cmdsynopsis>
65
+ <command>xmllint</command>
66
+ <group choice="opt">
67
+ <arg choice="plain"><option>--version</option></arg>
68
+ <arg choice="plain"><option>--debug</option></arg>
69
+ <arg choice="plain"><option>--quiet</option></arg>
70
+ <arg choice="plain"><option>--shell</option></arg>
71
+ <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
72
+ <arg choice="plain"><option>--debugent</option></arg>
73
+ <arg choice="plain"><option>--copy</option></arg>
74
+ <arg choice="plain"><option>--recover</option></arg>
75
+ <arg choice="plain"><option>--huge</option></arg>
76
+ <arg choice="plain"><option>--nocompact</option></arg>
77
+ <arg choice="plain"><option>--nodefdtd</option></arg>
78
+ <arg choice="plain"><option>--nodict</option></arg>
79
+ <arg choice="plain"><option>--noenc</option></arg>
80
+ <arg choice="plain"><option>--noent</option></arg>
81
+ <arg choice="plain"><option>--nofixup-base-uris</option></arg>
82
+ <arg choice="plain"><option>--noout</option></arg>
83
+ <arg choice="plain"><option>--nonet</option></arg>
84
+ <arg choice="plain"><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></arg>
85
+ <arg choice="plain"><option>--load-trace</option></arg>
86
+ <arg choice="plain"><option>--htmlout</option></arg>
87
+ <arg choice="plain"><option>--nowrap</option></arg>
88
+ <arg choice="plain"><option>--valid</option></arg>
89
+ <arg choice="plain"><option>--postvalid</option></arg>
90
+ <arg choice="plain"><option>--dtdvalid <replaceable class="option">URL</replaceable></option></arg>
91
+ <arg choice="plain"><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></arg>
92
+ <arg choice="plain"><option>--timing</option></arg>
93
+ <arg choice="plain"><option>--output <replaceable class="option">FILE</replaceable></option></arg>
94
+ <arg choice="plain"><option>--repeat</option></arg>
95
+ <arg choice="plain"><option>--insert</option></arg>
96
+ <arg choice="plain"><option>--compress</option></arg>
97
+ <arg choice="plain"><option>--html</option></arg>
98
+ <arg choice="plain"><option>--xmlout</option></arg>
99
+ <arg choice="plain"><option>--push</option></arg>
100
+ <arg choice="plain"><option>--memory</option></arg>
101
+ <arg choice="plain"><option>--max-ampl <replaceable class="option">INTEGER</replaceable></option></arg>
102
+ <arg choice="plain"><option>--maxmem <replaceable class="option">NBBYTES</replaceable></option></arg>
103
+ <arg choice="plain"><option>--nowarning</option></arg>
104
+ <arg choice="plain"><option>--noblanks</option></arg>
105
+ <arg choice="plain"><option>--nocdata</option></arg>
106
+ <arg choice="plain"><option>--format</option></arg>
107
+ <arg choice="plain"><option>--pretty <replaceable class="option">INTEGER</replaceable></option></arg>
108
+ <arg choice="plain"><option>--encode <replaceable class="option">ENCODING</replaceable></option></arg>
109
+ <arg choice="plain"><option>--dropdtd</option></arg>
110
+ <arg choice="plain"><option>--nsclean</option></arg>
111
+ <arg choice="plain"><option>--testIO</option></arg>
112
+ <arg choice="plain"><option>--catalogs</option></arg>
113
+ <arg choice="plain"><option>--nocatalogs</option></arg>
114
+ <arg choice="plain"><option>--auto</option></arg>
115
+ <arg choice="plain"><option>--xinclude</option></arg>
116
+ <arg choice="plain"><option>--noxincludenode</option></arg>
117
+ <arg choice="plain"><option>--loaddtd</option></arg>
118
+ <arg choice="plain"><option>--dtdattr</option></arg>
119
+ <arg choice="plain"><option>--stream</option></arg>
120
+ <arg choice="plain"><option>--walker</option></arg>
121
+ <arg choice="plain"><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></arg>
122
+ <arg choice="plain"><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></arg>
123
+ <arg choice="plain"><option>--schema <replaceable class="option">SCHEMA</replaceable></option></arg>
124
+ <arg choice="plain"><option>--schematron <replaceable class="option">SCHEMA</replaceable></option></arg>
125
+ <arg choice="plain"><option>--c14n</option></arg>
126
+ <arg choice="plain"><option>--c14n11</option></arg>
127
+ <arg choice="plain"><option>--exc-c14n</option></arg>
128
+ <arg choice="plain"><option>--pedantic</option></arg>
129
+ <arg choice="plain"><option>--sax</option></arg>
130
+ <arg choice="plain"><option>--sax1</option></arg>
131
+ <arg choice="plain"><option>--oldxml10</option></arg>
132
+ </group>
133
+ <group choice="req">
134
+ <arg choice="plain" rep="repeat"><replaceable>XML-FILE(S)</replaceable></arg>
135
+ <arg choice="plain" rep="norepeat">-</arg>
136
+ </group>
137
+ </cmdsynopsis>
138
+ </refsynopsisdiv>
139
+
140
+ <refsect1 id="description">
141
+ <title>DESCRIPTION</title>
142
+ <para>
143
+ The &xmllint; program parses one or more <acronym>XML</acronym> files,
144
+ specified on the command line as <replaceable>XML-FILE</replaceable>
145
+ (or the standard input if the filename provided
146
+ is <emphasis role="bold">-</emphasis> ). It prints various types of
147
+ output, depending upon the options selected. It is useful for detecting
148
+ errors both in <acronym>XML</acronym> code and in
149
+ the <acronym>XML</acronym> parser itself.
150
+ </para>
151
+ <para>&xmllint; is included in <citerefentry>
152
+ <refentrytitle>libxml</refentrytitle>
153
+ <manvolnum>3</manvolnum>
154
+ </citerefentry>.</para>
155
+ </refsect1>
156
+
157
+ <refsect1 id="options">
158
+ <title>OPTIONS</title>
159
+ <para>
160
+ &xmllint; accepts the following options (in alphabetical order):
161
+ </para>
162
+
163
+ <variablelist>
164
+
165
+ <varlistentry>
166
+ <term><option>--auto</option></term>
167
+ <listitem>
168
+ <para>Generate a small document for testing purposes.</para>
169
+ </listitem>
170
+ </varlistentry>
171
+
172
+ <varlistentry>
173
+ <term><option>--catalogs</option></term>
174
+ <listitem>
175
+ <para>
176
+ Use the <acronym>SGML</acronym> catalog(s) from <envar>SGML_CATALOG_FILES</envar>.
177
+ Otherwise <acronym>XML</acronym> catalogs starting
178
+ from <filename>/etc/xml/catalog</filename> or, more specifically,
179
+ <filename>${sysconfdir}/xml/catalog</filename> are used by default.
180
+ </para>
181
+ </listitem>
182
+ </varlistentry>
183
+
184
+ <varlistentry>
185
+ <term><option>--compress</option></term>
186
+ <listitem>
187
+ <para>
188
+ Turn on <citerefentry>
189
+ <refentrytitle>gzip</refentrytitle>
190
+ <manvolnum>1</manvolnum>
191
+ </citerefentry> compression of output.
192
+ </para>
193
+ </listitem>
194
+ </varlistentry>
195
+
196
+ <varlistentry>
197
+ <term><option>--copy</option></term>
198
+ <listitem>
199
+ <para>Test the internal copy implementation.</para>
200
+ </listitem>
201
+ </varlistentry>
202
+
203
+ <varlistentry>
204
+ <term><option>--c14n</option></term>
205
+ <term><option>--c14n11</option></term>
206
+ <term><option>--exc-c14n</option></term>
207
+ <listitem>
208
+ <para>
209
+ Use the W3C <acronym>XML</acronym> Canonicalisation (<acronym>C14N</acronym>) to
210
+ serialize the result of parsing to <filename class="devicefile">stdout</filename>.
211
+ It keeps comments in the result.
212
+ </para>
213
+ </listitem>
214
+ </varlistentry>
215
+
216
+ <varlistentry>
217
+ <term><option>--dtdvalid <replaceable class="option">URL</replaceable></option></term>
218
+ <listitem>
219
+ <para>
220
+ Use the <acronym>DTD</acronym> specified by
221
+ an <replaceable>URL</replaceable> for validation.
222
+ </para>
223
+ </listitem>
224
+ </varlistentry>
225
+
226
+ <varlistentry>
227
+ <term><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></term>
228
+ <listitem>
229
+ <para>
230
+ Use the <acronym>DTD</acronym> specified by a Formal Public
231
+ Identifier <replaceable>FPI</replaceable> for validation, note that this
232
+ will require a catalog exporting that Formal Public Identifier to work.
233
+ </para>
234
+ </listitem>
235
+ </varlistentry>
236
+
237
+ <varlistentry>
238
+ <term><option>--debug</option></term>
239
+ <listitem>
240
+ <para>
241
+ Parse a file and output an annotated tree of the
242
+ in-memory version of the document.
243
+ </para>
244
+ </listitem>
245
+ </varlistentry>
246
+
247
+ <varlistentry>
248
+ <term><option>--debugent</option></term>
249
+ <listitem>
250
+ <para>Debug the entities defined in the document.</para>
251
+ </listitem>
252
+ </varlistentry>
253
+
254
+ <varlistentry>
255
+ <term><option>--dropdtd</option></term>
256
+ <listitem>
257
+ <para>Remove <acronym>DTD</acronym> from output.</para>
258
+ </listitem>
259
+ </varlistentry>
260
+
261
+ <varlistentry>
262
+ <term><option>--dtdattr</option></term>
263
+ <listitem>
264
+ <para>
265
+ Fetch external <acronym>DTD</acronym> and populate the tree with
266
+ inherited attributes.
267
+ </para>
268
+ </listitem>
269
+ </varlistentry>
270
+
271
+ <varlistentry>
272
+ <term><option>--encode <replaceable class="option">ENCODING</replaceable></option></term>
273
+ <listitem>
274
+ <para>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</para>
275
+ </listitem>
276
+ </varlistentry>
277
+
278
+ <varlistentry>
279
+ <term><option>--format</option></term>
280
+ <listitem>
281
+ <para>
282
+ Reformat and reindent the output. The <envar>XMLLINT_INDENT</envar>
283
+ environment variable controls the indentation. The default value is two
284
+ spaces &quot; &quot;).
285
+ </para>
286
+ </listitem>
287
+ </varlistentry>
288
+
289
+ <varlistentry>
290
+ <term><option>--html</option></term>
291
+ <listitem>
292
+ <para>Use the <acronym>HTML</acronym> parser.</para>
293
+ </listitem>
294
+ </varlistentry>
295
+
296
+ <varlistentry>
297
+ <term><option>--htmlout</option></term>
298
+ <listitem>
299
+ <para>
300
+ Output results as an <acronym>HTML</acronym> file. This
301
+ causes &xmllint; to output the necessary <acronym>HTML</acronym>
302
+ tags surrounding the result tree output so the results can be
303
+ displayed/viewed in a browser.
304
+ </para>
305
+ </listitem>
306
+ </varlistentry>
307
+
308
+ <varlistentry>
309
+ <term><option>--huge</option></term>
310
+ <listitem>
311
+ <para>Ignore some hardcoded parser limits.</para>
312
+ </listitem>
313
+ </varlistentry>
314
+
315
+ <varlistentry>
316
+ <term><option>--insert</option></term>
317
+ <listitem>
318
+ <para>Test for valid insertions.</para>
319
+ </listitem>
320
+ </varlistentry>
321
+
322
+ <varlistentry>
323
+ <term><option>--loaddtd</option></term>
324
+ <listitem>
325
+ <para>Fetch an external <acronym>DTD</acronym>.</para>
326
+ </listitem>
327
+ </varlistentry>
328
+
329
+ <varlistentry>
330
+ <term><option>--load-trace</option></term>
331
+ <listitem>
332
+ <para>
333
+ Display all the documents loaded during the processing
334
+ to <filename class="devicefile">stderr</filename>.
335
+ </para>
336
+ </listitem>
337
+ </varlistentry>
338
+
339
+ <varlistentry>
340
+ <term><option>--max-ampl <replaceable class="option">INTEGER</replaceable></option></term>
341
+ <listitem>
342
+ <para>
343
+ Set the maximum amplification factor which protects against
344
+ exponential entity expansion ("billion laughs"). The default value
345
+ is 5. Documents making heavy use of entity expansion may require a
346
+ higher value.
347
+ </para>
348
+ </listitem>
349
+ </varlistentry>
350
+
351
+ <varlistentry>
352
+ <term><option>--maxmem <replaceable class="option">NNBYTES</replaceable></option></term>
353
+ <listitem>
354
+ <para>
355
+ Test the parser memory support. <replaceable>NNBYTES</replaceable>
356
+ is the maximum number of bytes the library is allowed to allocate.
357
+ This can also be used to make sure batch processing
358
+ of <acronym>XML</acronym> files will not exhaust the virtual memory
359
+ of the server running them.
360
+ </para>
361
+ </listitem>
362
+ </varlistentry>
363
+
364
+ <varlistentry>
365
+ <term><option>--memory</option></term>
366
+ <listitem>
367
+ <para>Parse from memory.</para>
368
+ </listitem>
369
+ </varlistentry>
370
+
371
+ <varlistentry>
372
+ <term><option>--noblanks</option></term>
373
+ <listitem>
374
+ <para>Drop ignorable blank spaces.</para>
375
+ </listitem>
376
+ </varlistentry>
377
+
378
+ <varlistentry>
379
+ <term><option>--nocatalogs</option></term>
380
+ <listitem>
381
+ <para>Do not use any catalogs.</para>
382
+ </listitem>
383
+ </varlistentry>
384
+
385
+ <varlistentry>
386
+ <term><option>--nocdata</option></term>
387
+ <listitem>
388
+ <para>Substitute CDATA section by equivalent text nodes.</para>
389
+ </listitem>
390
+ </varlistentry>
391
+
392
+ <varlistentry>
393
+ <term><option>--nocompact</option></term>
394
+ <listitem>
395
+ <para>
396
+ Do not generate compact text nodes (parser option
397
+ XML_PARSE_COMPACT). Only for debugging.
398
+ </para>
399
+ </listitem>
400
+ </varlistentry>
401
+
402
+ <varlistentry>
403
+ <term><option>--nodefdtd</option></term>
404
+ <listitem>
405
+ <para>
406
+ Do not set default HTML doctype (parser option
407
+ HTML_PARSE_NODEFDTD).
408
+ </para>
409
+ </listitem>
410
+ </varlistentry>
411
+
412
+ <varlistentry>
413
+ <term><option>--nodict</option></term>
414
+ <listitem>
415
+ <para>
416
+ Don't use dictionaries (parser option XML_PARSE_NODICT).
417
+ Only for debugging.
418
+ </para>
419
+ </listitem>
420
+ </varlistentry>
421
+
422
+ <varlistentry>
423
+ <term><option>--noenc</option></term>
424
+ <listitem>
425
+ <para>
426
+ Ignore encoding declaration (parser option
427
+ XML_PARSE_IGNORE_ENC).
428
+ </para>
429
+ </listitem>
430
+ </varlistentry>
431
+
432
+ <varlistentry>
433
+ <term><option>--noent</option></term>
434
+ <listitem>
435
+ <para>
436
+ Substitute entity values for entity references. By default, &xmllint;
437
+ leaves entity references in place.
438
+ </para>
439
+ </listitem>
440
+ </varlistentry>
441
+
442
+ <varlistentry>
443
+ <term><option>--nofixup-base-uris</option></term>
444
+ <listitem>
445
+ <para>
446
+ Don't fix xml:base URIs when processing XIncludes
447
+ (parser option XML_PARSE_NOBASEFIX).
448
+ </para>
449
+ </listitem>
450
+ </varlistentry>
451
+
452
+ <varlistentry>
453
+ <term><option>--nonet</option></term>
454
+ <listitem>
455
+ <para>
456
+ Do not use the Internet to fetch <acronym>DTD</acronym>s or entities.
457
+ </para>
458
+ </listitem>
459
+ </varlistentry>
460
+
461
+ <varlistentry>
462
+ <term><option>--noout</option></term>
463
+ <listitem>
464
+ <para>
465
+ Suppress output. By default, &xmllint; outputs the result tree.
466
+ </para>
467
+ </listitem>
468
+ </varlistentry>
469
+
470
+ <varlistentry>
471
+ <term><option>--nowarning</option></term>
472
+ <listitem>
473
+ <para>Do not emit warnings from the parser and/or validator.</para>
474
+ </listitem>
475
+ </varlistentry>
476
+
477
+ <varlistentry>
478
+ <term><option>--nowrap</option></term>
479
+ <listitem>
480
+ <para>Do not output <acronym>HTML</acronym> doc wrapper.</para>
481
+ </listitem>
482
+ </varlistentry>
483
+
484
+ <varlistentry>
485
+ <term><option>--noxincludenode</option></term>
486
+ <listitem>
487
+ <para>
488
+ Do XInclude processing but do not generate XInclude start and end nodes.
489
+ </para>
490
+ </listitem>
491
+ </varlistentry>
492
+
493
+ <varlistentry>
494
+ <term><option>--nsclean</option></term>
495
+ <listitem>
496
+ <para>Remove redundant namespace declarations.</para>
497
+ </listitem>
498
+ </varlistentry>
499
+
500
+ <varlistentry>
501
+ <term><option>--oldxml10</option></term>
502
+ <listitem>
503
+ <para>
504
+ Use deprecated parsing rules before XML 1.0,
505
+ 5th edition.
506
+ </para>
507
+ </listitem>
508
+ </varlistentry>
509
+
510
+ <varlistentry>
511
+ <term><option>--output <replaceable class="option">FILE</replaceable></option></term>
512
+ <listitem>
513
+ <para>
514
+ Define a file path where &xmllint; will save the result of parsing.
515
+ Usually the programs build a tree and save it
516
+ on <filename class="devicefile">stdout</filename>, with this option
517
+ the result <acronym>XML</acronym> instance will be saved onto a file.
518
+ </para>
519
+ </listitem>
520
+ </varlistentry>
521
+
522
+ <varlistentry>
523
+ <term><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></term>
524
+ <listitem>
525
+ <para>
526
+ Use the (space- or colon-separated) list of filesystem paths specified
527
+ by <replaceable>PATHS</replaceable> to load <acronym>DTD</acronym>s or
528
+ entities. Enclose space-separated lists by quotation marks.
529
+ </para>
530
+ </listitem>
531
+ </varlistentry>
532
+
533
+ <varlistentry>
534
+ <term><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></term>
535
+ <listitem>
536
+ <para>
537
+ Used to exercise the pattern recognition engine, which can be used
538
+ with the reader interface to the parser. It allows to select some
539
+ nodes in the document based on an XPath (subset) expression. Used
540
+ for debugging.
541
+ </para>
542
+ </listitem>
543
+ </varlistentry>
544
+
545
+ <varlistentry>
546
+ <term><option>--pedantic</option></term>
547
+ <listitem>
548
+ <para>Enable additional warnings.</para>
549
+ </listitem>
550
+ </varlistentry>
551
+
552
+ <varlistentry>
553
+ <term><option>--postvalid</option></term>
554
+ <listitem>
555
+ <para>Validate after parsing has completed.</para>
556
+ </listitem>
557
+ </varlistentry>
558
+
559
+ <varlistentry>
560
+ <term><option>--pretty <replaceable class="option">INTEGER</replaceable></option></term>
561
+ <listitem>
562
+ <para>
563
+ Value 0 means no formatting, 1 means XML_SAVE_FORMAT
564
+ (same as --format), 2 means XML_SAVE_WSNONSIG.
565
+ </para>
566
+ </listitem>
567
+ </varlistentry>
568
+
569
+ <varlistentry>
570
+ <term><option>--push</option></term>
571
+ <listitem>
572
+ <para>Use the push mode of the parser.</para>
573
+ </listitem>
574
+ </varlistentry>
575
+
576
+ <varlistentry>
577
+ <term><option>--quiet</option></term>
578
+ <listitem>
579
+ <para>Don't print informational messages to stderr.</para>
580
+ </listitem>
581
+ </varlistentry>
582
+
583
+ <varlistentry>
584
+ <term><option>--recover</option></term>
585
+ <listitem>
586
+ <para>Output any parsable portions of an invalid document.</para>
587
+ </listitem>
588
+ </varlistentry>
589
+
590
+ <varlistentry>
591
+ <term><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></term>
592
+ <listitem>
593
+ <para>
594
+ Use RelaxNG file named <replaceable class="option">SCHEMA</replaceable>
595
+ for validation.
596
+ </para>
597
+ </listitem>
598
+ </varlistentry>
599
+
600
+ <varlistentry>
601
+ <term><option>--repeat</option></term>
602
+ <listitem>
603
+ <para>Repeat 100 times, for timing or profiling.</para>
604
+ </listitem>
605
+ </varlistentry>
606
+
607
+ <varlistentry>
608
+ <term><option>--sax</option></term>
609
+ <listitem>
610
+ <para>Print SAX callbacks (only for debugging).</para>
611
+ </listitem>
612
+ </varlistentry>
613
+
614
+ <varlistentry>
615
+ <term><option>--sax1</option></term>
616
+ <listitem>
617
+ <para>Use deprecated SAX1 interface (only for debugging).</para>
618
+ </listitem>
619
+ </varlistentry>
620
+
621
+ <varlistentry>
622
+ <term><option>--schema <replaceable>SCHEMA</replaceable></option></term>
623
+ <listitem>
624
+ <para>
625
+ Use a W3C <acronym>XML</acronym> Schema file
626
+ named <replaceable>SCHEMA</replaceable> for validation.
627
+ </para>
628
+ </listitem>
629
+ </varlistentry>
630
+
631
+ <varlistentry>
632
+ <term><option>--schematron <replaceable>SCHEMA</replaceable></option></term>
633
+ <listitem>
634
+ <para>
635
+ Use a Schematron file
636
+ named <replaceable>SCHEMA</replaceable> for validation.
637
+ </para>
638
+ </listitem>
639
+ </varlistentry>
640
+
641
+ <varlistentry>
642
+ <term><option>--shell</option></term>
643
+ <listitem>
644
+ <para>
645
+ Run a navigating shell. Details on available commands in shell mode
646
+ are below (see <xref linkend="shell"/>).
647
+ </para>
648
+ </listitem>
649
+ </varlistentry>
650
+
651
+ <varlistentry>
652
+ <term><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></term>
653
+ <listitem>
654
+ <para>
655
+ Run an XPath expression given as argument and print the
656
+ result. In case of a nodeset result, each node in the
657
+ node set is serialized in full in the output. In case
658
+ of an empty node set the "XPath set is empty" result
659
+ will be shown and exit code 11 will be returned..
660
+ This feature is EXPERIMENTAL. Implementation details can
661
+ change without futher notice.
662
+ </para>
663
+ </listitem>
664
+ </varlistentry>
665
+
666
+ <varlistentry>
667
+ <term><option>--stream</option></term>
668
+ <listitem>
669
+ <para>
670
+ Use streaming <acronym>API</acronym> - useful when used in combination
671
+ with <option>--relaxng</option> or <option>--valid</option> options
672
+ for validation of files that are too large to be held in memory.
673
+ </para>
674
+ </listitem>
675
+ </varlistentry>
676
+
677
+ <varlistentry>
678
+ <term><option>--testIO</option></term>
679
+ <listitem>
680
+ <para>Test user input/output support.</para>
681
+ </listitem>
682
+ </varlistentry>
683
+
684
+ <varlistentry>
685
+ <term><option>--timing</option></term>
686
+ <listitem>
687
+ <para>
688
+ Output information about the time it takes &xmllint; to perform the
689
+ various steps.
690
+ </para>
691
+ </listitem>
692
+ </varlistentry>
693
+
694
+ <varlistentry>
695
+ <term><option>--valid</option></term>
696
+ <listitem>
697
+ <para>
698
+ Determine if the document is a valid instance of the included
699
+ Document Type Definition (<acronym>DTD</acronym>).
700
+ A <acronym>DTD</acronym> to be validated against also can be
701
+ specified at the command line using the <option>--dtdvalid</option>
702
+ option. By default, &xmllint; also checks to determine if the
703
+ document is well-formed.
704
+ </para>
705
+ </listitem>
706
+ </varlistentry>
707
+
708
+ <varlistentry>
709
+ <term><option>--version</option></term>
710
+ <listitem>
711
+ <para>
712
+ Display the version of <citerefentry>
713
+ <refentrytitle>libxml</refentrytitle>
714
+ <manvolnum>3</manvolnum>
715
+ </citerefentry> used.
716
+ </para>
717
+ </listitem>
718
+ </varlistentry>
719
+
720
+ <varlistentry>
721
+ <term><option>--walker</option></term>
722
+ <listitem>
723
+ <para>
724
+ Test the walker module, which is a reader interface but for a
725
+ document tree, instead of using the reader <acronym>API</acronym> on
726
+ an unparsed document it works on an existing in-memory tree. Used for
727
+ debugging.
728
+ </para>
729
+ </listitem>
730
+ </varlistentry>
731
+
732
+ <varlistentry>
733
+ <term><option>--xinclude</option></term>
734
+ <listitem>
735
+ <para>Do XInclude processing.</para>
736
+ </listitem>
737
+ </varlistentry>
738
+
739
+ <varlistentry>
740
+ <term><option>--xmlout</option></term>
741
+ <listitem>
742
+ <para>
743
+ Used in conjunction with <option>--html</option>. Usually
744
+ when <acronym>HTML</acronym> is parsed the document is saved with
745
+ the <acronym>HTML</acronym> serializer. But with this option the
746
+ resulting document is saved with the <acronym>XML</acronym>
747
+ serializer. This is primarily used to
748
+ generate <acronym>XHTML</acronym> from <acronym>HTML</acronym> input.
749
+ </para>
750
+ </listitem>
751
+ </varlistentry>
752
+
753
+ </variablelist>
754
+ </refsect1>
755
+
756
+ <refsect1 id="shell">
757
+ <title>SHELL COMMANDS</title>
758
+ <para>
759
+ &xmllint; offers an interactive shell mode invoked with
760
+ the <option>--shell</option> command. Available commands in shell mode
761
+ include (in alphabetical order):
762
+ </para>
763
+ <variablelist>
764
+
765
+ <varlistentry>
766
+ <term><command>base</command></term>
767
+ <listitem>
768
+ <para>Display <acronym>XML</acronym> base of the node.</para>
769
+ </listitem>
770
+ </varlistentry>
771
+
772
+ <varlistentry>
773
+ <term><command>bye</command></term>
774
+ <listitem>
775
+ <para>Leave the shell.</para>
776
+ </listitem>
777
+ </varlistentry>
778
+
779
+ <varlistentry>
780
+ <term><command>cat <replaceable>NODE</replaceable></command></term>
781
+ <listitem>
782
+ <para>Display the given node or the current one.</para>
783
+ </listitem>
784
+ </varlistentry>
785
+
786
+ <varlistentry>
787
+ <term><command>cd <replaceable>PATH</replaceable></command></term>
788
+ <listitem>
789
+ <para>
790
+ Change the current node to the given path (if unique) or root if no
791
+ argument is given.
792
+ </para>
793
+ </listitem>
794
+ </varlistentry>
795
+
796
+ <varlistentry>
797
+ <term><command>dir <replaceable>PATH</replaceable></command></term>
798
+ <listitem>
799
+ <para>
800
+ Dumps information about the node (namespace, attributes, content).
801
+ </para>
802
+ </listitem>
803
+ </varlistentry>
804
+
805
+ <varlistentry>
806
+ <term><command>du <replaceable>PATH</replaceable></command></term>
807
+ <listitem>
808
+ <para>
809
+ Show the structure of the subtree under the given path or the current node.
810
+ </para>
811
+ </listitem>
812
+ </varlistentry>
813
+
814
+ <varlistentry>
815
+ <term><command>exit</command></term>
816
+ <listitem>
817
+ <para>Leave the shell.</para>
818
+ </listitem>
819
+ </varlistentry>
820
+
821
+ <varlistentry>
822
+ <term><command>help</command></term>
823
+ <listitem>
824
+ <para>Show this help.</para>
825
+ </listitem>
826
+ </varlistentry>
827
+
828
+ <varlistentry>
829
+ <term><command>load <replaceable>FILENAME</replaceable></command></term>
830
+ <listitem>
831
+ <para>Load a new document with the given filename.</para>
832
+ </listitem>
833
+ </varlistentry>
834
+
835
+ <varlistentry>
836
+ <term><command>ls <replaceable>PATH</replaceable></command></term>
837
+ <listitem>
838
+ <para>List contents of the given path or the current directory.</para>
839
+ </listitem>
840
+ </varlistentry>
841
+
842
+ <varlistentry>
843
+ <term><command>pwd</command></term>
844
+ <listitem>
845
+ <para>Display the path to the current node.</para>
846
+ </listitem>
847
+ </varlistentry>
848
+
849
+ <varlistentry>
850
+ <term><command>quit</command></term>
851
+ <listitem>
852
+ <para>Leave the shell.</para>
853
+ </listitem>
854
+ </varlistentry>
855
+
856
+ <varlistentry>
857
+ <term><command>save <replaceable>FILENAME</replaceable></command></term>
858
+ <listitem>
859
+ <para>
860
+ Save the current document to the given filename or to the original name.
861
+ </para>
862
+ </listitem>
863
+ </varlistentry>
864
+
865
+ <varlistentry>
866
+ <term><option>validate</option></term>
867
+ <listitem>
868
+ <para>Check the document for errors.</para>
869
+ </listitem>
870
+ </varlistentry>
871
+
872
+ <varlistentry>
873
+ <term><command>write <replaceable>FILENAME</replaceable></command></term>
874
+ <listitem>
875
+ <para>Write the current node to the given filename.</para>
876
+ </listitem>
877
+ </varlistentry>
878
+
879
+ </variablelist>
880
+ </refsect1>
881
+
882
+ <refsect1 id="environment">
883
+ <title>ENVIRONMENT</title>
884
+ <variablelist>
885
+
886
+ <varlistentry>
887
+ <term><envar>SGML_CATALOG_FILES</envar></term>
888
+ <listitem>
889
+ <para><acronym>SGML</acronym> catalog behavior can be changed by redirecting
890
+ queries to the user's own set of catalogs. This can be done by setting
891
+ the <envar>SGML_CATALOG_FILES</envar> environment variable to a list
892
+ of catalogs. An empty one should deactivate loading the
893
+ default catalog.
894
+ </para>
895
+ </listitem>
896
+ </varlistentry>
897
+
898
+ <varlistentry>
899
+ <term><envar>XML_CATALOG_FILES</envar></term>
900
+ <listitem>
901
+ <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
902
+ queries to the user's own set of catalogs. This can be done by setting
903
+ the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
904
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
905
+ An empty variable should deactivate loading the default catalog.
906
+ </para>
907
+ </listitem>
908
+ </varlistentry>
909
+
910
+ <varlistentry>
911
+ <term><envar>XML_DEBUG_CATALOG</envar></term>
912
+ <listitem>
913
+ <para>Setting the environment variable <envar>XML_DEBUG_CATALOG</envar>
914
+ to <parameter>non-zero</parameter> using the <command>export</command>
915
+ command outputs debugging information related to catalog operations.
916
+ </para>
917
+ </listitem>
918
+ </varlistentry>
919
+
920
+ <varlistentry>
921
+ <term><envar>XMLLINT_INDENT</envar></term>
922
+ <listitem>
923
+ <para>Setting the environment variable <envar>XMLLINT_INDENT</envar>
924
+ controls the indentation. The default value is two spaces &quot; &quot;.
925
+ </para>
926
+ </listitem>
927
+ </varlistentry>
928
+
929
+ </variablelist>
930
+ </refsect1>
931
+
932
+ <refsect1 id="diagnostics">
933
+ <title>DIAGNOSTICS</title>
934
+ <para>
935
+ &xmllint; return codes provide information that can be used when
936
+ calling it from scripts.
937
+ </para>
938
+ <!-- better use segmentedlist element later,
939
+ which is currently only supported in snapshots -->
940
+ <variablelist>
941
+
942
+ <varlistentry>
943
+ <term><errorcode>0</errorcode></term>
944
+ <listitem>
945
+ <para>No error</para>
946
+ </listitem>
947
+ </varlistentry>
948
+
949
+ <varlistentry>
950
+ <term><errorcode>1</errorcode></term>
951
+ <listitem>
952
+ <para>Unclassified</para>
953
+ </listitem>
954
+ </varlistentry>
955
+
956
+ <varlistentry>
957
+ <term><errorcode>2</errorcode></term>
958
+ <listitem>
959
+ <para>Error in <acronym>DTD</acronym></para>
960
+ </listitem>
961
+ </varlistentry>
962
+
963
+ <varlistentry>
964
+ <term><errorcode>3</errorcode></term>
965
+ <listitem>
966
+ <para>Validation error</para>
967
+ </listitem>
968
+ </varlistentry>
969
+
970
+ <varlistentry>
971
+ <term><errorcode>4</errorcode></term>
972
+ <listitem>
973
+ <para>Validation error</para>
974
+ </listitem>
975
+ </varlistentry>
976
+
977
+ <varlistentry>
978
+ <term><errorcode>5</errorcode></term>
979
+ <listitem>
980
+ <para>Error in schema compilation</para>
981
+ </listitem>
982
+ </varlistentry>
983
+
984
+ <varlistentry>
985
+ <term><errorcode>6</errorcode></term>
986
+ <listitem>
987
+ <para>Error writing output</para>
988
+ </listitem>
989
+ </varlistentry>
990
+
991
+ <varlistentry>
992
+ <term><errorcode>7</errorcode></term>
993
+ <listitem>
994
+ <para>
995
+ Error in pattern (generated when <option>--pattern</option> option is used)
996
+ </para>
997
+ </listitem>
998
+ </varlistentry>
999
+
1000
+ <varlistentry>
1001
+ <term><errorcode>9</errorcode></term>
1002
+ <listitem>
1003
+ <para>Out of memory error</para>
1004
+ </listitem>
1005
+ </varlistentry>
1006
+
1007
+ <varlistentry>
1008
+ <term><errorcode>10</errorcode></term>
1009
+ <listitem>
1010
+ <para>XPath evaluation error</para>
1011
+ </listitem>
1012
+ </varlistentry>
1013
+
1014
+ <varlistentry>
1015
+ <term><errorcode>11</errorcode></term>
1016
+ <listitem>
1017
+ <para>XPath result is empty</para>
1018
+ </listitem>
1019
+ </varlistentry>
1020
+
1021
+ </variablelist>
1022
+ </refsect1>
1023
+
1024
+ <refsect1 id="seealso">
1025
+ <title>SEE ALSO</title>
1026
+ <para><citerefentry>
1027
+ <refentrytitle>libxml</refentrytitle>
1028
+ <manvolnum>3</manvolnum>
1029
+ </citerefentry>
1030
+ </para>
1031
+ <para>
1032
+ More information can be found at
1033
+ <itemizedlist>
1034
+ <listitem>
1035
+ <para><citerefentry>
1036
+ <refentrytitle>libxml</refentrytitle>
1037
+ <manvolnum>3</manvolnum>
1038
+ </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
1039
+ </para>
1040
+ </listitem>
1041
+ </itemizedlist>
1042
+ </para>
1043
+ </refsect1>
1044
+
1045
+ </refentry>
local-test-libxml2-full-01/afc-libxml2/example/.gitignore ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /gjobread
2
+ /io1
3
+ /io2
4
+ /parse1
5
+ /parse2
6
+ /parse3
7
+ /parse4
8
+ /reader1
9
+ /reader2
10
+ /reader3
11
+ /reader4
12
+ /testWriter
13
+ /tree1
14
+ /tree2
15
+ /xpath1
16
+ /xpath2
local-test-libxml2-full-01/afc-libxml2/example/Makefile.am ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ EXTRA_DIST = \
2
+ gjobs.xml \
3
+ meson.build \
4
+ test1.xml \
5
+ test2.xml \
6
+ test3.xml
7
+
8
+ check_PROGRAMS = \
9
+ gjobread \
10
+ io1 \
11
+ io2 \
12
+ parse1 \
13
+ parse2 \
14
+ parse3 \
15
+ parse4 \
16
+ reader1 \
17
+ reader2 \
18
+ reader3 \
19
+ reader4 \
20
+ testWriter \
21
+ tree1 \
22
+ tree2 \
23
+ xpath1 \
24
+ xpath2
25
+
26
+ AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
27
+ LDADD = $(top_builddir)/libxml2.la
28
+
29
+ gjobread_SOURCES=gjobread.c
30
+ io1_SOURCES = io1.c
31
+ io2_SOURCES = io2.c
32
+ parse1_SOURCES = parse1.c
33
+ parse2_SOURCES = parse2.c
34
+ parse3_SOURCES = parse3.c
35
+ parse4_SOURCES = parse4.c
36
+ reader1_SOURCES = reader1.c
37
+ reader2_SOURCES = reader2.c
38
+ reader3_SOURCES = reader3.c
39
+ reader4_SOURCES = reader4.c
40
+ testWriter_SOURCES = testWriter.c
41
+ tree1_SOURCES = tree1.c
42
+ tree2_SOURCES = tree2.c
43
+ xpath1_SOURCES = xpath1.c
44
+ xpath2_SOURCES = xpath2.c
local-test-libxml2-full-01/afc-libxml2/example/gjobread.c ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * gjobread.c : a small test program for gnome jobs XML format
3
+ *
4
+ * See Copyright for the status of this software.
5
+ *
6
7
+ */
8
+
9
+ #include <stdio.h>
10
+ #include <string.h>
11
+ #include <stdlib.h>
12
+
13
+ /*
14
+ * This example should compile and run indifferently with libxml-1.8.8 +
15
+ * and libxml2-2.1.0 +
16
+ * Check the COMPAT comments below
17
+ */
18
+
19
+ /*
20
+ * COMPAT using xml-config --cflags to get the include path this will
21
+ * work with both
22
+ */
23
+ #include <libxml/xmlmemory.h>
24
+ #include <libxml/parser.h>
25
+
26
+ #define DEBUG(x) printf(x)
27
+
28
+ /*
29
+ * A person record
30
+ * an xmlChar * is really an UTF8 encoded char string (0 terminated)
31
+ */
32
+ typedef struct person {
33
+ xmlChar *name;
34
+ xmlChar *email;
35
+ xmlChar *company;
36
+ xmlChar *organisation;
37
+ xmlChar *smail;
38
+ xmlChar *webPage;
39
+ xmlChar *phone;
40
+ } person, *personPtr;
41
+
42
+ /*
43
+ * And the code needed to parse it
44
+ */
45
+ static personPtr
46
+ parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
47
+ personPtr ret = NULL;
48
+
49
+ DEBUG("parsePerson\n");
50
+ /*
51
+ * allocate the struct
52
+ */
53
+ ret = (personPtr) malloc(sizeof(person));
54
+ if (ret == NULL) {
55
+ fprintf(stderr,"out of memory\n");
56
+ return(NULL);
57
+ }
58
+ memset(ret, 0, sizeof(person));
59
+
60
+ /* We don't care what the top level element name is */
61
+ /* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
62
+ cur = cur->xmlChildrenNode;
63
+ while (cur != NULL) {
64
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Person")) &&
65
+ (cur->ns == ns))
66
+ ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
67
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Email")) &&
68
+ (cur->ns == ns))
69
+ ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
70
+ cur = cur->next;
71
+ }
72
+
73
+ return(ret);
74
+ }
75
+
76
+ /*
77
+ * and to print it
78
+ */
79
+ static void
80
+ printPerson(personPtr cur) {
81
+ if (cur == NULL) return;
82
+ printf("------ Person\n");
83
+ if (cur->name) printf(" name: %s\n", cur->name);
84
+ if (cur->email) printf(" email: %s\n", cur->email);
85
+ if (cur->company) printf(" company: %s\n", cur->company);
86
+ if (cur->organisation) printf(" organisation: %s\n", cur->organisation);
87
+ if (cur->smail) printf(" smail: %s\n", cur->smail);
88
+ if (cur->webPage) printf(" Web: %s\n", cur->webPage);
89
+ if (cur->phone) printf(" phone: %s\n", cur->phone);
90
+ printf("------\n");
91
+ }
92
+
93
+ /*
94
+ * a Description for a Job
95
+ */
96
+ typedef struct job {
97
+ xmlChar *projectID;
98
+ xmlChar *application;
99
+ xmlChar *category;
100
+ personPtr contact;
101
+ int nbDevelopers;
102
+ personPtr developers[100]; /* using dynamic alloc is left as an exercise */
103
+ } job, *jobPtr;
104
+
105
+ /*
106
+ * And the code needed to parse it
107
+ */
108
+ static jobPtr
109
+ parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
110
+ jobPtr ret = NULL;
111
+
112
+ DEBUG("parseJob\n");
113
+ /*
114
+ * allocate the struct
115
+ */
116
+ ret = (jobPtr) malloc(sizeof(job));
117
+ if (ret == NULL) {
118
+ fprintf(stderr,"out of memory\n");
119
+ return(NULL);
120
+ }
121
+ memset(ret, 0, sizeof(job));
122
+
123
+ /* We don't care what the top level element name is */
124
+ cur = cur->xmlChildrenNode;
125
+ while (cur != NULL) {
126
+
127
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Project")) &&
128
+ (cur->ns == ns)) {
129
+ ret->projectID = xmlGetProp(cur, (const xmlChar *) "ID");
130
+ if (ret->projectID == NULL) {
131
+ fprintf(stderr, "Project has no ID\n");
132
+ }
133
+ }
134
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Application")) &&
135
+ (cur->ns == ns))
136
+ ret->application =
137
+ xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
138
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Category")) &&
139
+ (cur->ns == ns))
140
+ ret->category =
141
+ xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
142
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Contact")) &&
143
+ (cur->ns == ns))
144
+ ret->contact = parsePerson(doc, ns, cur);
145
+ cur = cur->next;
146
+ }
147
+
148
+ return(ret);
149
+ }
150
+
151
+ /*
152
+ * and to print it
153
+ */
154
+ static void
155
+ printJob(jobPtr cur) {
156
+ int i;
157
+
158
+ if (cur == NULL) return;
159
+ printf("======= Job\n");
160
+ if (cur->projectID != NULL) printf("projectID: %s\n", cur->projectID);
161
+ if (cur->application != NULL) printf("application: %s\n", cur->application);
162
+ if (cur->category != NULL) printf("category: %s\n", cur->category);
163
+ if (cur->contact != NULL) printPerson(cur->contact);
164
+ printf("%d developers\n", cur->nbDevelopers);
165
+
166
+ for (i = 0;i < cur->nbDevelopers;i++) printPerson(cur->developers[i]);
167
+ printf("======= \n");
168
+ }
169
+
170
+ /*
171
+ * A pool of Gnome Jobs
172
+ */
173
+ typedef struct gjob {
174
+ int nbJobs;
175
+ jobPtr jobs[500]; /* using dynamic alloc is left as an exercise */
176
+ } gJob, *gJobPtr;
177
+
178
+
179
+ static gJobPtr
180
+ parseGjobFile(char *filename) {
181
+ xmlDocPtr doc;
182
+ gJobPtr ret;
183
+ jobPtr curjob;
184
+ xmlNsPtr ns;
185
+ xmlNodePtr cur;
186
+
187
+ /*
188
+ * build an XML tree from a the file;
189
+ */
190
+ doc = xmlReadFile(filename, NULL, XML_PARSE_NOBLANKS);
191
+ if (doc == NULL) return(NULL);
192
+
193
+ /*
194
+ * Check the document is of the right kind
195
+ */
196
+
197
+ cur = xmlDocGetRootElement(doc);
198
+ if (cur == NULL) {
199
+ fprintf(stderr,"empty document\n");
200
+ xmlFreeDoc(doc);
201
+ return(NULL);
202
+ }
203
+ ns = xmlSearchNsByHref(doc, cur,
204
+ (const xmlChar *) "http://www.gnome.org/some-location");
205
+ if (ns == NULL) {
206
+ fprintf(stderr,
207
+ "document of the wrong type, GJob Namespace not found\n");
208
+ xmlFreeDoc(doc);
209
+ return(NULL);
210
+ }
211
+ if (xmlStrcmp(cur->name, (const xmlChar *) "Helping")) {
212
+ fprintf(stderr,"document of the wrong type, root node != Helping");
213
+ xmlFreeDoc(doc);
214
+ return(NULL);
215
+ }
216
+
217
+ /*
218
+ * Allocate the structure to be returned.
219
+ */
220
+ ret = (gJobPtr) malloc(sizeof(gJob));
221
+ if (ret == NULL) {
222
+ fprintf(stderr,"out of memory\n");
223
+ xmlFreeDoc(doc);
224
+ return(NULL);
225
+ }
226
+ memset(ret, 0, sizeof(gJob));
227
+
228
+ /*
229
+ * Now, walk the tree.
230
+ */
231
+ /* First level we expect just Jobs */
232
+ cur = cur->xmlChildrenNode;
233
+ while ( cur && xmlIsBlankNode ( cur ) ) {
234
+ cur = cur -> next;
235
+ }
236
+ if ( cur == 0 ) {
237
+ xmlFreeDoc(doc);
238
+ free(ret);
239
+ return ( NULL );
240
+ }
241
+ if ((xmlStrcmp(cur->name, (const xmlChar *) "Jobs")) || (cur->ns != ns)) {
242
+ fprintf(stderr,"document of the wrong type, was '%s', Jobs expected",
243
+ cur->name);
244
+ fprintf(stderr,"xmlDocDump follows\n");
245
+ #ifdef LIBXML_OUTPUT_ENABLED
246
+ xmlDocDump ( stderr, doc );
247
+ fprintf(stderr,"xmlDocDump finished\n");
248
+ #endif /* LIBXML_OUTPUT_ENABLED */
249
+ xmlFreeDoc(doc);
250
+ free(ret);
251
+ return(NULL);
252
+ }
253
+
254
+ /* Second level is a list of Job, but be laxist */
255
+ cur = cur->xmlChildrenNode;
256
+ while (cur != NULL) {
257
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Job")) &&
258
+ (cur->ns == ns)) {
259
+ curjob = parseJob(doc, ns, cur);
260
+ if (curjob != NULL)
261
+ ret->jobs[ret->nbJobs++] = curjob;
262
+ if (ret->nbJobs >= 500) break;
263
+ }
264
+ cur = cur->next;
265
+ }
266
+
267
+ return(ret);
268
+ }
269
+
270
+ static void
271
+ handleGjob(gJobPtr cur) {
272
+ int i;
273
+
274
+ /*
275
+ * Do whatever you want and free the structure.
276
+ */
277
+ printf("%d Jobs registered\n", cur->nbJobs);
278
+ for (i = 0; i < cur->nbJobs; i++) printJob(cur->jobs[i]);
279
+ }
280
+
281
+ int main(int argc, char **argv) {
282
+ int i;
283
+ gJobPtr cur;
284
+
285
+ /* COMPAT: Do not generate nodes for formatting spaces */
286
+ LIBXML_TEST_VERSION
287
+
288
+ for (i = 1; i < argc ; i++) {
289
+ cur = parseGjobFile(argv[i]);
290
+ if ( cur )
291
+ handleGjob(cur);
292
+ else
293
+ fprintf( stderr, "Error parsing file '%s'\n", argv[i]);
294
+
295
+ }
296
+
297
+ /* Clean up everything else before quitting. */
298
+ xmlCleanupParser();
299
+
300
+ return(0);
301
+ }
local-test-libxml2-full-01/afc-libxml2/example/gjobs.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <gjob:Helping xmlns:gjob="http://www.gnome.org/some-location">
3
+ <gjob:Jobs>
4
+
5
+ <gjob:Job>
6
+ <gjob:Project ID="3"/>
7
+ <gjob:Application>GBackup</gjob:Application>
8
+ <gjob:Category>Development</gjob:Category>
9
+
10
+ <gjob:Update>
11
+ <gjob:Status>Open</gjob:Status>
12
+ <gjob:Modified>Mon, 07 Jun 1999 20:27:45 -0400 MET DST</gjob:Modified>
13
+ <gjob:Salary>USD 0.00</gjob:Salary>
14
+ </gjob:Update>
15
+
16
+ <gjob:Developers>
17
+ <gjob:Developer>
18
+ </gjob:Developer>
19
+ </gjob:Developers>
20
+
21
+ <gjob:Contact>
22
+ <gjob:Person>Nathan Clemons</gjob:Person>
23
+ <gjob:Email>[email protected]</gjob:Email>
24
+ <gjob:Company>
25
+ </gjob:Company>
26
+ <gjob:Organisation>
27
+ </gjob:Organisation>
28
+ <gjob:Webpage>
29
+ </gjob:Webpage>
30
+ <gjob:Snailmail>
31
+ </gjob:Snailmail>
32
+ <gjob:Phone>
33
+ </gjob:Phone>
34
+ </gjob:Contact>
35
+
36
+ <gjob:Requirements>
37
+ The program should be released as free software, under the GPL.
38
+ </gjob:Requirements>
39
+
40
+ <gjob:Skills>
41
+ </gjob:Skills>
42
+
43
+ <gjob:Details>
44
+ A GNOME based system that will allow a superuser to configure
45
+ compressed and uncompressed files and/or file systems to be backed
46
+ up with a supported media in the system. This should be able to
47
+ perform via find commands generating a list of files that are passed
48
+ to tar, dd, cpio, cp, gzip, etc., to be directed to the tape machine
49
+ or via operations performed on the filesystem itself. Email
50
+ notification and GUI status display very important.
51
+ </gjob:Details>
52
+
53
+ </gjob:Job>
54
+
55
+ </gjob:Jobs>
56
+ </gjob:Helping>
57
+
local-test-libxml2-full-01/afc-libxml2/example/icu.c ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * icu.c: Example how to use ICU for character encoding conversion
3
+ *
4
+ * This example shows how to use ICU by installing a custom character
5
+ * encoding converter with xmlCtxtSetCharEncConvImpl, available
6
+ * since libxml2 2.14.
7
+ *
8
+ * This approach makes it possible to use ICU even if libxml2 is
9
+ * compiled without ICU support. It also makes sure that *only* ICU
10
+ * is used. Many Linux distros currently ship libxml2 with support
11
+ * for both ICU and iconv which makes the library's behavior hard to
12
+ * predict.
13
+ *
14
+ * The long-term plan is to make libxml2 only support a single
15
+ * conversion library internally (iconv on POSIX).
16
+ */
17
+
18
+ #include <stdio.h>
19
+ #include <libxml/parser.h>
20
+ #include <unicode/ucnv.h>
21
+
22
+ #define ICU_PIVOT_BUF_SIZE 1024
23
+
24
+ typedef struct {
25
+ UConverter *uconv; /* for conversion between an encoding and UTF-16 */
26
+ UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
27
+ UChar *pivot_source;
28
+ UChar *pivot_target;
29
+ int isInput;
30
+ UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
31
+ } myConvCtxt;
32
+
33
+ static int
34
+ icuConvert(unsigned char *out, int *outlen,
35
+ const unsigned char *in, int *inlen, void *vctxt) {
36
+ myConvCtxt *cd = vctxt;
37
+ const char *ucv_in = (const char *) in;
38
+ char *ucv_out = (char *) out;
39
+ UConverter *target, *source;
40
+ UErrorCode err = U_ZERO_ERROR;
41
+ int ret;
42
+
43
+ if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
44
+ if (outlen != NULL)
45
+ *outlen = 0;
46
+ return XML_ENC_ERR_INTERNAL;
47
+ }
48
+
49
+ /*
50
+ * Note that the ICU API is stateful. It can always consume a certain
51
+ * amount of input even if the output buffer would overflow. The
52
+ * remaining input must be processed by calling ucnv_convertEx with a
53
+ * possibly empty input buffer.
54
+ *
55
+ * ucnv_convertEx is always called with reset and flush set to 0,
56
+ * so we don't mess up the state. This should never generate
57
+ * U_TRUNCATED_CHAR_FOUND errors.
58
+ */
59
+ if (cd->isInput) {
60
+ source = cd->uconv;
61
+ target = cd->utf8;
62
+ } else {
63
+ source = cd->utf8;
64
+ target = cd->uconv;
65
+ }
66
+
67
+ ucnv_convertEx(target, source, &ucv_out, ucv_out + *outlen,
68
+ &ucv_in, ucv_in + *inlen, cd->pivot_buf,
69
+ &cd->pivot_source, &cd->pivot_target,
70
+ cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, 0, &err);
71
+
72
+ *inlen = ucv_in - (const char*) in;
73
+ *outlen = ucv_out - (char *) out;
74
+
75
+ if (U_SUCCESS(err)) {
76
+ ret = XML_ENC_ERR_SUCCESS;
77
+ } else {
78
+ switch (err) {
79
+ case U_TRUNCATED_CHAR_FOUND:
80
+ /* Shouldn't happen without flush */
81
+ ret = XML_ENC_ERR_SUCCESS;
82
+ break;
83
+
84
+ case U_BUFFER_OVERFLOW_ERROR:
85
+ ret = XML_ENC_ERR_SPACE;
86
+ break;
87
+
88
+ case U_INVALID_CHAR_FOUND:
89
+ case U_ILLEGAL_CHAR_FOUND:
90
+ case U_ILLEGAL_ESCAPE_SEQUENCE:
91
+ case U_UNSUPPORTED_ESCAPE_SEQUENCE:
92
+ ret = XML_ENC_ERR_INPUT;
93
+ break;
94
+
95
+ case U_MEMORY_ALLOCATION_ERROR:
96
+ ret = XML_ENC_ERR_MEMORY;
97
+ break;
98
+
99
+ default:
100
+ ret = XML_ENC_ERR_INTERNAL;
101
+ break;
102
+ }
103
+ }
104
+
105
+ return ret;
106
+ }
107
+
108
+ static int
109
+ icuOpen(const char* name, int isInput, myConvCtxt **out)
110
+ {
111
+ UErrorCode status;
112
+ myConvCtxt *cd;
113
+
114
+ *out = NULL;
115
+
116
+ cd = xmlMalloc(sizeof(myConvCtxt));
117
+ if (cd == NULL)
118
+ return XML_ERR_NO_MEMORY;
119
+
120
+ cd->isInput = isInput;
121
+ cd->pivot_source = cd->pivot_buf;
122
+ cd->pivot_target = cd->pivot_buf;
123
+
124
+ status = U_ZERO_ERROR;
125
+ cd->uconv = ucnv_open(name, &status);
126
+ if (U_FAILURE(status))
127
+ goto error;
128
+
129
+ status = U_ZERO_ERROR;
130
+ if (isInput) {
131
+ ucnv_setToUCallBack(cd->uconv, UCNV_TO_U_CALLBACK_STOP,
132
+ NULL, NULL, NULL, &status);
133
+ }
134
+ else {
135
+ ucnv_setFromUCallBack(cd->uconv, UCNV_FROM_U_CALLBACK_STOP,
136
+ NULL, NULL, NULL, &status);
137
+ }
138
+ if (U_FAILURE(status))
139
+ goto error;
140
+
141
+ status = U_ZERO_ERROR;
142
+ cd->utf8 = ucnv_open("UTF-8", &status);
143
+ if (U_FAILURE(status))
144
+ goto error;
145
+
146
+ *out = cd;
147
+ return 0;
148
+
149
+ error:
150
+ if (cd->uconv)
151
+ ucnv_close(cd->uconv);
152
+ xmlFree(cd);
153
+
154
+ if (status == U_FILE_ACCESS_ERROR)
155
+ return XML_ERR_UNSUPPORTED_ENCODING;
156
+ if (status == U_MEMORY_ALLOCATION_ERROR)
157
+ return XML_ERR_NO_MEMORY;
158
+ return XML_ERR_SYSTEM;
159
+ }
160
+
161
+ static void
162
+ icuClose(myConvCtxt *cd)
163
+ {
164
+ if (cd == NULL)
165
+ return;
166
+ ucnv_close(cd->uconv);
167
+ ucnv_close(cd->utf8);
168
+ xmlFree(cd);
169
+ }
170
+
171
+ static void
172
+ icuConvCtxtDtor(void *vctxt) {
173
+ icuClose(vctxt);
174
+ }
175
+
176
+ static int
177
+ icuConvImpl(void *vctxt, const char *name,
178
+ xmlCharEncConverter *conv) {
179
+ myConvCtxt *inputCtxt = NULL;
180
+ myConvCtxt *outputCtxt = NULL;
181
+ int ret;
182
+
183
+ ret = icuOpen(name, 1, &inputCtxt);
184
+ if (ret != 0)
185
+ goto error;
186
+ ret = icuOpen(name, 0, &outputCtxt);
187
+ if (ret != 0)
188
+ goto error;
189
+
190
+ conv->input = icuConvert;
191
+ conv->output = icuConvert;
192
+ conv->ctxtDtor = icuConvCtxtDtor;
193
+ conv->inputCtxt = inputCtxt;
194
+ conv->outputCtxt = outputCtxt;
195
+
196
+ return XML_ERR_OK;
197
+
198
+ error:
199
+ if (inputCtxt != NULL)
200
+ icuClose(inputCtxt);
201
+ if (outputCtxt != NULL)
202
+ icuClose(outputCtxt);
203
+ return ret;
204
+ }
205
+
206
+ int
207
+ main(void) {
208
+ xmlParserCtxtPtr ctxt;
209
+ xmlDocPtr doc;
210
+ const char *xml;
211
+ xmlChar *content;
212
+ int ret = 0;
213
+
214
+ /*
215
+ * We use IBM-1051, an alias for HP Roman, as a simple example that
216
+ * ICU supports, but iconv (typically) doesn't.
217
+ *
218
+ * Character code 0xDE is U+00DF Latin Small Letter Sharp S.
219
+ */
220
+ xml = "<doc>\xDE</doc>";
221
+
222
+ ctxt = xmlNewParserCtxt();
223
+ xmlCtxtSetCharEncConvImpl(ctxt, icuConvImpl, NULL);
224
+ doc = xmlCtxtReadDoc(ctxt, BAD_CAST xml, NULL, "IBM-1051", 0);
225
+ xmlFreeParserCtxt(ctxt);
226
+
227
+ content = xmlNodeGetContent((xmlNodePtr) doc);
228
+
229
+ printf("content: %s\n", content);
230
+
231
+ if (!xmlStrEqual(content, BAD_CAST "\xC3\x9F")) {
232
+ fprintf(stderr, "converison failed\n");
233
+ ret = 1;
234
+ }
235
+
236
+ xmlFree(content);
237
+ xmlFreeDoc(doc);
238
+
239
+ return ret;
240
+ }
241
+
local-test-libxml2-full-01/afc-libxml2/example/io1.c ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: InputOutput
3
+ * synopsis: Example of custom Input/Output
4
+ * purpose: Demonstrate the use of xmlRegisterInputCallbacks
5
+ * to build a custom I/O layer, this is used in an
6
+ * XInclude method context to show how dynamic document can
7
+ * be built in a clean way.
8
+ * usage: io1
9
+ * test: io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res
10
+ * author: Daniel Veillard
11
+ * copy: see Copyright for the status of this software.
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <stdlib.h>
16
+ #include <string.h>
17
+ #include <libxml/parser.h>
18
+ #include <libxml/tree.h>
19
+ #include <libxml/xinclude.h>
20
+ #include <libxml/xmlIO.h>
21
+
22
+ #ifdef LIBXML_XINCLUDE_ENABLED
23
+ static const char *result = "<list><people>a</people><people>b</people></list>";
24
+ static const char *cur = NULL;
25
+ static int rlen;
26
+
27
+ /**
28
+ * sqlMatch:
29
+ * @URI: an URI to test
30
+ *
31
+ * Check for an sql: query
32
+ *
33
+ * Returns 1 if yes and 0 if another Input module should be used
34
+ */
35
+ static int
36
+ sqlMatch(const char * URI) {
37
+ if ((URI != NULL) && (!strncmp(URI, "sql:", 4)))
38
+ return(1);
39
+ return(0);
40
+ }
41
+
42
+ /**
43
+ * sqlOpen:
44
+ * @URI: an URI to test
45
+ *
46
+ * Return a pointer to the sql: query handler, in this example simply
47
+ * the current pointer...
48
+ *
49
+ * Returns an Input context or NULL in case or error
50
+ */
51
+ static void *
52
+ sqlOpen(const char * URI) {
53
+ if ((URI == NULL) || (strncmp(URI, "sql:", 4)))
54
+ return(NULL);
55
+ cur = result;
56
+ rlen = strlen(result);
57
+ return((void *) cur);
58
+ }
59
+
60
+ /**
61
+ * sqlClose:
62
+ * @context: the read context
63
+ *
64
+ * Close the sql: query handler
65
+ *
66
+ * Returns 0 or -1 in case of error
67
+ */
68
+ static int
69
+ sqlClose(void * context) {
70
+ if (context == NULL) return(-1);
71
+ cur = NULL;
72
+ rlen = 0;
73
+ return(0);
74
+ }
75
+
76
+ /**
77
+ * sqlRead:
78
+ * @context: the read context
79
+ * @buffer: where to store data
80
+ * @len: number of bytes to read
81
+ *
82
+ * Implement an sql: query read.
83
+ *
84
+ * Returns the number of bytes read or -1 in case of error
85
+ */
86
+ static int
87
+ sqlRead(void * context, char * buffer, int len) {
88
+ const char *ptr = (const char *) context;
89
+
90
+ if ((context == NULL) || (buffer == NULL) || (len < 0))
91
+ return(-1);
92
+
93
+ if (len > rlen) len = rlen;
94
+ memcpy(buffer, ptr, len);
95
+ rlen -= len;
96
+ return(len);
97
+ }
98
+
99
+ const char *include = "<?xml version='1.0'?>\n\
100
+ <document xmlns:xi=\"http://www.w3.org/2003/XInclude\">\n\
101
+ <p>List of people:</p>\n\
102
+ <xi:include href=\"sql:select_name_from_people\"/>\n\
103
+ </document>\n";
104
+
105
+ int main(void) {
106
+ xmlDocPtr doc;
107
+
108
+ /*
109
+ * this initialize the library and check potential ABI mismatches
110
+ * between the version it was compiled for and the actual shared
111
+ * library used.
112
+ */
113
+ LIBXML_TEST_VERSION
114
+
115
+ /*
116
+ * register the new I/O handlers
117
+ */
118
+ if (xmlRegisterInputCallbacks(sqlMatch, sqlOpen, sqlRead, sqlClose) < 0) {
119
+ fprintf(stderr, "failed to register SQL handler\n");
120
+ exit(1);
121
+ }
122
+ /*
123
+ * parse include into a document
124
+ */
125
+ doc = xmlReadMemory(include, strlen(include), "include.xml", NULL, 0);
126
+ if (doc == NULL) {
127
+ fprintf(stderr, "failed to parse the including file\n");
128
+ exit(1);
129
+ }
130
+
131
+ /*
132
+ * apply the XInclude process, this should trigger the I/O just
133
+ * registered.
134
+ */
135
+ if (xmlXIncludeProcess(doc) <= 0) {
136
+ fprintf(stderr, "XInclude processing failed\n");
137
+ exit(1);
138
+ }
139
+
140
+ #ifdef LIBXML_OUTPUT_ENABLED
141
+ /*
142
+ * save the output for checking to stdout
143
+ */
144
+ xmlDocDump(stdout, doc);
145
+ #endif
146
+
147
+ /*
148
+ * Free the document
149
+ */
150
+ xmlFreeDoc(doc);
151
+
152
+ return(0);
153
+ }
154
+ #else
155
+ int main(void) {
156
+ fprintf(stderr, "XInclude support not compiled in\n");
157
+ return(0);
158
+ }
159
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/io2.c ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: InputOutput
3
+ * synopsis: Output to char buffer
4
+ * purpose: Demonstrate the use of xmlDocDumpMemory
5
+ * to output document to a character buffer
6
+ * usage: io2
7
+ * test: io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res
8
+ * author: John Fleck
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+
12
+ #include <libxml/parser.h>
13
+
14
+ #if defined(LIBXML_OUTPUT_ENABLED)
15
+ int
16
+ main(void)
17
+ {
18
+
19
+ xmlNodePtr n;
20
+ xmlDocPtr doc;
21
+ xmlChar *xmlbuff;
22
+ int buffersize;
23
+
24
+ /*
25
+ * Create the document.
26
+ */
27
+ doc = xmlNewDoc(BAD_CAST "1.0");
28
+ n = xmlNewDocNode(doc, NULL, BAD_CAST "root", NULL);
29
+ xmlNodeSetContent(n, BAD_CAST "content");
30
+ xmlDocSetRootElement(doc, n);
31
+
32
+ /*
33
+ * Dump the document to a buffer and print it
34
+ * for demonstration purposes.
35
+ */
36
+ xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
37
+ printf("%s", (char *) xmlbuff);
38
+
39
+ /*
40
+ * Free associated memory.
41
+ */
42
+ xmlFree(xmlbuff);
43
+ xmlFreeDoc(doc);
44
+
45
+ return (0);
46
+
47
+ }
48
+ #else
49
+ #include <stdio.h>
50
+
51
+ int
52
+ main(void)
53
+ {
54
+ fprintf(stderr,
55
+ "library not configured with output support\n");
56
+ return (0);
57
+ }
58
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/meson.build ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ examples = [
2
+ 'gjobread',
3
+ 'io1',
4
+ 'io2',
5
+ 'parse1',
6
+ 'parse2',
7
+ 'parse3',
8
+ 'parse4',
9
+ 'reader1',
10
+ 'reader2',
11
+ 'reader3',
12
+ 'reader4',
13
+ 'testWriter',
14
+ 'tree1',
15
+ 'tree2',
16
+ 'xpath1',
17
+ 'xpath2',
18
+ ]
19
+
20
+ foreach example : examples
21
+ exe = executable(
22
+ example,
23
+ files(example + '.c'),
24
+ dependencies: xml_dep,
25
+ include_directories: config_dir,
26
+ )
27
+ endforeach
local-test-libxml2-full-01/afc-libxml2/example/parse1.c ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse an XML file to a tree and free it
4
+ * purpose: Demonstrate the use of xmlReadFile() to read an XML file
5
+ * into a tree and xmlFreeDoc() to free the resulting tree
6
+ * usage: parse1 test1.xml
7
+ * test: parse1 test1.xml
8
+ * author: Daniel Veillard
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+
12
+ #include <stdio.h>
13
+ #include <libxml/parser.h>
14
+ #include <libxml/tree.h>
15
+
16
+ /**
17
+ * example1Func:
18
+ * @filename: a filename or an URL
19
+ *
20
+ * Parse the resource and free the resulting tree
21
+ */
22
+ static void
23
+ example1Func(const char *filename) {
24
+ xmlDocPtr doc; /* the resulting document tree */
25
+
26
+ doc = xmlReadFile(filename, NULL, 0);
27
+ if (doc == NULL) {
28
+ fprintf(stderr, "Failed to parse %s\n", filename);
29
+ return;
30
+ }
31
+ xmlFreeDoc(doc);
32
+ }
33
+
34
+ int main(int argc, char **argv) {
35
+ if (argc != 2)
36
+ return(1);
37
+
38
+ /*
39
+ * this initialize the library and check potential ABI mismatches
40
+ * between the version it was compiled for and the actual shared
41
+ * library used.
42
+ */
43
+ LIBXML_TEST_VERSION
44
+
45
+ example1Func(argv[1]);
46
+
47
+ return(0);
48
+ }
local-test-libxml2-full-01/afc-libxml2/example/parse2.c ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse and validate an XML file to a tree and free the result
4
+ * purpose: Create a parser context for an XML file, then parse and validate
5
+ * the file, creating a tree, check the validation result
6
+ * and xmlFreeDoc() to free the resulting tree.
7
+ * usage: parse2 test2.xml
8
+ * test: parse2 test2.xml
9
+ * author: Daniel Veillard
10
+ * copy: see Copyright for the status of this software.
11
+ */
12
+
13
+ #include <stdio.h>
14
+ #include <libxml/parser.h>
15
+ #include <libxml/tree.h>
16
+
17
+ /**
18
+ * exampleFunc:
19
+ * @filename: a filename or an URL
20
+ *
21
+ * Parse and validate the resource and free the resulting tree
22
+ */
23
+ static void
24
+ exampleFunc(const char *filename) {
25
+ xmlParserCtxtPtr ctxt; /* the parser context */
26
+ xmlDocPtr doc; /* the resulting document tree */
27
+
28
+ /* create a parser context */
29
+ ctxt = xmlNewParserCtxt();
30
+ if (ctxt == NULL) {
31
+ fprintf(stderr, "Failed to allocate parser context\n");
32
+ return;
33
+ }
34
+ /* parse the file, activating the DTD validation option */
35
+ doc = xmlCtxtReadFile(ctxt, filename, NULL, XML_PARSE_DTDVALID);
36
+ /* check if parsing succeeded */
37
+ if (doc == NULL) {
38
+ fprintf(stderr, "Failed to parse %s\n", filename);
39
+ } else {
40
+ /* check if validation succeeded */
41
+ if (ctxt->valid == 0)
42
+ fprintf(stderr, "Failed to validate %s\n", filename);
43
+ /* free up the resulting document */
44
+ xmlFreeDoc(doc);
45
+ }
46
+ /* free up the parser context */
47
+ xmlFreeParserCtxt(ctxt);
48
+ }
49
+
50
+ int main(int argc, char **argv) {
51
+ if (argc != 2)
52
+ return(1);
53
+
54
+ /*
55
+ * this initialize the library and check potential ABI mismatches
56
+ * between the version it was compiled for and the actual shared
57
+ * library used.
58
+ */
59
+ LIBXML_TEST_VERSION
60
+
61
+ exampleFunc(argv[1]);
62
+
63
+ return(0);
64
+ }
local-test-libxml2-full-01/afc-libxml2/example/parse3.c ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse an XML document in memory to a tree and free it
4
+ * purpose: Demonstrate the use of xmlReadMemory() to read an XML file
5
+ * into a tree and xmlFreeDoc() to free the resulting tree
6
+ * usage: parse3
7
+ * test: parse3
8
+ * author: Daniel Veillard
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+
12
+ #include <stdio.h>
13
+ #include <libxml/parser.h>
14
+ #include <libxml/tree.h>
15
+
16
+ static const char *document = "<doc/>";
17
+
18
+ /**
19
+ * example3Func:
20
+ * @content: the content of the document
21
+ * @length: the length in bytes
22
+ *
23
+ * Parse the in memory document and free the resulting tree
24
+ */
25
+ static void
26
+ example3Func(const char *content, int length) {
27
+ xmlDocPtr doc; /* the resulting document tree */
28
+
29
+ /*
30
+ * The document being in memory, it have no base per RFC 2396,
31
+ * and the "noname.xml" argument will serve as its base.
32
+ */
33
+ doc = xmlReadMemory(content, length, "noname.xml", NULL, 0);
34
+ if (doc == NULL) {
35
+ fprintf(stderr, "Failed to parse document\n");
36
+ return;
37
+ }
38
+ xmlFreeDoc(doc);
39
+ }
40
+
41
+ int main(void) {
42
+ /*
43
+ * this initialize the library and check potential ABI mismatches
44
+ * between the version it was compiled for and the actual shared
45
+ * library used.
46
+ */
47
+ LIBXML_TEST_VERSION
48
+
49
+ example3Func(document, 6);
50
+
51
+ return(0);
52
+ }
local-test-libxml2-full-01/afc-libxml2/example/parse4.c ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse an XML document chunk by chunk to a tree and free it
4
+ * purpose: Demonstrate the use of xmlCreatePushParserCtxt() and
5
+ * xmlParseChunk() to read an XML file progressively
6
+ * into a tree and xmlFreeDoc() to free the resulting tree
7
+ * usage: parse4 test3.xml
8
+ * test: parse4 test3.xml
9
+ * author: Daniel Veillard
10
+ * copy: see Copyright for the status of this software.
11
+ */
12
+
13
+ #include <stdio.h>
14
+ #include <libxml/parser.h>
15
+ #include <libxml/tree.h>
16
+
17
+ #ifdef LIBXML_PUSH_ENABLED
18
+ static FILE *desc;
19
+
20
+ /**
21
+ * readPacket:
22
+ * @mem: array to store the packet
23
+ * @size: the packet size
24
+ *
25
+ * read at most @size bytes from the document and store it in @mem
26
+ *
27
+ * Returns the number of bytes read
28
+ */
29
+ static int
30
+ readPacket(char *mem, int size) {
31
+ int res;
32
+
33
+ res = fread(mem, 1, size, desc);
34
+ return(res);
35
+ }
36
+
37
+ /**
38
+ * example4Func:
39
+ * @filename: a filename or an URL
40
+ *
41
+ * Parse the resource and free the resulting tree
42
+ */
43
+ static void
44
+ example4Func(const char *filename) {
45
+ xmlParserCtxtPtr ctxt;
46
+ char chars[4];
47
+ xmlDocPtr doc; /* the resulting document tree */
48
+ int res;
49
+
50
+ /*
51
+ * Read a few first byte to check the input used for the
52
+ * encoding detection at the parser level.
53
+ */
54
+ res = readPacket(chars, 4);
55
+ if (res <= 0) {
56
+ fprintf(stderr, "Failed to parse %s\n", filename);
57
+ return;
58
+ }
59
+
60
+ /*
61
+ * Create a progressive parsing context, the 2 first arguments
62
+ * are not used since we want to build a tree and not use a SAX
63
+ * parsing interface. We also pass the first bytes of the document
64
+ * to allow encoding detection when creating the parser but this
65
+ * is optional.
66
+ */
67
+ ctxt = xmlCreatePushParserCtxt(NULL, NULL,
68
+ chars, res, filename);
69
+ if (ctxt == NULL) {
70
+ fprintf(stderr, "Failed to create parser context !\n");
71
+ return;
72
+ }
73
+
74
+ /*
75
+ * loop on the input getting the document data, of course 4 bytes
76
+ * at a time is not realistic but allows to verify testing on small
77
+ * documents.
78
+ */
79
+ while ((res = readPacket(chars, 4)) > 0) {
80
+ xmlParseChunk(ctxt, chars, res, 0);
81
+ }
82
+
83
+ /*
84
+ * there is no more input, indicate the parsing is finished.
85
+ */
86
+ xmlParseChunk(ctxt, chars, 0, 1);
87
+
88
+ /*
89
+ * collect the document back and if it was wellformed
90
+ * and destroy the parser context.
91
+ */
92
+ doc = ctxt->myDoc;
93
+ res = ctxt->wellFormed;
94
+ xmlFreeParserCtxt(ctxt);
95
+
96
+ if (!res) {
97
+ fprintf(stderr, "Failed to parse %s\n", filename);
98
+ }
99
+
100
+ /*
101
+ * since we don't use the document, destroy it now.
102
+ */
103
+ xmlFreeDoc(doc);
104
+ }
105
+
106
+ int main(int argc, char **argv) {
107
+ if (argc != 2)
108
+ return(1);
109
+
110
+ /*
111
+ * this initialize the library and check potential ABI mismatches
112
+ * between the version it was compiled for and the actual shared
113
+ * library used.
114
+ */
115
+ LIBXML_TEST_VERSION
116
+
117
+ /*
118
+ * simulate a progressive parsing using the input file.
119
+ */
120
+ desc = fopen(argv[1], "rb");
121
+ if (desc != NULL) {
122
+ example4Func(argv[1]);
123
+ fclose(desc);
124
+ } else {
125
+ fprintf(stderr, "Failed to parse %s\n", argv[1]);
126
+ }
127
+
128
+ return(0);
129
+ }
130
+ #else /* ! LIBXML_PUSH_ENABLED */
131
+ int main(void) {
132
+ fprintf(stderr, "Library not compiled with push parser support\n");
133
+ return(0);
134
+ }
135
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/reader1.c ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Parse an XML file with an xmlReader
4
+ * purpose: Demonstrate the use of xmlReaderForFile() to parse an XML file
5
+ * and dump the information about the nodes found in the process.
6
+ * (Note that the XMLReader functions require libxml2 version later
7
+ * than 2.6.)
8
+ * usage: reader1 <filename>
9
+ * test: reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
10
+ * author: Daniel Veillard
11
+ * copy: see Copyright for the status of this software.
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <libxml/xmlreader.h>
16
+
17
+ #ifdef LIBXML_READER_ENABLED
18
+
19
+ /**
20
+ * processNode:
21
+ * @reader: the xmlReader
22
+ *
23
+ * Dump information about the current node
24
+ */
25
+ static void
26
+ processNode(xmlTextReaderPtr reader) {
27
+ const xmlChar *name, *value;
28
+
29
+ name = xmlTextReaderConstName(reader);
30
+ if (name == NULL)
31
+ name = BAD_CAST "--";
32
+
33
+ value = xmlTextReaderConstValue(reader);
34
+
35
+ printf("%d %d %s %d %d",
36
+ xmlTextReaderDepth(reader),
37
+ xmlTextReaderNodeType(reader),
38
+ name,
39
+ xmlTextReaderIsEmptyElement(reader),
40
+ xmlTextReaderHasValue(reader));
41
+ if (value == NULL)
42
+ printf("\n");
43
+ else {
44
+ if (xmlStrlen(value) > 40)
45
+ printf(" %.40s...\n", value);
46
+ else
47
+ printf(" %s\n", value);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * streamFile:
53
+ * @filename: the file name to parse
54
+ *
55
+ * Parse and print information about an XML file.
56
+ */
57
+ static void
58
+ streamFile(const char *filename) {
59
+ xmlTextReaderPtr reader;
60
+ int ret;
61
+
62
+ reader = xmlReaderForFile(filename, NULL, 0);
63
+ if (reader != NULL) {
64
+ ret = xmlTextReaderRead(reader);
65
+ while (ret == 1) {
66
+ processNode(reader);
67
+ ret = xmlTextReaderRead(reader);
68
+ }
69
+ xmlFreeTextReader(reader);
70
+ if (ret != 0) {
71
+ fprintf(stderr, "%s : failed to parse\n", filename);
72
+ }
73
+ } else {
74
+ fprintf(stderr, "Unable to open %s\n", filename);
75
+ }
76
+ }
77
+
78
+ int main(int argc, char **argv) {
79
+ if (argc != 2)
80
+ return(1);
81
+
82
+ /*
83
+ * this initialize the library and check potential ABI mismatches
84
+ * between the version it was compiled for and the actual shared
85
+ * library used.
86
+ */
87
+ LIBXML_TEST_VERSION
88
+
89
+ streamFile(argv[1]);
90
+
91
+ return(0);
92
+ }
93
+
94
+ #else
95
+ int main(void) {
96
+ fprintf(stderr, "XInclude support not compiled in\n");
97
+ return(0);
98
+ }
99
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/reader2.c ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Parse and validate an XML file with an xmlReader
4
+ * purpose: Demonstrate the use of xmlReaderForFile() to parse an XML file
5
+ * validating the content in the process and activating options
6
+ * like entities substitution, and DTD attributes defaulting.
7
+ * (Note that the XMLReader functions require libxml2 version later
8
+ * than 2.6.)
9
+ * usage: reader2 <valid_xml_filename>
10
+ * test: reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
11
+ * author: Daniel Veillard
12
+ * copy: see Copyright for the status of this software.
13
+ */
14
+
15
+ #include <stdio.h>
16
+ #include <libxml/xmlreader.h>
17
+ #include <libxml/parser.h>
18
+
19
+ #ifdef LIBXML_READER_ENABLED
20
+
21
+ /**
22
+ * processNode:
23
+ * @reader: the xmlReader
24
+ *
25
+ * Dump information about the current node
26
+ */
27
+ static void
28
+ processNode(xmlTextReaderPtr reader) {
29
+ const xmlChar *name, *value;
30
+
31
+ name = xmlTextReaderConstName(reader);
32
+ if (name == NULL)
33
+ name = BAD_CAST "--";
34
+
35
+ value = xmlTextReaderConstValue(reader);
36
+
37
+ printf("%d %d %s %d %d",
38
+ xmlTextReaderDepth(reader),
39
+ xmlTextReaderNodeType(reader),
40
+ name,
41
+ xmlTextReaderIsEmptyElement(reader),
42
+ xmlTextReaderHasValue(reader));
43
+ if (value == NULL)
44
+ printf("\n");
45
+ else {
46
+ if (xmlStrlen(value) > 40)
47
+ printf(" %.40s...\n", value);
48
+ else
49
+ printf(" %s\n", value);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * streamFile:
55
+ * @filename: the file name to parse
56
+ *
57
+ * Parse, validate and print information about an XML file.
58
+ */
59
+ static void
60
+ streamFile(const char *filename) {
61
+ xmlTextReaderPtr reader;
62
+ int ret;
63
+
64
+
65
+ /*
66
+ * Pass some special parsing options to activate DTD attribute defaulting,
67
+ * entities substitution and DTD validation
68
+ */
69
+ reader = xmlReaderForFile(filename, NULL,
70
+ XML_PARSE_DTDATTR | /* default DTD attributes */
71
+ XML_PARSE_NOENT | /* substitute entities */
72
+ XML_PARSE_DTDVALID); /* validate with the DTD */
73
+ if (reader != NULL) {
74
+ ret = xmlTextReaderRead(reader);
75
+ while (ret == 1) {
76
+ processNode(reader);
77
+ ret = xmlTextReaderRead(reader);
78
+ }
79
+ /*
80
+ * Once the document has been fully parsed check the validation results
81
+ */
82
+ if (xmlTextReaderIsValid(reader) != 1) {
83
+ fprintf(stderr, "Document %s does not validate\n", filename);
84
+ }
85
+ xmlFreeTextReader(reader);
86
+ if (ret != 0) {
87
+ fprintf(stderr, "%s : failed to parse\n", filename);
88
+ }
89
+ } else {
90
+ fprintf(stderr, "Unable to open %s\n", filename);
91
+ }
92
+ }
93
+
94
+ int main(int argc, char **argv) {
95
+ if (argc != 2)
96
+ return(1);
97
+
98
+ /*
99
+ * this initialize the library and check potential ABI mismatches
100
+ * between the version it was compiled for and the actual shared
101
+ * library used.
102
+ */
103
+ LIBXML_TEST_VERSION
104
+
105
+ streamFile(argv[1]);
106
+
107
+ return(0);
108
+ }
109
+
110
+ #else
111
+ int main(void) {
112
+ fprintf(stderr, "XInclude support not compiled in\n");
113
+ return(0);
114
+ }
115
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/reader3.c ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Show how to extract subdocuments with xmlReader
4
+ * purpose: Demonstrate the use of xmlTextReaderPreservePattern()
5
+ * to parse an XML file with the xmlReader while collecting
6
+ * only some subparts of the document.
7
+ * (Note that the XMLReader functions require libxml2 version later
8
+ * than 2.6.)
9
+ * usage: reader3
10
+ * test: reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res
11
+ * author: Daniel Veillard
12
+ * copy: see Copyright for the status of this software.
13
+ */
14
+
15
+ #include <stdio.h>
16
+ #include <libxml/xmlreader.h>
17
+
18
+ #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
19
+
20
+
21
+ /**
22
+ * streamFile:
23
+ * @filename: the file name to parse
24
+ *
25
+ * Parse and print information about an XML file.
26
+ *
27
+ * Returns the resulting doc with just the elements preserved.
28
+ */
29
+ static xmlDocPtr
30
+ extractFile(const char *filename, const xmlChar *pattern) {
31
+ xmlDocPtr doc;
32
+ xmlTextReaderPtr reader;
33
+ int ret;
34
+
35
+ /*
36
+ * build an xmlReader for that file
37
+ */
38
+ reader = xmlReaderForFile(filename, NULL, 0);
39
+ if (reader != NULL) {
40
+ /*
41
+ * add the pattern to preserve
42
+ */
43
+ if (xmlTextReaderPreservePattern(reader, pattern, NULL) < 0) {
44
+ fprintf(stderr, "%s : failed add preserve pattern %s\n",
45
+ filename, (const char *) pattern);
46
+ }
47
+ /*
48
+ * Parse and traverse the tree, collecting the nodes in the process
49
+ */
50
+ ret = xmlTextReaderRead(reader);
51
+ while (ret == 1) {
52
+ ret = xmlTextReaderRead(reader);
53
+ }
54
+ if (ret != 0) {
55
+ fprintf(stderr, "%s : failed to parse\n", filename);
56
+ xmlFreeTextReader(reader);
57
+ return(NULL);
58
+ }
59
+ /*
60
+ * get the resulting nodes
61
+ */
62
+ doc = xmlTextReaderCurrentDoc(reader);
63
+ /*
64
+ * Free up the reader
65
+ */
66
+ xmlFreeTextReader(reader);
67
+ } else {
68
+ fprintf(stderr, "Unable to open %s\n", filename);
69
+ return(NULL);
70
+ }
71
+ return(doc);
72
+ }
73
+
74
+ int main(int argc, char **argv) {
75
+ const char *filename = "test3.xml";
76
+ const char *pattern = "preserved";
77
+ xmlDocPtr doc;
78
+
79
+ if (argc == 3) {
80
+ filename = argv[1];
81
+ pattern = argv[2];
82
+ }
83
+
84
+ /*
85
+ * this initialize the library and check potential ABI mismatches
86
+ * between the version it was compiled for and the actual shared
87
+ * library used.
88
+ */
89
+ LIBXML_TEST_VERSION
90
+
91
+ doc = extractFile(filename, (const xmlChar *) pattern);
92
+ if (doc != NULL) {
93
+ /*
94
+ * output the result.
95
+ */
96
+ xmlDocDump(stdout, doc);
97
+ /*
98
+ * don't forget to free up the doc
99
+ */
100
+ xmlFreeDoc(doc);
101
+ }
102
+
103
+ return(0);
104
+ }
105
+
106
+ #else
107
+ int main(void) {
108
+ fprintf(stderr, "Reader, Pattern or output support not compiled in\n");
109
+ return(0);
110
+ }
111
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/reader4.c ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Parse multiple XML files reusing an xmlReader
4
+ * purpose: Demonstrate the use of xmlReaderForFile() and
5
+ * xmlReaderNewFile to parse XML files while reusing the reader object
6
+ * and parser context. (Note that the XMLReader functions require
7
+ * libxml2 version later than 2.6.)
8
+ * usage: reader4 <filename> [ filename ... ]
9
+ * test: reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res
10
+ * author: Graham Bennett
11
+ * copy: see Copyright for the status of this software.
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <libxml/xmlreader.h>
16
+
17
+ #ifdef LIBXML_READER_ENABLED
18
+
19
+ static void processDoc(xmlTextReaderPtr readerPtr) {
20
+ int ret;
21
+ xmlDocPtr docPtr;
22
+ const xmlChar *URL;
23
+
24
+ ret = xmlTextReaderRead(readerPtr);
25
+ while (ret == 1) {
26
+ ret = xmlTextReaderRead(readerPtr);
27
+ }
28
+
29
+ /*
30
+ * One can obtain the document pointer to get interesting
31
+ * information about the document like the URL, but one must also
32
+ * be sure to clean it up at the end (see below).
33
+ */
34
+ docPtr = xmlTextReaderCurrentDoc(readerPtr);
35
+ if (NULL == docPtr) {
36
+ fprintf(stderr, "failed to obtain document\n");
37
+ return;
38
+ }
39
+
40
+ URL = docPtr->URL;
41
+ if (NULL == URL) {
42
+ fprintf(stderr, "Failed to obtain URL\n");
43
+ }
44
+
45
+ if (ret != 0) {
46
+ fprintf(stderr, "%s: Failed to parse\n", URL);
47
+ return;
48
+ }
49
+
50
+ printf("%s: Processed ok\n", (const char *)URL);
51
+ }
52
+
53
+ int main(int argc, char **argv) {
54
+ xmlTextReaderPtr readerPtr;
55
+ int i;
56
+ xmlDocPtr docPtr;
57
+
58
+ if (argc < 2)
59
+ return(1);
60
+
61
+ /*
62
+ * this initialises the library and check potential ABI mismatches
63
+ * between the version it was compiled for and the actual shared
64
+ * library used.
65
+ */
66
+ LIBXML_TEST_VERSION
67
+
68
+ /*
69
+ * Create a new reader for the first file and process the
70
+ * document.
71
+ */
72
+ readerPtr = xmlReaderForFile(argv[1], NULL, 0);
73
+ if (NULL == readerPtr) {
74
+ fprintf(stderr, "%s: failed to create reader\n", argv[1]);
75
+ return(1);
76
+ }
77
+ processDoc(readerPtr);
78
+
79
+ /*
80
+ * The reader can be reused for subsequent files.
81
+ */
82
+ for (i=2; i < argc; ++i) {
83
+ xmlReaderNewFile(readerPtr, argv[i], NULL, 0);
84
+ if (NULL == readerPtr) {
85
+ fprintf(stderr, "%s: failed to create reader\n", argv[i]);
86
+ return(1);
87
+ }
88
+ processDoc(readerPtr);
89
+ }
90
+
91
+ /*
92
+ * Since we've called xmlTextReaderCurrentDoc, we now have to
93
+ * clean up after ourselves. We only have to do this the last
94
+ * time, because xmlReaderNewFile calls xmlCtxtReset which takes
95
+ * care of it.
96
+ */
97
+ docPtr = xmlTextReaderCurrentDoc(readerPtr);
98
+ if (docPtr != NULL)
99
+ xmlFreeDoc(docPtr);
100
+
101
+ /*
102
+ * Clean up the reader.
103
+ */
104
+ xmlFreeTextReader(readerPtr);
105
+
106
+ return(0);
107
+ }
108
+
109
+ #else
110
+ int main(void) {
111
+ fprintf(stderr, "xmlReader support not compiled in\n");
112
+ return(0);
113
+ }
114
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/test1.xml ADDED
@@ -0,0 +1 @@
 
 
1
+ <doc/>
local-test-libxml2-full-01/afc-libxml2/example/test2.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE doc [
2
+ <!ELEMENT doc (src | dest)*>
3
+ <!ELEMENT src EMPTY>
4
+ <!ELEMENT dest EMPTY>
5
+ <!ATTLIST src ref IDREF #IMPLIED>
6
+ <!ATTLIST dest id ID #IMPLIED>
7
+ ]>
8
+ <doc>
9
+ <src ref="foo"/>
10
+ <dest id="foo"/>
11
+ <src ref="foo"/>
12
+ </doc>
13
+
local-test-libxml2-full-01/afc-libxml2/example/test3.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <doc>
2
+ <parent>
3
+ <discarded>
4
+ <discarded/>
5
+ </discarded>
6
+ <preserved/>
7
+ This text node must be discarded
8
+ <discarded>
9
+ <discarded/>
10
+ </discarded>
11
+ <preserved>
12
+ content1
13
+ <child1></child1>
14
+ <child2>content2</child2>
15
+ <preserved>too</preserved>
16
+ <child2>content3</child2>
17
+ <preserved></preserved>
18
+ <child2>content4</child2>
19
+ <preserved/>
20
+ <child2>content5</child2>
21
+ content6
22
+ </preserved>
23
+ This text node must be discarded
24
+ <discarded>
25
+ <discarded/>
26
+ </discarded>
27
+ This text node must be discarded
28
+ <preserved></preserved>
29
+ This text node must be discarded
30
+ <preserved/>
31
+ This text node must be discarded
32
+ <discarded>
33
+ <discarded/>
34
+ </discarded>
35
+ This text node must be discarded
36
+ </parent>
37
+ </doc>
38
+
39
+
local-test-libxml2-full-01/afc-libxml2/example/testWriter.c ADDED
@@ -0,0 +1,1068 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlWriter
3
+ * synopsis: use various APIs for the xmlWriter
4
+ * purpose: tests a number of APIs for the xmlWriter, especially
5
+ * the various methods to write to a filename, to a memory
6
+ * buffer, to a new document, or to a subtree. It shows how to
7
+ * do encoding string conversions too. The resulting
8
+ * documents are then serialized.
9
+ * usage: testWriter
10
+ * test: testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done
11
+ * author: Alfred Mickautsch
12
+ * copy: see Copyright for the status of this software.
13
+ */
14
+ #include <stdio.h>
15
+ #include <string.h>
16
+ #include <libxml/encoding.h>
17
+ #include <libxml/xmlwriter.h>
18
+ #include <libxml/parser.h>
19
+
20
+ #ifndef _WIN32
21
+ #include <unistd.h>
22
+ #endif
23
+
24
+ #if defined(LIBXML_WRITER_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
25
+
26
+ #define MY_ENCODING "ISO-8859-1"
27
+
28
+ void testXmlwriterFilename(const char *uri);
29
+ void testXmlwriterMemory(void);
30
+ void testXmlwriterDoc(void);
31
+ void testXmlwriterTree(void);
32
+
33
+ int
34
+ main(void)
35
+ {
36
+ /*
37
+ * this initialize the library and check potential ABI mismatches
38
+ * between the version it was compiled for and the actual shared
39
+ * library used.
40
+ */
41
+ LIBXML_TEST_VERSION
42
+
43
+ /* first, the file version */
44
+ testXmlwriterFilename("writer1.tmp");
45
+ unlink("writer1.tmp");
46
+
47
+ /* next, the memory version */
48
+ testXmlwriterMemory();
49
+
50
+ /* next, the DOM version */
51
+ testXmlwriterDoc();
52
+
53
+ /* next, the tree version */
54
+ testXmlwriterTree();
55
+
56
+ return 0;
57
+ }
58
+
59
+ /**
60
+ * testXmlwriterFilename:
61
+ * @uri: the output URI
62
+ *
63
+ * test the xmlWriter interface when writing to a new file
64
+ */
65
+ void
66
+ testXmlwriterFilename(const char *uri)
67
+ {
68
+ int rc;
69
+ xmlTextWriterPtr writer;
70
+
71
+ /* Create a new XmlWriter for uri, with no compression. */
72
+ writer = xmlNewTextWriterFilename(uri, 0);
73
+ if (writer == NULL) {
74
+ printf("testXmlwriterFilename: Error creating the xml writer\n");
75
+ return;
76
+ }
77
+
78
+ /* Start the document with the xml default for the version,
79
+ * encoding ISO 8859-1 and the default for the standalone
80
+ * declaration. */
81
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
82
+ if (rc < 0) {
83
+ printf
84
+ ("testXmlwriterFilename: Error at xmlTextWriterStartDocument\n");
85
+ return;
86
+ }
87
+
88
+ /* Start an element named "EXAMPLE". Since this is the first
89
+ * element, this will be the root element of the document. */
90
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE");
91
+ if (rc < 0) {
92
+ printf
93
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
94
+ return;
95
+ }
96
+
97
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
98
+ if (rc < 0) {
99
+ printf
100
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteComment\n");
101
+ return;
102
+ }
103
+
104
+ /* Start an element named "ORDER" as child of EXAMPLE. */
105
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
106
+ if (rc < 0) {
107
+ printf
108
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
109
+ return;
110
+ }
111
+
112
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
113
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
114
+ BAD_CAST "1.0");
115
+ if (rc < 0) {
116
+ printf
117
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteAttribute\n");
118
+ return;
119
+ }
120
+
121
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
122
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
123
+ BAD_CAST "de");
124
+ if (rc < 0) {
125
+ printf
126
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteAttribute\n");
127
+ return;
128
+ }
129
+
130
+ /* Write a comment as child of ORDER */
131
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
132
+ if (rc < 0) {
133
+ printf
134
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatComment\n");
135
+ return;
136
+ }
137
+
138
+ /* Start an element named "HEADER" as child of ORDER. */
139
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
140
+ if (rc < 0) {
141
+ printf
142
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
143
+ return;
144
+ }
145
+
146
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
147
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
148
+ "%010d", 53535);
149
+ if (rc < 0) {
150
+ printf
151
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
152
+ return;
153
+ }
154
+
155
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
156
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
157
+ "%d", 1010);
158
+ if (rc < 0) {
159
+ printf
160
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
161
+ return;
162
+ }
163
+
164
+ /* Write an element named "NAME_1" as child of HEADER. */
165
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
166
+ BAD_CAST "Mueller");
167
+ if (rc < 0) {
168
+ printf
169
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
170
+ return;
171
+ }
172
+
173
+ /* Write an element named "NAME_2" as child of HEADER. */
174
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
175
+ BAD_CAST "Joerg");
176
+ if (rc < 0) {
177
+ printf
178
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
179
+ return;
180
+ }
181
+
182
+ /* Close the element named HEADER. */
183
+ rc = xmlTextWriterEndElement(writer);
184
+ if (rc < 0) {
185
+ printf
186
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
187
+ return;
188
+ }
189
+
190
+ /* Start an element named "ENTRIES" as child of ORDER. */
191
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
192
+ if (rc < 0) {
193
+ printf
194
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
195
+ return;
196
+ }
197
+
198
+ /* Start an element named "ENTRY" as child of ENTRIES. */
199
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
200
+ if (rc < 0) {
201
+ printf
202
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
203
+ return;
204
+ }
205
+
206
+ /* Write an element named "ARTICLE" as child of ENTRY. */
207
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
208
+ BAD_CAST "<Test>");
209
+ if (rc < 0) {
210
+ printf
211
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
212
+ return;
213
+ }
214
+
215
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
216
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
217
+ 10);
218
+ if (rc < 0) {
219
+ printf
220
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
221
+ return;
222
+ }
223
+
224
+ /* Close the element named ENTRY. */
225
+ rc = xmlTextWriterEndElement(writer);
226
+ if (rc < 0) {
227
+ printf
228
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
229
+ return;
230
+ }
231
+
232
+ /* Start an element named "ENTRY" as child of ENTRIES. */
233
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
234
+ if (rc < 0) {
235
+ printf
236
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
237
+ return;
238
+ }
239
+
240
+ /* Write an element named "ARTICLE" as child of ENTRY. */
241
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
242
+ BAD_CAST "<Test 2>");
243
+ if (rc < 0) {
244
+ printf
245
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
246
+ return;
247
+ }
248
+
249
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
250
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
251
+ 20);
252
+ if (rc < 0) {
253
+ printf
254
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
255
+ return;
256
+ }
257
+
258
+ /* Close the element named ENTRY. */
259
+ rc = xmlTextWriterEndElement(writer);
260
+ if (rc < 0) {
261
+ printf
262
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
263
+ return;
264
+ }
265
+
266
+ /* Close the element named ENTRIES. */
267
+ rc = xmlTextWriterEndElement(writer);
268
+ if (rc < 0) {
269
+ printf
270
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
271
+ return;
272
+ }
273
+
274
+ /* Start an element named "FOOTER" as child of ORDER. */
275
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
276
+ if (rc < 0) {
277
+ printf
278
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
279
+ return;
280
+ }
281
+
282
+ /* Write an element named "TEXT" as child of FOOTER. */
283
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
284
+ BAD_CAST "This is a text.");
285
+ if (rc < 0) {
286
+ printf
287
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
288
+ return;
289
+ }
290
+
291
+ /* Close the element named FOOTER. */
292
+ rc = xmlTextWriterEndElement(writer);
293
+ if (rc < 0) {
294
+ printf
295
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
296
+ return;
297
+ }
298
+
299
+ /* Here we could close the elements ORDER and EXAMPLE using the
300
+ * function xmlTextWriterEndElement, but since we do not want to
301
+ * write any other elements, we simply call xmlTextWriterEndDocument,
302
+ * which will do all the work. */
303
+ rc = xmlTextWriterEndDocument(writer);
304
+ if (rc < 0) {
305
+ printf
306
+ ("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n");
307
+ return;
308
+ }
309
+
310
+ xmlFreeTextWriter(writer);
311
+ }
312
+
313
+ /**
314
+ * testXmlwriterMemory:
315
+ * @file: the output file
316
+ *
317
+ * test the xmlWriter interface when writing to memory
318
+ */
319
+ void
320
+ testXmlwriterMemory(void)
321
+ {
322
+ int rc;
323
+ xmlTextWriterPtr writer;
324
+ xmlBufferPtr buf;
325
+
326
+ /* Create a new XML buffer, to which the XML document will be
327
+ * written */
328
+ buf = xmlBufferCreate();
329
+ if (buf == NULL) {
330
+ printf("testXmlwriterMemory: Error creating the xml buffer\n");
331
+ return;
332
+ }
333
+
334
+ /* Create a new XmlWriter for memory, with no compression.
335
+ * Remark: there is no compression for this kind of xmlTextWriter */
336
+ writer = xmlNewTextWriterMemory(buf, 0);
337
+ if (writer == NULL) {
338
+ printf("testXmlwriterMemory: Error creating the xml writer\n");
339
+ return;
340
+ }
341
+
342
+ /* Start the document with the xml default for the version,
343
+ * encoding ISO 8859-1 and the default for the standalone
344
+ * declaration. */
345
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
346
+ if (rc < 0) {
347
+ printf
348
+ ("testXmlwriterMemory: Error at xmlTextWriterStartDocument\n");
349
+ return;
350
+ }
351
+
352
+ /* Start an element named "EXAMPLE". Since this is the first
353
+ * element, this will be the root element of the document. */
354
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE");
355
+ if (rc < 0) {
356
+ printf
357
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
358
+ return;
359
+ }
360
+
361
+ /* Write a comment as child of EXAMPLE. */
362
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
363
+ if (rc < 0) {
364
+ printf
365
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteComment\n");
366
+ return;
367
+ }
368
+
369
+ /* Start an element named "ORDER" as child of EXAMPLE. */
370
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
371
+ if (rc < 0) {
372
+ printf
373
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
374
+ return;
375
+ }
376
+
377
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
378
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
379
+ BAD_CAST "1.0");
380
+ if (rc < 0) {
381
+ printf
382
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteAttribute\n");
383
+ return;
384
+ }
385
+
386
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
387
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
388
+ BAD_CAST "de");
389
+ if (rc < 0) {
390
+ printf
391
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteAttribute\n");
392
+ return;
393
+ }
394
+
395
+ /* Write a comment as child of ORDER */
396
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
397
+ if (rc < 0) {
398
+ printf
399
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatComment\n");
400
+ return;
401
+ }
402
+
403
+ /* Start an element named "HEADER" as child of ORDER. */
404
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
405
+ if (rc < 0) {
406
+ printf
407
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
408
+ return;
409
+ }
410
+
411
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
412
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
413
+ "%010d", 53535);
414
+ if (rc < 0) {
415
+ printf
416
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
417
+ return;
418
+ }
419
+
420
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
421
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
422
+ "%d", 1010);
423
+ if (rc < 0) {
424
+ printf
425
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
426
+ return;
427
+ }
428
+
429
+ /* Write an element named "NAME_1" as child of HEADER. */
430
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
431
+ BAD_CAST "Mueller");
432
+ if (rc < 0) {
433
+ printf
434
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
435
+ return;
436
+ }
437
+
438
+ /* Write an element named "NAME_2" as child of HEADER. */
439
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
440
+ BAD_CAST "Joerg");
441
+
442
+ if (rc < 0) {
443
+ printf
444
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
445
+ return;
446
+ }
447
+
448
+ /* Close the element named HEADER. */
449
+ rc = xmlTextWriterEndElement(writer);
450
+ if (rc < 0) {
451
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
452
+ return;
453
+ }
454
+
455
+ /* Start an element named "ENTRIES" as child of ORDER. */
456
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
457
+ if (rc < 0) {
458
+ printf
459
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
460
+ return;
461
+ }
462
+
463
+ /* Start an element named "ENTRY" as child of ENTRIES. */
464
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
465
+ if (rc < 0) {
466
+ printf
467
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
468
+ return;
469
+ }
470
+
471
+ /* Write an element named "ARTICLE" as child of ENTRY. */
472
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
473
+ BAD_CAST "<Test>");
474
+ if (rc < 0) {
475
+ printf
476
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
477
+ return;
478
+ }
479
+
480
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
481
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
482
+ 10);
483
+ if (rc < 0) {
484
+ printf
485
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
486
+ return;
487
+ }
488
+
489
+ /* Close the element named ENTRY. */
490
+ rc = xmlTextWriterEndElement(writer);
491
+ if (rc < 0) {
492
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
493
+ return;
494
+ }
495
+
496
+ /* Start an element named "ENTRY" as child of ENTRIES. */
497
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
498
+ if (rc < 0) {
499
+ printf
500
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
501
+ return;
502
+ }
503
+
504
+ /* Write an element named "ARTICLE" as child of ENTRY. */
505
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
506
+ BAD_CAST "<Test 2>");
507
+ if (rc < 0) {
508
+ printf
509
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
510
+ return;
511
+ }
512
+
513
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
514
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
515
+ 20);
516
+ if (rc < 0) {
517
+ printf
518
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
519
+ return;
520
+ }
521
+
522
+ /* Close the element named ENTRY. */
523
+ rc = xmlTextWriterEndElement(writer);
524
+ if (rc < 0) {
525
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
526
+ return;
527
+ }
528
+
529
+ /* Close the element named ENTRIES. */
530
+ rc = xmlTextWriterEndElement(writer);
531
+ if (rc < 0) {
532
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
533
+ return;
534
+ }
535
+
536
+ /* Start an element named "FOOTER" as child of ORDER. */
537
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
538
+ if (rc < 0) {
539
+ printf
540
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
541
+ return;
542
+ }
543
+
544
+ /* Write an element named "TEXT" as child of FOOTER. */
545
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
546
+ BAD_CAST "This is a text.");
547
+ if (rc < 0) {
548
+ printf
549
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
550
+ return;
551
+ }
552
+
553
+ /* Close the element named FOOTER. */
554
+ rc = xmlTextWriterEndElement(writer);
555
+ if (rc < 0) {
556
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
557
+ return;
558
+ }
559
+
560
+ /* Here we could close the elements ORDER and EXAMPLE using the
561
+ * function xmlTextWriterEndElement, but since we do not want to
562
+ * write any other elements, we simply call xmlTextWriterEndDocument,
563
+ * which will do all the work. */
564
+ rc = xmlTextWriterEndDocument(writer);
565
+ if (rc < 0) {
566
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
567
+ return;
568
+ }
569
+
570
+ xmlFreeTextWriter(writer);
571
+
572
+ xmlBufferFree(buf);
573
+ }
574
+
575
+ /**
576
+ * testXmlwriterDoc:
577
+ * @file: the output file
578
+ *
579
+ * test the xmlWriter interface when creating a new document
580
+ */
581
+ void
582
+ testXmlwriterDoc(void)
583
+ {
584
+ int rc;
585
+ xmlTextWriterPtr writer;
586
+ xmlDocPtr doc;
587
+
588
+
589
+ /* Create a new XmlWriter for DOM, with no compression. */
590
+ writer = xmlNewTextWriterDoc(&doc, 0);
591
+ if (writer == NULL) {
592
+ printf("testXmlwriterDoc: Error creating the xml writer\n");
593
+ return;
594
+ }
595
+
596
+ /* Start the document with the xml default for the version,
597
+ * encoding ISO 8859-1 and the default for the standalone
598
+ * declaration. */
599
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
600
+ if (rc < 0) {
601
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartDocument\n");
602
+ return;
603
+ }
604
+
605
+ /* Start an element named "EXAMPLE". Since this is the first
606
+ * element, this will be the root element of the document. */
607
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE");
608
+ if (rc < 0) {
609
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
610
+ return;
611
+ }
612
+
613
+ /* Write a comment as child of EXAMPLE. */
614
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
615
+ if (rc < 0) {
616
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteComment\n");
617
+ return;
618
+ }
619
+
620
+ /* Start an element named "ORDER" as child of EXAMPLE. */
621
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
622
+ if (rc < 0) {
623
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
624
+ return;
625
+ }
626
+
627
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
628
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
629
+ BAD_CAST "1.0");
630
+ if (rc < 0) {
631
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteAttribute\n");
632
+ return;
633
+ }
634
+
635
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
636
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
637
+ BAD_CAST "de");
638
+ if (rc < 0) {
639
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteAttribute\n");
640
+ return;
641
+ }
642
+
643
+ /* Write a comment as child of ORDER */
644
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
645
+ if (rc < 0) {
646
+ printf
647
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatComment\n");
648
+ return;
649
+ }
650
+
651
+ /* Start an element named "HEADER" as child of ORDER. */
652
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
653
+ if (rc < 0) {
654
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
655
+ return;
656
+ }
657
+
658
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
659
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
660
+ "%010d", 53535);
661
+ if (rc < 0) {
662
+ printf
663
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
664
+ return;
665
+ }
666
+
667
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
668
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
669
+ "%d", 1010);
670
+ if (rc < 0) {
671
+ printf
672
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
673
+ return;
674
+ }
675
+
676
+ /* Write an element named "NAME_1" as child of HEADER. */
677
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
678
+ BAD_CAST "Mueller");
679
+ if (rc < 0) {
680
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
681
+ return;
682
+ }
683
+
684
+ /* Write an element named "NAME_2" as child of HEADER. */
685
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
686
+ BAD_CAST "Joerg");
687
+ if (rc < 0) {
688
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
689
+ return;
690
+ }
691
+
692
+ /* Close the element named HEADER. */
693
+ rc = xmlTextWriterEndElement(writer);
694
+ if (rc < 0) {
695
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
696
+ return;
697
+ }
698
+
699
+ /* Start an element named "ENTRIES" as child of ORDER. */
700
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
701
+ if (rc < 0) {
702
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
703
+ return;
704
+ }
705
+
706
+ /* Start an element named "ENTRY" as child of ENTRIES. */
707
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
708
+ if (rc < 0) {
709
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
710
+ return;
711
+ }
712
+
713
+ /* Write an element named "ARTICLE" as child of ENTRY. */
714
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
715
+ BAD_CAST "<Test>");
716
+ if (rc < 0) {
717
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
718
+ return;
719
+ }
720
+
721
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
722
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
723
+ 10);
724
+ if (rc < 0) {
725
+ printf
726
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
727
+ return;
728
+ }
729
+
730
+ /* Close the element named ENTRY. */
731
+ rc = xmlTextWriterEndElement(writer);
732
+ if (rc < 0) {
733
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
734
+ return;
735
+ }
736
+
737
+ /* Start an element named "ENTRY" as child of ENTRIES. */
738
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
739
+ if (rc < 0) {
740
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
741
+ return;
742
+ }
743
+
744
+ /* Write an element named "ARTICLE" as child of ENTRY. */
745
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
746
+ BAD_CAST "<Test 2>");
747
+ if (rc < 0) {
748
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
749
+ return;
750
+ }
751
+
752
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
753
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
754
+ 20);
755
+ if (rc < 0) {
756
+ printf
757
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
758
+ return;
759
+ }
760
+
761
+ /* Close the element named ENTRY. */
762
+ rc = xmlTextWriterEndElement(writer);
763
+ if (rc < 0) {
764
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
765
+ return;
766
+ }
767
+
768
+ /* Close the element named ENTRIES. */
769
+ rc = xmlTextWriterEndElement(writer);
770
+ if (rc < 0) {
771
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
772
+ return;
773
+ }
774
+
775
+ /* Start an element named "FOOTER" as child of ORDER. */
776
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
777
+ if (rc < 0) {
778
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
779
+ return;
780
+ }
781
+
782
+ /* Write an element named "TEXT" as child of FOOTER. */
783
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
784
+ BAD_CAST "This is a text.");
785
+ if (rc < 0) {
786
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
787
+ return;
788
+ }
789
+
790
+ /* Close the element named FOOTER. */
791
+ rc = xmlTextWriterEndElement(writer);
792
+ if (rc < 0) {
793
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
794
+ return;
795
+ }
796
+
797
+ /* Here we could close the elements ORDER and EXAMPLE using the
798
+ * function xmlTextWriterEndElement, but since we do not want to
799
+ * write any other elements, we simply call xmlTextWriterEndDocument,
800
+ * which will do all the work. */
801
+ rc = xmlTextWriterEndDocument(writer);
802
+ if (rc < 0) {
803
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndDocument\n");
804
+ return;
805
+ }
806
+
807
+ xmlFreeTextWriter(writer);
808
+
809
+ xmlFreeDoc(doc);
810
+ }
811
+
812
+ /**
813
+ * testXmlwriterTree:
814
+ * @file: the output file
815
+ *
816
+ * test the xmlWriter interface when writing to a subtree
817
+ */
818
+ void
819
+ testXmlwriterTree(void)
820
+ {
821
+ int rc;
822
+ xmlTextWriterPtr writer;
823
+ xmlDocPtr doc;
824
+ xmlNodePtr node;
825
+
826
+ /* Create a new XML DOM tree, to which the XML document will be
827
+ * written */
828
+ doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
829
+ if (doc == NULL) {
830
+ printf
831
+ ("testXmlwriterTree: Error creating the xml document tree\n");
832
+ return;
833
+ }
834
+
835
+ /* Create a new XML node, to which the XML document will be
836
+ * appended */
837
+ node = xmlNewDocNode(doc, NULL, BAD_CAST "EXAMPLE", NULL);
838
+ if (node == NULL) {
839
+ printf("testXmlwriterTree: Error creating the xml node\n");
840
+ return;
841
+ }
842
+
843
+ /* Make ELEMENT the root node of the tree */
844
+ xmlDocSetRootElement(doc, node);
845
+
846
+ /* Create a new XmlWriter for DOM tree, with no compression. */
847
+ writer = xmlNewTextWriterTree(doc, node, 0);
848
+ if (writer == NULL) {
849
+ printf("testXmlwriterTree: Error creating the xml writer\n");
850
+ return;
851
+ }
852
+
853
+ /* Start the document with the xml default for the version,
854
+ * encoding ISO 8859-1 and the default for the standalone
855
+ * declaration. */
856
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
857
+ if (rc < 0) {
858
+ printf("testXmlwriterTree: Error at xmlTextWriterStartDocument\n");
859
+ return;
860
+ }
861
+
862
+ /* Write a comment as child of EXAMPLE. */
863
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
864
+ if (rc < 0) {
865
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteComment\n");
866
+ return;
867
+ }
868
+
869
+ /* Start an element named "ORDER" as child of EXAMPLE. */
870
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
871
+ if (rc < 0) {
872
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
873
+ return;
874
+ }
875
+
876
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
877
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
878
+ BAD_CAST "1.0");
879
+ if (rc < 0) {
880
+ printf
881
+ ("testXmlwriterTree: Error at xmlTextWriterWriteAttribute\n");
882
+ return;
883
+ }
884
+
885
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
886
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
887
+ BAD_CAST "de");
888
+ if (rc < 0) {
889
+ printf
890
+ ("testXmlwriterTree: Error at xmlTextWriterWriteAttribute\n");
891
+ return;
892
+ }
893
+
894
+ /* Write a comment as child of ORDER */
895
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
896
+ if (rc < 0) {
897
+ printf
898
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatComment\n");
899
+ return;
900
+ }
901
+
902
+ /* Start an element named "HEADER" as child of ORDER. */
903
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
904
+ if (rc < 0) {
905
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
906
+ return;
907
+ }
908
+
909
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
910
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
911
+ "%010d", 53535);
912
+ if (rc < 0) {
913
+ printf
914
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
915
+ return;
916
+ }
917
+
918
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
919
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
920
+ "%d", 1010);
921
+ if (rc < 0) {
922
+ printf
923
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
924
+ return;
925
+ }
926
+
927
+ /* Write an element named "NAME_1" as child of HEADER. */
928
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
929
+ BAD_CAST "Mueller");
930
+ if (rc < 0) {
931
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
932
+ return;
933
+ }
934
+
935
+ /* Write an element named "NAME_2" as child of HEADER. */
936
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
937
+ BAD_CAST "Joerg");
938
+ if (rc < 0) {
939
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
940
+ return;
941
+ }
942
+
943
+ /* Close the element named HEADER. */
944
+ rc = xmlTextWriterEndElement(writer);
945
+ if (rc < 0) {
946
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
947
+ return;
948
+ }
949
+
950
+ /* Start an element named "ENTRIES" as child of ORDER. */
951
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
952
+ if (rc < 0) {
953
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
954
+ return;
955
+ }
956
+
957
+ /* Start an element named "ENTRY" as child of ENTRIES. */
958
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
959
+ if (rc < 0) {
960
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
961
+ return;
962
+ }
963
+
964
+ /* Write an element named "ARTICLE" as child of ENTRY. */
965
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
966
+ BAD_CAST "<Test>");
967
+ if (rc < 0) {
968
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
969
+ return;
970
+ }
971
+
972
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
973
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
974
+ 10);
975
+ if (rc < 0) {
976
+ printf
977
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
978
+ return;
979
+ }
980
+
981
+ /* Close the element named ENTRY. */
982
+ rc = xmlTextWriterEndElement(writer);
983
+ if (rc < 0) {
984
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
985
+ return;
986
+ }
987
+
988
+ /* Start an element named "ENTRY" as child of ENTRIES. */
989
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
990
+ if (rc < 0) {
991
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
992
+ return;
993
+ }
994
+
995
+ /* Write an element named "ARTICLE" as child of ENTRY. */
996
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
997
+ BAD_CAST "<Test 2>");
998
+ if (rc < 0) {
999
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
1000
+ return;
1001
+ }
1002
+
1003
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
1004
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
1005
+ 20);
1006
+ if (rc < 0) {
1007
+ printf
1008
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
1009
+ return;
1010
+ }
1011
+
1012
+ /* Close the element named ENTRY. */
1013
+ rc = xmlTextWriterEndElement(writer);
1014
+ if (rc < 0) {
1015
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
1016
+ return;
1017
+ }
1018
+
1019
+ /* Close the element named ENTRIES. */
1020
+ rc = xmlTextWriterEndElement(writer);
1021
+ if (rc < 0) {
1022
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
1023
+ return;
1024
+ }
1025
+
1026
+ /* Start an element named "FOOTER" as child of ORDER. */
1027
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
1028
+ if (rc < 0) {
1029
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
1030
+ return;
1031
+ }
1032
+
1033
+ /* Write an element named "TEXT" as child of FOOTER. */
1034
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
1035
+ BAD_CAST "This is a text.");
1036
+ if (rc < 0) {
1037
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
1038
+ return;
1039
+ }
1040
+
1041
+ /* Close the element named FOOTER. */
1042
+ rc = xmlTextWriterEndElement(writer);
1043
+ if (rc < 0) {
1044
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
1045
+ return;
1046
+ }
1047
+
1048
+ /* Here we could close the elements ORDER and EXAMPLE using the
1049
+ * function xmlTextWriterEndElement, but since we do not want to
1050
+ * write any other elements, we simply call xmlTextWriterEndDocument,
1051
+ * which will do all the work. */
1052
+ rc = xmlTextWriterEndDocument(writer);
1053
+ if (rc < 0) {
1054
+ printf("testXmlwriterTree: Error at xmlTextWriterEndDocument\n");
1055
+ return;
1056
+ }
1057
+
1058
+ xmlFreeTextWriter(writer);
1059
+
1060
+ xmlFreeDoc(doc);
1061
+ }
1062
+
1063
+ #else
1064
+ int main(void) {
1065
+ fprintf(stderr, "Writer or output support not compiled in\n");
1066
+ return 0;
1067
+ }
1068
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/tree1.c ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Tree
3
+ * synopsis: Navigates a tree to print element names
4
+ * purpose: Parse a file to a tree, use xmlDocGetRootElement() to
5
+ * get the root element, then walk the document and print
6
+ * all the element name in document order.
7
+ * usage: tree1 filename_or_URL
8
+ * test: tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res
9
+ * author: Dodji Seketeli
10
+ * copy: see Copyright for the status of this software.
11
+ */
12
+ #include <stdio.h>
13
+ #include <libxml/parser.h>
14
+ #include <libxml/tree.h>
15
+
16
+ /*
17
+ *To compile this file using gcc you can type
18
+ *gcc `xml2-config --cflags --libs` -o xmlexample libxml2-example.c
19
+ */
20
+
21
+ /**
22
+ * print_element_names:
23
+ * @a_node: the initial xml node to consider.
24
+ *
25
+ * Prints the names of the all the xml elements
26
+ * that are siblings or children of a given xml node.
27
+ */
28
+ static void
29
+ print_element_names(xmlNode * a_node)
30
+ {
31
+ xmlNode *cur_node = NULL;
32
+
33
+ for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
34
+ if (cur_node->type == XML_ELEMENT_NODE) {
35
+ printf("node type: Element, name: %s\n", cur_node->name);
36
+ }
37
+
38
+ print_element_names(cur_node->children);
39
+ }
40
+ }
41
+
42
+
43
+ /**
44
+ * Simple example to parse a file called "file.xml",
45
+ * walk down the DOM, and print the name of the
46
+ * xml elements nodes.
47
+ */
48
+ int
49
+ main(int argc, char **argv)
50
+ {
51
+ xmlDoc *doc = NULL;
52
+ xmlNode *root_element = NULL;
53
+
54
+ if (argc != 2)
55
+ return(1);
56
+
57
+ /*
58
+ * this initialize the library and check potential ABI mismatches
59
+ * between the version it was compiled for and the actual shared
60
+ * library used.
61
+ */
62
+ LIBXML_TEST_VERSION
63
+
64
+ /*parse the file and get the DOM */
65
+ doc = xmlReadFile(argv[1], NULL, 0);
66
+
67
+ if (doc == NULL) {
68
+ printf("error: could not parse file %s\n", argv[1]);
69
+ }
70
+
71
+ /*Get the root element node */
72
+ root_element = xmlDocGetRootElement(doc);
73
+
74
+ print_element_names(root_element);
75
+
76
+ /*free the document */
77
+ xmlFreeDoc(doc);
78
+
79
+ return 0;
80
+ }
local-test-libxml2-full-01/afc-libxml2/example/tree2.c ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * section: Tree
3
+ * synopsis: Creates a tree
4
+ * purpose: Shows how to create document, nodes and dump it to stdout or file.
5
+ * usage: tree2 <filename> -Default output: stdout
6
+ * test: tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res
7
+ * author: Lucas Brasilino <[email protected]>
8
+ * copy: see Copyright for the status of this software
9
+ */
10
+
11
+ #include <stdio.h>
12
+ #include <libxml/parser.h>
13
+ #include <libxml/tree.h>
14
+
15
+ #if defined(LIBXML_OUTPUT_ENABLED)
16
+
17
+ /*
18
+ *To compile this file using gcc you can type
19
+ *gcc `xml2-config --cflags --libs` -o tree2 tree2.c
20
+ */
21
+
22
+ /* A simple example how to create DOM. Libxml2 automagically
23
+ * allocates the necessary amount of memory to it.
24
+ */
25
+ int
26
+ main(int argc, char **argv)
27
+ {
28
+ xmlDocPtr doc = NULL; /* document pointer */
29
+ xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;/* node pointers */
30
+ char buff[256];
31
+ int i, j;
32
+
33
+ LIBXML_TEST_VERSION;
34
+
35
+ /*
36
+ * Creates a new document, a node and set it as a root node
37
+ */
38
+ doc = xmlNewDoc(BAD_CAST "1.0");
39
+ root_node = xmlNewDocNode(doc, NULL, BAD_CAST "root", NULL);
40
+ xmlDocSetRootElement(doc, root_node);
41
+
42
+ /*
43
+ * Creates a DTD declaration. Isn't mandatory.
44
+ */
45
+ xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "tree2.dtd");
46
+
47
+ /*
48
+ * xmlNewChild() creates a new node, which is "attached" as child node
49
+ * of root_node node.
50
+ */
51
+ xmlNewChild(root_node, NULL, BAD_CAST "node1",
52
+ BAD_CAST "content of node 1");
53
+ /*
54
+ * The same as above, but the new child node doesn't have a content
55
+ */
56
+ xmlNewChild(root_node, NULL, BAD_CAST "node2", NULL);
57
+
58
+ /*
59
+ * xmlNewProp() creates attributes, which is "attached" to an node.
60
+ * It returns xmlAttrPtr, which isn't used here.
61
+ */
62
+ node =
63
+ xmlNewChild(root_node, NULL, BAD_CAST "node3",
64
+ BAD_CAST "this node has attributes");
65
+ xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes");
66
+ xmlNewProp(node, BAD_CAST "foo", BAD_CAST "bar");
67
+
68
+ /*
69
+ * Here goes another way to create nodes. xmlNewNode() and xmlNewText
70
+ * creates a node and a text node separately. They are "attached"
71
+ * by xmlAddChild()
72
+ */
73
+ node = xmlNewDocNode(doc, NULL, BAD_CAST "node4", NULL);
74
+ node1 = xmlNewDocText(doc, BAD_CAST
75
+ "other way to create content (which is also a node)");
76
+ xmlAddChild(node, node1);
77
+ xmlAddChild(root_node, node);
78
+
79
+ /*
80
+ * A simple loop that "automates" nodes creation
81
+ */
82
+ for (i = 5; i < 7; i++) {
83
+ snprintf(buff, sizeof(buff), "node%d", i);
84
+ node = xmlNewChild(root_node, NULL, BAD_CAST buff, NULL);
85
+ for (j = 1; j < 4; j++) {
86
+ snprintf(buff, sizeof(buff), "node%d%d", i, j);
87
+ node1 = xmlNewChild(node, NULL, BAD_CAST buff, NULL);
88
+ xmlNewProp(node1, BAD_CAST "odd", BAD_CAST((j % 2) ? "no" : "yes"));
89
+ }
90
+ }
91
+
92
+ /*
93
+ * Dumping document to stdio or file
94
+ */
95
+ xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1);
96
+
97
+ /*free the document */
98
+ xmlFreeDoc(doc);
99
+
100
+ return(0);
101
+ }
102
+ #else
103
+ int main(void) {
104
+ fprintf(stderr, "output support not compiled in\n");
105
+ return(0);
106
+ }
107
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/xpath1.c ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: XPath
3
+ * synopsis: Evaluate XPath expression and prints result node set.
4
+ * purpose: Shows how to evaluate XPath expression and register
5
+ * known namespaces in XPath context.
6
+ * usage: xpath1 <xml-file> <xpath-expr> [<known-ns-list>]
7
+ * test: xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res
8
+ * author: Aleksey Sanin
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+ #include <stdlib.h>
12
+ #include <stdio.h>
13
+ #include <string.h>
14
+ #include <assert.h>
15
+
16
+ #include <libxml/tree.h>
17
+ #include <libxml/parser.h>
18
+ #include <libxml/xpath.h>
19
+ #include <libxml/xpathInternals.h>
20
+
21
+ #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED)
22
+
23
+
24
+ static void usage(const char *name);
25
+ int execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList);
26
+ int register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList);
27
+ void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output);
28
+
29
+ int
30
+ main(int argc, char **argv) {
31
+ /* Parse command line and process file */
32
+ if((argc < 3) || (argc > 4)) {
33
+ fprintf(stderr, "Error: wrong number of arguments.\n");
34
+ usage(argv[0]);
35
+ return(-1);
36
+ }
37
+
38
+ /* Init libxml */
39
+ xmlInitParser();
40
+ LIBXML_TEST_VERSION
41
+
42
+ /* Do the main job */
43
+ if(execute_xpath_expression(argv[1], BAD_CAST argv[2], (argc > 3) ? BAD_CAST argv[3] : NULL) < 0) {
44
+ usage(argv[0]);
45
+ return(-1);
46
+ }
47
+
48
+ return 0;
49
+ }
50
+
51
+ /**
52
+ * usage:
53
+ * @name: the program name.
54
+ *
55
+ * Prints usage information.
56
+ */
57
+ static void
58
+ usage(const char *name) {
59
+ assert(name);
60
+
61
+ fprintf(stderr, "Usage: %s <xml-file> <xpath-expr> [<known-ns-list>]\n", name);
62
+ fprintf(stderr, "where <known-ns-list> is a list of known namespaces\n");
63
+ fprintf(stderr, "in \"<prefix1>=<href1> <prefix2>=href2> ...\" format\n");
64
+ }
65
+
66
+ /**
67
+ * execute_xpath_expression:
68
+ * @filename: the input XML filename.
69
+ * @xpathExpr: the xpath expression for evaluation.
70
+ * @nsList: the optional list of known namespaces in
71
+ * "<prefix1>=<href1> <prefix2>=href2> ..." format.
72
+ *
73
+ * Parses input XML file, evaluates XPath expression and prints results.
74
+ *
75
+ * Returns 0 on success and a negative value otherwise.
76
+ */
77
+ int
78
+ execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList) {
79
+ xmlDocPtr doc;
80
+ xmlXPathContextPtr xpathCtx;
81
+ xmlXPathObjectPtr xpathObj;
82
+
83
+ assert(filename);
84
+ assert(xpathExpr);
85
+
86
+ /* Load XML document */
87
+ doc = xmlParseFile(filename);
88
+ if (doc == NULL) {
89
+ fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
90
+ return(-1);
91
+ }
92
+
93
+ /* Create xpath evaluation context */
94
+ xpathCtx = xmlXPathNewContext(doc);
95
+ if(xpathCtx == NULL) {
96
+ fprintf(stderr,"Error: unable to create new XPath context\n");
97
+ xmlFreeDoc(doc);
98
+ return(-1);
99
+ }
100
+
101
+ /* Register namespaces from list (if any) */
102
+ if((nsList != NULL) && (register_namespaces(xpathCtx, nsList) < 0)) {
103
+ fprintf(stderr,"Error: failed to register namespaces list \"%s\"\n", nsList);
104
+ xmlXPathFreeContext(xpathCtx);
105
+ xmlFreeDoc(doc);
106
+ return(-1);
107
+ }
108
+
109
+ /* Evaluate xpath expression */
110
+ xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
111
+ if(xpathObj == NULL) {
112
+ fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr);
113
+ xmlXPathFreeContext(xpathCtx);
114
+ xmlFreeDoc(doc);
115
+ return(-1);
116
+ }
117
+
118
+ /* Print results */
119
+ print_xpath_nodes(xpathObj->nodesetval, stdout);
120
+
121
+ /* Cleanup */
122
+ xmlXPathFreeObject(xpathObj);
123
+ xmlXPathFreeContext(xpathCtx);
124
+ xmlFreeDoc(doc);
125
+
126
+ return(0);
127
+ }
128
+
129
+ /**
130
+ * register_namespaces:
131
+ * @xpathCtx: the pointer to an XPath context.
132
+ * @nsList: the list of known namespaces in
133
+ * "<prefix1>=<href1> <prefix2>=href2> ..." format.
134
+ *
135
+ * Registers namespaces from @nsList in @xpathCtx.
136
+ *
137
+ * Returns 0 on success and a negative value otherwise.
138
+ */
139
+ int
140
+ register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList) {
141
+ xmlChar* nsListDup;
142
+ xmlChar* prefix;
143
+ xmlChar* href;
144
+ xmlChar* next;
145
+
146
+ assert(xpathCtx);
147
+ assert(nsList);
148
+
149
+ nsListDup = xmlStrdup(nsList);
150
+ if(nsListDup == NULL) {
151
+ fprintf(stderr, "Error: unable to strdup namespaces list\n");
152
+ return(-1);
153
+ }
154
+
155
+ next = nsListDup;
156
+ while(next != NULL) {
157
+ /* skip spaces */
158
+ while((*next) == ' ') next++;
159
+ if((*next) == '\0') break;
160
+
161
+ /* find prefix */
162
+ prefix = next;
163
+ next = (xmlChar*)xmlStrchr(next, '=');
164
+ if(next == NULL) {
165
+ fprintf(stderr,"Error: invalid namespaces list format\n");
166
+ xmlFree(nsListDup);
167
+ return(-1);
168
+ }
169
+ *(next++) = '\0';
170
+
171
+ /* find href */
172
+ href = next;
173
+ next = (xmlChar*)xmlStrchr(next, ' ');
174
+ if(next != NULL) {
175
+ *(next++) = '\0';
176
+ }
177
+
178
+ /* do register namespace */
179
+ if(xmlXPathRegisterNs(xpathCtx, prefix, href) != 0) {
180
+ fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
181
+ xmlFree(nsListDup);
182
+ return(-1);
183
+ }
184
+ }
185
+
186
+ xmlFree(nsListDup);
187
+ return(0);
188
+ }
189
+
190
+ /**
191
+ * print_xpath_nodes:
192
+ * @nodes: the nodes set.
193
+ * @output: the output file handle.
194
+ *
195
+ * Prints the @nodes content to @output.
196
+ */
197
+ void
198
+ print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) {
199
+ xmlNodePtr cur;
200
+ int size;
201
+ int i;
202
+
203
+ assert(output);
204
+ size = (nodes) ? nodes->nodeNr : 0;
205
+
206
+ fprintf(output, "Result (%d nodes):\n", size);
207
+ for(i = 0; i < size; ++i) {
208
+ assert(nodes->nodeTab[i]);
209
+
210
+ if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
211
+ xmlNsPtr ns;
212
+
213
+ ns = (xmlNsPtr)nodes->nodeTab[i];
214
+ cur = (xmlNodePtr)ns->next;
215
+ if(cur->ns) {
216
+ fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n",
217
+ ns->prefix, ns->href, cur->ns->href, cur->name);
218
+ } else {
219
+ fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n",
220
+ ns->prefix, ns->href, cur->name);
221
+ }
222
+ } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
223
+ cur = nodes->nodeTab[i];
224
+ if(cur->ns) {
225
+ fprintf(output, "= element node \"%s:%s\"\n",
226
+ cur->ns->href, cur->name);
227
+ } else {
228
+ fprintf(output, "= element node \"%s\"\n",
229
+ cur->name);
230
+ }
231
+ } else {
232
+ cur = nodes->nodeTab[i];
233
+ fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type);
234
+ }
235
+ }
236
+ }
237
+
238
+ #else
239
+ int main(void) {
240
+ fprintf(stderr, "XPath support not compiled in\n");
241
+ return 0;
242
+ }
243
+ #endif
local-test-libxml2-full-01/afc-libxml2/example/xpath2.c ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: XPath
3
+ * synopsis: Load a document, locate subelements with XPath, modify
4
+ * said elements and save the resulting document.
5
+ * purpose: Shows how to make a full round-trip from a load/edit/save
6
+ * usage: xpath2 <xml-file> <xpath-expr> <new-value>
7
+ * test: xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res
8
+ * author: Aleksey Sanin and Daniel Veillard
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+ #include <stdlib.h>
12
+ #include <stdio.h>
13
+ #include <string.h>
14
+ #include <assert.h>
15
+
16
+ #include <libxml/tree.h>
17
+ #include <libxml/parser.h>
18
+ #include <libxml/xpath.h>
19
+ #include <libxml/xpathInternals.h>
20
+
21
+ #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED) && \
22
+ defined(LIBXML_OUTPUT_ENABLED)
23
+
24
+
25
+ static void usage(const char *name);
26
+ static int example4(const char *filename, const xmlChar * xpathExpr,
27
+ const xmlChar * value);
28
+ static void update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar * value);
29
+
30
+
31
+ int
32
+ main(int argc, char **argv) {
33
+ /* Parse command line and process file */
34
+ if (argc != 4) {
35
+ fprintf(stderr, "Error: wrong number of arguments.\n");
36
+ usage(argv[0]);
37
+ return(-1);
38
+ }
39
+
40
+ /* Init libxml */
41
+ xmlInitParser();
42
+ LIBXML_TEST_VERSION
43
+
44
+ /* Do the main job */
45
+ if (example4(argv[1], BAD_CAST argv[2], BAD_CAST argv[3])) {
46
+ usage(argv[0]);
47
+ return(-1);
48
+ }
49
+
50
+ return 0;
51
+ }
52
+
53
+ /**
54
+ * usage:
55
+ * @name: the program name.
56
+ *
57
+ * Prints usage information.
58
+ */
59
+ static void
60
+ usage(const char *name) {
61
+ assert(name);
62
+
63
+ fprintf(stderr, "Usage: %s <xml-file> <xpath-expr> <value>\n", name);
64
+ }
65
+
66
+ /**
67
+ * example4:
68
+ * @filename: the input XML filename.
69
+ * @xpathExpr: the xpath expression for evaluation.
70
+ * @value: the new node content.
71
+ *
72
+ * Parses input XML file, evaluates XPath expression and update the nodes
73
+ * then print the result.
74
+ *
75
+ * Returns 0 on success and a negative value otherwise.
76
+ */
77
+ static int
78
+ example4(const char* filename, const xmlChar* xpathExpr, const xmlChar* value) {
79
+ xmlDocPtr doc;
80
+ xmlXPathContextPtr xpathCtx;
81
+ xmlXPathObjectPtr xpathObj;
82
+
83
+ assert(filename);
84
+ assert(xpathExpr);
85
+ assert(value);
86
+
87
+ /* Load XML document */
88
+ doc = xmlParseFile(filename);
89
+ if (doc == NULL) {
90
+ fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
91
+ return(-1);
92
+ }
93
+
94
+ /* Create xpath evaluation context */
95
+ xpathCtx = xmlXPathNewContext(doc);
96
+ if(xpathCtx == NULL) {
97
+ fprintf(stderr,"Error: unable to create new XPath context\n");
98
+ xmlFreeDoc(doc);
99
+ return(-1);
100
+ }
101
+
102
+ /* Evaluate xpath expression */
103
+ xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
104
+ if(xpathObj == NULL) {
105
+ fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr);
106
+ xmlXPathFreeContext(xpathCtx);
107
+ xmlFreeDoc(doc);
108
+ return(-1);
109
+ }
110
+
111
+ /* update selected nodes */
112
+ update_xpath_nodes(xpathObj->nodesetval, value);
113
+
114
+
115
+ /* Cleanup of XPath data */
116
+ xmlXPathFreeObject(xpathObj);
117
+ xmlXPathFreeContext(xpathCtx);
118
+
119
+ /* dump the resulting document */
120
+ xmlDocDump(stdout, doc);
121
+
122
+
123
+ /* free the document */
124
+ xmlFreeDoc(doc);
125
+
126
+ return(0);
127
+ }
128
+
129
+ /**
130
+ * update_xpath_nodes:
131
+ * @nodes: the nodes set.
132
+ * @value: the new value for the node(s)
133
+ *
134
+ * Prints the @nodes content to @output.
135
+ */
136
+ static void
137
+ update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar* value) {
138
+ int size;
139
+ int i;
140
+
141
+ assert(value);
142
+ size = (nodes) ? nodes->nodeNr : 0;
143
+
144
+ /*
145
+ * NOTE: the nodes are processed in reverse order, i.e. reverse document
146
+ * order because xmlNodeSetContent can actually free up descendant
147
+ * of the node and such nodes may have been selected too ! Handling
148
+ * in reverse order ensure that descendant are accessed first, before
149
+ * they get removed. Mixing XPath and modifications on a tree must be
150
+ * done carefully !
151
+ */
152
+ for(i = size - 1; i >= 0; i--) {
153
+ assert(nodes->nodeTab[i]);
154
+
155
+ xmlNodeSetContent(nodes->nodeTab[i], value);
156
+ /*
157
+ * All the elements returned by an XPath query are pointers to
158
+ * elements from the tree *except* namespace nodes where the XPath
159
+ * semantic is different from the implementation in libxml2 tree.
160
+ * As a result when a returned node set is freed when
161
+ * xmlXPathFreeObject() is called, that routine must check the
162
+ * element type. But node from the returned set may have been removed
163
+ * by xmlNodeSetContent() resulting in access to freed data.
164
+ * This can be exercised by running
165
+ * valgrind xpath2 test3.xml '//discarded' discarded
166
+ * There is 2 ways around it:
167
+ * - make a copy of the pointers to the nodes from the result set
168
+ * then call xmlXPathFreeObject() and then modify the nodes
169
+ * or
170
+ * - remove the reference to the modified nodes from the node set
171
+ * as they are processed, if they are not namespace nodes.
172
+ */
173
+ if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
174
+ nodes->nodeTab[i] = NULL;
175
+ }
176
+ }
177
+
178
+ #else
179
+ int main(void) {
180
+ fprintf(stderr, "XPath support not compiled in\n");
181
+ return 0;
182
+ }
183
+ #endif
local-test-libxml2-full-01/afc-libxml2/include/Makefile.am ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ## Process this file with automake to produce Makefile.in
2
+ SUBDIRS=libxml private
3
+
4
+ EXTRA_DIST = wsockcompat.h meson.build
5
+
local-test-libxml2-full-01/afc-libxml2/include/meson.build ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+
2
+ inc_dir = include_directories('.')
local-test-libxml2-full-01/afc-libxml2/include/wsockcompat.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* include/wsockcompat.h
2
+ * Windows -> Berkeley Sockets compatibility things.
3
+ */
4
+
5
+ #if !defined __XML_WSOCKCOMPAT_H__
6
+ #define __XML_WSOCKCOMPAT_H__
7
+
8
+ #include <errno.h>
9
+ #include <winsock2.h>
10
+
11
+ /* Fix for old MinGW. */
12
+ #ifndef _WINSOCKAPI_
13
+ #define _WINSOCKAPI_
14
+ #endif
15
+
16
+ /* the following is a workaround a problem for 'inline' keyword in said
17
+ header when compiled with Borland C++ 6 */
18
+ #if defined(__BORLANDC__) && !defined(__cplusplus)
19
+ #define inline __inline
20
+ #define _inline __inline
21
+ #endif
22
+
23
+ #include <ws2tcpip.h>
24
+
25
+ /* Check if ws2tcpip.h is a recent version which provides getaddrinfo() */
26
+ #if defined(GetAddrInfo)
27
+ #include <wspiapi.h>
28
+ #ifndef SUPPORT_IP6
29
+ #define SUPPORT_IP6
30
+ #endif
31
+ #endif
32
+
33
+ #ifndef ECONNRESET
34
+ #define ECONNRESET WSAECONNRESET
35
+ #endif
36
+ #ifndef EINPROGRESS
37
+ #define EINPROGRESS WSAEINPROGRESS
38
+ #endif
39
+ #ifndef EINTR
40
+ #define EINTR WSAEINTR
41
+ #endif
42
+ #ifndef ESHUTDOWN
43
+ #define ESHUTDOWN WSAESHUTDOWN
44
+ #endif
45
+ #ifndef EWOULDBLOCK
46
+ #define EWOULDBLOCK WSAEWOULDBLOCK
47
+ #endif
48
+
49
+ #endif /* __XML_WSOCKCOMPAT_H__ */
local-test-libxml2-full-01/afc-libxml2/m4/ax_append_flag.m4 ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
12
+ # added in between.
13
+ #
14
+ # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15
+ # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
16
+ # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
17
+ # FLAG.
18
+ #
19
+ # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
20
+ #
21
+ # LICENSE
22
+ #
23
+ # Copyright (c) 2008 Guido U. Draheim <[email protected]>
24
+ # Copyright (c) 2011 Maarten Bosmans <[email protected]>
25
+ #
26
+ # Copying and distribution of this file, with or without modification, are
27
+ # permitted in any medium without royalty provided the copyright notice
28
+ # and this notice are preserved. This file is offered as-is, without any
29
+ # warranty.
30
+
31
+ #serial 8
32
+
33
+ AC_DEFUN([AX_APPEND_FLAG],
34
+ [dnl
35
+ AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
36
+ AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
37
+ AS_VAR_SET_IF(FLAGS,[
38
+ AS_CASE([" AS_VAR_GET(FLAGS) "],
39
+ [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
40
+ [
41
+ AS_VAR_APPEND(FLAGS,[" $1"])
42
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
43
+ ])
44
+ ],
45
+ [
46
+ AS_VAR_SET(FLAGS,[$1])
47
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
48
+ ])
49
+ AS_VAR_POPDEF([FLAGS])dnl
50
+ ])dnl AX_APPEND_FLAG
local-test-libxml2-full-01/afc-libxml2/m4/ax_append_link_flags.m4 ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # For every FLAG1, FLAG2 it is checked whether the linker works with the
12
+ # flag. If it does, the flag is added FLAGS-VARIABLE
13
+ #
14
+ # If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
15
+ # used. During the check the flag is always added to the linker's flags.
16
+ #
17
+ # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18
+ # when the check is done. The check is thus made with the flags: "LDFLAGS
19
+ # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20
+ # issue an error when a bad flag is given.
21
+ #
22
+ # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
23
+ #
24
+ # NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
25
+ # Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
26
+ #
27
+ # LICENSE
28
+ #
29
+ # Copyright (c) 2011 Maarten Bosmans <[email protected]>
30
+ #
31
+ # Copying and distribution of this file, with or without modification, are
32
+ # permitted in any medium without royalty provided the copyright notice
33
+ # and this notice are preserved. This file is offered as-is, without any
34
+ # warranty.
35
+
36
+ #serial 7
37
+
38
+ AC_DEFUN([AX_APPEND_LINK_FLAGS],
39
+ [AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
40
+ AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
41
+ for flag in $1; do
42
+ AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
43
+ done
44
+ ])dnl AX_APPEND_LINK_FLAGS
local-test-libxml2-full-01/afc-libxml2/m4/ax_check_link_flag.m4 ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # Check whether the given FLAG works with the linker or gives an error.
12
+ # (Warnings, however, are ignored)
13
+ #
14
+ # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15
+ # success/failure.
16
+ #
17
+ # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18
+ # when the check is done. The check is thus made with the flags: "LDFLAGS
19
+ # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20
+ # issue an error when a bad flag is given.
21
+ #
22
+ # INPUT gives an alternative input source to AC_LINK_IFELSE.
23
+ #
24
+ # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25
+ # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26
+ #
27
+ # LICENSE
28
+ #
29
+ # Copyright (c) 2008 Guido U. Draheim <[email protected]>
30
+ # Copyright (c) 2011 Maarten Bosmans <[email protected]>
31
+ #
32
+ # Copying and distribution of this file, with or without modification, are
33
+ # permitted in any medium without royalty provided the copyright notice
34
+ # and this notice are preserved. This file is offered as-is, without any
35
+ # warranty.
36
+
37
+ #serial 6
38
+
39
+ AC_DEFUN([AX_CHECK_LINK_FLAG],
40
+ [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41
+ AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
42
+ AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
43
+ ax_check_save_flags=$LDFLAGS
44
+ LDFLAGS="$LDFLAGS $4 $1"
45
+ AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46
+ [AS_VAR_SET(CACHEVAR,[yes])],
47
+ [AS_VAR_SET(CACHEVAR,[no])])
48
+ LDFLAGS=$ax_check_save_flags])
49
+ AS_VAR_IF(CACHEVAR,yes,
50
+ [m4_default([$2], :)],
51
+ [m4_default([$3], :)])
52
+ AS_VAR_POPDEF([CACHEVAR])dnl
53
+ ])dnl AX_CHECK_LINK_FLAGS
local-test-libxml2-full-01/afc-libxml2/m4/ax_gcc_func_attribute.m4 ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # This macro checks if the compiler supports one of GCC's function
12
+ # attributes; many other compilers also provide function attributes with
13
+ # the same syntax. Compiler warnings are used to detect supported
14
+ # attributes as unsupported ones are ignored by default so quieting
15
+ # warnings when using this macro will yield false positives.
16
+ #
17
+ # The ATTRIBUTE parameter holds the name of the attribute to be checked.
18
+ #
19
+ # If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
20
+ #
21
+ # The macro caches its result in the ax_cv_have_func_attribute_<attribute>
22
+ # variable.
23
+ #
24
+ # The macro currently supports the following function attributes:
25
+ #
26
+ # alias
27
+ # aligned
28
+ # alloc_size
29
+ # always_inline
30
+ # artificial
31
+ # cold
32
+ # const
33
+ # constructor
34
+ # constructor_priority for constructor attribute with priority
35
+ # deprecated
36
+ # destructor
37
+ # dllexport
38
+ # dllimport
39
+ # error
40
+ # externally_visible
41
+ # fallthrough
42
+ # flatten
43
+ # format
44
+ # format_arg
45
+ # gnu_format
46
+ # gnu_inline
47
+ # hot
48
+ # ifunc
49
+ # leaf
50
+ # malloc
51
+ # noclone
52
+ # noinline
53
+ # nonnull
54
+ # noreturn
55
+ # nothrow
56
+ # optimize
57
+ # pure
58
+ # sentinel
59
+ # sentinel_position
60
+ # unused
61
+ # used
62
+ # visibility
63
+ # warning
64
+ # warn_unused_result
65
+ # weak
66
+ # weakref
67
+ #
68
+ # Unsupported function attributes will be tested with a prototype
69
+ # returning an int and not accepting any arguments and the result of the
70
+ # check might be wrong or meaningless so use with care.
71
+ #
72
+ # LICENSE
73
+ #
74
+ # Copyright (c) 2013 Gabriele Svelto <[email protected]>
75
+ #
76
+ # Copying and distribution of this file, with or without modification, are
77
+ # permitted in any medium without royalty provided the copyright notice
78
+ # and this notice are preserved. This file is offered as-is, without any
79
+ # warranty.
80
+
81
+ #serial 13
82
+
83
+ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
84
+ AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
85
+
86
+ AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
87
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([
88
+ m4_case([$1],
89
+ [alias], [
90
+ int foo( void ) { return 0; }
91
+ int bar( void ) __attribute__(($1("foo")));
92
+ ],
93
+ [aligned], [
94
+ int foo( void ) __attribute__(($1(32)));
95
+ ],
96
+ [alloc_size], [
97
+ void *foo(int a) __attribute__(($1(1)));
98
+ ],
99
+ [always_inline], [
100
+ inline __attribute__(($1)) int foo( void ) { return 0; }
101
+ ],
102
+ [artificial], [
103
+ inline __attribute__(($1)) int foo( void ) { return 0; }
104
+ ],
105
+ [cold], [
106
+ int foo( void ) __attribute__(($1));
107
+ ],
108
+ [const], [
109
+ int foo( void ) __attribute__(($1));
110
+ ],
111
+ [constructor_priority], [
112
+ int foo( void ) __attribute__((__constructor__(65535/2)));
113
+ ],
114
+ [constructor], [
115
+ int foo( void ) __attribute__(($1));
116
+ ],
117
+ [deprecated], [
118
+ int foo( void ) __attribute__(($1("")));
119
+ ],
120
+ [destructor], [
121
+ int foo( void ) __attribute__(($1));
122
+ ],
123
+ [dllexport], [
124
+ __attribute__(($1)) int foo( void ) { return 0; }
125
+ ],
126
+ [dllimport], [
127
+ int foo( void ) __attribute__(($1));
128
+ ],
129
+ [error], [
130
+ int foo( void ) __attribute__(($1("")));
131
+ ],
132
+ [externally_visible], [
133
+ int foo( void ) __attribute__(($1));
134
+ ],
135
+ [fallthrough], [
136
+ void foo( int x ) {switch (x) { case 1: __attribute__(($1)); case 2: break ; }};
137
+ ],
138
+ [flatten], [
139
+ int foo( void ) __attribute__(($1));
140
+ ],
141
+ [format], [
142
+ int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
143
+ ],
144
+ [gnu_format], [
145
+ int foo(const char *p, ...) __attribute__((format(gnu_printf, 1, 2)));
146
+ ],
147
+ [format_arg], [
148
+ char *foo(const char *p) __attribute__(($1(1)));
149
+ ],
150
+ [gnu_inline], [
151
+ inline __attribute__(($1)) int foo( void ) { return 0; }
152
+ ],
153
+ [hot], [
154
+ int foo( void ) __attribute__(($1));
155
+ ],
156
+ [ifunc], [
157
+ int my_foo( void ) { return 0; }
158
+ static int (*resolve_foo(void))(void) { return my_foo; }
159
+ int foo( void ) __attribute__(($1("resolve_foo")));
160
+ ],
161
+ [leaf], [
162
+ __attribute__(($1)) int foo( void ) { return 0; }
163
+ ],
164
+ [malloc], [
165
+ void *foo( void ) __attribute__(($1));
166
+ ],
167
+ [noclone], [
168
+ int foo( void ) __attribute__(($1));
169
+ ],
170
+ [noinline], [
171
+ __attribute__(($1)) int foo( void ) { return 0; }
172
+ ],
173
+ [nonnull], [
174
+ int foo(char *p) __attribute__(($1(1)));
175
+ ],
176
+ [noreturn], [
177
+ void foo( void ) __attribute__(($1));
178
+ ],
179
+ [nothrow], [
180
+ int foo( void ) __attribute__(($1));
181
+ ],
182
+ [optimize], [
183
+ __attribute__(($1(3))) int foo( void ) { return 0; }
184
+ ],
185
+ [pure], [
186
+ int foo( void ) __attribute__(($1));
187
+ ],
188
+ [sentinel], [
189
+ int foo(void *p, ...) __attribute__(($1));
190
+ ],
191
+ [sentinel_position], [
192
+ int foo(void *p, ...) __attribute__(($1(1)));
193
+ ],
194
+ [returns_nonnull], [
195
+ void *foo( void ) __attribute__(($1));
196
+ ],
197
+ [unused], [
198
+ int foo( void ) __attribute__(($1));
199
+ ],
200
+ [used], [
201
+ int foo( void ) __attribute__(($1));
202
+ ],
203
+ [visibility], [
204
+ int foo_def( void ) __attribute__(($1("default")));
205
+ int foo_hid( void ) __attribute__(($1("hidden")));
206
+ int foo_int( void ) __attribute__(($1("internal")));
207
+ int foo_pro( void ) __attribute__(($1("protected")));
208
+ ],
209
+ [warning], [
210
+ int foo( void ) __attribute__(($1("")));
211
+ ],
212
+ [warn_unused_result], [
213
+ int foo( void ) __attribute__(($1));
214
+ ],
215
+ [weak], [
216
+ int foo( void ) __attribute__(($1));
217
+ ],
218
+ [weakref], [
219
+ static int foo( void ) { return 0; }
220
+ static int bar( void ) __attribute__(($1("foo")));
221
+ ],
222
+ [
223
+ m4_warn([syntax], [Unsupported attribute $1, the test may fail])
224
+ int foo( void ) __attribute__(($1));
225
+ ]
226
+ )], [])
227
+ ],
228
+ dnl GCC doesn't exit with an error if an unknown attribute is
229
+ dnl provided but only outputs a warning, so accept the attribute
230
+ dnl only if no warning were issued.
231
+ [AS_IF([grep -- -Wattributes conftest.err],
232
+ [AS_VAR_SET([ac_var], [no])],
233
+ [AS_VAR_SET([ac_var], [yes])])],
234
+ [AS_VAR_SET([ac_var], [no])])
235
+ ])
236
+
237
+ AS_IF([test yes = AS_VAR_GET([ac_var])],
238
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
239
+ [Define to 1 if the system has the `$1' function attribute])], [])
240
+
241
+ AS_VAR_POPDEF([ac_var])
242
+ ])
local-test-libxml2-full-01/afc-libxml2/m4/ax_recursive_eval.m4 ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_recursive_eval.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_RECURSIVE_EVAL(VALUE, RESULT)
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # Interpolate the VALUE in loop until it doesn't change, and set the
12
+ # result to $RESULT. WARNING: It's easy to get an infinite loop with some
13
+ # unsane input.
14
+ #
15
+ # LICENSE
16
+ #
17
+ # Copyright (c) 2008 Alexandre Duret-Lutz <[email protected]>
18
+ #
19
+ # This program is free software; you can redistribute it and/or modify it
20
+ # under the terms of the GNU General Public License as published by the
21
+ # Free Software Foundation; either version 2 of the License, or (at your
22
+ # option) any later version.
23
+ #
24
+ # This program is distributed in the hope that it will be useful, but
25
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
27
+ # Public License for more details.
28
+ #
29
+ # You should have received a copy of the GNU General Public License along
30
+ # with this program. If not, see <https://www.gnu.org/licenses/>.
31
+ #
32
+ # As a special exception, the respective Autoconf Macro's copyright owner
33
+ # gives unlimited permission to copy, distribute and modify the configure
34
+ # scripts that are the output of Autoconf when processing the Macro. You
35
+ # need not follow the terms of the GNU General Public License when using
36
+ # or distributing such scripts, even though portions of the text of the
37
+ # Macro appear in them. The GNU General Public License (GPL) does govern
38
+ # all other use of the material that constitutes the Autoconf Macro.
39
+ #
40
+ # This special exception to the GPL applies to versions of the Autoconf
41
+ # Macro released by the Autoconf Archive. When you make and distribute a
42
+ # modified version of the Autoconf Macro, you may extend this special
43
+ # exception to the GPL to apply to your modified version as well.
44
+
45
+ #serial 1
46
+
47
+ AC_DEFUN([AX_RECURSIVE_EVAL],
48
+ [_lcl_receval="$1"
49
+ $2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix"
50
+ test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
51
+ _lcl_receval_old=''
52
+ while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
53
+ _lcl_receval_old="[$]_lcl_receval"
54
+ eval _lcl_receval="\"[$]_lcl_receval\""
55
+ done
56
+ echo "[$]_lcl_receval")`])
local-test-libxml2-full-01/afc-libxml2/m4/ax_require_defined.m4 ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_REQUIRE_DEFINED(MACRO)
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
12
+ # been defined and thus are available for use. This avoids random issues
13
+ # where a macro isn't expanded. Instead the configure script emits a
14
+ # non-fatal:
15
+ #
16
+ # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
17
+ #
18
+ # It's like AC_REQUIRE except it doesn't expand the required macro.
19
+ #
20
+ # Here's an example:
21
+ #
22
+ # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
23
+ #
24
+ # LICENSE
25
+ #
26
+ # Copyright (c) 2014 Mike Frysinger <[email protected]>
27
+ #
28
+ # Copying and distribution of this file, with or without modification, are
29
+ # permitted in any medium without royalty provided the copyright notice
30
+ # and this notice are preserved. This file is offered as-is, without any
31
+ # warranty.
32
+
33
+ #serial 2
34
+
35
+ AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
36
+ m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
37
+ ])dnl AX_REQUIRE_DEFINED
local-test-libxml2-full-01/afc-libxml2/os400/README400 ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Implementation notes:
3
+
4
+ This is a true OS/400 implementation, not a PASE implementation (for PASE,
5
+ use an AIX implementation).
6
+
7
+ The biggest problem with OS/400 is EBCDIC. The current libxml2 implementation
8
+ uses UTF-8 internally. To ease encoding conversion between the calling
9
+ applications and libxml2, supplementary "convert and latch" functions are
10
+ provided (See below). To bind the EBCDIC OS/400 system calls and libxml2,
11
+ an ASCII run-time environment (QADRT) has been used and wrapper functions have
12
+ been designed.
13
+
14
+ Other problems are:
15
+ - Source code line length: to be stored in DB2 members, source files may not
16
+ have lines longer than 100 characters. Some header and documentation files
17
+ have been modified accordingly.
18
+ - va_list dereferencing: the OS/400 implementation of va_list type is an array
19
+ but the compiler forbids explicit array dereferencing. Source files have
20
+ been updated accordingly.
21
+ - Depending on the compilation/execution environment, it is possible that
22
+ stdin/stdout/stderr are not associated with a file descriptor; as a side
23
+ effect, open() may return a file descriptor value 0, 1 or 2 that is NOT
24
+ a C standard file. Thus using such a number may be inaccurate.
25
+ - iconv_open() arguments: OS/400 uses non-standard encoding names and does not
26
+ support standard names. For this reason, a name wrapper has been designed.
27
+ - dlopen() (support for xmodule): the function and its corollaries are not
28
+ provided by the OS/400 library. However a local implementation is provided.
29
+
30
+
31
+ Compiling on OS/400:
32
+
33
+ _ As a prerequisite, QADRT development environment must be installed.
34
+ _ Install the libxml2 source directory in IFS.
35
+ _ Enter shell (QSH)
36
+ _ Change current directory to the libxml2 installation directory
37
+ _ Change current directory to ./os400
38
+ _ Edit file iniscript.sh. You may want to change tunable configuration
39
+ parameters, like debug info generation, optimisation level, listing option,
40
+ target library, zlib availability, etc.
41
+ _ Copy any file in the current directory to makelog (i.e.:
42
+ cp initscript.sh makelog): this is intended to create the makelog file with
43
+ an ASCII CCSID!
44
+ _ Enter the command "sh make.sh >makelog 2>&1'
45
+ _ Examine the makelog file to check for compilation errors.
46
+
47
+ Leaving file initscript.sh unchanged, this will produce the following
48
+ OS/400 objects:
49
+ _ Library LIBXML2. All other objects will be stored in this library.
50
+ _ Modules for all libxml2 units, with full debug info and no code optimization.
51
+ _ Binding directory LIBXML2_A, to be used at calling program link time for
52
+ statically binding the modules (specify BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)
53
+ when creating a program using LIBXML2_A).
54
+ _ Service program LIBXML2. To be used at calling program run-time
55
+ when this program has dynamically bound libxml2 at link time.
56
+ _ Binding directory LIBXML2. To be used to dynamically bind libxml2 when
57
+ linking a calling program.
58
+ _ Source file LIBXML. It contains all the header members needed to compile a
59
+ C/C++ module using libxml2.
60
+ _ Standard and additional C/C++ libxml2 header members (possibly renamed) in
61
+ file LIBXML.
62
+ _ IFS directory /libxml2 with subdirectory include/libxml containing all
63
+ C/C++ header files for IFS-based compilation.
64
+ _ Source file LIBXMLRPG. It contains all the include members needed to compile a
65
+ ILE/RPG module/program using libxml2 (ILE/RPG binding).
66
+ _ ILE/RPG binding include members (possibly renamed) in file LIBXMLRPG.
67
+ _ IFS subdirectory /libxml2/include/libxmlrpg containing all ILE/RPG include
68
+ files for IFS-based compilation.
69
+
70
+
71
+ Renamed header files in DB2 members:
72
+ DB2 member names are limited to 10 characters, thus the following C/C++
73
+ header members are renamed as:
74
+ parserInternals.h --> PARSERINTE
75
+ schemasInternals.h --> SCHEMASINT
76
+ xmlautomata.h --> XMLAUTOMAT
77
+ xmlschemastype.h --> SCHMTYPES
78
+ xpathInternals.h --> XPATHINTER
79
+ IFS header files are NOT renamed.
80
+ ILE/RPG headers are processed likewise.
81
+
82
+
83
+ Special programming consideration:
84
+
85
+ QADRT being used, the following points must be considered:
86
+ _ If static binding is used, service program QADRTTS must be linked too.
87
+ _ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
88
+ another EBCDIC CCSID is required, it must be set via a locale through a call
89
+ to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
90
+ LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
91
+ object path before executing the program.
92
+ _ Always use *IFSIO or *IFS64IO to compile calling programs.
93
+
94
+
95
+
96
+ Supplementary (non libxml2 standard) support procedures for OS/400.
97
+
98
+ As cited above, there are some procedures to ease encoding conversion of
99
+ libxml2 function arguments and results: the mechanism is based on
100
+ dictionaries. The functions convert a string, latch the result in a dictionary
101
+ to ensure its persistence and return its address. It is the caller's
102
+ responsibility to clean the dictionary when it becomes too big or disappears.
103
+
104
+ The procedures are:
105
+
106
+ #include <libxml/transcode.h>
107
+
108
+ const char * xmlTranscodeResult(const xmlChar * s,
109
+ const char * encoding,
110
+ xmlDictPtr * dict,
111
+ void (*freeproc)(const void *));
112
+
113
+ const xmlChar * xmlTranscodeString(const char * s,
114
+ const char * encoding,
115
+ xmlDictPtr * dict);
116
+
117
+ const xmlChar * xmlTranscodeWString(const char * s,
118
+ const char * encoding,
119
+ xmlDictPtr * dict);
120
+
121
+ const xmlChar * xmlTranscodeWString(const char * s,
122
+ const char * encoding,
123
+ xmlDictPtr * dict);
124
+
125
+ where:
126
+ s is the string to translate.
127
+ encoding is the alternate character encoding. If null, the current job's
128
+ encoding (CCSID) is used.
129
+ dict is the address of the latching directory. If NULL, the procedure
130
+ functions as a simple non-latching encoding converter and
131
+ its result value should be freed by the caller.
132
+ freeproc is a procedure to release the original string, or NULL.
133
+
134
+ xmlTranscodeResult() converts from UTF-8 to the given alternate encoding.
135
+ xmlTranscodeString() converts from the given 8-bit encoding to UTF-8 (note that
136
+ UTF-8 itself is considered as a 8-bit encoding).
137
+ xmlTranscodeWString() converts from the given 16-bit encoding to UTF-8.
138
+ xmlTranscodeHString() converts from the given 32-bit encoding to UTF-8.
139
+
140
+
141
+ To shorten statements using these functions, shorthands are defined:
142
+
143
+ xmlTR for xmlTranscodeResult
144
+ xmlTS for xmlTranscodeString
145
+ xmlTW for xmlTranscodeWString
146
+ xmlTH for xmlTranscodeHstring
147
+
148
+ These shorthands may be disabled by defining XML_NO_SHORT_NAMES before
149
+ libxml/transcode.h inclusion.
150
+
151
+ A directory pointer must be preset to NULL before the first call using it to
152
+ one of the above procedure.
153
+
154
+ To release a latching directory, use function
155
+
156
+ void xmlZapDict(xmlDictPtr * dict);
157
+
158
+
159
+ Example:
160
+
161
+ #include <libxml/transcode.h>
162
+ #include <libxml/tree.h>
163
+
164
+ xmlDocPtr mySimpleXMLDoc(char * element, char * text)
165
+ {
166
+ xmlDocPtr doc;
167
+ xmlNodePtr node;
168
+ xmlDictPtr dict = NULL;
169
+
170
+ /* element and text are encoded in the current job's encoding. */
171
+
172
+ doc = xmlNewDoc();
173
+ xmlNewTextChild((xmlNodePtr) doc, NULL, xmlTS(element, NULL,
174
+ &dict), xmlTS(text, NULL, &dict));
175
+ xmlZapDict(&dict);
176
+ return doc;
177
+ }
178
+
179
+
180
+ Additionally, a formatter into latched/dynamic storage is provided:
181
+
182
+ const char * xmlVasprintf(xmlDictPtr * dict,
183
+ const char * encoding,
184
+ const xmlChar * fmt,
185
+ va_list args);
186
+
187
+
188
+ xmllint and xmlcatalog programs:
189
+
190
+ These programs are fully implemented at the qshell level, with standard
191
+ command line options. Links to these are installed in sub-directory bin of
192
+ the IFS installation directory.
193
+ CL command interfaces to these programs are also provided with limited
194
+ support. In particular, interactive mode is not supported and argument count
195
+ and lengths are limited by the CL command syntax.
196
+
197
+
198
+ ILE/RPG binding:
199
+
200
+ All standard types and procedures are provided. Since ILE/RPG does not
201
+ support macros, they have not been ported. However some of them are emulated
202
+ as functions: these are the more useful ones (xmlXPathNodeSetGetLength,
203
+ xmlXPathNodeSetItem, xmlXPathNodeSetIsEmpty, htmlDefaultSubelement,
204
+ htmlElementAllowedHereDesc, htmlRequiredAttrs) and the global/threaded
205
+ variables access macros. These variables can be read with function
206
+ get_xxx(void), where xxxx is the name of the variable; they may be set by
207
+ calling function set_xxxx(value), where value is of the same type as the
208
+ variable.
209
+
210
+ The C va_list is not implemented as such in ILE/RPG. Functions implementing
211
+ va_list and associated methods are provided:
212
+
213
+ /include "libxmlrpg/xmlstdarg"
214
+
215
+ d xmlVaStart pr
216
+ d list like(xmlVaList)
217
+ d lastargaddr * value
218
+ d lastargsize 10u 0 value
219
+
220
+ d xmlVaArg pr
221
+ d list like(xmlVaList)
222
+ d dest * value
223
+ d argsize 10i 0 value
224
+
225
+ d xmlVaEnd pr
226
+ d list like(xmlVaList)
local-test-libxml2-full-01/afc-libxml2/os400/initscript.sh ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ #
3
+ # Compilation scripts initialization for the OS/400 implementation.
4
+ #
5
+ # See Copyright for the status of this software.
6
+ #
7
+ # Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
8
+ #
9
+
10
+
11
+ case "${SCRIPTDIR}" in
12
+ /*) ;;
13
+ *) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
14
+ esac
15
+
16
+ while true
17
+ do case "${SCRIPTDIR}" in
18
+ */.) SCRIPTDIR="${SCRIPTDIR%/.}";;
19
+ *) break;;
20
+ esac
21
+ done
22
+
23
+ # The script directory is supposed to be in $TOPDIR/os400.
24
+
25
+ TOPDIR=`dirname "${SCRIPTDIR}"`
26
+ export SCRIPTDIR TOPDIR
27
+
28
+
29
+ setenv()
30
+
31
+ {
32
+ # Define and export.
33
+
34
+ eval ${1}="${2}"
35
+ export ${1}
36
+ }
37
+
38
+
39
+ ################################################################################
40
+ #
41
+ # Tunable configuration parameters.
42
+ #
43
+ ################################################################################
44
+
45
+ setenv TARGETLIB 'LIBXML2' # Target OS/400 program library.
46
+ setenv STATBNDDIR 'LIBXML2_A' # Static binding directory.
47
+ setenv DYNBNDDIR 'LIBXML2' # Dynamic binding directory.
48
+ setenv SRVPGM "LIBXML2" # Service program.
49
+ setenv TGTCCSID '500' # Target CCSID of objects.
50
+ setenv DEBUG '*ALL' # Debug level.
51
+ setenv OPTIMIZE '10' # Optimisation level.
52
+ setenv OUTPUT '*NONE' # Compilation output option.
53
+ setenv TGTRLS 'V6R1M0' # Target OS release.
54
+ setenv IFSDIR '/libxml2' # Installation IFS directory.
55
+
56
+
57
+ ################################################################################
58
+ #
59
+ # Conditional compilation parameters.
60
+ #
61
+ ################################################################################
62
+
63
+ setenv WITH_TRIO 1 # Configure trio support.
64
+ setenv WITH_THREADS 1 # Configure thread support.
65
+ setenv WITH_THREAD_ALLOC 1 # Whether allocation hooks are per-thread.
66
+ setenv WITH_TREE 1 # Compile DOM tree API.
67
+ setenv WITH_OUTPUT 1 # Compile serialization/saving support.
68
+ setenv WITH_PUSH 1 # Compile push parser.
69
+ setenv WITH_READER 1 # Compile parsing interface.
70
+ setenv WITH_PATTERN 1 # Compile pattern node selection interface.
71
+ setenv WITH_WRITER 1 # Compile saving interface.
72
+ setenv WITH_SAX1 1 # Compile SAX version 1 interface.
73
+ setenv WITH_FTP 1 # Compile FTP support.
74
+ setenv WITH_HTTP 1 # Compile HTTP support.
75
+ setenv WITH_VALID 1 # Compile DTD validation support.
76
+ setenv WITH_HTML 1 # Compile HTML support.
77
+ setenv WITH_LEGACY 1 # Compile deprecated API.
78
+ setenv WITH_C14N 1 # Compile canonicalization support.
79
+ setenv WITH_CATALOG 1 # Compile catalog support.
80
+ setenv WITH_DOCB 1 # Compile SGML Docbook support.
81
+ setenv WITH_XPATH 1 # Compile XPath support.
82
+ setenv WITH_XPTR 1 # Compile XPointer support.
83
+ setenv WITH_XINCLUDE 1 # Compile XInclude support.
84
+ setenv WITH_ICONV 1 # Whether iconv support is available.
85
+ setenv WITH_ICU 0 # Whether icu support is available.
86
+ setenv WITH_ISO8859X 1 # Compile ISO-8859-* support if no iconv.
87
+ setenv WITH_DEBUG 1 # Compile debugging module.
88
+ setenv WITH_MEM_DEBUG 1 # Compile memory debugging module.
89
+ setenv WITH_RUN_DEBUG 1 # Compile runtime debugging.
90
+ setenv WITH_REGEXPS 1 # Compile regular expression interfaces.
91
+ setenv WITH_SCHEMAS 1 # Compile schema validation interface.
92
+ setenv WITH_SCHEMATRON 1 # Compile schematron validation interface.
93
+ setenv WITH_MODULES 1 # Compile module interfaces.
94
+ setenv WITH_ZLIB 0 # Whether zlib is available.
95
+ setenv WITH_LZMA 0 # Whether LZMA is available.
96
+
97
+ # Define ZLIB locations. This is ignored if WITH_ZLIB is 0.
98
+
99
+ setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
100
+ setenv ZLIB_LIB 'ZLIB' # ZLIB library.
101
+ setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
102
+
103
+ ################################################################################
104
+ #
105
+ # OS/400 specific definitions.
106
+ #
107
+ ################################################################################
108
+
109
+ setenv LIBIFSNAME "/QSYS.LIB/${TARGETLIB}.LIB"
110
+ setenv MODULE_EXTENSION '.SRVPGM'
111
+
112
+
113
+ ################################################################################
114
+ #
115
+ # Extract version information.
116
+ #
117
+ ################################################################################
118
+
119
+
120
+ # Transitional: get file name of configure script.
121
+
122
+ AUTOCONFSCRIPT="${TOPDIR}/configure.ac"
123
+
124
+ if [ ! -f "${AUTOCONFSCRIPT}" ]
125
+ then AUTOCONFSCRIPT="${TOPDIR}/configure.in"
126
+ fi
127
+
128
+ # Need to get the version definitions.
129
+
130
+ eval "`grep '^LIBXML_[A-Z]*_VERSION=' \"${AUTOCONFSCRIPT}\"`"
131
+ eval "`grep '^LIBXML_MICRO_VERSION_SUFFIX=' \"${AUTOCONFSCRIPT}\"`"
132
+ LIBXML_VERSION="${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}"
133
+ LIBXML_VERSION="${LIBXML_VERSION}.${LIBXML_MICRO_VERSION}"
134
+ LIBXML_VERSION="${LIBXML_VERSION}${LIBXML_MICRO_VERSION_SUFFIX}"
135
+ LIBXML_VERSION_NUMBER=`expr "${LIBXML_MAJOR_VERSION}" \* 10000 + \
136
+ "${LIBXML_MINOR_VERSION}" \* 100 + \
137
+ "${LIBXML_MICRO_VERSION}"`
138
+ export LIBXML_MAJOR_VERSION LIBXML_MINOR_VERSION
139
+ export LIBXML_MICRO_VERSION LIBXML_MICROVERSION_SUFFIX
140
+ export LIBXML_VERSION LIBXML_VERSION_NUMBER
141
+ setenv LIBXML_VERSION_EXTRA ''
142
+ setenv VERSION "${LIBXML_VERSION}"
143
+
144
+
145
+ ################################################################################
146
+ #
147
+ # Procedures.
148
+ #
149
+ ################################################################################
150
+
151
+ # action_needed dest [src]
152
+ #
153
+ # dest is an object to build
154
+ # if specified, src is an object on which dest depends.
155
+ #
156
+ # exit 0 (succeeds) if some action has to be taken, else 1.
157
+
158
+ action_needed()
159
+
160
+ {
161
+ [ ! -e "${1}" ] && return 0
162
+ [ "${2}" ] || return 1
163
+ [ "${1}" -ot "${2}" ] && return 0
164
+ return 1
165
+ }
166
+
167
+
168
+ # make_module [option] module_name source_name
169
+ #
170
+ # Compile source name into ASCII module if needed.
171
+ # As side effect, append the module name to variable MODULES.
172
+ # Set LINK to "YES" if the module has been compiled.
173
+ # Options are:
174
+ # --define <additional definitions>
175
+ # --ebcdic
176
+ # --sysiconv
177
+
178
+ make_module()
179
+
180
+ {
181
+ DEFN=
182
+ EBCDIC=
183
+ SYSICONV=
184
+ while true
185
+ do case "${1}" in
186
+ --define)
187
+ DEFN="${2}"
188
+ shift
189
+ ;;
190
+ --ebcdic)
191
+ EBCDIC=yes
192
+ ;;
193
+ --sysiconv)
194
+ SYSICONV=yes
195
+ ;;
196
+ *) break
197
+ esac
198
+ shift
199
+ done
200
+ MODULES="${MODULES} ${1}"
201
+ MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
202
+ action_needed "${MODIFSNAME}" "${2}" || return 0;
203
+
204
+ # #pragma convert has to be in the source file itself, i.e.
205
+ # putting it in an include file makes it only active
206
+ # for that include file.
207
+ # Thus we build a temporary file with the pragma prepended to
208
+ # the source file and we compile that temporary file.
209
+
210
+ rm -f __tmpsrcf.c
211
+ if [ -z "${EBCDIC}" ]
212
+ then echo "#line 1 \"${2}\"" >> __tmpsrcf.c
213
+ echo "#pragma convert(819)" >> __tmpsrcf.c
214
+ echo '#include "wrappers.h"' >> __tmpsrcf.c
215
+ fi
216
+ echo "#line 1 \"${2}\"" >> __tmpsrcf.c
217
+ cat "${2}" >> __tmpsrcf.c
218
+ CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
219
+ # CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
220
+ CMD="${CMD} OPTION(*INCDIRFIRST) FLAG(10)"
221
+ CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
222
+ CMD="${CMD} INCDIR("
223
+ if [ -z "${SYSICONV}" ]
224
+ then CMD="${CMD} '${TOPDIR}/os400/iconv'"
225
+ fi
226
+ if [ -z "${EBCDIC}" ]
227
+ then CMD="${CMD} '/qibm/proddata/qadrt/include'"
228
+ fi
229
+ CMD="${CMD} '${TOPDIR}/os400' '${TOPDIR}/os400/dlfcn'"
230
+ CMD="${CMD} '${IFSDIR}/include/libxml' '${IFSDIR}/include'"
231
+ if [ "${ZLIB_INCLUDE}" ]
232
+ then CMD="${CMD} '${ZLIB_INCLUDE}'"
233
+ fi
234
+ CMD="${CMD} '${TOPDIR}' ${INCLUDES})"
235
+ CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
236
+ CMD="${CMD} OUTPUT(${OUTPUT})"
237
+ CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
238
+ CMD="${CMD} DBGVIEW(${DEBUG})"
239
+ CMD="${CMD} DEFINE('_REENTRANT' 'TRIO_HAVE_CONFIG_H' 'NDEBUG' ${DEFN})"
240
+
241
+ system "${CMD}"
242
+ rm -f __tmpsrcf.c
243
+ LINK=YES
244
+ }
245
+
246
+
247
+ # Determine DB2 object name from IFS name.
248
+
249
+ db2_name()
250
+
251
+ {
252
+ if [ "${2}" = 'nomangle' ]
253
+ then basename "${1}" |
254
+ tr 'a-z-' 'A-Z_' |
255
+ sed -e 's/\..*//' \
256
+ -e 's/^\(..........\).*$/\1/'
257
+ else basename "${1}" |
258
+ tr 'a-z-' 'A-Z_' |
259
+ sed -e 's/\..*//' \
260
+ -e 's/^TEST/T/' \
261
+ -e 's/^XML/X/' \
262
+ -e 's/^\(.\).*\(.........\)$/\1\2/'
263
+ fi
264
+ }
265
+
266
+
267
+ # Copy IFS file replacing version & configuration info.
268
+
269
+ versioned_copy()
270
+
271
+ {
272
+ sed -e "s/@LIBXML_VERSION@/${LIBXML_VERSION}/g" \
273
+ \
274
+ -e "s#@LIBXML_MAJOR_VERSION@#${LIBXML_MAJOR_VERSION}#g" \
275
+ -e "s#@LIBXML_MINOR_VERSION@#${LIBXML_MINOR_VERSION}#g" \
276
+ -e "s#@LIBXML_MICRO_VERSION@#${LIBXML_MICRO_VERSION}#g" \
277
+ -e "s#@LIBXML_MICRO_VERSION_SUFFIX@#${LIBXML_MICRO_VERSION_SUFFIX}#g" \
278
+ -e "s#@LIBXML_VERSION@#${LIBXML_VERSION}#g" \
279
+ -e "s#@LIBXML_VERSION_NUMBER@#${LIBXML_VERSION_NUMBER}#g" \
280
+ -e "s#@LIBXML_VERSION_EXTRA@#${LIBXML_VERSION_EXTRA}#g" \
281
+ -e "s#@VERSION@#${VERSION}#g" \
282
+ -e "s#@WITH_TRIO@#${WITH_TRIO}#g" \
283
+ -e "s#@WITH_THREADS@#${WITH_THREADS}#g" \
284
+ -e "s#@WITH_THREAD_ALLOC@#${WITH_THREAD_ALLOC}#g" \
285
+ -e "s#@WITH_TREE@#${WITH_TREE}#g" \
286
+ -e "s#@WITH_OUTPUT@#${WITH_OUTPUT}#g" \
287
+ -e "s#@WITH_PUSH@#${WITH_PUSH}#g" \
288
+ -e "s#@WITH_READER@#${WITH_READER}#g" \
289
+ -e "s#@WITH_PATTERN@#${WITH_PATTERN}#g" \
290
+ -e "s#@WITH_WRITER@#${WITH_WRITER}#g" \
291
+ -e "s#@WITH_SAX1@#${WITH_SAX1}#g" \
292
+ -e "s#@WITH_FTP@#${WITH_FTP}#g" \
293
+ -e "s#@WITH_HTTP@#${WITH_HTTP}#g" \
294
+ -e "s#@WITH_VALID@#${WITH_VALID}#g" \
295
+ -e "s#@WITH_HTML@#${WITH_HTML}#g" \
296
+ -e "s#@WITH_LEGACY@#${WITH_LEGACY}#g" \
297
+ -e "s#@WITH_C14N@#${WITH_C14N}#g" \
298
+ -e "s#@WITH_CATALOG@#${WITH_CATALOG}#g" \
299
+ -e "s#@WITH_DOCB@#${WITH_DOCB}#g" \
300
+ -e "s#@WITH_XPATH@#${WITH_XPATH}#g" \
301
+ -e "s#@WITH_XPTR@#${WITH_XPTR}#g" \
302
+ -e "s#@WITH_XINCLUDE@#${WITH_XINCLUDE}#g" \
303
+ -e "s#@WITH_ICONV@#${WITH_ICONV}#g" \
304
+ -e "s#@WITH_ICU@#${WITH_ICU}#g" \
305
+ -e "s#@WITH_ISO8859X@#${WITH_ISO8859X}#g" \
306
+ -e "s#@WITH_DEBUG@#${WITH_DEBUG}#g" \
307
+ -e "s#@WITH_MEM_DEBUG@#${WITH_MEM_DEBUG}#g" \
308
+ -e "s#@WITH_RUN_DEBUG@#${WITH_RUN_DEBUG}#g" \
309
+ -e "s#@WITH_REGEXPS@#${WITH_REGEXPS}#g" \
310
+ -e "s#@WITH_SCHEMAS@#${WITH_SCHEMAS}#g" \
311
+ -e "s#@WITH_SCHEMATRON@#${WITH_SCHEMATRON}#g" \
312
+ -e "s#@WITH_MODULES@#${WITH_MODULES}#g" \
313
+ -e "s#@WITH_ZLIB@#${WITH_ZLIB}#g" \
314
+ -e "s#@WITH_LZMA@#${WITH_LZMA}#g"
315
+ }
local-test-libxml2-full-01/afc-libxml2/os400/libxmlmain.c ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *** QADRT/QADRTMAIN2 substitution program.
3
+ *** This is needed because the IBM-provided QADRTMAIN2 does not
4
+ *** properly translate arguments by default or if no locale is provided.
5
+ ***
6
+ *** See Copyright for the status of this software.
7
+ ***
8
+ *** Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
9
+ **/
10
+
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+ #include <iconv.h>
14
+ #include <errno.h>
15
+ #include <locale.h>
16
+
17
+ /* Do not use qadrt.h since it defines unneeded static procedures. */
18
+ extern void QadrtInit(void);
19
+ extern int QadrtFreeConversionTable(void);
20
+ extern int QadrtFreeEnviron(void);
21
+ extern char * setlocale_a(int, const char *);
22
+
23
+
24
+ /* The ASCII main program. */
25
+ extern int main_a(int argc, char * * argv);
26
+
27
+ /* Global values of original EBCDIC arguments. */
28
+ int ebcdic_argc;
29
+ char * * ebcdic_argv;
30
+
31
+
32
+ int
33
+ main(int argc, char * * argv)
34
+
35
+ {
36
+ int i;
37
+ int j;
38
+ iconv_t cd;
39
+ size_t bytecount = 0;
40
+ char * inbuf;
41
+ char * outbuf;
42
+ size_t inbytesleft;
43
+ size_t outbytesleft;
44
+ char dummybuf[128];
45
+ char tocode[32];
46
+ char fromcode[32];
47
+
48
+ ebcdic_argc = argc;
49
+ ebcdic_argv = argv;
50
+
51
+ /* Build the encoding converter. */
52
+ strncpy(tocode, "IBMCCSID01208", sizeof tocode);
53
+ strncpy(fromcode, "IBMCCSID000000000010", sizeof fromcode);
54
+ cd = iconv_open(tocode, fromcode);
55
+
56
+ /* Measure the arguments. */
57
+ for (i = 0; i < argc; i++) {
58
+ inbuf = argv[i];
59
+ do {
60
+ inbytesleft = 0;
61
+ outbuf = dummybuf;
62
+ outbytesleft = sizeof dummybuf;
63
+ j = iconv(cd,
64
+ &inbuf, &inbytesleft, &outbuf, &outbytesleft);
65
+ bytecount += outbuf - dummybuf;
66
+ } while (j == -1 && errno == E2BIG);
67
+ /* Reset the shift state. */
68
+ iconv(cd, NULL, &inbytesleft, &outbuf, &outbytesleft);
69
+ }
70
+
71
+ /* Allocate memory for the ASCII arguments and vector. */
72
+ argv = (char * *) malloc((argc + 1) * sizeof *argv + bytecount);
73
+
74
+ /* Build the vector and convert argument encoding. */
75
+ outbuf = (char *) (argv + argc + 1);
76
+ outbytesleft = bytecount;
77
+
78
+ for (i = 0; i < argc; i++) {
79
+ argv[i] = outbuf;
80
+ inbuf = ebcdic_argv[i];
81
+ inbytesleft = 0;
82
+ iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
83
+ iconv(cd, NULL, &inbytesleft, &outbuf, &outbytesleft);
84
+ }
85
+
86
+ iconv_close(cd);
87
+ argv[argc] = NULL;
88
+
89
+ /* Try setting the locale regardless of QADRT_ENV_LOCALE. */
90
+ setlocale_a(LC_ALL, "");
91
+
92
+ /* Call the program. */
93
+ i = main_a(argc, argv);
94
+
95
+ /* Clean-up allocated items. */
96
+ free((char *) argv);
97
+ QadrtFreeConversionTable();
98
+ QadrtFreeEnviron();
99
+
100
+ /* Terminate. */
101
+ return i;
102
+ }
local-test-libxml2-full-01/afc-libxml2/os400/make-bldcsndfa.sh ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ #
3
+ # Compilation script for the iconv names DFA builer.
4
+ #
5
+ # See Copyright for the status of this software.
6
+ #
7
+ # Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
8
+ #
9
+
10
+ SCRIPTDIR=`dirname "${0}"`
11
+ . "${SCRIPTDIR}/initscript.sh"
12
+ cd "${TOPDIR}/os400/iconv/bldcsndfa"
13
+
14
+
15
+ # This is for old XML library (bootstrapping).
16
+ #rm -rf xml.h xml
17
+ #ln -s /QSYS.LIB/XML.LIB/H.FILE/XML.MBR xml.h
18
+ #mkdir xml
19
+ #mkdir xml/h
20
+ #ln -s /QSYS.LIB/XML.LIB/H.FILE/UTF8.MBR xml/h/utf8
21
+
22
+
23
+ # Compile.
24
+
25
+ CMD="CRTCMOD MODULE(${TARGETLIB}/BLDCSNDFA) SRCSTMF('bldcsndfa.c')"
26
+ CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
27
+ CMD="${CMD} INCDIR("
28
+ CMD="${CMD} '${IFSDIR}/include' ${INCLUDES})"
29
+ CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
30
+ CMD="${CMD} OUTPUT(${OUTPUT})"
31
+ CMD="${CMD} OPTIMIZE(10)"
32
+ CMD="${CMD} DBGVIEW(${DEBUG})"
33
+ #CMD="${CMD} DEFINE('OLDXML' 'xmlXPathSetContextNode=xmlXPathSetCurrentNode')"
34
+
35
+ system "${CMD}"
36
+
37
+ # Link
38
+
39
+ CMD="CRTPGM PGM(${TARGETLIB}/BLDCSNDFA) MODULE(${TARGETLIB}/BLDCSNDFA)"
40
+ CMD="${CMD} BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
41
+ #CMD="${CMD} BNDDIR(XML/XML)"
42
+ CMD="${CMD} TGTRLS(${TGTRLS})"
43
+ system "${CMD}"
local-test-libxml2-full-01/afc-libxml2/os400/make-include.sh ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ #
3
+ # Installation of the C header files in the OS/400 library.
4
+ #
5
+ # See Copyright for the status of this software.
6
+ #
7
+ # Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
8
+ #
9
+
10
+ SCRIPTDIR=`dirname "${0}"`
11
+ . "${SCRIPTDIR}/initscript.sh"
12
+ cd "${TOPDIR}/include"
13
+
14
+
15
+ # Create the OS/400 source program file for the C header files.
16
+
17
+ SRCPF="${LIBIFSNAME}/LIBXML.FILE"
18
+
19
+ if action_needed "${SRCPF}"
20
+ then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXML) RCDLEN(112)"
21
+ CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: C/C++ header files')"
22
+ system "${CMD}"
23
+ fi
24
+
25
+
26
+ # Create the IFS directory for the C header files.
27
+
28
+ if action_needed "${IFSDIR}/include/libxml"
29
+ then mkdir -p "${IFSDIR}/include/libxml"
30
+ fi
31
+
32
+
33
+
34
+ # Enumeration values may be used as va_arg tagfields, so they MUST be
35
+ # integers.
36
+
37
+ copy_hfile()
38
+
39
+ {
40
+ sed -e '1i\
41
+ #pragma enum(int)\
42
+ ' "${@}" -e '$a\
43
+ #pragma enum(pop)\
44
+ '
45
+ }
46
+
47
+ # Copy the header files to DB2 library. Link from IFS include directory.
48
+
49
+ for HFILE in "${TOPDIR}/os400/transcode.h" libxml/*.h libxml/*.h.in
50
+ do CMD="cat \"${HFILE}\""
51
+ DEST="${SRCPF}/`db2_name \"${HFILE}\" nomangle`.MBR"
52
+
53
+ case "`basename \"${HFILE}\"`" in
54
+
55
+ *.in) CMD="${CMD} | versioned_copy";;
56
+
57
+ xmlschemastypes.h) # Special case: rename colliding file.
58
+ DEST="${SRCPF}/SCHMTYPES.MBR";;
59
+
60
+ esac
61
+
62
+ if action_needed "${DEST}" "${HFILE}"
63
+ then eval "${CMD}" | copy_hfile > tmphdrfile
64
+
65
+ # Need to translate to target CCSID.
66
+
67
+ CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
68
+ CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
69
+ system "${CMD}"
70
+ fi
71
+
72
+ IFSFILE="${IFSDIR}/include/libxml/`basename \"${HFILE}\" .in`"
73
+
74
+ if action_needed "${IFSFILE}" "${DEST}"
75
+ then rm -f "${IFSFILE}"
76
+ ln -s "${DEST}" "${IFSFILE}"
77
+ fi
78
+ done
local-test-libxml2-full-01/afc-libxml2/os400/make-rpg.sh ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ #
3
+ # Installation of the ILE/RPG header files in the OS/400 library.
4
+ #
5
+ # See Copyright for the status of this software.
6
+ #
7
+ # Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
8
+ #
9
+
10
+ SCRIPTDIR=`dirname "${0}"`
11
+ . "${SCRIPTDIR}/initscript.sh"
12
+ cd "${TOPDIR}/os400/libxmlrpg"
13
+
14
+
15
+ # Create the OS/400 source program file for the ILE/RPG header files.
16
+
17
+ SRCPF="${LIBIFSNAME}/LIBXMLRPG.FILE"
18
+
19
+ if action_needed "${SRCPF}"
20
+ then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXMLRPG) RCDLEN(112)"
21
+ CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: ILE/RPG header files')"
22
+ system "${CMD}"
23
+ fi
24
+
25
+
26
+ # Map file names to DB2 name syntax.
27
+
28
+ for HFILE in *.rpgle *.rpgle.in
29
+ do NAME="`basename \"${HFILE}\" .in`"
30
+ VAR="`basename \"${NAME}\" .rpgle`"
31
+ VAL="`db2_name \"${NAME}\" nomangle`"
32
+
33
+ if [ "${VAR}" = 'xmlschemastypes' ]
34
+ then VAL=SCHMTYPES
35
+ fi
36
+
37
+ eval "VAR_${VAR}=\"${VAL}\""
38
+ echo "${VAR} s/${VAR}/${VAL}/g"
39
+ done > tmpsubstfile1
40
+
41
+ # Order substitution commands so that a prefix appears after all
42
+ # file names beginning with the prefix.
43
+
44
+ sort -r tmpsubstfile1 | sed 's/^[^ ]*[ ]*//' > tmpsubstfile2
45
+
46
+
47
+ change_include()
48
+
49
+ {
50
+ sed -e '\#^....../include *"libxmlrpg/#{' \
51
+ -e 's///' \
52
+ -e 's/".*//' \
53
+ -f tmpsubstfile2 \
54
+ -e 's#.*# /include libxmlrpg,&#' \
55
+ -e '}'
56
+ }
57
+
58
+
59
+ # Create the IFS directory for the ILE/RPG header files.
60
+
61
+ RPGIFSDIR="${IFSDIR}/include/libxmlrpg"
62
+
63
+ if action_needed "${RPGIFSDIR}"
64
+ then mkdir -p "${RPGIFSDIR}"
65
+ fi
66
+
67
+ # Copy the header files to IFS ILE/RPG include directory.
68
+ # Copy them with include path editing to the DB2 library.
69
+
70
+ for HFILE in *.rpgle *.rpgle.in
71
+ do IFSCMD="cat \"${HFILE}\""
72
+ DB2CMD="change_include < \"${HFILE}\""
73
+ IFSFILE="`basename \"${HFILE}\" .in`"
74
+
75
+ case "${HFILE}" in
76
+
77
+ *.in) IFSCMD="${IFSCMD} | versioned_copy"
78
+ DB2CMD="${DB2CMD} | versioned_copy"
79
+ ;;
80
+ esac
81
+
82
+ IFSDEST="${RPGIFSDIR}/${IFSFILE}"
83
+
84
+ if action_needed "${IFSDEST}" "${HFILE}"
85
+ then eval "${IFSCMD}" > "${IFSDEST}"
86
+ fi
87
+
88
+ eval DB2MBR="\"\${VAR_`basename \"${IFSDEST}\" .rpgle`}\""
89
+ DB2DEST="${SRCPF}/${DB2MBR}.MBR"
90
+
91
+ if action_needed "${DB2DEST}" "${HFILE}"
92
+ then eval "${DB2CMD}" | change_include > tmphdrfile
93
+
94
+ # Need to translate to target CCSID.
95
+
96
+ CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DB2DEST}')"
97
+ CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
98
+ system "${CMD}"
99
+ fi
100
+ done