libxml-ruby 4.1.2 → 6.0.0

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.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY → CHANGELOG.md} +875 -887
  3. data/LICENSE +20 -20
  4. data/README.md +67 -0
  5. data/Rakefile +77 -98
  6. data/ext/libxml/extconf.rb +39 -20
  7. data/ext/libxml/libxml.c +67 -79
  8. data/ext/libxml/ruby_libxml.h +43 -44
  9. data/ext/libxml/ruby_xml.c +556 -899
  10. data/ext/libxml/ruby_xml.h +9 -10
  11. data/ext/libxml/ruby_xml_attr.c +338 -333
  12. data/ext/libxml/ruby_xml_attr.h +13 -12
  13. data/ext/libxml/ruby_xml_attr_decl.c +19 -12
  14. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  15. data/ext/libxml/ruby_xml_attributes.c +18 -9
  16. data/ext/libxml/ruby_xml_attributes.h +17 -15
  17. data/ext/libxml/ruby_xml_document.c +1142 -1129
  18. data/ext/libxml/ruby_xml_document.h +12 -11
  19. data/ext/libxml/ruby_xml_dtd.c +287 -248
  20. data/ext/libxml/ruby_xml_dtd.h +10 -9
  21. data/ext/libxml/ruby_xml_encoding.c +250 -250
  22. data/ext/libxml/ruby_xml_encoding.h +20 -18
  23. data/ext/libxml/ruby_xml_error.c +1003 -996
  24. data/ext/libxml/ruby_xml_error.h +14 -14
  25. data/ext/libxml/ruby_xml_html_parser.c +91 -91
  26. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  27. data/ext/libxml/ruby_xml_html_parser_context.c +364 -337
  28. data/ext/libxml/ruby_xml_html_parser_context.h +11 -10
  29. data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
  30. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  31. data/ext/libxml/ruby_xml_input_cbg.c +216 -188
  32. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  33. data/ext/libxml/ruby_xml_io.c +49 -47
  34. data/ext/libxml/ruby_xml_io.h +10 -10
  35. data/ext/libxml/ruby_xml_namespace.c +159 -154
  36. data/ext/libxml/ruby_xml_namespace.h +11 -10
  37. data/ext/libxml/ruby_xml_namespaces.c +313 -293
  38. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  39. data/ext/libxml/ruby_xml_node.c +1433 -1398
  40. data/ext/libxml/ruby_xml_node.h +15 -13
  41. data/ext/libxml/ruby_xml_parser.c +91 -91
  42. data/ext/libxml/ruby_xml_parser.h +10 -10
  43. data/ext/libxml/ruby_xml_parser_context.c +1016 -1001
  44. data/ext/libxml/ruby_xml_parser_context.h +11 -10
  45. data/ext/libxml/ruby_xml_parser_options.c +74 -66
  46. data/ext/libxml/ruby_xml_parser_options.h +10 -10
  47. data/ext/libxml/ruby_xml_reader.c +40 -31
  48. data/ext/libxml/ruby_xml_reader.h +14 -14
  49. data/ext/libxml/ruby_xml_registry.c +31 -0
  50. data/ext/libxml/ruby_xml_registry.h +22 -0
  51. data/ext/libxml/ruby_xml_relaxng.c +21 -5
  52. data/ext/libxml/ruby_xml_relaxng.h +9 -8
  53. data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
  54. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  55. data/ext/libxml/ruby_xml_sax_parser.c +108 -116
  56. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  57. data/ext/libxml/ruby_xml_schema.c +22 -15
  58. data/ext/libxml/ruby_xml_schema.h +26 -25
  59. data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
  60. data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
  61. data/ext/libxml/ruby_xml_schema_element.c +8 -8
  62. data/ext/libxml/ruby_xml_schema_element.h +11 -11
  63. data/ext/libxml/ruby_xml_schema_facet.c +50 -50
  64. data/ext/libxml/ruby_xml_schema_facet.h +9 -9
  65. data/ext/libxml/ruby_xml_schema_type.c +12 -19
  66. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  67. data/ext/libxml/ruby_xml_version.h +9 -9
  68. data/ext/libxml/ruby_xml_writer.c +183 -185
  69. data/ext/libxml/ruby_xml_writer.h +6 -6
  70. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  71. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  72. data/ext/libxml/ruby_xml_xpath.c +195 -195
  73. data/ext/libxml/ruby_xml_xpath.h +15 -15
  74. data/ext/libxml/ruby_xml_xpath_context.c +408 -362
  75. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  76. data/ext/libxml/ruby_xml_xpath_expression.c +12 -6
  77. data/ext/libxml/ruby_xml_xpath_expression.h +11 -10
  78. data/ext/libxml/ruby_xml_xpath_object.c +69 -54
  79. data/ext/libxml/ruby_xml_xpath_object.h +19 -17
  80. data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
  81. data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
  82. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  83. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  84. data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
  85. data/lib/libxml/attr.rb +122 -122
  86. data/lib/libxml/attr_decl.rb +80 -80
  87. data/lib/libxml/attributes.rb +13 -13
  88. data/lib/libxml/document.rb +165 -194
  89. data/lib/libxml/error.rb +122 -95
  90. data/lib/libxml/html_parser.rb +80 -96
  91. data/lib/libxml/namespace.rb +61 -61
  92. data/lib/libxml/namespaces.rb +37 -37
  93. data/lib/libxml/node.rb +321 -323
  94. data/lib/libxml/parser.rb +94 -100
  95. data/lib/libxml/sax_callbacks.rb +179 -179
  96. data/lib/libxml/sax_parser.rb +40 -40
  97. data/lib/libxml/schema/attribute.rb +27 -19
  98. data/lib/libxml/schema/element.rb +20 -0
  99. data/lib/libxml/schema/type.rb +44 -21
  100. data/lib/libxml/schema.rb +47 -47
  101. data/lib/libxml/tree.rb +28 -28
  102. data/lib/libxml-ruby.rb +30 -30
  103. data/libxml-ruby.gemspec +46 -48
  104. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  105. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  106. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  107. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  108. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  109. data/test/c14n/result/with-comments/example-1 +5 -5
  110. data/test/c14n/result/with-comments/example-2 +10 -10
  111. data/test/c14n/result/with-comments/example-3 +13 -13
  112. data/test/c14n/result/with-comments/example-4 +8 -8
  113. data/test/c14n/result/with-comments/example-5 +3 -3
  114. data/test/c14n/result/without-comments/example-1 +3 -3
  115. data/test/c14n/result/without-comments/example-2 +10 -10
  116. data/test/c14n/result/without-comments/example-3 +13 -13
  117. data/test/c14n/result/without-comments/example-4 +8 -8
  118. data/test/c14n/result/without-comments/example-5 +2 -2
  119. data/test/test_attr.rb +179 -180
  120. data/test/test_attr_decl.rb +131 -131
  121. data/test/test_attributes.rb +135 -135
  122. data/test/test_canonicalize.rb +122 -120
  123. data/test/test_document.rb +138 -132
  124. data/test/test_document_write.rb +142 -145
  125. data/test/test_dtd.rb +134 -129
  126. data/test/test_encoding.rb +126 -129
  127. data/test/test_encoding_sax.rb +114 -114
  128. data/test/test_error.rb +197 -194
  129. data/test/test_helper.rb +21 -13
  130. data/test/test_html_parser.rb +166 -162
  131. data/test/test_html_parser_context.rb +22 -22
  132. data/test/test_input_callbacks.rb +36 -0
  133. data/test/test_namespace.rb +58 -60
  134. data/test/test_namespaces.rb +200 -200
  135. data/test/test_node.rb +251 -237
  136. data/test/test_node_cdata.rb +50 -50
  137. data/test/test_node_comment.rb +32 -32
  138. data/test/test_node_copy.rb +40 -40
  139. data/test/test_node_edit.rb +176 -158
  140. data/test/test_node_pi.rb +37 -37
  141. data/test/test_node_text.rb +69 -69
  142. data/test/test_node_write.rb +93 -96
  143. data/test/test_node_xlink.rb +28 -28
  144. data/test/test_parser.rb +297 -324
  145. data/test/test_parser_context.rb +198 -198
  146. data/test/test_properties.rb +38 -38
  147. data/test/test_reader.rb +413 -364
  148. data/test/test_relaxng.rb +59 -53
  149. data/test/test_sax_parser.rb +345 -326
  150. data/test/test_schema.rb +28 -0
  151. data/test/test_traversal.rb +152 -152
  152. data/test/test_writer.rb +469 -468
  153. data/test/test_xinclude.rb +20 -20
  154. data/test/test_xml.rb +164 -267
  155. data/test/test_xpath.rb +244 -244
  156. data/test/test_xpath_context.rb +87 -87
  157. data/test/test_xpath_expression.rb +37 -37
  158. metadata +49 -31
  159. data/README.rdoc +0 -217
  160. data/ext/libxml/extconf.h +0 -3
  161. data/ext/libxml/ruby_xml_cbg.c +0 -85
  162. data/lib/libxml/hpricot.rb +0 -78
  163. data/lib/libxml.rb +0 -5
  164. data/lib/xml/libxml.rb +0 -10
  165. data/lib/xml.rb +0 -14
  166. data/script/benchmark/depixelate +0 -634
  167. data/script/benchmark/hamlet.xml +0 -9055
  168. data/script/benchmark/parsecount +0 -170
  169. data/script/benchmark/sock_entries.xml +0 -507
  170. data/script/benchmark/throughput +0 -41
  171. data/script/test +0 -6
  172. data/test/test_deprecated_require.rb +0 -12
