libxml-ruby 3.2.2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/HISTORY +848 -0
  3. data/LICENSE +21 -0
  4. data/MANIFEST +166 -0
  5. data/README.rdoc +217 -0
  6. data/Rakefile +99 -0
  7. data/ext/libxml/extconf.rb +61 -0
  8. data/ext/libxml/libxml.c +80 -0
  9. data/ext/libxml/libxml_ruby.def +35 -0
  10. data/ext/libxml/ruby_libxml.h +67 -0
  11. data/ext/libxml/ruby_xml.c +933 -0
  12. data/ext/libxml/ruby_xml.h +10 -0
  13. data/ext/libxml/ruby_xml_attr.c +333 -0
  14. data/ext/libxml/ruby_xml_attr.h +12 -0
  15. data/ext/libxml/ruby_xml_attr_decl.c +153 -0
  16. data/ext/libxml/ruby_xml_attr_decl.h +11 -0
  17. data/ext/libxml/ruby_xml_attributes.c +275 -0
  18. data/ext/libxml/ruby_xml_attributes.h +15 -0
  19. data/ext/libxml/ruby_xml_cbg.c +85 -0
  20. data/ext/libxml/ruby_xml_document.c +1123 -0
  21. data/ext/libxml/ruby_xml_document.h +11 -0
  22. data/ext/libxml/ruby_xml_dtd.c +248 -0
  23. data/ext/libxml/ruby_xml_dtd.h +9 -0
  24. data/ext/libxml/ruby_xml_encoding.c +250 -0
  25. data/ext/libxml/ruby_xml_encoding.h +16 -0
  26. data/ext/libxml/ruby_xml_error.c +996 -0
  27. data/ext/libxml/ruby_xml_error.h +12 -0
  28. data/ext/libxml/ruby_xml_html_parser.c +89 -0
  29. data/ext/libxml/ruby_xml_html_parser.h +10 -0
  30. data/ext/libxml/ruby_xml_html_parser_context.c +337 -0
  31. data/ext/libxml/ruby_xml_html_parser_context.h +10 -0
  32. data/ext/libxml/ruby_xml_html_parser_options.c +46 -0
  33. data/ext/libxml/ruby_xml_html_parser_options.h +10 -0
  34. data/ext/libxml/ruby_xml_input_cbg.c +191 -0
  35. data/ext/libxml/ruby_xml_input_cbg.h +20 -0
  36. data/ext/libxml/ruby_xml_io.c +47 -0
  37. data/ext/libxml/ruby_xml_io.h +10 -0
  38. data/ext/libxml/ruby_xml_namespace.c +153 -0
  39. data/ext/libxml/ruby_xml_namespace.h +10 -0
  40. data/ext/libxml/ruby_xml_namespaces.c +293 -0
  41. data/ext/libxml/ruby_xml_namespaces.h +9 -0
  42. data/ext/libxml/ruby_xml_node.c +1402 -0
  43. data/ext/libxml/ruby_xml_node.h +13 -0
  44. data/ext/libxml/ruby_xml_parser.c +91 -0
  45. data/ext/libxml/ruby_xml_parser.h +12 -0
  46. data/ext/libxml/ruby_xml_parser_context.c +999 -0
  47. data/ext/libxml/ruby_xml_parser_context.h +10 -0
  48. data/ext/libxml/ruby_xml_parser_options.c +66 -0
  49. data/ext/libxml/ruby_xml_parser_options.h +12 -0
  50. data/ext/libxml/ruby_xml_reader.c +1239 -0
  51. data/ext/libxml/ruby_xml_reader.h +17 -0
  52. data/ext/libxml/ruby_xml_relaxng.c +110 -0
  53. data/ext/libxml/ruby_xml_relaxng.h +10 -0
  54. data/ext/libxml/ruby_xml_sax2_handler.c +326 -0
  55. data/ext/libxml/ruby_xml_sax2_handler.h +10 -0
  56. data/ext/libxml/ruby_xml_sax_parser.c +116 -0
  57. data/ext/libxml/ruby_xml_sax_parser.h +10 -0
  58. data/ext/libxml/ruby_xml_schema.c +278 -0
  59. data/ext/libxml/ruby_xml_schema.h +809 -0
  60. data/ext/libxml/ruby_xml_schema_attribute.c +109 -0
  61. data/ext/libxml/ruby_xml_schema_attribute.h +15 -0
  62. data/ext/libxml/ruby_xml_schema_element.c +95 -0
  63. data/ext/libxml/ruby_xml_schema_element.h +14 -0
  64. data/ext/libxml/ruby_xml_schema_facet.c +52 -0
  65. data/ext/libxml/ruby_xml_schema_facet.h +13 -0
  66. data/ext/libxml/ruby_xml_schema_type.c +232 -0
  67. data/ext/libxml/ruby_xml_schema_type.h +9 -0
  68. data/ext/libxml/ruby_xml_version.h +9 -0
  69. data/ext/libxml/ruby_xml_writer.c +1133 -0
  70. data/ext/libxml/ruby_xml_writer.h +10 -0
  71. data/ext/libxml/ruby_xml_xinclude.c +16 -0
  72. data/ext/libxml/ruby_xml_xinclude.h +11 -0
  73. data/ext/libxml/ruby_xml_xpath.c +194 -0
  74. data/ext/libxml/ruby_xml_xpath.h +13 -0
  75. data/ext/libxml/ruby_xml_xpath_context.c +360 -0
  76. data/ext/libxml/ruby_xml_xpath_context.h +9 -0
  77. data/ext/libxml/ruby_xml_xpath_expression.c +81 -0
  78. data/ext/libxml/ruby_xml_xpath_expression.h +10 -0
  79. data/ext/libxml/ruby_xml_xpath_object.c +338 -0
  80. data/ext/libxml/ruby_xml_xpath_object.h +17 -0
  81. data/ext/libxml/ruby_xml_xpointer.c +99 -0
  82. data/ext/libxml/ruby_xml_xpointer.h +11 -0
  83. data/ext/vc/libxml_ruby.sln +28 -0
  84. data/lib/3.1/libxml_ruby.so +0 -0
  85. data/lib/libxml/attr.rb +123 -0
  86. data/lib/libxml/attr_decl.rb +80 -0
  87. data/lib/libxml/attributes.rb +14 -0
  88. data/lib/libxml/document.rb +194 -0
  89. data/lib/libxml/error.rb +95 -0
  90. data/lib/libxml/hpricot.rb +78 -0
  91. data/lib/libxml/html_parser.rb +96 -0
  92. data/lib/libxml/namespace.rb +62 -0
  93. data/lib/libxml/namespaces.rb +38 -0
  94. data/lib/libxml/node.rb +323 -0
  95. data/lib/libxml/parser.rb +101 -0
  96. data/lib/libxml/sax_callbacks.rb +180 -0
  97. data/lib/libxml/sax_parser.rb +41 -0
  98. data/lib/libxml/schema/attribute.rb +19 -0
  99. data/lib/libxml/schema/element.rb +19 -0
  100. data/lib/libxml/schema/type.rb +21 -0
  101. data/lib/libxml/schema.rb +48 -0
  102. data/lib/libxml/tree.rb +29 -0
  103. data/lib/libxml-ruby.rb +30 -0
  104. data/lib/libxml.rb +5 -0
  105. data/lib/xml/libxml.rb +10 -0
  106. data/lib/xml.rb +14 -0
  107. data/libxml-ruby.gemspec +48 -0
  108. data/script/benchmark/depixelate +634 -0
  109. data/script/benchmark/hamlet.xml +9055 -0
  110. data/script/benchmark/parsecount +170 -0
  111. data/script/benchmark/sock_entries.xml +507 -0
  112. data/script/benchmark/throughput +41 -0
  113. data/script/test +6 -0
  114. data/setup.rb +1584 -0
  115. data/test/c14n/given/doc.dtd +1 -0
  116. data/test/c14n/given/example-1.xml +14 -0
  117. data/test/c14n/given/example-2.xml +11 -0
  118. data/test/c14n/given/example-3.xml +18 -0
  119. data/test/c14n/given/example-4.xml +9 -0
  120. data/test/c14n/given/example-5.xml +12 -0
  121. data/test/c14n/given/example-6.xml +2 -0
  122. data/test/c14n/given/example-7.xml +11 -0
  123. data/test/c14n/given/example-8.xml +11 -0
  124. data/test/c14n/given/example-8.xpath +10 -0
  125. data/test/c14n/given/world.txt +1 -0
  126. data/test/c14n/result/1-1-without-comments/example-1 +4 -0
  127. data/test/c14n/result/1-1-without-comments/example-2 +11 -0
  128. data/test/c14n/result/1-1-without-comments/example-3 +14 -0
  129. data/test/c14n/result/1-1-without-comments/example-4 +9 -0
  130. data/test/c14n/result/1-1-without-comments/example-5 +3 -0
  131. data/test/c14n/result/1-1-without-comments/example-6 +1 -0
  132. data/test/c14n/result/1-1-without-comments/example-7 +1 -0
  133. data/test/c14n/result/1-1-without-comments/example-8 +1 -0
  134. data/test/c14n/result/with-comments/example-1 +6 -0
  135. data/test/c14n/result/with-comments/example-2 +11 -0
  136. data/test/c14n/result/with-comments/example-3 +14 -0
  137. data/test/c14n/result/with-comments/example-4 +9 -0
  138. data/test/c14n/result/with-comments/example-5 +4 -0
  139. data/test/c14n/result/with-comments/example-6 +1 -0
  140. data/test/c14n/result/with-comments/example-7 +1 -0
  141. data/test/c14n/result/without-comments/example-1 +4 -0
  142. data/test/c14n/result/without-comments/example-2 +11 -0
  143. data/test/c14n/result/without-comments/example-3 +14 -0
  144. data/test/c14n/result/without-comments/example-4 +9 -0
  145. data/test/c14n/result/without-comments/example-5 +3 -0
  146. data/test/c14n/result/without-comments/example-6 +1 -0
  147. data/test/c14n/result/without-comments/example-7 +1 -0
  148. data/test/model/atom.xml +13 -0
  149. data/test/model/bands.iso-8859-1.xml +5 -0
  150. data/test/model/bands.utf-8.xml +5 -0
  151. data/test/model/bands.xml +5 -0
  152. data/test/model/books.xml +154 -0
  153. data/test/model/cwm_1_0.xml +11336 -0
  154. data/test/model/merge_bug_data.xml +58 -0
  155. data/test/model/ruby-lang.html +238 -0
  156. data/test/model/rubynet.xml +79 -0
  157. data/test/model/rubynet_project +1 -0
  158. data/test/model/shiporder.rnc +28 -0
  159. data/test/model/shiporder.rng +86 -0
  160. data/test/model/shiporder.xml +23 -0
  161. data/test/model/shiporder.xsd +40 -0
  162. data/test/model/soap.xml +27 -0
  163. data/test/model/xinclude.xml +5 -0
  164. data/test/test_attr.rb +181 -0
  165. data/test/test_attr_decl.rb +132 -0
  166. data/test/test_attributes.rb +136 -0
  167. data/test/test_canonicalize.rb +120 -0
  168. data/test/test_deprecated_require.rb +12 -0
  169. data/test/test_document.rb +132 -0
  170. data/test/test_document_write.rb +146 -0
  171. data/test/test_dtd.rb +129 -0
  172. data/test/test_encoding.rb +129 -0
  173. data/test/test_encoding_sax.rb +115 -0
  174. data/test/test_error.rb +178 -0
  175. data/test/test_helper.rb +9 -0
  176. data/test/test_html_parser.rb +162 -0
  177. data/test/test_html_parser_context.rb +23 -0
  178. data/test/test_namespace.rb +60 -0
  179. data/test/test_namespaces.rb +200 -0
  180. data/test/test_node.rb +237 -0
  181. data/test/test_node_cdata.rb +50 -0
  182. data/test/test_node_comment.rb +32 -0
  183. data/test/test_node_copy.rb +40 -0
  184. data/test/test_node_edit.rb +158 -0
  185. data/test/test_node_pi.rb +37 -0
  186. data/test/test_node_text.rb +69 -0
  187. data/test/test_node_write.rb +97 -0
  188. data/test/test_node_xlink.rb +28 -0
  189. data/test/test_parser.rb +324 -0
  190. data/test/test_parser_context.rb +198 -0
  191. data/test/test_properties.rb +38 -0
  192. data/test/test_reader.rb +364 -0
  193. data/test/test_relaxng.rb +53 -0
  194. data/test/test_sax_parser.rb +326 -0
  195. data/test/test_schema.rb +168 -0
  196. data/test/test_suite.rb +48 -0
  197. data/test/test_traversal.rb +152 -0
  198. data/test/test_writer.rb +468 -0
  199. data/test/test_xinclude.rb +20 -0
  200. data/test/test_xml.rb +263 -0
  201. data/test/test_xpath.rb +244 -0
  202. data/test/test_xpath_context.rb +88 -0
  203. data/test/test_xpath_expression.rb +37 -0
  204. data/test/test_xpointer.rb +72 -0
  205. metadata +325 -0
