libxml-ruby 0.9.4-x86-mswin32-60 → 0.9.5-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +22 -0
- data/README +3 -1
- data/ext/libxml/cbg.c +86 -76
- data/ext/libxml/extconf.rb +2 -1
- data/ext/libxml/libxml.c +899 -885
- data/ext/libxml/ruby_libxml.h +65 -70
- data/ext/libxml/ruby_xml_attr.c +485 -500
- data/ext/libxml/ruby_xml_attributes.c +107 -106
- data/ext/libxml/ruby_xml_document.c +355 -356
- data/ext/libxml/ruby_xml_dtd.c +119 -117
- data/ext/libxml/ruby_xml_error.c +1112 -581
- data/ext/libxml/ruby_xml_html_parser.c +35 -34
- data/ext/libxml/ruby_xml_input.c +182 -187
- data/ext/libxml/ruby_xml_input_cbg.c +197 -179
- data/ext/libxml/ruby_xml_node.c +1529 -1566
- data/ext/libxml/ruby_xml_node.h +2 -2
- data/ext/libxml/ruby_xml_ns.c +150 -156
- data/ext/libxml/ruby_xml_parser.c +37 -36
- data/ext/libxml/ruby_xml_parser_context.c +657 -659
- data/ext/libxml/ruby_xml_reader.c +203 -209
- data/ext/libxml/ruby_xml_relaxng.c +29 -25
- data/ext/libxml/ruby_xml_sax_parser.c +33 -32
- data/ext/libxml/ruby_xml_schema.c +165 -161
- data/ext/libxml/ruby_xml_state.c +19 -21
- data/ext/libxml/ruby_xml_xinclude.c +24 -25
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath_context.c +305 -293
- data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
- data/ext/libxml/ruby_xml_xpath_object.c +89 -96
- data/ext/libxml/ruby_xml_xpointer.c +107 -109
- data/ext/libxml/ruby_xml_xpointer.h +13 -13
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/Rakefile +1 -1
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +1 -1
- data/lib/libxml/error.rb +4 -4
- data/test/tc_node_edit.rb +14 -2
- data/test/tc_node_text.rb +9 -9
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
(See log/ChangeLog for more detailed changes derived directly from source control.)
|
2
2
|
|
3
|
+
== 0.9.5 / 2008-11-29 Charlie Savage
|
4
|
+
|
5
|
+
* Ruby 1.9.1 preview release compatability (Felipe Contreras)
|
6
|
+
|
7
|
+
* Update Node#remove! to return the removed node and to set
|
8
|
+
its document to nil. This allows the node to be either
|
9
|
+
moved to another document, another part of the same document
|
10
|
+
or to be freed on the next garbage collection once its
|
11
|
+
references have gone out of scope.
|
12
|
+
|
13
|
+
* Fix bug where XPathExpression#compile mistakenly overwrote
|
14
|
+
RegExp#compile.
|
15
|
+
|
16
|
+
* Update Node to use standard ruby allocators and initializers.
|
17
|
+
|
18
|
+
* Update HTML parser to be more forgiving of invalid documents.
|
19
|
+
|
20
|
+
* Update include paths for Darwin Ports on OS X.
|
21
|
+
|
22
|
+
* Updated C code base to use BSD/Allman style
|
23
|
+
|
24
|
+
|
3
25
|
== 0.9.4 / 2008-11-24 Charlie Savage
|
4
26
|
|
5
27
|
* Update HTML parser so that it can read files, strings and io
|
data/README
CHANGED
@@ -33,7 +33,9 @@ If you are running Windows, make sure to install the Win32 RubyGem
|
|
33
33
|
which includes an already built binary file. The binary is built
|
34
34
|
against libxml2 version 2.7.2 and iconv version 1.11. Both of these
|
35
35
|
are also included as pre-built binaries, and should be put either in
|
36
|
-
the libxml/lib directory or on the Windows path.
|
36
|
+
the libxml/lib directory or on the Windows path. Due to a bug
|
37
|
+
in ruby-gems, you cannot install the gem to a path that contains
|
38
|
+
spaces (see http://rubyforge.org/tracker/?func=detail&aid=23003&group_id=126&atid=577).
|
37
39
|
|
38
40
|
The Windows binaries are built with MingW and include libxml-ruby,
|
39
41
|
libxml2 and iconv. The gem also includes a Microsoft VC++ 2008
|
data/ext/libxml/cbg.c
CHANGED
@@ -1,76 +1,86 @@
|
|
1
|
-
#include <string.h>
|
2
|
-
#include <libxml/xmlIO.h>
|
3
|
-
#include "ruby.h"
|
4
|
-
|
5
|
-
/*
|
6
|
-
int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
int (*xmlInputMatchCallback) (char const *filename);
|
13
|
-
void* (*xmlInputOpenCallback) (char const *filename);
|
14
|
-
int (*xmlInputReadCallback) (void *context,
|
15
|
-
|
16
|
-
|
17
|
-
int (*xmlInputCloseCallback) (void *context);
|
18
|
-
*/
|
19
|
-
|
20
|
-
typedef struct deb_doc_context
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
1
|
+
#include <string.h>
|
2
|
+
#include <libxml/xmlIO.h>
|
3
|
+
#include "ruby.h"
|
4
|
+
|
5
|
+
/*
|
6
|
+
int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
7
|
+
xmlInputOpenCallback openFunc,
|
8
|
+
xmlInputReadCallback readFunc,
|
9
|
+
xmlInputCloseCallback closeFunc);
|
10
|
+
|
11
|
+
|
12
|
+
int (*xmlInputMatchCallback) (char const *filename);
|
13
|
+
void* (*xmlInputOpenCallback) (char const *filename);
|
14
|
+
int (*xmlInputReadCallback) (void *context,
|
15
|
+
char *buffer,
|
16
|
+
int len);
|
17
|
+
int (*xmlInputCloseCallback) (void *context);
|
18
|
+
*/
|
19
|
+
|
20
|
+
typedef struct deb_doc_context
|
21
|
+
{
|
22
|
+
char *buffer;
|
23
|
+
char *bpos;
|
24
|
+
int remaining;
|
25
|
+
} deb_doc_context;
|
26
|
+
|
27
|
+
int deb_Match(char const *filename)
|
28
|
+
{
|
29
|
+
fprintf(stderr, "deb_Match: %s\n", filename);
|
30
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6))
|
31
|
+
{
|
32
|
+
return (1);
|
33
|
+
}
|
34
|
+
return (0);
|
35
|
+
}
|
36
|
+
|
37
|
+
void* deb_Open(char const *filename)
|
38
|
+
{
|
39
|
+
deb_doc_context *deb_doc;
|
40
|
+
VALUE res;
|
41
|
+
|
42
|
+
deb_doc = (deb_doc_context*) malloc(sizeof(deb_doc_context));
|
43
|
+
|
44
|
+
res = rb_funcall(rb_funcall(rb_mKernel, rb_intern("const_get"), 1,
|
45
|
+
rb_str_new2("DEBSystem")), rb_intern("document_query"), 1, rb_str_new2(
|
46
|
+
filename));
|
47
|
+
deb_doc->buffer = strdup(StringValuePtr(res));
|
48
|
+
//deb_doc->buffer = strdup("<serepes>serepes</serepes>");
|
49
|
+
|
50
|
+
deb_doc->bpos = deb_doc->buffer;
|
51
|
+
deb_doc->remaining = strlen(deb_doc->buffer);
|
52
|
+
return deb_doc;
|
53
|
+
}
|
54
|
+
|
55
|
+
int deb_Read(void *context, char *buffer, int len)
|
56
|
+
{
|
57
|
+
deb_doc_context *deb_doc;
|
58
|
+
int ret_len;
|
59
|
+
deb_doc = (deb_doc_context*) context;
|
60
|
+
|
61
|
+
if (len >= deb_doc->remaining)
|
62
|
+
{
|
63
|
+
ret_len = deb_doc->remaining;
|
64
|
+
}
|
65
|
+
else
|
66
|
+
{
|
67
|
+
ret_len = len;
|
68
|
+
}
|
69
|
+
deb_doc->remaining -= ret_len;
|
70
|
+
strncpy(buffer, deb_doc->bpos, ret_len);
|
71
|
+
deb_doc->bpos += ret_len;
|
72
|
+
|
73
|
+
return ret_len;
|
74
|
+
}
|
75
|
+
|
76
|
+
int deb_Close(void *context)
|
77
|
+
{
|
78
|
+
free(((deb_doc_context*) context)->buffer);
|
79
|
+
free(context);
|
80
|
+
return 1;
|
81
|
+
}
|
82
|
+
|
83
|
+
void deb_register_cbg()
|
84
|
+
{
|
85
|
+
xmlRegisterInputCallbacks(deb_Match, deb_Open, deb_Read, deb_Close);
|
86
|
+
}
|
data/ext/libxml/extconf.rb
CHANGED
@@ -79,7 +79,8 @@ unless (have_library('xml2', 'xmlParseDoc') or
|
|
79
79
|
find_library('xml2', 'xmlParseDoc', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
|
80
80
|
(have_header('libxml/xmlversion.h') or
|
81
81
|
find_header('libxml/xmlversion.h',
|
82
|
-
"#{CONFIG['prefix']}/include",
|
82
|
+
"#{CONFIG['prefix']}/include",
|
83
|
+
"#{CONFIG['prefix']}/include/libxml2",
|
83
84
|
'/opt/include/libxml2',
|
84
85
|
'/usr/local/include/libxml2',
|
85
86
|
'/usr/include/libxml2'))
|
data/ext/libxml/libxml.c
CHANGED
@@ -1,885 +1,899 @@
|
|
1
|
-
/* $Id: libxml.c
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#include "ruby_libxml.h"
|
6
|
-
|
7
|
-
VALUE mLibXML;
|
8
|
-
VALUE mXML;
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
*
|
26
|
-
*
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
*
|
40
|
-
*
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
#
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
#
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
*
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
#
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
*
|
202
|
-
*
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
#
|
209
|
-
|
210
|
-
#
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
*
|
217
|
-
*
|
218
|
-
*
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
/*
|
231
|
-
* call-seq:
|
232
|
-
* XML.
|
233
|
-
*
|
234
|
-
* Determine whether libxml
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
/*
|
247
|
-
* call-seq:
|
248
|
-
* XML.
|
249
|
-
*
|
250
|
-
* Determine whether libxml
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
*
|
265
|
-
*
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
#
|
272
|
-
return(
|
273
|
-
#
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
*
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
#
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
#
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
*
|
345
|
-
*
|
346
|
-
*
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
return(
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
*
|
368
|
-
*
|
369
|
-
*
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
if (
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
return(Qtrue);
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
*
|
406
|
-
*
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
return(
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
*
|
440
|
-
*
|
441
|
-
*
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
return(
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
*
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
else
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
*
|
474
|
-
*
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
return(
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
*
|
490
|
-
*
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
return(
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
*
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
return(Qtrue);
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
/*
|
522
|
-
* call-seq:
|
523
|
-
* XML.default_substitute_entities
|
524
|
-
*
|
525
|
-
*
|
526
|
-
* (for external entities) by default.
|
527
|
-
*/
|
528
|
-
static VALUE
|
529
|
-
|
530
|
-
if (
|
531
|
-
|
532
|
-
|
533
|
-
return(Qfalse);
|
534
|
-
}
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
*
|
559
|
-
*
|
560
|
-
*
|
561
|
-
*
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
}
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
*
|
574
|
-
*
|
575
|
-
*
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
*
|
589
|
-
*
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
return(
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
*
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
}
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
*
|
622
|
-
*
|
623
|
-
*
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
*
|
658
|
-
*
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
*
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
/*
|
726
|
-
* call-seq:
|
727
|
-
* XML.indent_tree_output
|
728
|
-
*
|
729
|
-
*
|
730
|
-
* (using the string supplied to +default_indent_tree_string+)
|
731
|
-
*/
|
732
|
-
static VALUE
|
733
|
-
|
734
|
-
if (
|
735
|
-
|
736
|
-
|
737
|
-
return(
|
738
|
-
}
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
mXML
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
rb_define_module_function(mXML, "
|
813
|
-
rb_define_module_function(mXML, "
|
814
|
-
rb_define_module_function(mXML, "
|
815
|
-
rb_define_module_function(mXML, "
|
816
|
-
rb_define_module_function(mXML, "
|
817
|
-
|
818
|
-
rb_define_module_function(mXML, "
|
819
|
-
rb_define_module_function(mXML, "
|
820
|
-
|
821
|
-
rb_define_module_function(mXML, "
|
822
|
-
|
823
|
-
rb_define_module_function(mXML, "
|
824
|
-
rb_define_module_function(mXML, "
|
825
|
-
rb_define_module_function(mXML, "
|
826
|
-
|
827
|
-
rb_define_module_function(mXML, "
|
828
|
-
rb_define_module_function(mXML, "
|
829
|
-
|
830
|
-
|
831
|
-
rb_define_module_function(mXML, "
|
832
|
-
|
833
|
-
rb_define_module_function(mXML, "
|
834
|
-
|
835
|
-
rb_define_module_function(mXML, "
|
836
|
-
|
837
|
-
rb_define_module_function(mXML, "
|
838
|
-
|
839
|
-
rb_define_module_function(mXML, "default_load_external_dtd",
|
840
|
-
|
841
|
-
rb_define_module_function(mXML, "default_line_numbers",
|
842
|
-
|
843
|
-
rb_define_module_function(mXML, "
|
844
|
-
|
845
|
-
rb_define_module_function(mXML, "
|
846
|
-
|
847
|
-
rb_define_module_function(mXML, "
|
848
|
-
|
849
|
-
rb_define_module_function(mXML, "
|
850
|
-
|
851
|
-
rb_define_module_function(mXML, "
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
rb_define_module_function(mXML, "
|
856
|
-
|
857
|
-
rb_define_module_function(mXML, "
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
1
|
+
/* $Id: libxml.c 650 2008-11-30 03:40:22Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
|
7
|
+
VALUE mLibXML;
|
8
|
+
VALUE mXML;
|
9
|
+
|
10
|
+
/*
|
11
|
+
* call-seq:
|
12
|
+
* XML.catalog_dump -> true
|
13
|
+
*
|
14
|
+
* Dump all the global catalog content stdout.
|
15
|
+
*/
|
16
|
+
static VALUE rxml_catalog_dump(VALUE self)
|
17
|
+
{
|
18
|
+
xmlCatalogDump(stdout);
|
19
|
+
return (Qtrue);
|
20
|
+
}
|
21
|
+
|
22
|
+
/*
|
23
|
+
* call-seq:
|
24
|
+
* XML.catalog_remove(catalog) -> true
|
25
|
+
*
|
26
|
+
* Remove the specified resource catalog.
|
27
|
+
*/
|
28
|
+
static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
|
29
|
+
{
|
30
|
+
Check_Type(cat, T_STRING);
|
31
|
+
xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
|
32
|
+
return (Qtrue);
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* call-seq:
|
37
|
+
* XML.check_lib_versions -> true
|
38
|
+
*
|
39
|
+
* Check LIBXML version matches version the bindings
|
40
|
+
* were compiled to. Throws an exception if not.
|
41
|
+
*/
|
42
|
+
static VALUE rxml_check_lib_versions(VALUE class)
|
43
|
+
{
|
44
|
+
xmlCheckVersion(LIBXML_VERSION);
|
45
|
+
return (Qtrue);
|
46
|
+
}
|
47
|
+
|
48
|
+
/*
|
49
|
+
* call-seq:
|
50
|
+
* XML.enabled_automata? -> (true|false)
|
51
|
+
*
|
52
|
+
* Determine whether libxml regexp automata support is enabled.
|
53
|
+
*/
|
54
|
+
static VALUE rxml_enabled_automata_q(VALUE class)
|
55
|
+
{
|
56
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
57
|
+
return(Qtrue);
|
58
|
+
#else
|
59
|
+
return (Qfalse);
|
60
|
+
#endif
|
61
|
+
}
|
62
|
+
|
63
|
+
/*
|
64
|
+
* call-seq:
|
65
|
+
* XML.enabled_c14n? -> (true|false)
|
66
|
+
*
|
67
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
68
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
69
|
+
*/
|
70
|
+
static VALUE rxml_enabled_c14n_q(VALUE class)
|
71
|
+
{
|
72
|
+
#ifdef LIBXML_C14N_ENABLED
|
73
|
+
return(Qtrue);
|
74
|
+
#else
|
75
|
+
return (Qfalse);
|
76
|
+
#endif
|
77
|
+
}
|
78
|
+
|
79
|
+
/*
|
80
|
+
* call-seq:
|
81
|
+
* XML.enabled_catalog? -> (true|false)
|
82
|
+
*
|
83
|
+
* Determine whether libxml resource catalog support is enabled.
|
84
|
+
*/
|
85
|
+
static VALUE rxml_enabled_catalog_q(VALUE class)
|
86
|
+
{
|
87
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
88
|
+
return(Qtrue);
|
89
|
+
#else
|
90
|
+
return (Qfalse);
|
91
|
+
#endif
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
* call-seq:
|
96
|
+
* XML.enabled_debug? -> (true|false)
|
97
|
+
*
|
98
|
+
* Determine whether libxml debugging support is enabled.
|
99
|
+
*/
|
100
|
+
static VALUE rxml_enabled_debug_q(VALUE class)
|
101
|
+
{
|
102
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
103
|
+
return(Qtrue);
|
104
|
+
#else
|
105
|
+
return (Qfalse);
|
106
|
+
#endif
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* call-seq:
|
111
|
+
* XML.enabled_docbook? -> (true|false)
|
112
|
+
*
|
113
|
+
* Determine whether libxml docbook support is enabled.
|
114
|
+
*/
|
115
|
+
static VALUE rxml_enabled_docbook_q(VALUE class)
|
116
|
+
{
|
117
|
+
#ifdef LIBXML_DOCB_ENABLED
|
118
|
+
return(Qtrue);
|
119
|
+
#else
|
120
|
+
return (Qfalse);
|
121
|
+
#endif
|
122
|
+
}
|
123
|
+
|
124
|
+
/*
|
125
|
+
* call-seq:
|
126
|
+
* XML.enabled_ftp? -> (true|false)
|
127
|
+
*
|
128
|
+
* Determine whether libxml ftp client support is enabled.
|
129
|
+
*/
|
130
|
+
static VALUE rxml_enabled_ftp_q(VALUE class)
|
131
|
+
{
|
132
|
+
#ifdef LIBXML_FTP_ENABLED
|
133
|
+
return(Qtrue);
|
134
|
+
#else
|
135
|
+
return (Qfalse);
|
136
|
+
#endif
|
137
|
+
}
|
138
|
+
|
139
|
+
/*
|
140
|
+
* call-seq:
|
141
|
+
* XML.enabled_http? -> (true|false)
|
142
|
+
*
|
143
|
+
* Determine whether libxml http client support is enabled.
|
144
|
+
*/
|
145
|
+
static VALUE rxml_enabled_http_q(VALUE class)
|
146
|
+
{
|
147
|
+
#ifdef LIBXML_HTTP_ENABLED
|
148
|
+
return(Qtrue);
|
149
|
+
#else
|
150
|
+
return (Qfalse);
|
151
|
+
#endif
|
152
|
+
}
|
153
|
+
|
154
|
+
/*
|
155
|
+
* call-seq:
|
156
|
+
* XML.enabled_html? -> (true|false)
|
157
|
+
*
|
158
|
+
* Determine whether libxml html support is enabled.
|
159
|
+
*/
|
160
|
+
static VALUE rxml_enabled_html_q(VALUE class)
|
161
|
+
{
|
162
|
+
#ifdef LIBXML_HTML_ENABLED
|
163
|
+
return(Qtrue);
|
164
|
+
#else
|
165
|
+
return (Qfalse);
|
166
|
+
#endif
|
167
|
+
}
|
168
|
+
|
169
|
+
/*
|
170
|
+
* call-seq:
|
171
|
+
* XML.enabled_iconv? -> (true|false)
|
172
|
+
*
|
173
|
+
* Determine whether libxml iconv support is enabled.
|
174
|
+
*/
|
175
|
+
static VALUE rxml_enabled_iconv_q(VALUE class)
|
176
|
+
{
|
177
|
+
#ifdef LIBXML_ICONV_ENABLED
|
178
|
+
return(Qtrue);
|
179
|
+
#else
|
180
|
+
return (Qfalse);
|
181
|
+
#endif
|
182
|
+
}
|
183
|
+
|
184
|
+
/*
|
185
|
+
* call-seq:
|
186
|
+
* XML.enabled_memory_debug? -> (true|false)
|
187
|
+
*
|
188
|
+
* Determine whether libxml memory location debugging support
|
189
|
+
* is enabled.
|
190
|
+
*/
|
191
|
+
static VALUE rxml_enabled_memory_debug_location_q(VALUE class)
|
192
|
+
{
|
193
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
194
|
+
return(Qtrue);
|
195
|
+
#else
|
196
|
+
return (Qfalse);
|
197
|
+
#endif
|
198
|
+
}
|
199
|
+
|
200
|
+
/*
|
201
|
+
* call-seq:
|
202
|
+
* XML.enabled_regexp? -> (true|false)
|
203
|
+
*
|
204
|
+
* Determine whether libxml regular expression support is enabled.
|
205
|
+
*/
|
206
|
+
static VALUE rxml_enabled_regexp_q(VALUE class)
|
207
|
+
{
|
208
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
209
|
+
return(Qtrue);
|
210
|
+
#else
|
211
|
+
return (Qfalse);
|
212
|
+
#endif
|
213
|
+
}
|
214
|
+
|
215
|
+
/*
|
216
|
+
* call-seq:
|
217
|
+
* XML.enabled_schemas? -> (true|false)
|
218
|
+
*
|
219
|
+
* Determine whether libxml schema support is enabled.
|
220
|
+
*/
|
221
|
+
static VALUE rxml_enabled_schemas_q(VALUE class)
|
222
|
+
{
|
223
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
224
|
+
return(Qtrue);
|
225
|
+
#else
|
226
|
+
return (Qfalse);
|
227
|
+
#endif
|
228
|
+
}
|
229
|
+
|
230
|
+
/*
|
231
|
+
* call-seq:
|
232
|
+
* XML.enabled_thread? -> (true|false)
|
233
|
+
*
|
234
|
+
* Determine whether libxml thread-safe semantics support
|
235
|
+
* is enabled (I think?).
|
236
|
+
*/
|
237
|
+
static VALUE rxml_enabled_thread_q(VALUE class)
|
238
|
+
{
|
239
|
+
#ifdef LIBXML_THREAD_ENABLED
|
240
|
+
return(Qtrue);
|
241
|
+
#else
|
242
|
+
return (Qfalse);
|
243
|
+
#endif
|
244
|
+
}
|
245
|
+
|
246
|
+
/*
|
247
|
+
* call-seq:
|
248
|
+
* XML.enabled_unicode? -> (true|false)
|
249
|
+
*
|
250
|
+
* Determine whether libxml unicode support is enabled.
|
251
|
+
*/
|
252
|
+
static VALUE rxml_enabled_unicode_q(VALUE class)
|
253
|
+
{
|
254
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
255
|
+
return(Qtrue);
|
256
|
+
#else
|
257
|
+
return (Qfalse);
|
258
|
+
#endif
|
259
|
+
}
|
260
|
+
|
261
|
+
/*
|
262
|
+
* call-seq:
|
263
|
+
* XML.enabled_xinclude? -> (true|false)
|
264
|
+
*
|
265
|
+
* Determine whether libxml xinclude support is enabled.
|
266
|
+
*/
|
267
|
+
static VALUE rxml_enabled_xinclude_q(VALUE class)
|
268
|
+
{
|
269
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
270
|
+
return(Qtrue);
|
271
|
+
#else
|
272
|
+
return (Qfalse);
|
273
|
+
#endif
|
274
|
+
}
|
275
|
+
|
276
|
+
/*
|
277
|
+
* call-seq:
|
278
|
+
* XML.enabled_xpath? -> (true|false)
|
279
|
+
*
|
280
|
+
* Determine whether libxml xpath support is enabled.
|
281
|
+
*/
|
282
|
+
static VALUE rxml_enabled_xpath_q(VALUE class)
|
283
|
+
{
|
284
|
+
#ifdef LIBXML_XPATH_ENABLED
|
285
|
+
return(Qtrue);
|
286
|
+
#else
|
287
|
+
return (Qfalse);
|
288
|
+
#endif
|
289
|
+
}
|
290
|
+
|
291
|
+
/*
|
292
|
+
* call-seq:
|
293
|
+
* XML.enabled_xpointer? -> (true|false)
|
294
|
+
*
|
295
|
+
* Determine whether libxml xpointer support is enabled.
|
296
|
+
*/
|
297
|
+
static VALUE rxml_enabled_xpointer_q(VALUE class)
|
298
|
+
{
|
299
|
+
#ifdef LIBXML_XPTR_ENABLED
|
300
|
+
return(Qtrue);
|
301
|
+
#else
|
302
|
+
return (Qfalse);
|
303
|
+
#endif
|
304
|
+
}
|
305
|
+
|
306
|
+
/*
|
307
|
+
* call-seq:
|
308
|
+
* XML.enabled_zlib? -> (true|false)
|
309
|
+
*
|
310
|
+
* Determine whether libxml zlib support is enabled.
|
311
|
+
*/
|
312
|
+
static VALUE rxml_enabled_zlib_q(VALUE class)
|
313
|
+
{
|
314
|
+
#ifdef HAVE_ZLIB_H
|
315
|
+
return(Qtrue);
|
316
|
+
#else
|
317
|
+
return (Qfalse);
|
318
|
+
#endif
|
319
|
+
}
|
320
|
+
|
321
|
+
/*
|
322
|
+
* call-seq:
|
323
|
+
* XML.debug_entities -> (true|false)
|
324
|
+
*
|
325
|
+
* Determine whether included-entity debugging is enabled.
|
326
|
+
* (Requires Libxml to be compiled with debugging support)
|
327
|
+
*/
|
328
|
+
static VALUE rxml_debug_entities_get(VALUE class)
|
329
|
+
{
|
330
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
331
|
+
if (xmlParserDebugEntities)
|
332
|
+
return(Qtrue);
|
333
|
+
else
|
334
|
+
return(Qfalse);
|
335
|
+
#else
|
336
|
+
rb_warn("libxml was compiled with debugging turned off");
|
337
|
+
return (Qfalse);
|
338
|
+
#endif
|
339
|
+
}
|
340
|
+
|
341
|
+
/*
|
342
|
+
* call-seq:
|
343
|
+
* XML.debug_entities = true|false
|
344
|
+
*
|
345
|
+
* Enable or disable included-entity debugging.
|
346
|
+
* (Requires Libxml to be compiled with debugging support)
|
347
|
+
*/
|
348
|
+
static VALUE rxml_debug_entities_set(VALUE class, VALUE bool)
|
349
|
+
{
|
350
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
351
|
+
if (TYPE(bool) == T_FALSE)
|
352
|
+
{
|
353
|
+
xmlParserDebugEntities = 0;
|
354
|
+
return(Qfalse);
|
355
|
+
}
|
356
|
+
else
|
357
|
+
{
|
358
|
+
xmlParserDebugEntities = 1;
|
359
|
+
return(Qtrue);
|
360
|
+
}
|
361
|
+
#else
|
362
|
+
rb_warn("libxml was compiled with debugging turned off");
|
363
|
+
#endif
|
364
|
+
}
|
365
|
+
|
366
|
+
/*
|
367
|
+
* call-seq:
|
368
|
+
* XML.default_keep_blanks -> (true|false)
|
369
|
+
*
|
370
|
+
* Determine whether parsers retain whitespace by default.
|
371
|
+
*/
|
372
|
+
static VALUE rxml_default_keep_blanks_get(VALUE class)
|
373
|
+
{
|
374
|
+
if (xmlKeepBlanksDefaultValue)
|
375
|
+
return (Qtrue);
|
376
|
+
else
|
377
|
+
return (Qfalse);
|
378
|
+
}
|
379
|
+
|
380
|
+
/*
|
381
|
+
* call-seq:
|
382
|
+
* XML.default_keep_blanks = true|false
|
383
|
+
*
|
384
|
+
* Controls whether parsers retain whitespace by default.
|
385
|
+
*/
|
386
|
+
static VALUE rxml_default_keep_blanks_set(VALUE class, VALUE bool)
|
387
|
+
{
|
388
|
+
if (TYPE(bool) == T_FALSE)
|
389
|
+
{
|
390
|
+
xmlKeepBlanksDefaultValue = 0;
|
391
|
+
return (Qfalse);
|
392
|
+
}
|
393
|
+
else if (TYPE(bool) == T_TRUE)
|
394
|
+
{
|
395
|
+
xmlKeepBlanksDefaultValue = 1;
|
396
|
+
return (Qtrue);
|
397
|
+
}
|
398
|
+
else
|
399
|
+
{
|
400
|
+
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
/*
|
405
|
+
* call-seq:
|
406
|
+
* XML.default_load_external_dtd -> (true|false)
|
407
|
+
*
|
408
|
+
* Determine whether parsers load external DTDs by default.
|
409
|
+
*/
|
410
|
+
static VALUE rxml_default_load_external_dtd_get(VALUE class)
|
411
|
+
{
|
412
|
+
if (xmlLoadExtDtdDefaultValue)
|
413
|
+
return (Qtrue);
|
414
|
+
else
|
415
|
+
return (Qfalse);
|
416
|
+
}
|
417
|
+
|
418
|
+
/*
|
419
|
+
* call-seq:
|
420
|
+
* XML.default_load_external_dtd = true|false
|
421
|
+
*
|
422
|
+
* Controls whether parsers load external DTDs by default.
|
423
|
+
*/
|
424
|
+
static VALUE rxml_default_load_external_dtd_set(VALUE class, VALUE bool)
|
425
|
+
{
|
426
|
+
if (TYPE(bool) == T_FALSE)
|
427
|
+
{
|
428
|
+
xmlLoadExtDtdDefaultValue = 0;
|
429
|
+
return (Qfalse);
|
430
|
+
}
|
431
|
+
else
|
432
|
+
{
|
433
|
+
xmlLoadExtDtdDefaultValue = 1;
|
434
|
+
return (Qtrue);
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
/*
|
439
|
+
* call-seq:
|
440
|
+
* XML.default_line_numbers -> (true|false)
|
441
|
+
*
|
442
|
+
* Determine whether parsers retain line-numbers by default.
|
443
|
+
*/
|
444
|
+
static VALUE rxml_default_line_numbers_get(VALUE class)
|
445
|
+
{
|
446
|
+
if (xmlLineNumbersDefaultValue)
|
447
|
+
return (Qtrue);
|
448
|
+
else
|
449
|
+
return (Qfalse);
|
450
|
+
}
|
451
|
+
|
452
|
+
/*
|
453
|
+
* call-seq:
|
454
|
+
* XML.default_line_numbers = true|false
|
455
|
+
*
|
456
|
+
* Controls whether parsers retain line-numbers by default.
|
457
|
+
*/
|
458
|
+
static VALUE rxml_default_line_numbers_set(VALUE class, VALUE bool)
|
459
|
+
{
|
460
|
+
if (TYPE(bool) == T_FALSE)
|
461
|
+
{
|
462
|
+
xmlLineNumbersDefault(0);
|
463
|
+
return (Qfalse);
|
464
|
+
}
|
465
|
+
else
|
466
|
+
{
|
467
|
+
xmlLineNumbersDefault(1);
|
468
|
+
return (Qtrue);
|
469
|
+
}
|
470
|
+
}
|
471
|
+
|
472
|
+
/*
|
473
|
+
* call-seq:
|
474
|
+
* XML.default_pedantic_parser -> (true|false)
|
475
|
+
*
|
476
|
+
* Determine whether parsers are pedantic by default.
|
477
|
+
*/
|
478
|
+
static VALUE rxml_default_pedantic_parser_get(VALUE class)
|
479
|
+
{
|
480
|
+
if (xmlPedanticParserDefaultValue)
|
481
|
+
return (Qtrue);
|
482
|
+
else
|
483
|
+
return (Qfalse);
|
484
|
+
}
|
485
|
+
|
486
|
+
/*
|
487
|
+
* call-seq:
|
488
|
+
* XML.default_pedantic_parser = true|false
|
489
|
+
*
|
490
|
+
* Controls whether parsers are pedantic by default.
|
491
|
+
*/
|
492
|
+
static VALUE rxml_default_pedantic_parser_set(VALUE class, VALUE bool)
|
493
|
+
{
|
494
|
+
if (TYPE(bool) == T_FALSE)
|
495
|
+
{
|
496
|
+
xmlPedanticParserDefault(0);
|
497
|
+
return (Qfalse);
|
498
|
+
}
|
499
|
+
else
|
500
|
+
{
|
501
|
+
xmlPedanticParserDefault(1);
|
502
|
+
return (Qtrue);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
|
506
|
+
/*
|
507
|
+
* call-seq:
|
508
|
+
* XML.default_substitute_entities -> (true|false)
|
509
|
+
*
|
510
|
+
* Determine whether parsers perform inline entity substitution
|
511
|
+
* (for external entities) by default.
|
512
|
+
*/
|
513
|
+
static VALUE rxml_default_substitute_entities_get(VALUE class)
|
514
|
+
{
|
515
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
516
|
+
return (Qtrue);
|
517
|
+
else
|
518
|
+
return (Qfalse);
|
519
|
+
}
|
520
|
+
|
521
|
+
/*
|
522
|
+
* call-seq:
|
523
|
+
* XML.default_substitute_entities = true|false
|
524
|
+
*
|
525
|
+
* Controls whether parsers perform inline entity substitution
|
526
|
+
* (for external entities) by default.
|
527
|
+
*/
|
528
|
+
static VALUE rxml_default_substitute_entities_set(VALUE class, VALUE bool)
|
529
|
+
{
|
530
|
+
if (TYPE(bool) == T_FALSE)
|
531
|
+
{
|
532
|
+
xmlSubstituteEntitiesDefault(0);
|
533
|
+
return (Qfalse);
|
534
|
+
}
|
535
|
+
else
|
536
|
+
{
|
537
|
+
xmlSubstituteEntitiesDefault(1);
|
538
|
+
return (Qtrue);
|
539
|
+
}
|
540
|
+
}
|
541
|
+
|
542
|
+
/*
|
543
|
+
* call-seq:
|
544
|
+
* XML.default_tree_indent_string -> "string"
|
545
|
+
*
|
546
|
+
* Obtain the default string used by parsers to indent the XML tree
|
547
|
+
* for output.
|
548
|
+
*/
|
549
|
+
static VALUE rxml_default_tree_indent_string_get(VALUE class)
|
550
|
+
{
|
551
|
+
if (xmlTreeIndentString == NULL)
|
552
|
+
return (Qnil);
|
553
|
+
else
|
554
|
+
return (rb_str_new2(xmlTreeIndentString));
|
555
|
+
}
|
556
|
+
|
557
|
+
/*
|
558
|
+
* call-seq:
|
559
|
+
* XML.default_tree_indent_string = "string"
|
560
|
+
*
|
561
|
+
* Set the default string used by parsers to indent the XML tree
|
562
|
+
* for output.
|
563
|
+
*/
|
564
|
+
static VALUE rxml_default_tree_indent_string_set(VALUE class, VALUE string)
|
565
|
+
{
|
566
|
+
Check_Type(string, T_STRING);
|
567
|
+
xmlTreeIndentString = xmlStrdup(StringValuePtr(string));
|
568
|
+
return (string);
|
569
|
+
}
|
570
|
+
|
571
|
+
/*
|
572
|
+
* call-seq:
|
573
|
+
* XML.default_validity_checking -> (true|false)
|
574
|
+
*
|
575
|
+
* Determine whether parsers perform XML validation by default.
|
576
|
+
*/
|
577
|
+
static VALUE rxml_default_validity_checking_get(VALUE class)
|
578
|
+
{
|
579
|
+
if (xmlDoValidityCheckingDefaultValue)
|
580
|
+
return (Qtrue);
|
581
|
+
else
|
582
|
+
return (Qfalse);
|
583
|
+
}
|
584
|
+
|
585
|
+
/*
|
586
|
+
* call-seq:
|
587
|
+
* XML.default_validity_checking = true|false
|
588
|
+
*
|
589
|
+
* Controls whether parsers perform XML validation by default.
|
590
|
+
*/
|
591
|
+
static VALUE rxml_default_validity_checking_set(VALUE class, VALUE bool)
|
592
|
+
{
|
593
|
+
if (TYPE(bool) == T_FALSE)
|
594
|
+
{
|
595
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
596
|
+
return (Qfalse);
|
597
|
+
}
|
598
|
+
else
|
599
|
+
{
|
600
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
601
|
+
return (Qtrue);
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
/*
|
606
|
+
* call-seq:
|
607
|
+
* XML.default_warnings -> (true|false)
|
608
|
+
*
|
609
|
+
* Determine whether parsers output warnings by default.
|
610
|
+
*/
|
611
|
+
static VALUE rxml_default_warnings_get(VALUE class)
|
612
|
+
{
|
613
|
+
if (xmlGetWarningsDefaultValue)
|
614
|
+
return (Qtrue);
|
615
|
+
else
|
616
|
+
return (Qfalse);
|
617
|
+
}
|
618
|
+
|
619
|
+
/*
|
620
|
+
* call-seq:
|
621
|
+
* XML.default_warnings = true|false
|
622
|
+
*
|
623
|
+
* Controls whether parsers output warnings by default.
|
624
|
+
*/
|
625
|
+
static VALUE rxml_default_warnings_set(VALUE class, VALUE bool)
|
626
|
+
{
|
627
|
+
if (TYPE(bool) == T_FALSE)
|
628
|
+
{
|
629
|
+
xmlGetWarningsDefaultValue = 0;
|
630
|
+
return (Qfalse);
|
631
|
+
}
|
632
|
+
else
|
633
|
+
{
|
634
|
+
xmlGetWarningsDefaultValue = 1;
|
635
|
+
return (Qtrue);
|
636
|
+
}
|
637
|
+
}
|
638
|
+
|
639
|
+
/*
|
640
|
+
* call-seq:
|
641
|
+
* XML.default_compression -> (true|false)
|
642
|
+
*
|
643
|
+
* Determine whether parsers use Zlib compression by default
|
644
|
+
* (requires libxml to be compiled with Zlib support).
|
645
|
+
*/
|
646
|
+
static VALUE rxml_default_compression_get(VALUE class)
|
647
|
+
{
|
648
|
+
#ifdef HAVE_ZLIB_H
|
649
|
+
return(INT2FIX(xmlGetCompressMode()));
|
650
|
+
#else
|
651
|
+
rb_warn("libxml was compiled without zlib support");
|
652
|
+
return (Qfalse);
|
653
|
+
#endif
|
654
|
+
}
|
655
|
+
|
656
|
+
/*
|
657
|
+
* call-seq:
|
658
|
+
* XML.default_compression = true|false
|
659
|
+
*
|
660
|
+
* Controls whether parsers use Zlib compression by default
|
661
|
+
* (requires libxml to be compiled with Zlib support).
|
662
|
+
*/
|
663
|
+
static VALUE rxml_default_compression_set(VALUE class, VALUE num)
|
664
|
+
{
|
665
|
+
#ifdef HAVE_ZLIB_H
|
666
|
+
Check_Type(num, T_FIXNUM);
|
667
|
+
xmlSetCompressMode(FIX2INT(num));
|
668
|
+
return(num);
|
669
|
+
#else
|
670
|
+
rb_warn("libxml was compiled without zlib support");
|
671
|
+
return (Qfalse);
|
672
|
+
#endif
|
673
|
+
}
|
674
|
+
|
675
|
+
/*
|
676
|
+
* call-seq:
|
677
|
+
* XML.features -> ["feature", ..., "feature"]
|
678
|
+
*
|
679
|
+
* Obtains an array of strings representing features supported
|
680
|
+
* (and enabled) by the installed libxml.
|
681
|
+
*/
|
682
|
+
static VALUE rxml_features(VALUE class)
|
683
|
+
{
|
684
|
+
VALUE arr, str;
|
685
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
686
|
+
char **list = NULL;
|
687
|
+
|
688
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
689
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
690
|
+
|
691
|
+
arr = rb_ary_new();
|
692
|
+
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
|
693
|
+
return Qnil;
|
694
|
+
|
695
|
+
for (i = 0; i < len; i++)
|
696
|
+
{
|
697
|
+
str = rb_str_new2((const char *) list[i]);
|
698
|
+
rb_gc_unregister_address(&str);
|
699
|
+
rb_ary_push(arr, str);
|
700
|
+
}
|
701
|
+
|
702
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
703
|
+
rb_warn(
|
704
|
+
"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");
|
705
|
+
|
706
|
+
ruby_xfree(list);
|
707
|
+
return (arr);
|
708
|
+
}
|
709
|
+
|
710
|
+
/*
|
711
|
+
* call-seq:
|
712
|
+
* XML.indent_tree_output -> (true|false)
|
713
|
+
*
|
714
|
+
* Determines whether XML output will be indented
|
715
|
+
* (using the string supplied to +default_indent_tree_string+)
|
716
|
+
*/
|
717
|
+
static VALUE rxml_indent_tree_output_get(VALUE class)
|
718
|
+
{
|
719
|
+
if (xmlIndentTreeOutput)
|
720
|
+
return (Qtrue);
|
721
|
+
else
|
722
|
+
return (Qfalse);
|
723
|
+
}
|
724
|
+
|
725
|
+
/*
|
726
|
+
* call-seq:
|
727
|
+
* XML.indent_tree_output = true|false
|
728
|
+
*
|
729
|
+
* Controls whether XML output will be indented
|
730
|
+
* (using the string supplied to +default_indent_tree_string+)
|
731
|
+
*/
|
732
|
+
static VALUE rxml_indent_tree_output_set(VALUE class, VALUE bool)
|
733
|
+
{
|
734
|
+
if (TYPE(bool) == T_TRUE)
|
735
|
+
{
|
736
|
+
xmlIndentTreeOutput = 1;
|
737
|
+
return (Qtrue);
|
738
|
+
}
|
739
|
+
else if (TYPE(bool) == T_FALSE)
|
740
|
+
{
|
741
|
+
xmlIndentTreeOutput = 0;
|
742
|
+
return (Qfalse);
|
743
|
+
}
|
744
|
+
else
|
745
|
+
{
|
746
|
+
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
747
|
+
}
|
748
|
+
}
|
749
|
+
|
750
|
+
/*
|
751
|
+
* call-seq:
|
752
|
+
* XML.memory_dump -> (true|false)
|
753
|
+
*
|
754
|
+
* Perform a parser memory dump (requires memory debugging
|
755
|
+
* support in libxml).
|
756
|
+
*/
|
757
|
+
static VALUE rxml_memory_dump(VALUE self)
|
758
|
+
{
|
759
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
760
|
+
xmlMemoryDump();
|
761
|
+
return(Qtrue);
|
762
|
+
#else
|
763
|
+
rb_warn("libxml was compiled without memory debugging support");
|
764
|
+
return (Qfalse);
|
765
|
+
#endif
|
766
|
+
}
|
767
|
+
|
768
|
+
/*
|
769
|
+
* call-seq:
|
770
|
+
* XML.memory_used -> num_bytes
|
771
|
+
*
|
772
|
+
* Perform a parser memory dump (requires memory debugging
|
773
|
+
* support in libxml).
|
774
|
+
*/
|
775
|
+
static VALUE rxml_memory_used(VALUE self)
|
776
|
+
{
|
777
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
778
|
+
return(INT2NUM(xmlMemUsed()));
|
779
|
+
#else
|
780
|
+
rb_warn("libxml was compiled without memory debugging support");
|
781
|
+
return (Qfalse);
|
782
|
+
#endif
|
783
|
+
}
|
784
|
+
|
785
|
+
#if defined(_WIN32)
|
786
|
+
__declspec(dllexport)
|
787
|
+
#endif
|
788
|
+
void Init_libxml_ruby(void)
|
789
|
+
{
|
790
|
+
mLibXML = rb_define_module("LibXML");
|
791
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
792
|
+
|
793
|
+
/* Constants */
|
794
|
+
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
795
|
+
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
796
|
+
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
797
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2(
|
798
|
+
(const char*) XML_XML_NAMESPACE));
|
799
|
+
|
800
|
+
rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q,
|
801
|
+
0);
|
802
|
+
rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
|
803
|
+
rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
|
804
|
+
rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
|
805
|
+
rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
|
806
|
+
rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
|
807
|
+
rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
|
808
|
+
rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
|
809
|
+
rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
|
810
|
+
rb_define_module_function(mXML, "enabled_memory_debug?",
|
811
|
+
rxml_enabled_memory_debug_location_q, 0);
|
812
|
+
rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
|
813
|
+
rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
|
814
|
+
rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
|
815
|
+
rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
|
816
|
+
rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q,
|
817
|
+
0);
|
818
|
+
rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
|
819
|
+
rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q,
|
820
|
+
0);
|
821
|
+
rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
|
822
|
+
|
823
|
+
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
|
824
|
+
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
|
825
|
+
rb_define_module_function(mXML, "check_lib_versions",
|
826
|
+
rxml_check_lib_versions, 0);
|
827
|
+
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
|
828
|
+
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
|
829
|
+
rb_define_module_function(mXML, "default_compression",
|
830
|
+
rxml_default_compression_get, 0);
|
831
|
+
rb_define_module_function(mXML, "default_compression=",
|
832
|
+
rxml_default_compression_set, 1);
|
833
|
+
rb_define_module_function(mXML, "default_keep_blanks",
|
834
|
+
rxml_default_keep_blanks_get, 0);
|
835
|
+
rb_define_module_function(mXML, "default_keep_blanks=",
|
836
|
+
rxml_default_keep_blanks_set, 1);
|
837
|
+
rb_define_module_function(mXML, "default_load_external_dtd",
|
838
|
+
rxml_default_load_external_dtd_get, 0);
|
839
|
+
rb_define_module_function(mXML, "default_load_external_dtd=",
|
840
|
+
rxml_default_load_external_dtd_set, 1);
|
841
|
+
rb_define_module_function(mXML, "default_line_numbers",
|
842
|
+
rxml_default_line_numbers_get, 0);
|
843
|
+
rb_define_module_function(mXML, "default_line_numbers=",
|
844
|
+
rxml_default_line_numbers_set, 1);
|
845
|
+
rb_define_module_function(mXML, "default_pedantic_parser",
|
846
|
+
rxml_default_pedantic_parser_get, 0);
|
847
|
+
rb_define_module_function(mXML, "default_pedantic_parser=",
|
848
|
+
rxml_default_pedantic_parser_set, 1);
|
849
|
+
rb_define_module_function(mXML, "default_substitute_entities",
|
850
|
+
rxml_default_substitute_entities_get, 0);
|
851
|
+
rb_define_module_function(mXML, "default_substitute_entities=",
|
852
|
+
rxml_default_substitute_entities_set, 1);
|
853
|
+
rb_define_module_function(mXML, "default_tree_indent_string",
|
854
|
+
rxml_default_tree_indent_string_get, 0);
|
855
|
+
rb_define_module_function(mXML, "default_tree_indent_string=",
|
856
|
+
rxml_default_tree_indent_string_set, 1);
|
857
|
+
rb_define_module_function(mXML, "default_validity_checking",
|
858
|
+
rxml_default_validity_checking_get, 0);
|
859
|
+
rb_define_module_function(mXML, "default_validity_checking=",
|
860
|
+
rxml_default_validity_checking_set, 1);
|
861
|
+
rb_define_module_function(mXML, "default_warnings",
|
862
|
+
rxml_default_warnings_get, 0);
|
863
|
+
rb_define_module_function(mXML, "default_warnings=",
|
864
|
+
rxml_default_warnings_set, 1);
|
865
|
+
rb_define_module_function(mXML, "features", rxml_features, 0);
|
866
|
+
rb_define_module_function(mXML, "indent_tree_output",
|
867
|
+
rxml_indent_tree_output_get, 0);
|
868
|
+
rb_define_module_function(mXML, "indent_tree_output=",
|
869
|
+
rxml_indent_tree_output_set, 1);
|
870
|
+
rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
|
871
|
+
rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
|
872
|
+
|
873
|
+
/* Now initialize all the other modules */
|
874
|
+
ruby_init_xml_error();
|
875
|
+
ruby_init_xml_input();
|
876
|
+
ruby_init_state();
|
877
|
+
ruby_init_parser();
|
878
|
+
ruby_init_xml_parser_context();
|
879
|
+
ruby_init_xml_node();
|
880
|
+
ruby_init_xml_attributes();
|
881
|
+
ruby_init_xml_attr();
|
882
|
+
ruby_init_xml_document();
|
883
|
+
ruby_init_xml_ns();
|
884
|
+
ruby_init_xml_sax_parser();
|
885
|
+
ruby_init_xml_xinclude();
|
886
|
+
ruby_init_xml_xpath();
|
887
|
+
ruby_init_xml_xpath_context();
|
888
|
+
ruby_init_xml_xpath_expression();
|
889
|
+
ruby_init_xml_xpointer();
|
890
|
+
ruby_init_html_parser();
|
891
|
+
ruby_init_input_callbacks();
|
892
|
+
ruby_init_xml_dtd();
|
893
|
+
ruby_init_xml_schema();
|
894
|
+
ruby_init_xml_relaxng();
|
895
|
+
ruby_init_xml_reader();
|
896
|
+
|
897
|
+
rxml_default_substitute_entities_set(mXML, Qtrue);
|
898
|
+
rxml_default_load_external_dtd_set(mXML, Qtrue);
|
899
|
+
}
|