@@ -41,38 +41,47 @@ typedef struct
41
41
  int closed;
42
42
  } rxml_writer_object;
43
43
 
44
- static void rxml_writer_free(rxml_writer_object* rwo)
44
+ static void rxml_writer_free(void* data)
45
45
  {
46
- #if 0 /* seems to be done by xmlFreeTextWriter */
47
- if (NULL != rwo->buffer)
48
- {
49
- xmlBufferFree(rwo->buffer);
50
- }
51
- #endif
46
+ rxml_writer_object* rwo = (rxml_writer_object*)data;
47
+ xmlBufferPtr buffer = rwo->buffer;
52
48
 
53
49
  rwo->closed = 1;
54
50
  xmlFreeTextWriter(rwo->writer);
51
+
52
+ if (NULL != buffer)
53
+ {
54
+ xmlBufferFree(buffer);
55
+ }
56
+
55
57
  xfree(rwo);
56
58
  }
57
59
 
58
- static void rxml_writer_mark(rxml_writer_object* rwo)
60
+ static void rxml_writer_mark(void* data)
59
61
  {
62
+ rxml_writer_object* rwo = (rxml_writer_object*)data;
60
63
  if (!NIL_P(rwo->output))
61
64
  {
62
65
  rb_gc_mark(rwo->output);
63
66
  }
64
67
  }
65
68
 
69
+ static const rb_data_type_t rxml_writer_data_type = {
70
+ .wrap_struct_name = "LibXML::XML::Writer",
71
+ .function = { .dmark = rxml_writer_mark, .dfree = rxml_writer_free },
72
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
73
+ };
74
+
66
75
  static VALUE rxml_writer_wrap(rxml_writer_object* rwo)
67
76
  {
68
- return Data_Wrap_Struct(cXMLWriter, rxml_writer_mark, rxml_writer_free, rwo);
77
+ return TypedData_Wrap_Struct(cXMLWriter, &rxml_writer_data_type, rwo);
69
78
  }
70
79
 
71
80
  static rxml_writer_object* rxml_textwriter_get(VALUE obj)
72
81
  {
73
82
  rxml_writer_object* rwo;
74
83
 
75
- Data_Get_Struct(obj, rxml_writer_object, rwo);
84
+ TypedData_Get_Struct(obj, rxml_writer_object, &rxml_writer_data_type, rwo);
76
85
 
77
86
  return rwo;
78
87
  }
@@ -116,11 +125,11 @@ static VALUE rxml_writer_io(VALUE klass, VALUE io)
116
125
  xmlCharEncodingHandlerPtr encodingHdlr = xmlFindCharEncodingHandler(rwo->encoding->name);