@@ -0,0 +1,933 @@
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml.h"
3
+
4
+ VALUE mXML;
5
+
6
+ /*
7
+ * call-seq:
8
+ * XML.catalog_dump -> true
9
+ *
10
+ * Dump all the global catalog content stdout.
11
+ */
12
+ static VALUE rxml_catalog_dump(VALUE self)
13
+ {
14
+ xmlCatalogDump(stdout);
15
+ return (Qtrue);
16
+ }
17
+
18
+ /*
19
+ * call-seq:
20
+ * XML.catalog_remove(catalog) -> true
21
+ *
22
+ * Remove the specified resource catalog.
23
+ */
24
+ static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
25
+ {
26
+ Check_Type(cat, T_STRING);
27
+ xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
28
+ return (Qtrue);
29
+ }
30
+
31
+ /*
32
+ * call-seq:
33
+ * XML.check_lib_versions -> true
34
+ *
35
+ * Check LIBXML version matches version the bindings
36
+ * were compiled to. Throws an exception if not.
37
+ */
38
+ static VALUE rxml_check_lib_versions(VALUE klass)
39
+ {
40
+ xmlCheckVersion(LIBXML_VERSION);
41
+ return (Qtrue);
42
+ }
43
+
44
+ /*
45
+ * call-seq:
46
+ * XML.enabled_automata? -> (true|false)
47
+ *
48
+ * Determine whether libxml regexp automata support is enabled.
49
+ */
50
+ static VALUE rxml_enabled_automata_q(VALUE klass)
51
+ {
52
+ #ifdef LIBXML_AUTOMATA_ENABLED
53
+ return(Qtrue);
54
+ #else
55
+ return (Qfalse);
56
+ #endif
57
+ }
58
+
59
+ /*
60
+ * call-seq:
61
+ * XML.enabled_c14n? -> (true|false)
62
+ *
63
+ * Determine whether libxml 'canonical XML' support is enabled.
64
+ * See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
65
+ */
66
+ static VALUE rxml_enabled_c14n_q(VALUE klass)
67
+ {
68
+ #ifdef LIBXML_C14N_ENABLED
69
+ return(Qtrue);
70
+ #else
71
+ return (Qfalse);
72
+ #endif
73
+ }
74
+
75
+ /*
76
+ * call-seq:
77
+ * XML.enabled_catalog? -> (true|false)
78
+ *
79
+ * Determine whether libxml resource catalog support is enabled.
80
+ */
81
+ static VALUE rxml_enabled_catalog_q(VALUE klass)
82
+ {
83
+ #ifdef LIBXML_CATALOG_ENABLED
84
+ return(Qtrue);
85
+ #else
86
+ return (Qfalse);
87
+ #endif
88
+ }
89
+
90
+ /*
91
+ * call-seq:
92
+ * XML.enabled_debug? -> (true|false)
93
+ *
94
+ * Determine whether libxml debugging support is enabled.
95
+ */
96
+ static VALUE rxml_enabled_debug_q(VALUE klass)
97
+ {
98
+ #ifdef LIBXML_DEBUG_ENABLED
99
+ return(Qtrue);
100
+ #else
101
+ return (Qfalse);
102
+ #endif
103
+ }
104
+
105
+ /*
106
+ * call-seq:
107
+ * XML.enabled_docbook? -> (true|false)
108
+ *
109
+ * Determine whether libxml docbook support is enabled.
110
+ */
111
+ static VALUE rxml_enabled_docbook_q(VALUE klass)
112
+ {
113
+ #ifdef LIBXML_DOCB_ENABLED
114
+ return(Qtrue);
115
+ #else
116
+ return (Qfalse);
117
+ #endif
118
+ }
119
+
120
+ /*
121
+ * call-seq:
122
+ * XML.enabled_ftp? -> (true|false)
123
+ *
124
+ * Determine whether libxml ftp client support is enabled.
125
+ */
126
+ static VALUE rxml_enabled_ftp_q(VALUE klass)
127
+ {
128
+ #ifdef LIBXML_FTP_ENABLED
129
+ return(Qtrue);
130
+ #else
131
+ return (Qfalse);
132
+ #endif
133
+ }
134
+
135
+ /*
136
+ * call-seq:
137
+ * XML.enabled_http? -> (true|false)
138
+ *
139
+ * Determine whether libxml http client support is enabled.
140
+ */
141
+ static VALUE rxml_enabled_http_q(VALUE klass)
142
+ {
143
+ #ifdef LIBXML_HTTP_ENABLED
144
+ return(Qtrue);
145
+ #else
146
+ return (Qfalse);
147
+ #endif
148
+ }
149
+
150
+ /*
151
+ * call-seq:
152
+ * XML.enabled_html? -> (true|false)
153
+ *
154
+ * Determine whether libxml html support is enabled.
155
+ */
156
+ static VALUE rxml_enabled_html_q(VALUE klass)
157
+ {
158
+ #ifdef LIBXML_HTML_ENABLED
159
+ return(Qtrue);
160
+ #else
161
+ return (Qfalse);
162
+ #endif
163
+ }
164
+
165
+ /*
166
+ * call-seq:
167
+ * XML.enabled_iconv? -> (true|false)
168
+ *
169
+ * Determine whether libxml iconv support is enabled.
170
+ */
171
+ static VALUE rxml_enabled_iconv_q(VALUE klass)
172
+ {
173
+ #ifdef LIBXML_ICONV_ENABLED
174
+ return(Qtrue);
175
+ #else
176
+ return (Qfalse);
177
+ #endif
178
+ }
179
+
180
+ /*
181
+ * call-seq:
182
+ * XML.enabled_memory_debug? -> (true|false)
183
+ *
184
+ * Determine whether libxml memory location debugging support
185
+ * is enabled.
186
+ */
187
+ static VALUE rxml_enabled_memory_debug_location_q(VALUE klass)
188
+ {
189
+ #ifdef DEBUG_MEMORY_LOCATION
190
+ return(Qtrue);
191
+ #else
192
+ return (Qfalse);
193
+ #endif
194
+ }
195
+
196
+ /*
197
+ * call-seq:
198
+ * XML.enabled_regexp? -> (true|false)
199
+ *
200
+ * Determine whether libxml regular expression support is enabled.
201
+ */
202
+ static VALUE rxml_enabled_regexp_q(VALUE klass)
203
+ {
204
+ #ifdef LIBXML_REGEXP_ENABLED
205
+ return(Qtrue);
206
+ #else
207
+ return (Qfalse);
208
+ #endif
209
+ }
210
+
211
+ /*
212
+ * call-seq:
213
+ * XML.enabled_schemas? -> (true|false)
214
+ *
215
+ * Determine whether libxml schema support is enabled.
216
+ */
217
+ static VALUE rxml_enabled_schemas_q(VALUE klass)
218
+ {
219
+ #ifdef LIBXML_SCHEMAS_ENABLED
220
+ return(Qtrue);
221
+ #else
222
+ return (Qfalse);
223
+ #endif
224
+ }
225
+
226
+ /*
227
+ * call-seq:
228
+ * XML.enabled_thread? -> (true|false)
229
+ *
230
+ * Determine whether thread-safe semantics support for libxml is enabled and
231
+ * is used by this ruby extension. Threading support in libxml uses pthread
232
+ * on Unix-like systems and Win32 threads on Windows.
233
+ */
234
+ static VALUE rxml_enabled_thread_q(VALUE klass)
235
+ {
236
+ /* This won't be defined unless this code is compiled with _REENTRANT or __MT__
237
+ * defined or the compiler is in C99 mode.
238
+ *
239
+ * Note the relevant portion libxml/xmlversion.h on a thread-enabled build:
240
+ *
241
+ * #if defined(_REENTRANT) || defined(__MT__) || \
242
+ * (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
243
+ * #define LIBXML_THREAD_ENABLED
244
+ * #endif
245
+ *
246
+ */
247
+ #ifdef LIBXML_THREAD_ENABLED
248
+ return(Qtrue);
249
+ #else
250
+ return (Qfalse);
251
+ #endif
252
+ }
253
+
254
+ /*
255
+ * call-seq:
256
+ * XML.enabled_unicode? -> (true|false)
257
+ *
258
+ * Determine whether libxml unicode support is enabled.
259
+ */
260
+ static VALUE rxml_enabled_unicode_q(VALUE klass)
261
+ {
262
+ #ifdef LIBXML_UNICODE_ENABLED
263
+ return(Qtrue);
264
+ #else
265
+ return (Qfalse);
266
+ #endif
267
+ }
268
+
269
+ /*
270
+ * call-seq:
271
+ * XML.enabled_xinclude? -> (true|false)
272
+ *
273
+ * Determine whether libxml xinclude support is enabled.
274
+ */
275
+ static VALUE rxml_enabled_xinclude_q(VALUE klass)
276
+ {
277
+ #ifdef LIBXML_XINCLUDE_ENABLED
278
+ return(Qtrue);
279
+ #else
280
+ return (Qfalse);
281
+ #endif
282
+ }
283
+
284
+ /*
285
+ * call-seq:
286
+ * XML.enabled_xpath? -> (true|false)
287
+ *
288
+ * Determine whether libxml xpath support is enabled.
289
+ */
290
+ static VALUE rxml_enabled_xpath_q(VALUE klass)
291
+ {
292
+ #ifdef LIBXML_XPATH_ENABLED
293
+ return(Qtrue);
294
+ #else
295
+ return (Qfalse);
296
+ #endif
297
+ }
298
+
299
+ /*
300
+ * call-seq:
301
+ * XML.enabled_xpointer? -> (true|false)
302
+ *
303
+ * Determine whether libxml xpointer support is enabled.
304
+ */
305
+ static VALUE rxml_enabled_xpointer_q(VALUE klass)
306
+ {
307
+ #ifdef LIBXML_XPTR_ENABLED
308
+ return(Qtrue);
309
+ #else
310
+ return (Qfalse);
311
+ #endif
312
+ }
313
+
314
+ /*
315
+ * call-seq:
316
+ * XML.enabled_zlib? -> (true|false)
317
+ *
318
+ * Determine whether libxml zlib support is enabled.
319
+ */
320
+ static VALUE rxml_enabled_zlib_q(VALUE klass)
321
+ {
322
+ #ifdef HAVE_ZLIB_H
323
+ return(Qtrue);
324
+ #else
325
+ return (Qfalse);
326
+ #endif
327
+ }
328
+
329
+ /*
330
+ * call-seq:
331
+ * XML.debug_entities -> (true|false)
332
+ *
333
+ * Determine whether included-entity debugging is enabled.
334
+ * (Requires Libxml to be compiled with debugging support)
335
+ */
336
+ static VALUE rxml_debug_entities_get(VALUE klass)
337
+ {
338
+ #ifdef LIBXML_DEBUG_ENABLED
339
+ if (xmlParserDebugEntities)
340
+ return(Qtrue);
341
+ else
342
+ return(Qfalse);
343
+ #else
344
+ rb_warn("libxml was compiled with debugging turned off");
345
+ return (Qfalse);
346
+ #endif
347
+ }
348
+
349
+ /*
350
+ * call-seq:
351
+ * XML.debug_entities = true|false
352
+ *
353
+ * Enable or disable included-entity debugging.
354
+ * (Requires Libxml to be compiled with debugging support)
355
+ */
356
+ static VALUE rxml_debug_entities_set(VALUE klass, VALUE value)
357
+ {
358
+ #ifdef LIBXML_DEBUG_ENABLED
359
+ if (value == Qfalse)
360
+ {
361
+ xmlParserDebugEntities = 0;
362
+ return(Qfalse);
363
+ }
364
+ else
365
+ {
366
+ xmlParserDebugEntities = 1;
367
+ return(Qtrue);
368
+ }
369
+ #else
370
+ rb_warn("libxml was compiled with debugging turned off");
371
+ #endif
372
+ }
373
+
374
+ /*
375
+ * call-seq:
376
+ * XML.default_keep_blanks -> (true|false)
377
+ *
378
+ * Determine whether parsers retain whitespace by default.
379
+ */
380
+ static VALUE rxml_default_keep_blanks_get(VALUE klass)
381
+ {
382
+ if (xmlKeepBlanksDefaultValue)
383
+ return (Qtrue);
384
+ else
385
+ return (Qfalse);
386
+ }
387
+
388
+ /*
389
+ * call-seq:
390
+ * XML.default_keep_blanks = true|false
391
+ *
392
+ * Controls whether parsers retain whitespace by default.
393
+ */
394
+ static VALUE rxml_default_keep_blanks_set(VALUE klass, VALUE value)
395
+ {
396
+ if (value == Qfalse)
397
+ {
398
+ xmlKeepBlanksDefaultValue = 0;
399
+ return (Qfalse);
400
+ }
401
+ else if (value == Qtrue)
402
+ {
403
+ xmlKeepBlanksDefaultValue = 1;
404
+ return (Qtrue);
405
+ }
406
+ else
407
+ {
408
+ rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
409
+ }
410
+ }
411
+
412
+ /*
413
+ * call-seq:
414
+ * XML.default_load_external_dtd -> (true|false)
415
+ *
416
+ * Determine whether parsers load external DTDs by default.
417
+ */
418
+ static VALUE rxml_default_load_external_dtd_get(VALUE klass)
419
+ {
420
+ if (xmlLoadExtDtdDefaultValue)
421
+ return (Qtrue);
422
+ else
423
+ return (Qfalse);
424
+ }
425
+
426
+ /*
427
+ * call-seq:
428
+ * XML.default_load_external_dtd = true|false
429
+ *
430
+ * Controls whether parsers load external DTDs by default.
431
+ */
432
+ static VALUE rxml_default_load_external_dtd_set(VALUE klass, VALUE value)
433
+ {
434
+ if (value == Qfalse)
435
+ {
436
+ xmlLoadExtDtdDefaultValue = 0;
437
+ return (Qfalse);
438
+ }
439
+ else
440
+ {
441
+ xmlLoadExtDtdDefaultValue = 1;
442
+ return (Qtrue);
443
+ }
444
+ }
445
+
446
+ /*
447
+ * call-seq:
448
+ * XML.default_line_numbers -> (true|false)
449
+ *
450
+ * Determine whether parsers retain line-numbers by default.
451
+ */
452
+ static VALUE rxml_default_line_numbers_get(VALUE klass)
453
+ {
454
+ if (xmlLineNumbersDefaultValue)
455
+ return (Qtrue);
456
+ else
457
+ return (Qfalse);
458
+ }
459
+
460
+ /*
461
+ * call-seq:
462
+ * XML.default_line_numbers = true|false
463
+ *
464
+ * Controls whether parsers retain line-numbers by default.
465
+ */
466
+ static VALUE rxml_default_line_numbers_set(VALUE klass, VALUE value)
467
+ {
468
+ if (value == Qfalse)
469
+ {
470
+ xmlLineNumbersDefault(0);
471
+ return (Qfalse);
472
+ }
473
+ else
474
+ {
475
+ xmlLineNumbersDefault(1);
476
+ return (Qtrue);
477
+ }
478
+ }
479
+
480
+ int rxml_libxml_default_options()
481
+ {
482
+ int options = 0;
483
+
484
+ if (xmlLoadExtDtdDefaultValue)
485
+ options |= XML_PARSE_DTDLOAD;
486
+
487
+ if (xmlDoValidityCheckingDefaultValue)
488
+ options |= XML_PARSE_DTDVALID;
489
+
490
+ if (!xmlKeepBlanksDefaultValue)
491
+ options |= XML_PARSE_NOBLANKS;
492
+
493
+ if (xmlSubstituteEntitiesDefaultValue)
494
+ options |= XML_PARSE_NOENT;
495
+
496
+ if (!xmlGetWarningsDefaultValue)
497
+ options |= XML_PARSE_NOWARNING;
498
+
499
+ if (xmlPedanticParserDefaultValue)
500
+ options |= XML_PARSE_PEDANTIC;
501
+
502
+ return options;
503
+ }
504
+
505
+ /*
506
+ * call-seq:
507
+ * XML.default_options -> int
508
+ *
509
+ * Returns an integer that summarize libxml2's default options.
510
+ */
511
+ static VALUE rxml_default_options_get(VALUE klass)
512
+ {
513
+ int options = rxml_libxml_default_options();
514
+ return INT2NUM(options);
515
+ }
516
+
517
+ /*
518
+ * call-seq:
519
+ * XML.default_pedantic_parser -> (true|false)
520
+ *
521
+ * Determine whether parsers are pedantic by default.
522
+ */
523
+ static VALUE rxml_default_pedantic_parser_get(VALUE klass)
524
+ {
525
+ if (xmlPedanticParserDefaultValue)
526
+ return (Qtrue);
527
+ else
528
+ return (Qfalse);
529
+ }
530
+
531
+ /*
532
+ * call-seq:
533
+ * XML.default_pedantic_parser = true|false
534
+ *
535
+ * Controls whether parsers are pedantic by default.
536
+ */
537
+ static VALUE rxml_default_pedantic_parser_set(VALUE klass, VALUE value)
538
+ {
539
+ if (value == Qfalse)
540
+ {
541
+ xmlPedanticParserDefault(0);
542
+ return (Qfalse);
543
+ }
544
+ else
545
+ {
546
+ xmlPedanticParserDefault(1);
547
+ return (Qtrue);
548
+ }
549
+ }
550
+
551
+ /*
552
+ * call-seq:
553
+ * XML.default_substitute_entities -> (true|false)
554
+ *
555
+ * Determine whether parsers perform inline entity substitution
556
+ * (for external entities) by default.
557
+ */
558
+ static VALUE rxml_default_substitute_entities_get(VALUE klass)
559
+ {
560
+ if (xmlSubstituteEntitiesDefaultValue)
561
+ return (Qtrue);
562
+ else
563
+ return (Qfalse);
564
+ }
565
+
566
+ /*
567
+ * call-seq:
568
+ * XML.default_substitute_entities = true|false
569
+ *
570
+ * Controls whether parsers perform inline entity substitution
571
+ * (for external entities) by default.
572
+ */
573
+ static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE value)
574
+ {
575
+ if (value == Qfalse)
576
+ {
577
+ xmlSubstituteEntitiesDefault(0);
578
+ return (Qfalse);
579
+ }
580
+ else
581
+ {
582
+ xmlSubstituteEntitiesDefault(1);
583
+ return (Qtrue);
584
+ }
585
+ }
586
+
587
+ /*
588
+ * call-seq:
589
+ * XML.default_tree_indent_string -> "string"
590
+ *
591
+ * Obtain the default string used by parsers to indent the XML tree
592
+ * for output.
593
+ */
594
+ static VALUE rxml_default_tree_indent_string_get(VALUE klass)
595
+ {
596
+ if (xmlTreeIndentString == NULL)
597
+ return (Qnil);
598
+ else
599
+ return (rb_str_new2(xmlTreeIndentString));
600
+ }
601
+
602
+ /*
603
+ * call-seq:
604
+ * XML.default_tree_indent_string = "string"
605
+ *
606
+ * Set the default string used by parsers to indent the XML tree
607
+ * for output.
608
+ */
609
+ static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
610
+ {
611
+ Check_Type(string, T_STRING);
612
+ xmlTreeIndentString = (const char *)xmlStrdup((xmlChar *)StringValuePtr(string));
613
+ return (string);
614
+ }
615
+
616
+ /*
617
+ * call-seq:
618
+ * XML.default_validity_checking -> (true|false)
619
+ *
620
+ * Determine whether parsers perform XML validation by default.
621
+ */
622
+ static VALUE rxml_default_validity_checking_get(VALUE klass)
623
+ {
624
+ if (xmlDoValidityCheckingDefaultValue)
625
+ return (Qtrue);
626
+ else
627
+ return (Qfalse);
628
+ }
629
+
630
+ /*
631
+ * call-seq:
632
+ * XML.default_validity_checking = true|false
633
+ *
634
+ * Controls whether parsers perform XML validation by default.
635
+ */
636
+ static VALUE rxml_default_validity_checking_set(VALUE klass, VALUE value)
637
+ {
638
+ if (value == Qfalse)
639
+ {
640
+ xmlDoValidityCheckingDefaultValue = 0;
641
+ return (Qfalse);
642
+ }
643
+ else
644
+ {
645
+ xmlDoValidityCheckingDefaultValue = 1;
646
+ return (Qtrue);
647
+ }
648
+ }
649
+
650
+ /*
651
+ * call-seq:
652
+ * XML.default_warnings -> (true|false)
653
+ *
654
+ * Determine whether parsers output warnings by default.
655
+ */
656
+ static VALUE rxml_default_warnings_get(VALUE klass)
657
+ {
658
+ if (xmlGetWarningsDefaultValue)
659
+ return (Qtrue);
660
+ else
661
+ return (Qfalse);
662
+ }
663
+
664
+ /*
665
+ * call-seq:
666
+ * XML.default_warnings = true|false
667
+ *
668
+ * Controls whether parsers output warnings by default.
669
+ */
670
+ static VALUE rxml_default_warnings_set(VALUE klass, VALUE value)
671
+ {
672
+ if (value == Qfalse)
673
+ {
674
+ xmlGetWarningsDefaultValue = 0;
675
+ return (Qfalse);
676
+ }
677
+ else
678
+ {
679
+ xmlGetWarningsDefaultValue = 1;
680
+ return (Qtrue);
681
+ }
682
+ }
683
+
684
+ /*
685
+ * call-seq:
686
+ * XML.default_compression -> (true|false)
687
+ *
688
+ * Determine whether parsers use Zlib compression by default
689
+ * (requires libxml to be compiled with Zlib support).
690
+ */
691
+ static VALUE rxml_default_compression_get(VALUE klass)
692
+ {
693
+ #ifdef HAVE_ZLIB_H
694
+ return(INT2FIX(xmlGetCompressMode()));
695
+ #else
696
+ rb_warn("libxml was compiled without zlib support");
697
+ return (Qfalse);
698
+ #endif
699
+ }
700
+
701
+ /*
702
+ * call-seq:
703
+ * XML.default_compression = true|false
704
+ *
705
+ * Controls whether parsers use Zlib compression by default
706
+ * (requires libxml to be compiled with Zlib support).
707
+ */
708
+ static VALUE rxml_default_compression_set(VALUE klass, VALUE num)
709
+ {
710
+ #ifdef HAVE_ZLIB_H
711
+ Check_Type(num, T_FIXNUM);
712
+ xmlSetCompressMode(FIX2INT(num));
713
+ return(num);
714
+ #else
715
+ rb_warn("libxml was compiled without zlib support");
716
+ return (Qfalse);
717
+ #endif
718
+ }
719
+
720
+ /*
721
+ * call-seq:
722
+ * XML.default_save_no_empty_tags -> (true|false)
723
+ *
724
+ * Determine whether serializer outputs empty tags by default.
725
+ */
726
+ static VALUE rxml_default_save_no_empty_tags_get(VALUE klass)
727
+ {
728
+ if (xmlSaveNoEmptyTags)
729
+ return (Qtrue);
730
+ else
731
+ return (Qfalse);
732
+ }
733
+
734
+ /*
735
+ * call-seq:
736
+ * XML.default_save_no_empty_tags = true|false
737
+ *
738
+ * Controls whether serializer outputs empty tags by default.
739
+ */
740
+ static VALUE rxml_default_save_no_empty_tags_set(VALUE klass, VALUE value)
741
+ {
742
+ if (value == Qfalse)
743
+ {
744
+ xmlSaveNoEmptyTags = 0;
745
+ return (Qfalse);
746
+ }
747
+ else if (value == Qtrue)
748
+ {
749
+ xmlSaveNoEmptyTags = 1;
750
+ return (Qtrue);
751
+ }
752
+ else
753
+ {
754
+ rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
755
+ }
756
+ }
757
+
758
+ /*
759
+ * call-seq:
760
+ * XML.features -> ["feature", ..., "feature"]
761
+ *
762
+ * Obtains an array of strings representing features supported
763
+ * (and enabled) by the installed libxml.
764
+ */
765
+ static VALUE rxml_features(VALUE klass)
766
+ {
767
+ VALUE arr, str;
768
+ int i, len = MAX_LIBXML_FEATURES_LEN;
769
+ char **list = NULL;
770
+
771
+ list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
772
+ MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
773
+
774
+ arr = rb_ary_new();
775
+ if (xmlGetFeaturesList(&len, (const char **) list) == -1)
776
+ return Qnil;
777
+
778
+ for (i = 0; i < len; i++)
779
+ {
780
+ str = rb_str_new2((const char *) list[i]);
781
+ rb_gc_unregister_address(&str);
782
+ rb_ary_push(arr, str);
783
+ }
784
+
785
+ if (len == MAX_LIBXML_FEATURES_LEN)
786
+ rb_warn(
787
+ "Please contact libxml-devel@rubyforge.org and ask to have the \"MAX_LIBXML_FEATURES_LEN increased\" because you could possibly be seeing an incomplete list");
788
+
789
+ ruby_xfree(list);
790
+ return (arr);
791
+ }
792
+
793
+ /*
794
+ * call-seq:
795
+ * XML.indent_tree_output -> (true|false)
796
+ *
797
+ * Determines whether XML output will be indented
798
+ * (using the string supplied to +default_indent_tree_string+)
799
+ */
800
+ static VALUE rxml_indent_tree_output_get(VALUE klass)
801
+ {
802
+ if (xmlIndentTreeOutput)
803
+ return (Qtrue);
804
+ else
805
+ return (Qfalse);
806
+ }
807
+
808
+ /*
809
+ * call-seq:
810
+ * XML.indent_tree_output = true|false
811
+ *
812
+ * Controls whether XML output will be indented
813
+ * (using the string supplied to +default_indent_tree_string+)
814
+ */
815
+ static VALUE rxml_indent_tree_output_set(VALUE klass, VALUE value)
816
+ {
817
+ if (value == Qtrue)
818
+ {
819
+ xmlIndentTreeOutput = 1;
820
+ return (Qtrue);
821
+ }
822
+ else if (value == Qfalse)
823
+ {
824
+ xmlIndentTreeOutput = 0;
825
+ return (Qfalse);
826
+ }
827
+ else
828
+ {
829
+ rb_raise(rb_eArgError, "Invalid argument, must be boolean");
830
+ }
831
+ }
832
+
833
+ /*
834
+ * call-seq:
835
+ * XML.memory_dump -> (true|false)
836
+ *
837
+ * Perform a parser memory dump (requires memory debugging
838
+ * support in libxml).
839
+ */
840
+ static VALUE rxml_memory_dump(VALUE self)
841
+ {
842
+ #ifdef DEBUG_MEMORY_LOCATION
843
+ xmlMemoryDump();
844
+ return(Qtrue);
845
+ #else
846
+ rb_warn("libxml was compiled without memory debugging support");
847
+ return (Qfalse);
848
+ #endif
849
+ }
850
+
851
+ /*
852
+ * call-seq:
853
+ * XML.memory_used -> num_bytes
854
+ *
855
+ * Perform a parser memory dump (requires memory debugging
856
+ * support in libxml).
857
+ */
858
+ static VALUE rxml_memory_used(VALUE self)
859
+ {
860
+ #ifdef DEBUG_MEMORY_LOCATION
861
+ return(INT2NUM(xmlMemUsed()));
862
+ #else
863
+ rb_warn("libxml was compiled without memory debugging support");
864
+ return (Qfalse);
865
+ #endif
866
+ }
867
+
868
+ /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
869
+ * XML toolkit. Refer to the README file to get started
870
+ * and the LICENSE file for copyright and distribution information.
871
+ */
872
+
873
+ void rxml_init_xml(void)
874
+ {
875
+ mXML = rb_define_module_under(mLibXML, "XML");
876
+
877
+ /* Constants */
878
+ rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
879
+ rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
880
+ rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
881
+ rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*) XML_XML_NAMESPACE));
882
+
883
+ rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
884
+ rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
885
+ rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
886
+ rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
887
+ rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
888
+ rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
889
+ rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
890
+ rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
891
+ rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
892
+ rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
893
+ rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
894
+ rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
895
+ rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
896
+ rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
897
+ rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
898
+ rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
899
+ rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
900
+ rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
901
+
902
+ rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
903
+ rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
904
+ rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
905
+ rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
906
+ rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
907
+ rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
908
+ rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
909
+ rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
910
+ rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
911
+ rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
912
+ rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
913
+ rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
914
+ rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
915
+ rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
916
+ rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
917
+ rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
918
+ rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
919
+ rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
920
+ rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
921
+ rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
922
+ rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
923
+ rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
924
+ rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
925
+ rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
926
+ rb_define_module_function(mXML, "default_save_no_empty_tags", rxml_default_save_no_empty_tags_get, 0);
927
+ rb_define_module_function(mXML, "default_save_no_empty_tags=", rxml_default_save_no_empty_tags_set, 1);
928
+ rb_define_module_function(mXML, "features", rxml_features, 0);
929
+ rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
930
+ rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
931
+ rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
932
+ rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
933
+ }