117
126
  if (NULL == (out = xmlOutputBufferCreateIO(rxml_writer_write_callback, NULL, (void*)rwo, encodingHdlr)))
118
127
  {
119
- rxml_raise(&xmlLastError);
128
+ rxml_raise(xmlGetLastError());
120
129
  }
121
130
  if (NULL == (rwo->writer = xmlNewTextWriter(out)))
122
131
  {
123
- rxml_raise(&xmlLastError);
132
+ rxml_raise(xmlGetLastError());
124
133
  }
125
134
 
126
135
  return rxml_writer_wrap(rwo);
@@ -145,7 +154,7 @@ static VALUE rxml_writer_file(VALUE klass, VALUE filename)
145
154
  rwo->output_type = RXMLW_OUTPUT_NONE;
146
155
  if (NULL == (rwo->writer = xmlNewTextWriterFilename(StringValueCStr(filename), 0)))
147
156
  {
148
- rxml_raise(&xmlLastError);
157
+ rxml_raise(xmlGetLastError());
149
158
  }
150
159
 
151
160
  return rxml_writer_wrap(rwo);
@@ -167,12 +176,12 @@ static VALUE rxml_writer_string(VALUE klass)
167
176
  rwo->output_type = RXMLW_OUTPUT_STRING;
168
177
  if (NULL == (rwo->buffer = xmlBufferCreate()))
169
178
  {
170
- rxml_raise(&xmlLastError);
179
+ rxml_raise(xmlGetLastError());
171
180
  }
172
181
  if (NULL == (rwo->writer = xmlNewTextWriterMemory(rwo->buffer, 0)))
173
182
  {
174
183
  xmlBufferFree(rwo->buffer);
175
- rxml_raise(&xmlLastError);
184
+ rxml_raise(xmlGetLastError());
176
185
  }
177
186
 
178
187
  return rxml_writer_wrap(rwo);
@@ -187,6 +196,7 @@ static VALUE rxml_writer_doc(VALUE klass)
187
196
  {
188
197
  xmlDocPtr doc;
189
198
  rxml_writer_object* rwo;
199
+ VALUE output, result;
190
200
 
191
201
  rwo = ALLOC(rxml_writer_object);
192
202
  rwo->buffer = NULL;
@@ -196,11 +206,14 @@ static VALUE rxml_writer_doc(VALUE klass)
196
206
  rwo->output_type = RXMLW_OUTPUT_DOC;
197
207
  if (NULL == (rwo->writer = xmlNewTextWriterDoc(&doc, 0)))
198
208
  {
199
- rxml_raise(&xmlLastError);
209
+ rxml_raise(xmlGetLastError());
200
210
  }
201
- rwo->output = rxml_document_wrap(doc);
211
+ output = rxml_document_wrap(doc);
212
+ rwo->output = output;
202
213
 
203
- return rxml_writer_wrap(rwo);
214
+ result = rxml_writer_wrap(rwo);
215
+ RB_GC_GUARD(output);
216
+ return result;
204
217
  }
205
218
 
206
219
  /* ===== public instance methods ===== */
@@ -224,7 +237,7 @@ static VALUE rxml_writer_flush(int argc, VALUE* argv, VALUE self)
224
237
  rwo = rxml_textwriter_get(self);
225
238
  if (-1 == (ret = xmlTextWriterFlush(rwo->writer)))
226
239
  {
227
- rxml_raise(&xmlLastError);
240
+ rxml_raise(xmlGetLastError());
228
241
  }
229
242
 
230
243
  if (NULL != rwo->buffer)
@@ -260,7 +273,7 @@ static VALUE rxml_writer_result(VALUE self)
260
273
 
261
274
  if (bytesWritten == -1)
262
275
  {
263
- rxml_raise(&xmlLastError);
276
+ rxml_raise(xmlGetLastError());
264
277
  }
265
278
 
266
279
  switch (rwo->output_type)
@@ -283,134 +296,44 @@ static VALUE rxml_writer_result(VALUE self)
283
296
  }
284
297
 
285
298
  /* ===== private helpers ===== */
286
-
287
- static VALUE numeric_rxml_writer_void(VALUE obj, int (*fn)(xmlTextWriterPtr))
299
+ static void encodeStrings(rb_encoding* encoding, int count, VALUE* strings, const xmlChar** encoded_strings)
288
300
  {
289
- int ret;
290
- rxml_writer_object* rwo;
291
-
292
- rwo = rxml_textwriter_get(obj);
293
- ret = fn(rwo->writer);
294
-
295
- return (-1 == ret ? Qfalse : Qtrue);
296
- }
297
-
298
- #define numeric_rxml_writer_string(/*VALUE*/ obj, /*VALUE*/ name_or_content, /*int (**/fn/*)(xmlTextWriterPtr, const xmlChar *)*/) \
299
- numeric_rxml_writer_va_strings(obj, Qundef, 1, fn, name_or_content)
300
-
301
- /**
302
- * This is quite ugly but thanks to libxml2 coding style, all xmlTextWriter*
303
- * calls can be redirected to a single function. This can be convenient to:
304
- * - avoid repeating yourself
305
- * - convert strings to UTF-8
306
- * - validate names
307
- * and so on
308
- **/
309
- #define XMLWRITER_MAX_STRING_ARGS 5
310
- static VALUE numeric_rxml_writer_va_strings(VALUE obj, VALUE pe, size_t strings_count, int (*fn)(ANYARGS), ...)
311
- {
312
- va_list ap;
313
- size_t argc;
314
- int ret = -1;
315
- rxml_writer_object* rwo;
316
- const xmlChar* argv[XMLWRITER_MAX_STRING_ARGS];
317
- VALUE utf8[XMLWRITER_MAX_STRING_ARGS], orig[XMLWRITER_MAX_STRING_ARGS];
318
-
319
- if (strings_count > XMLWRITER_MAX_STRING_ARGS)
301
+ for (int i = 0; i < count; i++)
320
302
  {
321
- rb_bug("more arguments than expected");
322
- }
323
- va_start(ap, fn);
324
- rwo = rxml_textwriter_get(obj);
325
- for (argc = 0; argc < strings_count; argc++)
326
- {
327
- VALUE arg;
303
+ VALUE string = strings[i];
328
304
 
329
- arg = va_arg(ap, VALUE);
330
- orig[argc] = arg;
331
- if (NIL_P(arg))
305
+ if (NIL_P(string))
332
306
  {
333
- utf8[argc] = Qnil;
334
- argv[argc] = NULL;
307
+ encoded_strings[i] = NULL;
335
308
  }
336
309
  else
337
310
  {
338
- utf8[argc] = rb_str_conv_enc(orig[argc], rb_enc_get(orig[argc]), rwo->encoding);
339
- argv[argc] = BAD_CAST StringValueCStr(utf8[argc]);
311
+ VALUE encoded = rb_str_conv_enc(strings[i], rb_enc_get(string), encoding);
312
+ encoded_strings[i] = BAD_CAST StringValueCStr(encoded);
340
313
  }
341
314
  }
342
- va_end(ap);
315
+ }
343
316
 
344
- if (Qundef == pe)
345
- {
346
- switch (strings_count)
347
- {
348
- case 0:
349
- ret = fn(rwo->writer);
350
- break;
351
- case 1:
352
- ret = fn(rwo->writer, argv[0]);
353
- break;
354
- case 2:
355
- ret = fn(rwo->writer, argv[0], argv[1]);
356
- break;
357
- case 3:
358
- ret = fn(rwo->writer, argv[0], argv[1], argv[2]);
359
- break;
360
- case 4:
361
- ret = fn(rwo->writer, argv[0], argv[1], argv[2], argv[3]);
362
- break;
363
- case 5:
364
- ret = fn(rwo->writer, argv[0], argv[1], argv[2], argv[3], argv[4]);
365
- break;
366
- default:
367
- break;
368
- }
369
- }
370
- else
371
- {
372
- int xpe;
373
-
374
- xpe = RTEST(pe);
375
- switch (strings_count)
376
- { /* strings_count doesn't include pe */
377
- case 0:
378
- ret = fn(rwo->writer, xpe);
379
- break;
380
- case 1:
381
- ret = fn(rwo->writer, xpe, argv[0]);
382
- break;
383
- case 2:
384
- ret = fn(rwo->writer, xpe, argv[0], argv[1]);
385
- break;
386
- case 3:
387
- ret = fn(rwo->writer, xpe, argv[0], argv[1], argv[2]);
388
- break;
389
- case 4:
390
- ret = fn(rwo->writer, xpe, argv[0], argv[1], argv[2], argv[3]);
391
- break;
392
- case 5:
393
- ret = fn(rwo->writer, xpe, argv[0], argv[1], argv[2], argv[3], argv[4]);
394
- break;
395
- default:
396
- break;
397
- }
398
- }
317
+ static VALUE invoke_void_arg_function(VALUE self, int (*fn)(xmlTextWriterPtr))
318
+ {
319
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
320
+ int result = fn(rwo->writer);
321
+ return (result == -1 ? Qfalse : Qtrue);
322
+ }
399
323
 
400
- while (--strings_count > 0)
401
- {
402
- if (!NIL_P(orig[strings_count]))
403
- {
404
- if (orig[strings_count] != utf8[strings_count])
405
- {
406
- rb_str_free(utf8[strings_count]);
407
- }
408
- }
409
- }
324
+ static VALUE invoke_single_arg_function(VALUE self, int (*fn)(xmlTextWriterPtr, const xmlChar *), VALUE value)
325
+ {
326
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
410
327
 
411
- return (-1 == ret ? Qfalse : Qtrue);
328
+ VALUE rubyStrings[] = { value };
329
+ const xmlChar* xmlStrings[] = { NULL };
330
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
331
+
332
+ int result = fn(rwo->writer, xmlStrings[0]);
333
+ return (result == -1 ? Qfalse : Qtrue);
412
334
  }
413
335
 
336
+
414
337
  /* ===== public instance methods ===== */
415
338
 
416
339
  #if LIBXML_VERSION >= 20605
@@ -443,7 +366,7 @@ static VALUE rxml_writer_set_indent(VALUE self, VALUE indentation)
443
366
  */
444
367
  static VALUE rxml_writer_set_indent_string(VALUE self, VALUE indentation)
445
368
  {
446
- return numeric_rxml_writer_string(self, indentation, xmlTextWriterSetIndentString);
369
+ return invoke_single_arg_function(self, xmlTextWriterSetIndentString, indentation);
447
370
  }
448
371
  #endif /* LIBXML_VERSION >= 20605 */
449
372
 
@@ -459,7 +382,7 @@ static VALUE rxml_writer_set_indent_string(VALUE self, VALUE indentation)
459
382
  */
460
383
  static VALUE rxml_writer_write_comment(VALUE self, VALUE content)
461
384
  {
462
- return numeric_rxml_writer_string(self, content, xmlTextWriterWriteComment);
385
+ return invoke_single_arg_function(self, xmlTextWriterWriteComment, content);
463
386
  }
464
387
 
465
388
  /* call-seq:
@@ -470,7 +393,7 @@ static VALUE rxml_writer_write_comment(VALUE self, VALUE content)
470
393
  */
471
394
  static VALUE rxml_writer_write_cdata(VALUE self, VALUE content)
472
395
  {
473
- return numeric_rxml_writer_string(self, content, xmlTextWriterWriteCDATA);
396
+ return invoke_single_arg_function(self, xmlTextWriterWriteCDATA, content);
474
397
  }
475
398
 
476
399
  static VALUE rxml_writer_start_element(VALUE, VALUE);
@@ -499,7 +422,13 @@ static VALUE rxml_writer_write_element(int argc, VALUE* argv, VALUE self)
499
422
  }
500
423
  else
501
424
  {
502
- return numeric_rxml_writer_va_strings(self, Qundef, 2, xmlTextWriterWriteElement, name, content);
425
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
426
+ VALUE rubyStrings[] = {name, content};
427
+ const xmlChar* xmlStrings[] = {NULL, NULL};
428
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
429
+
430
+ int result = xmlTextWriterWriteElement(rwo->writer, xmlStrings[0], xmlStrings[1]);
431
+ return (result == -1 ? Qfalse : Qtrue);
503
432
  }
504
433
  }
505
434
 
@@ -537,7 +466,12 @@ static VALUE rxml_writer_write_element_ns(int argc, VALUE* argv, VALUE self)
537
466
  }
538
467
  else
539
468
  {
540
- return numeric_rxml_writer_va_strings(self, Qundef, 4, xmlTextWriterWriteElementNS, prefix, name, namespaceURI, content);
469
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
470
+ VALUE rubyStrings[] = {prefix, name, namespaceURI, content};
471
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL, NULL};
472
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
473
+ int result = xmlTextWriterWriteElementNS(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2], xmlStrings[3]);
474
+ return (result == -1 ? Qfalse : Qtrue);
541
475
  }
542
476
  }
543
477
 
@@ -549,7 +483,12 @@ static VALUE rxml_writer_write_element_ns(int argc, VALUE* argv, VALUE self)
549
483
  */
550
484
  static VALUE rxml_writer_write_attribute(VALUE self, VALUE name, VALUE content)
551
485
  {
552
- return numeric_rxml_writer_va_strings(self, Qundef, 2, xmlTextWriterWriteAttribute, name, content);
486
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
487
+ VALUE rubyStrings[] = {name, content};
488
+ const xmlChar* xmlStrings[] = {NULL, NULL};
489
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
490
+ int result = xmlTextWriterWriteAttribute(rwo->writer, xmlStrings[0], xmlStrings[1]);
491
+ return (result == -1 ? Qfalse : Qtrue);
553
492
  }
554
493
 
555
494
  /* call-seq:
@@ -569,10 +508,14 @@ static VALUE rxml_writer_write_attribute(VALUE self, VALUE name, VALUE content)
569
508
  static VALUE rxml_writer_write_attribute_ns(int argc, VALUE* argv, VALUE self)
570
509
  {
571
510
  VALUE prefix, name, namespaceURI, content;
572
-
573
511
  rb_scan_args(argc, argv, "22", &prefix, &name, &namespaceURI, &content);
574
512
 
575
- return numeric_rxml_writer_va_strings(self, Qundef, 4, xmlTextWriterWriteAttributeNS, prefix, name, namespaceURI, content);
513
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
514
+ VALUE rubyStrings[] = {prefix, name, namespaceURI, content};
515
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL, NULL};
516
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
517
+ int result = xmlTextWriterWriteAttributeNS(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2], xmlStrings[3]);
518
+ return (result == -1 ? Qfalse : Qtrue);
576
519
  }
577
520
 
578
521
  /* call-seq:
@@ -583,7 +526,12 @@ static VALUE rxml_writer_write_attribute_ns(int argc, VALUE* argv, VALUE self)
583
526
  */
584
527
  static VALUE rxml_writer_write_pi(VALUE self, VALUE target, VALUE content)
585
528
  {
586
- return numeric_rxml_writer_va_strings(self, Qundef, 2, xmlTextWriterWritePI, target, content);
529
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
530
+ VALUE rubyStrings[] = {target, content};
531
+ const xmlChar* xmlStrings[] = {NULL, NULL};
532
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
533
+ int result = xmlTextWriterWritePI(rwo->writer, xmlStrings[0], xmlStrings[1]);
534
+ return (result == -1 ? Qfalse : Qtrue);
587
535
  }
588
536
 
589
537
  /* ===== public start/end interface ===== */
@@ -597,7 +545,7 @@ static VALUE rxml_writer_write_pi(VALUE self, VALUE target, VALUE content)
597
545
  */
598
546
  static VALUE rxml_writer_write_string(VALUE self, VALUE content)
599
547
  {
600
- return numeric_rxml_writer_string(self, content, xmlTextWriterWriteString);
548
+ return invoke_single_arg_function(self, xmlTextWriterWriteString, content);
601
549
  }
602
550
 
603
551
  /* call-seq:
@@ -609,7 +557,7 @@ static VALUE rxml_writer_write_string(VALUE self, VALUE content)
609
557
  */
610
558
  static VALUE rxml_writer_write_raw(VALUE self, VALUE content)
611
559
  {
612
- return numeric_rxml_writer_string(self, content, xmlTextWriterWriteRaw);
560
+ return invoke_single_arg_function(self, xmlTextWriterWriteRaw, content);
613
561
  }
614
562
 
615
563
  /* call-seq:
@@ -619,7 +567,7 @@ static VALUE rxml_writer_write_raw(VALUE self, VALUE content)
619
567
  */
620
568
  static VALUE rxml_writer_start_attribute(VALUE self, VALUE name)
621
569
  {
622
- return numeric_rxml_writer_string(self, name, xmlTextWriterStartAttribute);
570
+ return invoke_single_arg_function(self, xmlTextWriterStartAttribute, name);
623
571
  }
624
572
 
625
573
  /* call-seq:
@@ -635,10 +583,14 @@ static VALUE rxml_writer_start_attribute(VALUE self, VALUE name)
635
583
  static VALUE rxml_writer_start_attribute_ns(int argc, VALUE* argv, VALUE self)
636
584
  {
637
585
  VALUE prefix, name, namespaceURI;
638
-
639
586
  rb_scan_args(argc, argv, "21", &prefix, &name, &namespaceURI);
640
587
 
641
- return numeric_rxml_writer_va_strings(self, Qundef, 3, xmlTextWriterStartAttributeNS, prefix, name, namespaceURI);
588
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
589
+ VALUE rubyStrings[] = {prefix, name, namespaceURI};
590
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL};
591
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
592
+ int result = xmlTextWriterStartAttributeNS(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2]);
593
+ return (result == -1 ? Qfalse : Qtrue);
642
594
  }
643
595
 
644
596
  /* call-seq:
@@ -648,7 +600,7 @@ static VALUE rxml_writer_start_attribute_ns(int argc, VALUE* argv, VALUE self)
648
600
  */
649
601
  static VALUE rxml_writer_end_attribute(VALUE self)
650
602
  {
651
- return numeric_rxml_writer_void(self, xmlTextWriterEndAttribute);
603
+ return invoke_void_arg_function(self, xmlTextWriterEndAttribute);
652
604
  }
653
605
 
654
606
  #if LIBXML_VERSION >= 20607
@@ -660,7 +612,7 @@ static VALUE rxml_writer_end_attribute(VALUE self)
660
612
  */
661
613
  static VALUE rxml_writer_start_comment(VALUE self)
662
614
  {
663
- return numeric_rxml_writer_void(self, xmlTextWriterStartComment);
615
+ return invoke_void_arg_function(self, xmlTextWriterStartComment);
664
616
  }
665
617
 
666
618
  /* call-seq:
@@ -671,7 +623,7 @@ static VALUE rxml_writer_start_comment(VALUE self)
671
623
  */
672
624
  static VALUE rxml_writer_end_comment(VALUE self)
673
625
  {
674
- return numeric_rxml_writer_void(self, xmlTextWriterEndComment);
626
+ return invoke_void_arg_function(self, xmlTextWriterEndComment);
675
627
  }
676
628
  #endif /* LIBXML_VERSION >= 20607 */
677
629
 
@@ -682,7 +634,7 @@ static VALUE rxml_writer_end_comment(VALUE self)
682
634
  */
683
635
  static VALUE rxml_writer_start_element(VALUE self, VALUE name)
684
636
  {
685
- return numeric_rxml_writer_string(self, name, xmlTextWriterStartElement);
637
+ return invoke_single_arg_function(self, xmlTextWriterStartElement, name);
686
638
  }
687
639
 
688
640
  /* call-seq:
@@ -698,10 +650,14 @@ static VALUE rxml_writer_start_element(VALUE self, VALUE name)
698
650
  static VALUE rxml_writer_start_element_ns(int argc, VALUE* argv, VALUE self)
699
651
  {
700
652
  VALUE prefix, name, namespaceURI;
701
-
702
653
  rb_scan_args(argc, argv, "21", &prefix, &name, &namespaceURI);
703
654
 
704
- return numeric_rxml_writer_va_strings(self, Qundef, 3, xmlTextWriterStartElementNS, prefix, name, namespaceURI);
655
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
656
+ VALUE rubyStrings[] = {prefix, name, namespaceURI};
657
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL};
658
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
659
+ int result = xmlTextWriterStartElementNS(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2]);
660
+ return (result == -1 ? Qfalse : Qtrue);
705
661
  }
706
662
 
707
663
  /* call-seq:
@@ -711,7 +667,7 @@ static VALUE rxml_writer_start_element_ns(int argc, VALUE* argv, VALUE self)
711
667
  */
712
668
  static VALUE rxml_writer_end_element(VALUE self)
713
669
  {
714
- return numeric_rxml_writer_void(self, xmlTextWriterEndElement);
670
+ return invoke_void_arg_function(self, xmlTextWriterEndElement);
715
671
  }
716
672
 
717
673
  /* call-seq:
@@ -723,7 +679,7 @@ static VALUE rxml_writer_end_element(VALUE self)
723
679
  */
724
680
  static VALUE rxml_writer_full_end_element(VALUE self)
725
681
  {
726
- return numeric_rxml_writer_void(self, xmlTextWriterFullEndElement);
682
+ return invoke_void_arg_function(self, xmlTextWriterFullEndElement);
727
683
  }
728
684
 
729
685
  /* call-seq:
@@ -733,7 +689,7 @@ static VALUE rxml_writer_full_end_element(VALUE self)
733
689
  */
734
690
  static VALUE rxml_writer_start_cdata(VALUE self)
735
691
  {
736
- return numeric_rxml_writer_void(self, xmlTextWriterStartCDATA);
692
+ return invoke_void_arg_function(self, xmlTextWriterStartCDATA);
737
693
  }
738
694
 
739
695
  /* call-seq:
@@ -743,7 +699,7 @@ static VALUE rxml_writer_start_cdata(VALUE self)
743
699
  */
744
700
  static VALUE rxml_writer_end_cdata(VALUE self)
745
701
  {
746
- return numeric_rxml_writer_void(self, xmlTextWriterEndCDATA);
702
+ return invoke_void_arg_function(self, xmlTextWriterEndCDATA);
747
703
  }
748
704
 
749
705
  /* call-seq:
@@ -801,7 +757,7 @@ static VALUE rxml_writer_start_document(int argc, VALUE* argv, VALUE self)
801
757
  */
802
758
  static VALUE rxml_writer_end_document(VALUE self)
803
759
  {
804
- return numeric_rxml_writer_void(self, xmlTextWriterEndDocument);
760
+ return invoke_void_arg_function(self, xmlTextWriterEndDocument);
805
761
  }
806
762
 
807
763
  /* call-seq:
@@ -811,7 +767,7 @@ static VALUE rxml_writer_end_document(VALUE self)
811
767
  */
812
768
  static VALUE rxml_writer_start_pi(VALUE self, VALUE target)
813
769
  {
814
- return numeric_rxml_writer_string(self, target, xmlTextWriterStartPI);
770
+ return invoke_single_arg_function(self, xmlTextWriterStartPI, target);
815
771
  }
816
772
 
817
773
  /* call-seq:
@@ -821,7 +777,7 @@ static VALUE rxml_writer_start_pi(VALUE self, VALUE target)
821
777
  */
822
778
  static VALUE rxml_writer_end_pi(VALUE self)
823
779
  {
824
- return numeric_rxml_writer_void(self, xmlTextWriterEndPI);
780
+ return invoke_void_arg_function(self, xmlTextWriterEndPI);
825
781
  }
826
782
 
827
783
  /* call-seq:
@@ -832,10 +788,14 @@ static VALUE rxml_writer_end_pi(VALUE self)
832
788
  static VALUE rxml_writer_start_dtd(int argc, VALUE* argv, VALUE self)
833
789
  {
834
790
  VALUE name, pubid, sysid;
835
-
836
791
  rb_scan_args(argc, argv, "12", &name, &pubid, &sysid);
837
792
 
838
- return numeric_rxml_writer_va_strings(self, Qundef, 3, xmlTextWriterStartDTD, name, pubid, sysid);
793
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
794
+ VALUE rubyStrings[] = {name, pubid, sysid};
795
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL};
796
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
797
+ int result = xmlTextWriterStartDTD(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2]);
798
+ return (result == -1 ? Qfalse : Qtrue);
839
799
  }
840
800
 
841
801
  /* call-seq:
@@ -845,7 +805,7 @@ static VALUE rxml_writer_start_dtd(int argc, VALUE* argv, VALUE self)
845
805
  */
846
806
  static VALUE rxml_writer_start_dtd_element(VALUE self, VALUE name)
847
807
  {
848
- return numeric_rxml_writer_string(self, name, xmlTextWriterStartDTDElement);
808
+ return invoke_single_arg_function(self, xmlTextWriterStartDTDElement, name);
849
809
  }
850
810
 
851
811
  /* call-seq:
@@ -856,14 +816,14 @@ static VALUE rxml_writer_start_dtd_element(VALUE self, VALUE name)
856
816
  static VALUE rxml_writer_start_dtd_entity(int argc, VALUE* argv, VALUE self)
857
817
  {
858
818
  VALUE name, pe;
859
-
860
819
  rb_scan_args(argc, argv, "11", &name, &pe);
861
- if (NIL_P(pe))
862
- {
863
- pe = Qfalse;
864
- }
865
820
 
866
- return numeric_rxml_writer_va_strings(self, pe, 1, xmlTextWriterStartDTDEntity, name);
821
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
822
+ VALUE rubyStrings[] = {name};
823
+ const xmlChar* xmlStrings[] = {NULL};
824
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
825
+ int result = xmlTextWriterStartDTDEntity(rwo->writer, RB_TEST(pe), xmlStrings[0]);
826
+ return (result == -1 ? Qfalse : Qtrue);
867
827
  }
868
828
 
869
829
  /* call-seq:
@@ -873,7 +833,7 @@ static VALUE rxml_writer_start_dtd_entity(int argc, VALUE* argv, VALUE self)
873
833
  */
874
834
  static VALUE rxml_writer_start_dtd_attlist(VALUE self, VALUE name)
875
835
  {
876
- return numeric_rxml_writer_string(self, name, xmlTextWriterStartDTDAttlist);
836
+ return invoke_single_arg_function(self, xmlTextWriterStartDTDAttlist, name);
877
837
  }
878
838
 
879
839
  /* call-seq:
@@ -883,7 +843,7 @@ static VALUE rxml_writer_start_dtd_attlist(VALUE self, VALUE name)
883
843
  */
884
844
  static VALUE rxml_writer_end_dtd(VALUE self)
885
845
  {
886
- return numeric_rxml_writer_void(self, xmlTextWriterEndDTD);
846
+ return invoke_void_arg_function(self, xmlTextWriterEndDTD);
887
847
  }
888
848
 
889
849
  /* call-seq:
@@ -893,7 +853,7 @@ static VALUE rxml_writer_end_dtd(VALUE self)
893
853
  */
894
854
  static VALUE rxml_writer_end_dtd_entity(VALUE self)
895
855
  {
896
- return numeric_rxml_writer_void(self, xmlTextWriterEndDTDEntity);
856
+ return invoke_void_arg_function(self, xmlTextWriterEndDTDEntity);
897
857
  }
898
858
 
899
859
  /* call-seq:
@@ -903,7 +863,7 @@ static VALUE rxml_writer_end_dtd_entity(VALUE self)
903
863
  */
904
864
  static VALUE rxml_writer_end_dtd_attlist(VALUE self)
905
865
  {
906
- return numeric_rxml_writer_void(self, xmlTextWriterEndDTDAttlist);
866
+ return invoke_void_arg_function(self, xmlTextWriterEndDTDAttlist);
907
867
  }
908
868
 
909
869
  /* call-seq:
@@ -913,7 +873,7 @@ static VALUE rxml_writer_end_dtd_attlist(VALUE self)
913
873
  */
914
874
  static VALUE rxml_writer_end_dtd_element(VALUE self)
915
875
  {
916
- return numeric_rxml_writer_void(self, xmlTextWriterEndDTDElement);
876
+ return invoke_void_arg_function(self, xmlTextWriterEndDTDElement);
917
877
  }
918
878
 
919
879
  /* call-seq:
@@ -938,10 +898,14 @@ static VALUE rxml_writer_end_dtd_element(VALUE self)
938
898
  static VALUE rxml_writer_write_dtd(int argc, VALUE* argv, VALUE self)
939
899
  {
940
900
  VALUE name, pubid, sysid, subset;
941
-
942
901
  rb_scan_args(argc, argv, "13", &name, &pubid, &sysid, &subset);
943
902
 
944
- return numeric_rxml_writer_va_strings(self, Qundef, 4, xmlTextWriterWriteDTD, name, pubid, sysid, subset);
903
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
904
+ VALUE rubyStrings[] = {name, pubid, sysid, subset};
905
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL, NULL};
906
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
907
+ int result = xmlTextWriterWriteDTD(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2], xmlStrings[3]);
908
+ return (result == -1 ? Qfalse : Qtrue);
945
909
  }
946
910
 
947
911
  /* call-seq:
@@ -953,7 +917,12 @@ static VALUE rxml_writer_write_dtd(int argc, VALUE* argv, VALUE self)
953
917
  */
954
918
  static VALUE rxml_writer_write_dtd_attlist(VALUE self, VALUE name, VALUE content)
955
919
  {
956
- return numeric_rxml_writer_va_strings(self, Qundef, 2, xmlTextWriterWriteDTDAttlist, name, content);
920
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
921
+ VALUE rubyStrings[] = {name, content};
922
+ const xmlChar* xmlStrings[] = {NULL, NULL};
923
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
924
+ int result = xmlTextWriterWriteDTDAttlist(rwo->writer, xmlStrings[0], xmlStrings[1]);
925
+ return (result == -1 ? Qfalse : Qtrue);
957
926
  }
958
927
 
959
928
  /* call-seq:
@@ -965,7 +934,12 @@ static VALUE rxml_writer_write_dtd_attlist(VALUE self, VALUE name, VALUE content
965
934
  */
966
935
  static VALUE rxml_writer_write_dtd_element(VALUE self, VALUE name, VALUE content)
967
936
  {
968
- return numeric_rxml_writer_va_strings(self, Qundef, 2, xmlTextWriterWriteDTDElement, name, content);
937
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
938
+ VALUE rubyStrings[] = {name, content};
939
+ const xmlChar* xmlStrings[] = {NULL, NULL};
940
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
941
+ int result = xmlTextWriterWriteDTDElement(rwo->writer, xmlStrings[0], xmlStrings[1]);
942
+ return (result == -1 ? Qfalse : Qtrue);
969
943
  }
970
944
 
971
945
  /* call-seq:
@@ -975,7 +949,12 @@ static VALUE rxml_writer_write_dtd_element(VALUE self, VALUE name, VALUE content
975
949
  */
976
950
  static VALUE rxml_writer_write_dtd_entity(VALUE self, VALUE name, VALUE pubid, VALUE sysid, VALUE ndataid, VALUE content, VALUE pe)
977
951
  {
978
- return numeric_rxml_writer_va_strings(self, pe, 5, xmlTextWriterWriteDTDEntity, name, pubid, sysid, ndataid, content);
952
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
953
+ VALUE rubyStrings[] = {name, pubid, sysid, ndataid, content};
954
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL, NULL, NULL};
955
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
956
+ int result = xmlTextWriterWriteDTDEntity(rwo->writer, RB_TEST(pe), xmlStrings[0], xmlStrings[1], xmlStrings[2], xmlStrings[3], xmlStrings[4]);
957
+ return (result == -1 ? Qfalse : Qtrue);
979
958
  }
980
959
 
981
960
  /* call-seq:
@@ -992,7 +971,12 @@ static VALUE rxml_writer_write_dtd_entity(VALUE self, VALUE name, VALUE pubid, V
992
971
  */
993
972
  static VALUE rxml_writer_write_dtd_external_entity(VALUE self, VALUE name, VALUE pubid, VALUE sysid, VALUE ndataid, VALUE pe)
994
973
  {
995
- return numeric_rxml_writer_va_strings(self, pe, 4, xmlTextWriterWriteDTDExternalEntity, name, pubid, sysid, ndataid);
974
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
975
+ VALUE rubyStrings[] = {name, pubid, sysid, ndataid};
976
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL, NULL};
977
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
978
+ int result = xmlTextWriterWriteDTDExternalEntity(rwo->writer, RB_TEST(pe), xmlStrings[0], xmlStrings[1], xmlStrings[2], xmlStrings[3]);
979
+ return (result == -1 ? Qfalse : Qtrue);
996
980
  }
997
981
 
998
982
  /* call-seq:
@@ -1002,7 +986,12 @@ static VALUE rxml_writer_write_dtd_external_entity(VALUE self, VALUE name, VALUE
1002
986
  */
1003
987
  static VALUE rxml_writer_write_dtd_external_entity_contents(VALUE self, VALUE pubid, VALUE sysid, VALUE ndataid)
1004
988
  {
1005
- return numeric_rxml_writer_va_strings(self, Qundef, 3, xmlTextWriterWriteDTDExternalEntityContents, pubid, sysid, ndataid);
989
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
990
+ VALUE rubyStrings[] = {pubid, sysid, ndataid,};
991
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL};
992
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
993
+ int result = xmlTextWriterWriteDTDExternalEntityContents(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2]);
994
+ return (result == -1 ? Qfalse : Qtrue);
1006
995
  }
1007
996
 
1008
997
  /* call-seq:
@@ -1018,7 +1007,12 @@ static VALUE rxml_writer_write_dtd_external_entity_contents(VALUE self, VALUE pu
1018
1007
  */
1019
1008
  static VALUE rxml_writer_write_dtd_internal_entity(VALUE self, VALUE name, VALUE content, VALUE pe)
1020
1009
  {
1021
- return numeric_rxml_writer_va_strings(self, pe, 2, xmlTextWriterWriteDTDInternalEntity, name, content);
1010
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
1011
+ VALUE rubyStrings[] = {name, content};
1012
+ const xmlChar* xmlStrings[] = {NULL, NULL};
1013
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
1014
+ int result = xmlTextWriterWriteDTDInternalEntity(rwo->writer, RB_TEST(pe), xmlStrings[0], xmlStrings[1]);
1015
+ return (result == -1 ? Qfalse : Qtrue);
1022
1016
  }
1023
1017
 
1024
1018
  /* call-seq:
@@ -1028,7 +1022,12 @@ static VALUE rxml_writer_write_dtd_internal_entity(VALUE self, VALUE name, VALUE
1028
1022
  */
1029
1023
  static VALUE rxml_writer_write_dtd_notation(VALUE self, VALUE name, VALUE pubid, VALUE sysid)
1030
1024
  {
1031
- return numeric_rxml_writer_va_strings(self, Qundef, 3, xmlTextWriterWriteDTDNotation, name, pubid, sysid);
1025
+ rxml_writer_object* rwo = rxml_textwriter_get(self);
1026
+ VALUE rubyStrings[] = {name, pubid, sysid};
1027
+ const xmlChar* xmlStrings[] = {NULL, NULL, NULL};
1028
+ encodeStrings(rwo->encoding, sizeof(rubyStrings)/sizeof(VALUE), rubyStrings, xmlStrings);
1029
+ int result = xmlTextWriterWriteDTDNotation(rwo->writer, xmlStrings[0], xmlStrings[1], xmlStrings[2]);
1030
+ return (result == -1 ? Qfalse : Qtrue);
1032
1031
  }
1033
1032
 
1034
1033
  #if LIBXML_VERSION >= 20900
@@ -1135,4 +1134,3 @@ void rxml_init_writer(void)
1135
1134
  rb_undef_method(CLASS_OF(cXMLWriter), "new");
1136
1135
  #endif
1137
1136
  }
1138
-