nokogiri 1.10.3 → 1.11.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +1015 -947
  4. data/LICENSE.md +1 -1
  5. data/README.md +173 -94
  6. data/dependencies.yml +28 -26
  7. data/ext/nokogiri/depend +37 -358
  8. data/ext/nokogiri/extconf.rb +611 -391
  9. data/ext/nokogiri/html_document.c +78 -82
  10. data/ext/nokogiri/html_element_description.c +84 -71
  11. data/ext/nokogiri/html_entity_lookup.c +21 -16
  12. data/ext/nokogiri/html_sax_parser_context.c +69 -66
  13. data/ext/nokogiri/html_sax_push_parser.c +42 -34
  14. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  15. data/ext/nokogiri/nokogiri.c +192 -87
  16. data/ext/nokogiri/nokogiri.h +181 -89
  17. data/ext/nokogiri/test_global_handlers.c +40 -0
  18. data/ext/nokogiri/xml_attr.c +15 -15
  19. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  20. data/ext/nokogiri/xml_cdata.c +13 -18
  21. data/ext/nokogiri/xml_comment.c +19 -26
  22. data/ext/nokogiri/xml_document.c +255 -183
  23. data/ext/nokogiri/xml_document_fragment.c +13 -15
  24. data/ext/nokogiri/xml_dtd.c +54 -48
  25. data/ext/nokogiri/xml_element_content.c +30 -27
  26. data/ext/nokogiri/xml_element_decl.c +22 -22
  27. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  28. data/ext/nokogiri/xml_entity_decl.c +32 -30
  29. data/ext/nokogiri/xml_entity_reference.c +16 -18
  30. data/ext/nokogiri/xml_namespace.c +56 -49
  31. data/ext/nokogiri/xml_node.c +387 -316
  32. data/ext/nokogiri/xml_node_set.c +168 -156
  33. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  34. data/ext/nokogiri/xml_reader.c +195 -172
  35. data/ext/nokogiri/xml_relax_ng.c +52 -28
  36. data/ext/nokogiri/xml_sax_parser.c +118 -118
  37. data/ext/nokogiri/xml_sax_parser_context.c +103 -86
  38. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  39. data/ext/nokogiri/xml_schema.c +111 -34
  40. data/ext/nokogiri/xml_syntax_error.c +42 -21
  41. data/ext/nokogiri/xml_text.c +13 -17
  42. data/ext/nokogiri/xml_xpath_context.c +206 -123
  43. data/ext/nokogiri/xslt_stylesheet.c +158 -165
  44. data/lib/nokogiri/css/node.rb +1 -0
  45. data/lib/nokogiri/css/parser.rb +63 -62
  46. data/lib/nokogiri/css/parser.y +2 -2
  47. data/lib/nokogiri/css/parser_extras.rb +39 -36
  48. data/lib/nokogiri/css/syntax_error.rb +1 -0
  49. data/lib/nokogiri/css/tokenizer.rb +105 -103
  50. data/lib/nokogiri/css/xpath_visitor.rb +73 -43
  51. data/lib/nokogiri/css.rb +1 -0
  52. data/lib/nokogiri/decorators/slop.rb +1 -0
  53. data/lib/nokogiri/extension.rb +26 -0
  54. data/lib/nokogiri/html/builder.rb +1 -0
  55. data/lib/nokogiri/html/document.rb +13 -26
  56. data/lib/nokogiri/html/document_fragment.rb +16 -15
  57. data/lib/nokogiri/html/element_description.rb +1 -0
  58. data/lib/nokogiri/html/element_description_defaults.rb +1 -0
  59. data/lib/nokogiri/html/entity_lookup.rb +1 -0
  60. data/lib/nokogiri/html/sax/parser.rb +1 -0
  61. data/lib/nokogiri/html/sax/parser_context.rb +1 -0
  62. data/lib/nokogiri/html/sax/push_parser.rb +1 -0
  63. data/lib/nokogiri/html.rb +1 -0
  64. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  65. data/lib/nokogiri/syntax_error.rb +1 -0
  66. data/lib/nokogiri/version/constant.rb +5 -0
  67. data/lib/nokogiri/version/info.rb +205 -0
  68. data/lib/nokogiri/version.rb +3 -109
  69. data/lib/nokogiri/xml/attr.rb +1 -0
  70. data/lib/nokogiri/xml/attribute_decl.rb +1 -0
  71. data/lib/nokogiri/xml/builder.rb +36 -32
  72. data/lib/nokogiri/xml/cdata.rb +1 -0
  73. data/lib/nokogiri/xml/character_data.rb +1 -0
  74. data/lib/nokogiri/xml/document.rb +92 -41
  75. data/lib/nokogiri/xml/document_fragment.rb +5 -6
  76. data/lib/nokogiri/xml/dtd.rb +1 -0
  77. data/lib/nokogiri/xml/element_content.rb +1 -0
  78. data/lib/nokogiri/xml/element_decl.rb +1 -0
  79. data/lib/nokogiri/xml/entity_decl.rb +1 -0
  80. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  81. data/lib/nokogiri/xml/namespace.rb +1 -0
  82. data/lib/nokogiri/xml/node/save_options.rb +1 -0
  83. data/lib/nokogiri/xml/node.rb +625 -290
  84. data/lib/nokogiri/xml/node_set.rb +1 -0
  85. data/lib/nokogiri/xml/notation.rb +1 -0
  86. data/lib/nokogiri/xml/parse_options.rb +10 -3
  87. data/lib/nokogiri/xml/pp/character_data.rb +1 -0
  88. data/lib/nokogiri/xml/pp/node.rb +1 -0
  89. data/lib/nokogiri/xml/pp.rb +1 -0
  90. data/lib/nokogiri/xml/processing_instruction.rb +1 -0
  91. data/lib/nokogiri/xml/reader.rb +9 -12
  92. data/lib/nokogiri/xml/relax_ng.rb +7 -2
  93. data/lib/nokogiri/xml/sax/document.rb +1 -0
  94. data/lib/nokogiri/xml/sax/parser.rb +1 -0
  95. data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
  96. data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
  97. data/lib/nokogiri/xml/sax.rb +1 -0
  98. data/lib/nokogiri/xml/schema.rb +13 -4
  99. data/lib/nokogiri/xml/searchable.rb +25 -16
  100. data/lib/nokogiri/xml/syntax_error.rb +1 -0
  101. data/lib/nokogiri/xml/text.rb +1 -0
  102. data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
  103. data/lib/nokogiri/xml/xpath.rb +2 -3
  104. data/lib/nokogiri/xml/xpath_context.rb +1 -0
  105. data/lib/nokogiri/xml.rb +1 -0
  106. data/lib/nokogiri/xslt/stylesheet.rb +1 -0
  107. data/lib/nokogiri/xslt.rb +1 -0
  108. data/lib/nokogiri.rb +6 -27
  109. data/lib/xsd/xmlparser/nokogiri.rb +1 -0
  110. data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
  111. data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
  112. data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +25 -0
  113. data/patches/libxml2/0004-use-glibc-strlen.patch +53 -0
  114. data/patches/libxml2/0005-avoid-isnan-isinf.patch +81 -0
  115. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2511 -0
  116. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
  117. data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +19 -0
  118. data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
  119. data/ports/archives/libxslt-1.1.34.tar.gz +0 -0
  120. metadata +102 -147
  121. data/ext/nokogiri/html_document.h +0 -10
  122. data/ext/nokogiri/html_element_description.h +0 -10
  123. data/ext/nokogiri/html_entity_lookup.h +0 -8
  124. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  125. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  126. data/ext/nokogiri/xml_attr.h +0 -9
  127. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  128. data/ext/nokogiri/xml_cdata.h +0 -9
  129. data/ext/nokogiri/xml_comment.h +0 -9
  130. data/ext/nokogiri/xml_document.h +0 -23
  131. data/ext/nokogiri/xml_document_fragment.h +0 -10
  132. data/ext/nokogiri/xml_dtd.h +0 -10
  133. data/ext/nokogiri/xml_element_content.h +0 -10
  134. data/ext/nokogiri/xml_element_decl.h +0 -9
  135. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  136. data/ext/nokogiri/xml_entity_decl.h +0 -10
  137. data/ext/nokogiri/xml_entity_reference.h +0 -9
  138. data/ext/nokogiri/xml_io.c +0 -61
  139. data/ext/nokogiri/xml_io.h +0 -11
  140. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  141. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  142. data/ext/nokogiri/xml_namespace.h +0 -14
  143. data/ext/nokogiri/xml_node.h +0 -13
  144. data/ext/nokogiri/xml_node_set.h +0 -12
  145. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  146. data/ext/nokogiri/xml_reader.h +0 -10
  147. data/ext/nokogiri/xml_relax_ng.h +0 -9
  148. data/ext/nokogiri/xml_sax_parser.h +0 -39
  149. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  150. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  151. data/ext/nokogiri/xml_schema.h +0 -9
  152. data/ext/nokogiri/xml_syntax_error.h +0 -13
  153. data/ext/nokogiri/xml_text.h +0 -9
  154. data/ext/nokogiri/xml_xpath_context.h +0 -10
  155. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  156. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  157. data/patches/libxslt/0001-Fix-security-framework-bypass.patch +0 -120
  158. data/ports/archives/libxml2-2.9.9.tar.gz +0 -0
  159. data/ports/archives/libxslt-1.1.33.tar.gz +0 -0
@@ -1,9 +1,12 @@
1
- #include <xml_node.h>
1
+ #include <nokogiri.h>
2
2
 
3
- static ID decorate, decorate_bang;
3
+ VALUE cNokogiriXmlNode ;
4
+
5
+ static ID id_decorate, id_decorate_bang;
4
6
 
5
7
  #ifdef DEBUG
6
- static void debug_node_dealloc(xmlNodePtr x)
8
+ static void
9
+ debug_node_dealloc(xmlNodePtr x)
7
10
  {
8
11
  NOKOGIRI_DEBUG_START(x)
9
12
  NOKOGIRI_DEBUG_END(x)
@@ -12,23 +15,25 @@ static void debug_node_dealloc(xmlNodePtr x)
12
15
  # define debug_node_dealloc 0
13
16
  #endif
14
17
 
15
- static void mark(xmlNodePtr node)
18
+ static void
19
+ mark(xmlNodePtr node)
16
20
  {
17
21
  xmlDocPtr doc = node->doc;
18
- if(doc->type == XML_DOCUMENT_NODE || doc->type == XML_HTML_DOCUMENT_NODE) {
19
- if(DOC_RUBY_OBJECT_TEST(doc)) {
22
+ if (doc->type == XML_DOCUMENT_NODE || doc->type == XML_HTML_DOCUMENT_NODE) {
23
+ if (DOC_RUBY_OBJECT_TEST(doc)) {
20
24
  rb_gc_mark(DOC_RUBY_OBJECT(doc));
21
25
  }
22
- } else if(node->doc->_private) {
26
+ } else if (node->doc->_private) {
23
27
  rb_gc_mark((VALUE)doc->_private);
24
28
  }
25
29
  }
26
30
 
27
31
  /* :nodoc: */
28
- typedef xmlNodePtr (*pivot_reparentee_func)(xmlNodePtr, xmlNodePtr);
32
+ typedef xmlNodePtr(*pivot_reparentee_func)(xmlNodePtr, xmlNodePtr);
29
33
 
30
34
  /* :nodoc: */
31
- static void relink_namespace(xmlNodePtr reparented)
35
+ static void
36
+ relink_namespace(xmlNodePtr reparented)
32
37
  {
33
38
  xmlNodePtr child;
34
39
 
@@ -42,7 +47,7 @@ static void relink_namespace(xmlNodePtr reparented)
42
47
  name = xmlSplitQName2(reparented->name, &prefix);
43
48
 
44
49
  if (reparented->type == XML_ATTRIBUTE_NODE) {
45
- if (prefix == NULL || strcmp((char*)prefix, XMLNS_PREFIX) == 0) {
50
+ if (prefix == NULL || strcmp((char *)prefix, XMLNS_PREFIX) == 0) {
46
51
  xmlFree(name);
47
52
  xmlFree(prefix);
48
53
  return;
@@ -87,7 +92,7 @@ static void relink_namespace(xmlNodePtr reparented)
87
92
  } else {
88
93
  reparented->nsDef = curr->next;
89
94
  }
90
- nokogiri_root_nsdef(curr, reparented->doc);
95
+ noko_xml_document_pin_namespace(curr, reparented->doc);
91
96
  } else {
92
97
  prev = curr;
93
98
  }
@@ -128,7 +133,7 @@ static void relink_namespace(xmlNodePtr reparented)
128
133
 
129
134
  if (reparented->type == XML_ELEMENT_NODE) {
130
135
  child = (xmlNodePtr)((xmlElementPtr)reparented)->attributes;
131
- while(NULL != child) {
136
+ while (NULL != child) {
132
137
  relink_namespace(child);
133
138
  child = child->next;
134
139
  }
@@ -136,7 +141,8 @@ static void relink_namespace(xmlNodePtr reparented)
136
141
  }
137
142
 
138
143
  /* :nodoc: */
139
- static xmlNodePtr xmlReplaceNodeWrapper(xmlNodePtr pivot, xmlNodePtr new_node)
144
+ static xmlNodePtr
145
+ xmlReplaceNodeWrapper(xmlNodePtr pivot, xmlNodePtr new_node)
140
146
  {
141
147
  xmlNodePtr retval ;
142
148
 
@@ -160,16 +166,17 @@ static xmlNodePtr xmlReplaceNodeWrapper(xmlNodePtr pivot, xmlNodePtr new_node)
160
166
  }
161
167
 
162
168
  /* :nodoc: */
163
- static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_reparentee_func prf)
169
+ static VALUE
170
+ reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_reparentee_func prf)
164
171
  {
165
172
  VALUE reparented_obj ;
166
173
  xmlNodePtr reparentee, pivot, reparented, next_text, new_next_text, parent ;
167
174
  int original_ns_prefix_is_default = 0 ;
168
175
 
169
- if(!rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlNode)) {
176
+ if (!rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlNode)) {
170
177
  rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
171
178
  }
172
- if(rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlDocument)) {
179
+ if (rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlDocument)) {
173
180
  rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
174
181
  }
175
182
 
@@ -290,7 +297,7 @@ ok:
290
297
  original_ns_prefix_is_default = 1;
291
298
  }
292
299
 
293
- nokogiri_root_node(reparentee);
300
+ noko_xml_document_pin_node(reparentee);
294
301
 
295
302
  if (!(reparentee = xmlDocCopyNode(reparentee, pivot->doc, 1))) {
296
303
  rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
@@ -301,7 +308,7 @@ ok:
301
308
  * issue #391, where new node's prefix may become the string "default"
302
309
  * see libxml2 tree.c xmlNewReconciliedNs which implements this behavior.
303
310
  */
304
- xmlFree(reparentee->ns->prefix);
311
+ xmlFree((xmlChar *)reparentee->ns->prefix);
305
312
  reparentee->ns->prefix = NULL;
306
313
  }
307
314
  }
@@ -330,12 +337,12 @@ ok:
330
337
  new_next_text = xmlDocCopyNode(next_text, pivot->doc, 1) ;
331
338
 
332
339
  xmlUnlinkNode(next_text);
333
- nokogiri_root_node(next_text);
340
+ noko_xml_document_pin_node(next_text);
334
341
 
335
342
  xmlAddNextSibling(pivot, new_next_text);
336
343
  }
337
344
 
338
- if(!(reparented = (*prf)(pivot, reparentee))) {
345
+ if (!(reparented = (*prf)(pivot, reparentee))) {
339
346
  rb_raise(rb_eRuntimeError, "Could not reparent node");
340
347
  }
341
348
 
@@ -348,9 +355,9 @@ ok:
348
355
 
349
356
  relink_namespace(reparented);
350
357
 
351
- reparented_obj = Nokogiri_wrap_xml_node(Qnil, reparented);
358
+ reparented_obj = noko_xml_node_wrap(Qnil, reparented);
352
359
 
353
- rb_funcall(reparented_obj, decorate_bang, 0);
360
+ rb_funcall(reparented_obj, id_decorate_bang, 0);
354
361
 
355
362
  return reparented_obj ;
356
363
  }
@@ -362,7 +369,8 @@ ok:
362
369
  *
363
370
  * Get the document for this Node
364
371
  */
365
- static VALUE document(VALUE self)
372
+ static VALUE
373
+ document(VALUE self)
366
374
  {
367
375
  xmlNodePtr node;
368
376
  Data_Get_Struct(self, xmlNode, node);
@@ -375,7 +383,8 @@ static VALUE document(VALUE self)
375
383
  *
376
384
  * Get the internal pointer number
377
385
  */
378
- static VALUE pointer_id(VALUE self)
386
+ static VALUE
387
+ pointer_id(VALUE self)
379
388
  {
380
389
  xmlNodePtr node;
381
390
  Data_Get_Struct(self, xmlNode, node);
@@ -389,7 +398,8 @@ static VALUE pointer_id(VALUE self)
389
398
  *
390
399
  * Encode any special characters in +string+
391
400
  */
392
- static VALUE encode_special_chars(VALUE self, VALUE string)
401
+ static VALUE
402
+ encode_special_chars(VALUE self, VALUE string)
393
403
  {
394
404
  xmlNodePtr node;
395
405
  xmlChar *encoded;
@@ -419,7 +429,8 @@ static VALUE encode_special_chars(VALUE self, VALUE string)
419
429
  * doc.create_internal_subset("chapter", nil, "chapter.dtd")
420
430
  * # => <!DOCTYPE chapter SYSTEM "chapter.dtd">
421
431
  */
422
- static VALUE create_internal_subset(VALUE self, VALUE name, VALUE external_id, VALUE system_id)
432
+ static VALUE
433
+ create_internal_subset(VALUE self, VALUE name, VALUE external_id, VALUE system_id)
423
434
  {
424
435
  xmlNodePtr node;
425
436
  xmlDocPtr doc;
@@ -429,7 +440,7 @@ static VALUE create_internal_subset(VALUE self, VALUE name, VALUE external_id, V
429
440
 
430
441
  doc = node->doc;
431
442
 
432
- if(xmlGetIntSubset(doc)) {
443
+ if (xmlGetIntSubset(doc)) {
433
444
  rb_raise(rb_eRuntimeError, "Document already has an internal subset");
434
445
  }
435
446
 
@@ -440,9 +451,9 @@ static VALUE create_internal_subset(VALUE self, VALUE name, VALUE external_id, V
440
451
  NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
441
452
  );
442
453
 
443
- if(!dtd) { return Qnil; }
454
+ if (!dtd) { return Qnil; }
444
455
 
445
- return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
456
+ return noko_xml_node_wrap(Qnil, (xmlNodePtr)dtd);
446
457
  }
447
458
 
448
459
  /*
@@ -451,7 +462,8 @@ static VALUE create_internal_subset(VALUE self, VALUE name, VALUE external_id, V
451
462
  *
452
463
  * Create an external subset
453
464
  */
454
- static VALUE create_external_subset(VALUE self, VALUE name, VALUE external_id, VALUE system_id)
465
+ static VALUE
466
+ create_external_subset(VALUE self, VALUE name, VALUE external_id, VALUE system_id)
455
467
  {
456
468
  xmlNodePtr node;
457
469
  xmlDocPtr doc;
@@ -461,7 +473,7 @@ static VALUE create_external_subset(VALUE self, VALUE name, VALUE external_id, V
461
473
 
462
474
  doc = node->doc;
463
475
 
464
- if(doc->extSubset) {
476
+ if (doc->extSubset) {
465
477
  rb_raise(rb_eRuntimeError, "Document already has an external subset");
466
478
  }
467
479
 
@@ -472,9 +484,9 @@ static VALUE create_external_subset(VALUE self, VALUE name, VALUE external_id, V
472
484
  NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
473
485
  );
474
486
 
475
- if(!dtd) { return Qnil; }
487
+ if (!dtd) { return Qnil; }
476
488
 
477
- return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
489
+ return noko_xml_node_wrap(Qnil, (xmlNodePtr)dtd);
478
490
  }
479
491
 
480
492
  /*
@@ -483,7 +495,8 @@ static VALUE create_external_subset(VALUE self, VALUE name, VALUE external_id, V
483
495
  *
484
496
  * Get the external subset
485
497
  */
486
- static VALUE external_subset(VALUE self)
498
+ static VALUE
499
+ external_subset(VALUE self)
487
500
  {
488
501
  xmlNodePtr node;
489
502
  xmlDocPtr doc;
@@ -491,14 +504,14 @@ static VALUE external_subset(VALUE self)
491
504
 
492
505
  Data_Get_Struct(self, xmlNode, node);
493
506
 
494
- if(!node->doc) { return Qnil; }
507
+ if (!node->doc) { return Qnil; }
495
508
 
496
509
  doc = node->doc;
497
510
  dtd = doc->extSubset;
498
511
 
499
- if(!dtd) { return Qnil; }
512
+ if (!dtd) { return Qnil; }
500
513
 
501
- return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
514
+ return noko_xml_node_wrap(Qnil, (xmlNodePtr)dtd);
502
515
  }
503
516
 
504
517
  /*
@@ -507,7 +520,8 @@ static VALUE external_subset(VALUE self)
507
520
  *
508
521
  * Get the internal subset
509
522
  */
510
- static VALUE internal_subset(VALUE self)
523
+ static VALUE
524
+ internal_subset(VALUE self)
511
525
  {
512
526
  xmlNodePtr node;
513
527
  xmlDocPtr doc;
@@ -515,14 +529,14 @@ static VALUE internal_subset(VALUE self)
515
529
 
516
530
  Data_Get_Struct(self, xmlNode, node);
517
531
 
518
- if(!node->doc) { return Qnil; }
532
+ if (!node->doc) { return Qnil; }
519
533
 
520
534
  doc = node->doc;
521
535
  dtd = xmlGetIntSubset(doc);
522
536
 
523
- if(!dtd) { return Qnil; }
537
+ if (!dtd) { return Qnil; }
524
538
 
525
- return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
539
+ return noko_xml_node_wrap(Qnil, (xmlNodePtr)dtd);
526
540
  }
527
541
 
528
542
  /*
@@ -537,7 +551,8 @@ static VALUE internal_subset(VALUE self)
537
551
  * node's parent document. Defaults to the current node's document.
538
552
  * current document.
539
553
  */
540
- static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
554
+ static VALUE
555
+ duplicate_node(int argc, VALUE *argv, VALUE self)
541
556
  {
542
557
  VALUE r_level, r_new_parent_doc;
543
558
  int level;
@@ -561,11 +576,11 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
561
576
  }
562
577
 
563
578
  dup = xmlDocCopyNode(node, new_parent_doc, level);
564
- if(dup == NULL) { return Qnil; }
579
+ if (dup == NULL) { return Qnil; }
565
580
 
566
- nokogiri_root_node(dup);
581
+ noko_xml_document_pin_node(dup);
567
582
 
568
- return Nokogiri_wrap_xml_node(rb_obj_class(self), dup);
583
+ return noko_xml_node_wrap(rb_obj_class(self), dup);
569
584
  }
570
585
 
571
586
  /*
@@ -574,12 +589,13 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
574
589
  *
575
590
  * Unlink this node from its current context.
576
591
  */
577
- static VALUE unlink_node(VALUE self)
592
+ static VALUE
593
+ unlink_node(VALUE self)
578
594
  {
579
595
  xmlNodePtr node;
580
596
  Data_Get_Struct(self, xmlNode, node);
581
597
  xmlUnlinkNode(node);
582
- nokogiri_root_node(node);
598
+ noko_xml_document_pin_node(node);
583
599
  return self;
584
600
  }
585
601
 
@@ -589,7 +605,8 @@ static VALUE unlink_node(VALUE self)
589
605
  *
590
606
  * Is this node blank?
591
607
  */
592
- static VALUE blank_eh(VALUE self)
608
+ static VALUE
609
+ blank_eh(VALUE self)
593
610
  {
594
611
  xmlNodePtr node;
595
612
  Data_Get_Struct(self, xmlNode, node);
@@ -602,15 +619,16 @@ static VALUE blank_eh(VALUE self)
602
619
  *
603
620
  * Returns the next sibling node
604
621
  */
605
- static VALUE next_sibling(VALUE self)
622
+ static VALUE
623
+ next_sibling(VALUE self)
606
624
  {
607
625
  xmlNodePtr node, sibling;
608
626
  Data_Get_Struct(self, xmlNode, node);
609
627
 
610
628
  sibling = node->next;
611
- if(!sibling) { return Qnil; }
629
+ if (!sibling) { return Qnil; }
612
630
 
613
- return Nokogiri_wrap_xml_node(Qnil, sibling) ;
631
+ return noko_xml_node_wrap(Qnil, sibling) ;
614
632
  }
615
633
 
616
634
  /*
@@ -619,15 +637,16 @@ static VALUE next_sibling(VALUE self)
619
637
  *
620
638
  * Returns the previous sibling node
621
639
  */
622
- static VALUE previous_sibling(VALUE self)
640
+ static VALUE
641
+ previous_sibling(VALUE self)
623
642
  {
624
643
  xmlNodePtr node, sibling;
625
644
  Data_Get_Struct(self, xmlNode, node);
626
645
 
627
646
  sibling = node->prev;
628
- if(!sibling) { return Qnil; }
647
+ if (!sibling) { return Qnil; }
629
648
 
630
- return Nokogiri_wrap_xml_node(Qnil, sibling);
649
+ return noko_xml_node_wrap(Qnil, sibling);
631
650
  }
632
651
 
633
652
  /*
@@ -636,15 +655,16 @@ static VALUE previous_sibling(VALUE self)
636
655
  *
637
656
  * Returns the next Nokogiri::XML::Element type sibling node.
638
657
  */
639
- static VALUE next_element(VALUE self)
658
+ static VALUE
659
+ next_element(VALUE self)
640
660
  {
641
661
  xmlNodePtr node, sibling;
642
662
  Data_Get_Struct(self, xmlNode, node);
643
663
 
644
664
  sibling = xmlNextElementSibling(node);
645
- if(!sibling) { return Qnil; }
665
+ if (!sibling) { return Qnil; }
646
666
 
647
- return Nokogiri_wrap_xml_node(Qnil, sibling);
667
+ return noko_xml_node_wrap(Qnil, sibling);
648
668
  }
649
669
 
650
670
  /*
@@ -653,7 +673,8 @@ static VALUE next_element(VALUE self)
653
673
  *
654
674
  * Returns the previous Nokogiri::XML::Element type sibling node.
655
675
  */
656
- static VALUE previous_element(VALUE self)
676
+ static VALUE
677
+ previous_element(VALUE self)
657
678
  {
658
679
  xmlNodePtr node, sibling;
659
680
  Data_Get_Struct(self, xmlNode, node);
@@ -662,23 +683,24 @@ static VALUE previous_element(VALUE self)
662
683
  * note that we don't use xmlPreviousElementSibling here because it's buggy pre-2.7.7.
663
684
  */
664
685
  sibling = node->prev;
665
- if(!sibling) { return Qnil; }
686
+ if (!sibling) { return Qnil; }
666
687
 
667
- while(sibling && sibling->type != XML_ELEMENT_NODE) {
688
+ while (sibling && sibling->type != XML_ELEMENT_NODE) {
668
689
  sibling = sibling->prev;
669
690
  }
670
691
 
671
- return sibling ? Nokogiri_wrap_xml_node(Qnil, sibling) : Qnil ;
692
+ return sibling ? noko_xml_node_wrap(Qnil, sibling) : Qnil ;
672
693
  }
673
694
 
674
695
  /* :nodoc: */
675
- static VALUE replace(VALUE self, VALUE new_node)
696
+ static VALUE
697
+ replace(VALUE self, VALUE new_node)
676
698
  {
677
699
  VALUE reparent = reparent_node_with(self, new_node, xmlReplaceNodeWrapper);
678
700
 
679
701
  xmlNodePtr pivot;
680
702
  Data_Get_Struct(self, xmlNode, pivot);
681
- nokogiri_root_node(pivot);
703
+ noko_xml_document_pin_node(pivot);
682
704
 
683
705
  return reparent;
684
706
  }
@@ -689,7 +711,8 @@ static VALUE replace(VALUE self, VALUE new_node)
689
711
  *
690
712
  * Get the list of children for this node as a NodeSet
691
713
  */
692
- static VALUE children(VALUE self)
714
+ static VALUE
715
+ children(VALUE self)
693
716
  {
694
717
  xmlNodePtr node;
695
718
  xmlNodePtr child;
@@ -704,15 +727,15 @@ static VALUE children(VALUE self)
704
727
 
705
728
  document = DOC_RUBY_OBJECT(node->doc);
706
729
 
707
- if(!child) { return Nokogiri_wrap_xml_node_set(set, document); }
730
+ if (!child) { return noko_xml_node_set_wrap(set, document); }
708
731
 
709
732
  child = child->next;
710
- while(NULL != child) {
733
+ while (NULL != child) {
711
734
  xmlXPathNodeSetAddUnique(set, child);
712
735
  child = child->next;
713
736
  }
714
737
 
715
- node_set = Nokogiri_wrap_xml_node_set(set, document);
738
+ node_set = noko_xml_node_set_wrap(set, document);
716
739
 
717
740
  return node_set;
718
741
  }
@@ -728,7 +751,8 @@ static VALUE children(VALUE self)
728
751
  *
729
752
  * @doc.root.element_children.all? { |x| x.element? } # => true
730
753
  */
731
- static VALUE element_children(VALUE self)
754
+ static VALUE
755
+ element_children(VALUE self)
732
756
  {
733
757
  xmlNodePtr node;
734
758
  xmlNodePtr child;
@@ -743,15 +767,15 @@ static VALUE element_children(VALUE self)
743
767
 
744
768
  document = DOC_RUBY_OBJECT(node->doc);
745
769
 
746
- if(!child) { return Nokogiri_wrap_xml_node_set(set, document); }
770
+ if (!child) { return noko_xml_node_set_wrap(set, document); }
747
771
 
748
772
  child = xmlNextElementSibling(child);
749
- while(NULL != child) {
773
+ while (NULL != child) {
750
774
  xmlXPathNodeSetAddUnique(set, child);
751
775
  child = xmlNextElementSibling(child);
752
776
  }
753
777
 
754
- node_set = Nokogiri_wrap_xml_node_set(set, document);
778
+ node_set = noko_xml_node_set_wrap(set, document);
755
779
 
756
780
  return node_set;
757
781
  }
@@ -762,15 +786,16 @@ static VALUE element_children(VALUE self)
762
786
  *
763
787
  * Returns the child node
764
788
  */
765
- static VALUE child(VALUE self)
789
+ static VALUE
790
+ child(VALUE self)
766
791
  {
767
792
  xmlNodePtr node, child;
768
793
  Data_Get_Struct(self, xmlNode, node);
769
794
 
770
795
  child = node->children;
771
- if(!child) { return Qnil; }
796
+ if (!child) { return Qnil; }
772
797
 
773
- return Nokogiri_wrap_xml_node(Qnil, child);
798
+ return noko_xml_node_wrap(Qnil, child);
774
799
  }
775
800
 
776
801
  /*
@@ -783,15 +808,16 @@ static VALUE child(VALUE self)
783
808
  *
784
809
  * @doc.root.first_element_child.element? # => true
785
810
  */
786
- static VALUE first_element_child(VALUE self)
811
+ static VALUE
812
+ first_element_child(VALUE self)
787
813
  {
788
814
  xmlNodePtr node, child;
789
815
  Data_Get_Struct(self, xmlNode, node);
790
816
 
791
817
  child = xmlFirstElementChild(node);
792
- if(!child) { return Qnil; }
818
+ if (!child) { return Qnil; }
793
819
 
794
- return Nokogiri_wrap_xml_node(Qnil, child);
820
+ return noko_xml_node_wrap(Qnil, child);
795
821
  }
796
822
 
797
823
  /*
@@ -804,15 +830,16 @@ static VALUE first_element_child(VALUE self)
804
830
  *
805
831
  * @doc.root.last_element_child.element? # => true
806
832
  */
807
- static VALUE last_element_child(VALUE self)
833
+ static VALUE
834
+ last_element_child(VALUE self)
808
835
  {
809
836
  xmlNodePtr node, child;
810
837
  Data_Get_Struct(self, xmlNode, node);
811
838
 
812
839
  child = xmlLastElementChild(node);
813
- if(!child) { return Qnil; }
840
+ if (!child) { return Qnil; }
814
841
 
815
- return Nokogiri_wrap_xml_node(Qnil, child);
842
+ return noko_xml_node_wrap(Qnil, child);
816
843
  }
817
844
 
818
845
  /*
@@ -821,11 +848,12 @@ static VALUE last_element_child(VALUE self)
821
848
  *
822
849
  * Returns true if +attribute+ is set
823
850
  */
824
- static VALUE key_eh(VALUE self, VALUE attribute)
851
+ static VALUE
852
+ key_eh(VALUE self, VALUE attribute)
825
853
  {
826
854
  xmlNodePtr node;
827
855
  Data_Get_Struct(self, xmlNode, node);
828
- if(xmlHasProp(node, (xmlChar *)StringValueCStr(attribute))) {
856
+ if (xmlHasProp(node, (xmlChar *)StringValueCStr(attribute))) {
829
857
  return Qtrue;
830
858
  }
831
859
  return Qfalse;
@@ -837,12 +865,13 @@ static VALUE key_eh(VALUE self, VALUE attribute)
837
865
  *
838
866
  * Returns true if +attribute+ is set with +namespace+
839
867
  */
840
- static VALUE namespaced_key_eh(VALUE self, VALUE attribute, VALUE namespace)
868
+ static VALUE
869
+ namespaced_key_eh(VALUE self, VALUE attribute, VALUE namespace)
841
870
  {
842
871
  xmlNodePtr node;
843
872
  Data_Get_Struct(self, xmlNode, node);
844
- if(xmlHasNsProp(node, (xmlChar *)StringValueCStr(attribute),
845
- NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace))) {
873
+ if (xmlHasNsProp(node, (xmlChar *)StringValueCStr(attribute),
874
+ NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace))) {
846
875
  return Qtrue;
847
876
  }
848
877
  return Qfalse;
@@ -854,7 +883,8 @@ static VALUE namespaced_key_eh(VALUE self, VALUE attribute, VALUE namespace)
854
883
  *
855
884
  * Set the +property+ to +value+
856
885
  */
857
- static VALUE set(VALUE self, VALUE property, VALUE value)
886
+ static VALUE
887
+ set(VALUE self, VALUE property, VALUE value)
858
888
  {
859
889
  xmlNodePtr node, cur;
860
890
  xmlAttrPtr prop;
@@ -867,13 +897,13 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
867
897
  * We can avoid this by unlinking these nodes first.
868
898
  */
869
899
  if (node->type != XML_ELEMENT_NODE) {
870
- return(Qnil);
900
+ return (Qnil);
871
901
  }
872
902
  prop = xmlHasProp(node, (xmlChar *)StringValueCStr(property));
873
903
  if (prop && prop->children) {
874
904
  for (cur = prop->children; cur; cur = cur->next) {
875
905
  if (cur->_private) {
876
- nokogiri_root_node(cur);
906
+ noko_xml_document_pin_node(cur);
877
907
  xmlUnlinkNode(cur);
878
908
  }
879
909
  }
@@ -891,7 +921,8 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
891
921
  *
892
922
  * Get the value for +attribute+
893
923
  */
894
- static VALUE get(VALUE self, VALUE rattribute)
924
+ static VALUE
925
+ get(VALUE self, VALUE rattribute)
895
926
  {
896
927
  xmlNodePtr node;
897
928
  xmlChar *value = 0;
@@ -917,7 +948,7 @@ static VALUE get(VALUE self, VALUE rattribute)
917
948
  if (ns) {
918
949
  value = xmlGetNsProp(node, attr_name, ns->href);
919
950
  } else {
920
- value = xmlGetProp(node, (xmlChar*)StringValueCStr(rattribute));
951
+ value = xmlGetProp(node, (xmlChar *)StringValueCStr(rattribute));
921
952
  }
922
953
  } else {
923
954
  value = xmlGetNoNsProp(node, attribute);
@@ -938,14 +969,15 @@ static VALUE get(VALUE self, VALUE rattribute)
938
969
  *
939
970
  * Set the namespace to +namespace+
940
971
  */
941
- static VALUE set_namespace(VALUE self, VALUE namespace)
972
+ static VALUE
973
+ set_namespace(VALUE self, VALUE namespace)
942
974
  {
943
975
  xmlNodePtr node;
944
976
  xmlNsPtr ns = NULL;
945
977
 
946
978
  Data_Get_Struct(self, xmlNode, node);
947
979
 
948
- if(!NIL_P(namespace)) {
980
+ if (!NIL_P(namespace)) {
949
981
  Data_Get_Struct(namespace, xmlNs, ns);
950
982
  }
951
983
 
@@ -960,15 +992,16 @@ static VALUE set_namespace(VALUE self, VALUE namespace)
960
992
  *
961
993
  * Get the attribute node with +name+
962
994
  */
963
- static VALUE attr(VALUE self, VALUE name)
995
+ static VALUE
996
+ attr(VALUE self, VALUE name)
964
997
  {
965
998
  xmlNodePtr node;
966
999
  xmlAttrPtr prop;
967
1000
  Data_Get_Struct(self, xmlNode, node);
968
1001
  prop = xmlHasProp(node, (xmlChar *)StringValueCStr(name));
969
1002
 
970
- if(! prop) { return Qnil; }
971
- return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)prop);
1003
+ if (! prop) { return Qnil; }
1004
+ return noko_xml_node_wrap(Qnil, (xmlNodePtr)prop);
972
1005
  }
973
1006
 
974
1007
  /*
@@ -977,7 +1010,8 @@ static VALUE attr(VALUE self, VALUE name)
977
1010
  *
978
1011
  * Get the attribute node with +name+ and +namespace+
979
1012
  */
980
- static VALUE attribute_with_ns(VALUE self, VALUE name, VALUE namespace)
1013
+ static VALUE
1014
+ attribute_with_ns(VALUE self, VALUE name, VALUE namespace)
981
1015
  {
982
1016
  xmlNodePtr node;
983
1017
  xmlAttrPtr prop;
@@ -985,28 +1019,23 @@ static VALUE attribute_with_ns(VALUE self, VALUE name, VALUE namespace)
985
1019
  prop = xmlHasNsProp(node, (xmlChar *)StringValueCStr(name),
986
1020
  NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace));
987
1021
 
988
- if(! prop) { return Qnil; }
989
- return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)prop);
1022
+ if (! prop) { return Qnil; }
1023
+ return noko_xml_node_wrap(Qnil, (xmlNodePtr)prop);
990
1024
  }
991
1025
 
992
1026
  /*
993
- * call-seq:
994
- * attribute_nodes()
995
- *
996
- * returns a list containing the Node attributes.
1027
+ * @overload attribute_nodes()
1028
+ * Get the attributes for a Node
1029
+ * @return [Array<Nokogiri::XML::Attr>] containing the Node's attributes.
997
1030
  */
998
- static VALUE attribute_nodes(VALUE self)
1031
+ static VALUE
1032
+ attribute_nodes(VALUE rb_node)
999
1033
  {
1000
- /* this code in the mode of xmlHasProp() */
1001
- xmlNodePtr node;
1002
- VALUE attr;
1003
-
1004
- Data_Get_Struct(self, xmlNode, node);
1034
+ xmlNodePtr c_node;
1005
1035
 
1006
- attr = rb_ary_new();
1007
- Nokogiri_xml_node_properties(node, attr);
1036
+ Data_Get_Struct(rb_node, xmlNode, c_node);
1008
1037
 
1009
- return attr ;
1038
+ return noko_xml_node_attrs(c_node);
1010
1039
  }
1011
1040
 
1012
1041
 
@@ -1017,16 +1046,17 @@ static VALUE attribute_nodes(VALUE self)
1017
1046
  * returns the namespace of the element or attribute node as a Namespace
1018
1047
  * object, or nil if there is no namespace for the element or attribute.
1019
1048
  */
1020
- static VALUE namespace(VALUE self)
1049
+ static VALUE
1050
+ noko_xml_node_namespace(VALUE rb_node)
1021
1051
  {
1022
- xmlNodePtr node ;
1023
- Data_Get_Struct(self, xmlNode, node);
1052
+ xmlNodePtr c_node ;
1053
+ Data_Get_Struct(rb_node, xmlNode, c_node);
1024
1054
 
1025
- if (node->ns) {
1026
- return Nokogiri_wrap_xml_namespace(node->doc, node->ns);
1027
- }
1055
+ if (c_node->ns) {
1056
+ return noko_xml_namespace_wrap(c_node->ns, c_node->doc);
1057
+ }
1028
1058
 
1029
- return Qnil ;
1059
+ return Qnil ;
1030
1060
  }
1031
1061
 
1032
1062
  /*
@@ -1035,27 +1065,27 @@ return Qnil ;
1035
1065
  *
1036
1066
  * returns namespaces defined on self element directly, as an array of Namespace objects. Includes both a default namespace (as in"xmlns="), and prefixed namespaces (as in "xmlns:prefix=").
1037
1067
  */
1038
- static VALUE namespace_definitions(VALUE self)
1068
+ static VALUE
1069
+ namespace_definitions(VALUE rb_node)
1039
1070
  {
1040
1071
  /* this code in the mode of xmlHasProp() */
1041
- xmlNodePtr node ;
1042
- VALUE list;
1043
- xmlNsPtr ns;
1044
-
1045
- Data_Get_Struct(self, xmlNode, node);
1046
-
1047
- list = rb_ary_new();
1072
+ xmlNodePtr c_node ;
1073
+ xmlNsPtr c_namespace;
1074
+ VALUE definitions = rb_ary_new();
1048
1075
 
1049
- ns = node->nsDef;
1076
+ Data_Get_Struct(rb_node, xmlNode, c_node);
1050
1077
 
1051
- if(!ns) { return list; }
1078
+ c_namespace = c_node->nsDef;
1079
+ if (!c_namespace) {
1080
+ return definitions;
1081
+ }
1052
1082
 
1053
- while(NULL != ns) {
1054
- rb_ary_push(list, Nokogiri_wrap_xml_namespace(node->doc, ns));
1055
- ns = ns->next;
1083
+ while (c_namespace != NULL) {
1084
+ rb_ary_push(definitions, noko_xml_namespace_wrap(c_namespace, c_node->doc));
1085
+ c_namespace = c_namespace->next;
1056
1086
  }
1057
1087
 
1058
- return list;
1088
+ return definitions;
1059
1089
  }
1060
1090
 
1061
1091
  /*
@@ -1067,26 +1097,27 @@ static VALUE namespace_definitions(VALUE self)
1067
1097
  * namespaces ("xmlns=" style) for self are included in this array; Default
1068
1098
  * namespaces for ancestors, however, are not. See also #namespaces
1069
1099
  */
1070
- static VALUE namespace_scopes(VALUE self)
1100
+ static VALUE
1101
+ namespace_scopes(VALUE rb_node)
1071
1102
  {
1072
- xmlNodePtr node ;
1073
- VALUE list;
1074
- xmlNsPtr *ns_list;
1103
+ xmlNodePtr c_node ;
1104
+ xmlNsPtr *namespaces;
1105
+ VALUE scopes = rb_ary_new();
1075
1106
  int j;
1076
1107
 
1077
- Data_Get_Struct(self, xmlNode, node);
1078
-
1079
- list = rb_ary_new();
1080
- ns_list = xmlGetNsList(node->doc, node);
1108
+ Data_Get_Struct(rb_node, xmlNode, c_node);
1081
1109
 
1082
- if(!ns_list) { return list; }
1110
+ namespaces = xmlGetNsList(c_node->doc, c_node);
1111
+ if (!namespaces) {
1112
+ return scopes;
1113
+ }
1083
1114
 
1084
- for (j = 0 ; ns_list[j] != NULL ; ++j) {
1085
- rb_ary_push(list, Nokogiri_wrap_xml_namespace(node->doc, ns_list[j]));
1115
+ for (j = 0 ; namespaces[j] != NULL ; ++j) {
1116
+ rb_ary_push(scopes, noko_xml_namespace_wrap(namespaces[j], c_node->doc));
1086
1117
  }
1087
1118
 
1088
- xmlFree(ns_list);
1089
- return list;
1119
+ xmlFree(namespaces);
1120
+ return scopes;
1090
1121
  }
1091
1122
 
1092
1123
  /*
@@ -1095,7 +1126,8 @@ static VALUE namespace_scopes(VALUE self)
1095
1126
  *
1096
1127
  * Get the type for this Node
1097
1128
  */
1098
- static VALUE node_type(VALUE self)
1129
+ static VALUE
1130
+ node_type(VALUE self)
1099
1131
  {
1100
1132
  xmlNodePtr node;
1101
1133
  Data_Get_Struct(self, xmlNode, node);
@@ -1108,7 +1140,8 @@ static VALUE node_type(VALUE self)
1108
1140
  *
1109
1141
  * Set the content for this Node
1110
1142
  */
1111
- static VALUE set_native_content(VALUE self, VALUE content)
1143
+ static VALUE
1144
+ set_native_content(VALUE self, VALUE content)
1112
1145
  {
1113
1146
  xmlNodePtr node, child, next ;
1114
1147
  Data_Get_Struct(self, xmlNode, node);
@@ -1117,7 +1150,7 @@ static VALUE set_native_content(VALUE self, VALUE content)
1117
1150
  while (NULL != child) {
1118
1151
  next = child->next ;
1119
1152
  xmlUnlinkNode(child) ;
1120
- nokogiri_root_node(child);
1153
+ noko_xml_document_pin_node(child);
1121
1154
  child = next ;
1122
1155
  }
1123
1156
 
@@ -1132,15 +1165,16 @@ static VALUE set_native_content(VALUE self, VALUE content)
1132
1165
  * Returns the plaintext content for this Node. Note that entities will always
1133
1166
  * be expanded in the returned string.
1134
1167
  */
1135
- static VALUE get_native_content(VALUE self)
1168
+ static VALUE
1169
+ get_native_content(VALUE self)
1136
1170
  {
1137
1171
  xmlNodePtr node;
1138
- xmlChar * content;
1172
+ xmlChar *content;
1139
1173
 
1140
1174
  Data_Get_Struct(self, xmlNode, node);
1141
1175
 
1142
1176
  content = xmlNodeGetContent(node);
1143
- if(content) {
1177
+ if (content) {
1144
1178
  VALUE rval = NOKOGIRI_STR_NEW2(content);
1145
1179
  xmlFree(content);
1146
1180
  return rval;
@@ -1154,13 +1188,14 @@ static VALUE get_native_content(VALUE self)
1154
1188
  *
1155
1189
  * Set the language of a node, i.e. the values of the xml:lang attribute.
1156
1190
  */
1157
- static VALUE set_lang(VALUE self_rb, VALUE lang_rb)
1191
+ static VALUE
1192
+ set_lang(VALUE self_rb, VALUE lang_rb)
1158
1193
  {
1159
1194
  xmlNodePtr self ;
1160
- xmlChar* lang ;
1195
+ xmlChar *lang ;
1161
1196
 
1162
1197
  Data_Get_Struct(self_rb, xmlNode, self);
1163
- lang = (xmlChar*)StringValueCStr(lang_rb);
1198
+ lang = (xmlChar *)StringValueCStr(lang_rb);
1164
1199
 
1165
1200
  xmlNodeSetLang(self, lang);
1166
1201
 
@@ -1174,10 +1209,11 @@ static VALUE set_lang(VALUE self_rb, VALUE lang_rb)
1174
1209
  * Searches the language of a node, i.e. the values of the xml:lang attribute or
1175
1210
  * the one carried by the nearest ancestor.
1176
1211
  */
1177
- static VALUE get_lang(VALUE self_rb)
1212
+ static VALUE
1213
+ get_lang(VALUE self_rb)
1178
1214
  {
1179
1215
  xmlNodePtr self ;
1180
- xmlChar* lang ;
1216
+ xmlChar *lang ;
1181
1217
  VALUE lang_rb ;
1182
1218
 
1183
1219
  Data_Get_Struct(self_rb, xmlNode, self);
@@ -1193,7 +1229,8 @@ static VALUE get_lang(VALUE self_rb)
1193
1229
  }
1194
1230
 
1195
1231
  /* :nodoc: */
1196
- static VALUE add_child(VALUE self, VALUE new_child)
1232
+ static VALUE
1233
+ add_child(VALUE self, VALUE new_child)
1197
1234
  {
1198
1235
  return reparent_node_with(self, new_child, xmlAddChild);
1199
1236
  }
@@ -1204,15 +1241,16 @@ static VALUE add_child(VALUE self, VALUE new_child)
1204
1241
  *
1205
1242
  * Get the parent Node for this Node
1206
1243
  */
1207
- static VALUE get_parent(VALUE self)
1244
+ static VALUE
1245
+ get_parent(VALUE self)
1208
1246
  {
1209
1247
  xmlNodePtr node, parent;
1210
1248
  Data_Get_Struct(self, xmlNode, node);
1211
1249
 
1212
1250
  parent = node->parent;
1213
- if(!parent) { return Qnil; }
1251
+ if (!parent) { return Qnil; }
1214
1252
 
1215
- return Nokogiri_wrap_xml_node(Qnil, parent) ;
1253
+ return noko_xml_node_wrap(Qnil, parent) ;
1216
1254
  }
1217
1255
 
1218
1256
  /*
@@ -1221,11 +1259,12 @@ static VALUE get_parent(VALUE self)
1221
1259
  *
1222
1260
  * Set the name for this Node
1223
1261
  */
1224
- static VALUE set_name(VALUE self, VALUE new_name)
1262
+ static VALUE
1263
+ set_name(VALUE self, VALUE new_name)
1225
1264
  {
1226
1265
  xmlNodePtr node;
1227
1266
  Data_Get_Struct(self, xmlNode, node);
1228
- xmlNodeSetName(node, (xmlChar*)StringValueCStr(new_name));
1267
+ xmlNodeSetName(node, (xmlChar *)StringValueCStr(new_name));
1229
1268
  return new_name;
1230
1269
  }
1231
1270
 
@@ -1235,11 +1274,12 @@ static VALUE set_name(VALUE self, VALUE new_name)
1235
1274
  *
1236
1275
  * Returns the name for this Node
1237
1276
  */
1238
- static VALUE get_name(VALUE self)
1277
+ static VALUE
1278
+ get_name(VALUE self)
1239
1279
  {
1240
1280
  xmlNodePtr node;
1241
1281
  Data_Get_Struct(self, xmlNode, node);
1242
- if(node->name) {
1282
+ if (node->name) {
1243
1283
  return NOKOGIRI_STR_NEW2(node->name);
1244
1284
  }
1245
1285
  return Qnil;
@@ -1251,7 +1291,8 @@ static VALUE get_name(VALUE self)
1251
1291
  *
1252
1292
  * Returns the path associated with this Node
1253
1293
  */
1254
- static VALUE path(VALUE self)
1294
+ static VALUE
1295
+ path(VALUE self)
1255
1296
  {
1256
1297
  xmlNodePtr node;
1257
1298
  xmlChar *path ;
@@ -1266,13 +1307,15 @@ static VALUE path(VALUE self)
1266
1307
  }
1267
1308
 
1268
1309
  /* :nodoc: */
1269
- static VALUE add_next_sibling(VALUE self, VALUE new_sibling)
1310
+ static VALUE
1311
+ add_next_sibling(VALUE self, VALUE new_sibling)
1270
1312
  {
1271
1313
  return reparent_node_with(self, new_sibling, xmlAddNextSibling) ;
1272
1314
  }
1273
1315
 
1274
1316
  /* :nodoc: */
1275
- static VALUE add_previous_sibling(VALUE self, VALUE new_sibling)
1317
+ static VALUE
1318
+ add_previous_sibling(VALUE self, VALUE new_sibling)
1276
1319
  {
1277
1320
  return reparent_node_with(self, new_sibling, xmlAddPrevSibling) ;
1278
1321
  }
@@ -1283,7 +1326,8 @@ static VALUE add_previous_sibling(VALUE self, VALUE new_sibling)
1283
1326
  *
1284
1327
  * Write this Node to +io+ with +encoding+ and +options+
1285
1328
  */
1286
- static VALUE native_write_to(
1329
+ static VALUE
1330
+ native_write_to(
1287
1331
  VALUE self,
1288
1332
  VALUE io,
1289
1333
  VALUE encoding,
@@ -1292,7 +1336,7 @@ static VALUE native_write_to(
1292
1336
  )
1293
1337
  {
1294
1338
  xmlNodePtr node;
1295
- const char * before_indent;
1339
+ const char *before_indent;
1296
1340
  xmlSaveCtxtPtr savectx;
1297
1341
 
1298
1342
  Data_Get_Struct(self, xmlNode, node);
@@ -1304,8 +1348,8 @@ static VALUE native_write_to(
1304
1348
  xmlTreeIndentString = StringValueCStr(indent_string);
1305
1349
 
1306
1350
  savectx = xmlSaveToIO(
1307
- (xmlOutputWriteCallback)io_write_callback,
1308
- (xmlOutputCloseCallback)io_close_callback,
1351
+ (xmlOutputWriteCallback)noko_io_write,
1352
+ (xmlOutputCloseCallback)noko_io_close,
1309
1353
  (void *)io,
1310
1354
  RTEST(encoding) ? StringValueCStr(encoding) : NULL,
1311
1355
  (int)NUM2INT(options)
@@ -1324,7 +1368,8 @@ static VALUE native_write_to(
1324
1368
  *
1325
1369
  * Returns the line for this Node
1326
1370
  */
1327
- static VALUE line(VALUE self)
1371
+ static VALUE
1372
+ line(VALUE self)
1328
1373
  {
1329
1374
  xmlNodePtr node;
1330
1375
  Data_Get_Struct(self, xmlNode, node);
@@ -1332,6 +1377,26 @@ static VALUE line(VALUE self)
1332
1377
  return INT2NUM(xmlGetLineNo(node));
1333
1378
  }
1334
1379
 
1380
+ /*
1381
+ * call-seq:
1382
+ * line=(num)
1383
+ *
1384
+ * Sets the line for this Node. num must be less than 65535.
1385
+ */
1386
+ static VALUE
1387
+ set_line(VALUE self, VALUE num)
1388
+ {
1389
+ xmlNodePtr node;
1390
+ int value = NUM2INT(num);
1391
+
1392
+ Data_Get_Struct(self, xmlNode, node);
1393
+ if (value < 65535) {
1394
+ node->line = value;
1395
+ }
1396
+
1397
+ return num;
1398
+ }
1399
+
1335
1400
  /*
1336
1401
  * call-seq:
1337
1402
  * add_namespace_definition(prefix, href)
@@ -1343,45 +1408,47 @@ static VALUE line(VALUE self)
1343
1408
  * show up in #attributes, but they will be included as an xmlns attribute
1344
1409
  * when the node is serialized to XML.
1345
1410
  */
1346
- static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href)
1411
+ static VALUE
1412
+ add_namespace_definition(VALUE rb_node, VALUE rb_prefix, VALUE rb_href)
1347
1413
  {
1348
- xmlNodePtr node, namespace;
1349
- xmlNsPtr ns;
1414
+ xmlNodePtr c_node, element;
1415
+ xmlNsPtr c_namespace;
1416
+ const xmlChar *c_prefix = (const xmlChar *)(NIL_P(rb_prefix) ? NULL : StringValueCStr(rb_prefix));
1350
1417
 
1351
- Data_Get_Struct(self, xmlNode, node);
1352
- namespace = node ;
1418
+ Data_Get_Struct(rb_node, xmlNode, c_node);
1419
+ element = c_node ;
1353
1420
 
1354
- ns = xmlSearchNs(
1355
- node->doc,
1356
- node,
1357
- (const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
1358
- );
1421
+ c_namespace = xmlSearchNs(c_node->doc, c_node, c_prefix);
1359
1422
 
1360
- if(!ns) {
1361
- if (node->type != XML_ELEMENT_NODE) {
1362
- namespace = node->parent;
1423
+ if (!c_namespace) {
1424
+ if (c_node->type != XML_ELEMENT_NODE) {
1425
+ element = c_node->parent;
1363
1426
  }
1364
- ns = xmlNewNs(
1365
- namespace,
1366
- (const xmlChar *)StringValueCStr(href),
1367
- (const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
1368
- );
1427
+ c_namespace = xmlNewNs(element, (const xmlChar *)StringValueCStr(rb_href), c_prefix);
1369
1428
  }
1370
1429
 
1371
- if (!ns) { return Qnil ; }
1430
+ if (!c_namespace) {
1431
+ return Qnil ;
1432
+ }
1372
1433
 
1373
- if(NIL_P(prefix) || node != namespace) { xmlSetNs(node, ns); }
1434
+ if (NIL_P(rb_prefix) || c_node != element) {
1435
+ xmlSetNs(c_node, c_namespace);
1436
+ }
1374
1437
 
1375
- return Nokogiri_wrap_xml_namespace(node->doc, ns);
1438
+ return noko_xml_namespace_wrap(c_namespace, c_node->doc);
1376
1439
  }
1377
1440
 
1378
1441
  /*
1379
- * call-seq:
1380
- * new(name, document)
1381
- *
1382
- * Create a new node with +name+ sharing GC lifecycle with +document+
1442
+ * @overload new(name, document)
1443
+ * Create a new node with +name+ sharing GC lifecycle with +document+.
1444
+ * @param name [String]
1445
+ * @param document [Nokogiri::XML::Document]
1446
+ * @yieldparam node [Nokogiri::XML::Node]
1447
+ * @return [Nokogiri::XML::Node]
1448
+ * @see Nokogiri::XML::Node#initialize
1383
1449
  */
1384
- static VALUE new(int argc, VALUE *argv, VALUE klass)
1450
+ static VALUE
1451
+ rb_xml_node_new(int argc, VALUE *argv, VALUE klass)
1385
1452
  {
1386
1453
  xmlDocPtr doc;
1387
1454
  xmlNodePtr node;
@@ -1396,15 +1463,15 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
1396
1463
 
1397
1464
  node = xmlNewNode(NULL, (xmlChar *)StringValueCStr(name));
1398
1465
  node->doc = doc->doc;
1399
- nokogiri_root_node(node);
1466
+ noko_xml_document_pin_node(node);
1400
1467
 
1401
- rb_node = Nokogiri_wrap_xml_node(
1468
+ rb_node = noko_xml_node_wrap(
1402
1469
  klass == cNokogiriXmlNode ? (VALUE)NULL : klass,
1403
1470
  node
1404
1471
  );
1405
1472
  rb_obj_call_init(rb_node, argc, argv);
1406
1473
 
1407
- if(rb_block_given_p()) { rb_yield(rb_node); }
1474
+ if (rb_block_given_p()) { rb_yield(rb_node); }
1408
1475
 
1409
1476
  return rb_node;
1410
1477
  }
@@ -1415,7 +1482,8 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
1415
1482
  *
1416
1483
  * Returns the Node as html.
1417
1484
  */
1418
- static VALUE dump_html(VALUE self)
1485
+ static VALUE
1486
+ dump_html(VALUE self)
1419
1487
  {
1420
1488
  xmlBufferPtr buf ;
1421
1489
  xmlNodePtr node ;
@@ -1436,7 +1504,8 @@ static VALUE dump_html(VALUE self)
1436
1504
  *
1437
1505
  * Compare this Node to +other+ with respect to their Document
1438
1506
  */
1439
- static VALUE compare(VALUE self, VALUE _other)
1507
+ static VALUE
1508
+ compare(VALUE self, VALUE _other)
1440
1509
  {
1441
1510
  xmlNodePtr node, other;
1442
1511
  Data_Get_Struct(self, xmlNode, node);
@@ -1453,7 +1522,8 @@ static VALUE compare(VALUE self, VALUE _other)
1453
1522
  * Loads and substitutes all xinclude elements below the node. The
1454
1523
  * parser context will be initialized with +options+.
1455
1524
  */
1456
- static VALUE process_xincludes(VALUE self, VALUE options)
1525
+ static VALUE
1526
+ process_xincludes(VALUE self, VALUE options)
1457
1527
  {
1458
1528
  int rcode ;
1459
1529
  xmlNodePtr node;
@@ -1469,7 +1539,7 @@ static VALUE process_xincludes(VALUE self, VALUE options)
1469
1539
  xmlErrorPtr error;
1470
1540
 
1471
1541
  error = xmlGetLastError();
1472
- if(error) {
1542
+ if (error) {
1473
1543
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
1474
1544
  } else {
1475
1545
  rb_raise(rb_eRuntimeError, "Could not perform xinclude substitution");
@@ -1481,7 +1551,8 @@ static VALUE process_xincludes(VALUE self, VALUE options)
1481
1551
 
1482
1552
 
1483
1553
  /* TODO: DOCUMENT ME */
1484
- static VALUE in_context(VALUE self, VALUE _str, VALUE _options)
1554
+ static VALUE
1555
+ in_context(VALUE self, VALUE _str, VALUE _options)
1485
1556
  {
1486
1557
  xmlNodePtr node, list = 0, tmp, child_iter, node_children, doc_children;
1487
1558
  xmlNodeSetPtr set;
@@ -1576,178 +1647,178 @@ static VALUE in_context(VALUE self, VALUE _str, VALUE _options)
1576
1647
  tmp = list->next;
1577
1648
  list->next = NULL;
1578
1649
  xmlXPathNodeSetAddUnique(set, list);
1579
- nokogiri_root_node(list);
1650
+ noko_xml_document_pin_node(list);
1580
1651
  list = tmp;
1581
1652
  }
1582
1653
 
1583
- return Nokogiri_wrap_xml_node_set(set, doc);
1654
+ return noko_xml_node_set_wrap(set, doc);
1584
1655
  }
1585
1656
 
1586
1657
 
1587
- VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1658
+ VALUE
1659
+ noko_xml_node_wrap(VALUE rb_class, xmlNodePtr c_node)
1588
1660
  {
1589
- VALUE document = Qnil ;
1590
- VALUE node_cache = Qnil ;
1591
- VALUE rb_node = Qnil ;
1661
+ VALUE rb_document, rb_node_cache, rb_node;
1592
1662
  nokogiriTuplePtr node_has_a_document;
1593
- xmlDocPtr doc;
1663
+ xmlDocPtr c_doc;
1594
1664
  void (*mark_method)(xmlNodePtr) = NULL ;
1595
1665
 
1596
- assert(node);
1666
+ assert(c_node);
1597
1667
 
1598
- if(node->type == XML_DOCUMENT_NODE || node->type == XML_HTML_DOCUMENT_NODE) {
1599
- return DOC_RUBY_OBJECT(node->doc);
1668
+ if (c_node->type == XML_DOCUMENT_NODE || c_node->type == XML_HTML_DOCUMENT_NODE) {
1669
+ return DOC_RUBY_OBJECT(c_node->doc);
1600
1670
  }
1601
1671
 
1602
1672
  /* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
1603
1673
  /* see https://github.com/sparklemotion/nokogiri/issues/95 */
1604
1674
  /* and https://github.com/sparklemotion/nokogiri/issues/439 */
1605
- doc = node->doc;
1606
- if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
1607
- node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
1675
+ c_doc = c_node->doc;
1676
+ if (c_doc->type == XML_DOCUMENT_FRAG_NODE) { c_doc = c_doc->doc; }
1677
+ node_has_a_document = DOC_RUBY_OBJECT_TEST(c_doc);
1608
1678
 
1609
- if(node->_private && node_has_a_document) {
1610
- return (VALUE)node->_private;
1679
+ if (c_node->_private && node_has_a_document) {
1680
+ return (VALUE)c_node->_private;
1611
1681
  }
1612
1682
 
1613
- if(!RTEST(klass)) {
1614
- switch(node->type) {
1683
+ if (!RTEST(rb_class)) {
1684
+ switch (c_node->type) {
1615
1685
  case XML_ELEMENT_NODE:
1616
- klass = cNokogiriXmlElement;
1686
+ rb_class = cNokogiriXmlElement;
1617
1687
  break;
1618
1688
  case XML_TEXT_NODE:
1619
- klass = cNokogiriXmlText;
1689
+ rb_class = cNokogiriXmlText;
1620
1690
  break;
1621
1691
  case XML_ATTRIBUTE_NODE:
1622
- klass = cNokogiriXmlAttr;
1692
+ rb_class = cNokogiriXmlAttr;
1623
1693
  break;
1624
1694
  case XML_ENTITY_REF_NODE:
1625
- klass = cNokogiriXmlEntityReference;
1695
+ rb_class = cNokogiriXmlEntityReference;
1626
1696
  break;
1627
1697
  case XML_COMMENT_NODE:
1628
- klass = cNokogiriXmlComment;
1698
+ rb_class = cNokogiriXmlComment;
1629
1699
  break;
1630
1700
  case XML_DOCUMENT_FRAG_NODE:
1631
- klass = cNokogiriXmlDocumentFragment;
1701
+ rb_class = cNokogiriXmlDocumentFragment;
1632
1702
  break;
1633
1703
  case XML_PI_NODE:
1634
- klass = cNokogiriXmlProcessingInstruction;
1704
+ rb_class = cNokogiriXmlProcessingInstruction;
1635
1705
  break;
1636
1706
  case XML_ENTITY_DECL:
1637
- klass = cNokogiriXmlEntityDecl;
1707
+ rb_class = cNokogiriXmlEntityDecl;
1638
1708
  break;
1639
1709
  case XML_CDATA_SECTION_NODE:
1640
- klass = cNokogiriXmlCData;
1710
+ rb_class = cNokogiriXmlCData;
1641
1711
  break;
1642
1712
  case XML_DTD_NODE:
1643
- klass = cNokogiriXmlDtd;
1713
+ rb_class = cNokogiriXmlDtd;
1644
1714
  break;
1645
1715
  case XML_ATTRIBUTE_DECL:
1646
- klass = cNokogiriXmlAttributeDecl;
1716
+ rb_class = cNokogiriXmlAttributeDecl;
1647
1717
  break;
1648
1718
  case XML_ELEMENT_DECL:
1649
- klass = cNokogiriXmlElementDecl;
1719
+ rb_class = cNokogiriXmlElementDecl;
1650
1720
  break;
1651
1721
  default:
1652
- klass = cNokogiriXmlNode;
1722
+ rb_class = cNokogiriXmlNode;
1653
1723
  }
1654
1724
  }
1655
1725
 
1656
1726
  mark_method = node_has_a_document ? mark : NULL ;
1657
1727
 
1658
- rb_node = Data_Wrap_Struct(klass, mark_method, debug_node_dealloc, node) ;
1659
- node->_private = (void *)rb_node;
1728
+ rb_node = Data_Wrap_Struct(rb_class, mark_method, debug_node_dealloc, c_node) ;
1729
+ c_node->_private = (void *)rb_node;
1660
1730
 
1661
1731
  if (node_has_a_document) {
1662
- document = DOC_RUBY_OBJECT(doc);
1663
- node_cache = DOC_NODE_CACHE(doc);
1664
- rb_ary_push(node_cache, rb_node);
1665
- rb_funcall(document, decorate, 1, rb_node);
1732
+ rb_document = DOC_RUBY_OBJECT(c_doc);
1733
+ rb_node_cache = DOC_NODE_CACHE(c_doc);
1734
+ rb_ary_push(rb_node_cache, rb_node);
1735
+ rb_funcall(rb_document, id_decorate, 1, rb_node);
1666
1736
  }
1667
1737
 
1668
1738
  return rb_node ;
1669
1739
  }
1670
1740
 
1671
1741
 
1672
- void Nokogiri_xml_node_properties(xmlNodePtr node, VALUE attr_list)
1742
+ /*
1743
+ * return Array<Nokogiri::XML::Attr> containing the node's attributes
1744
+ */
1745
+ VALUE
1746
+ noko_xml_node_attrs(xmlNodePtr c_node)
1673
1747
  {
1674
- xmlAttrPtr prop;
1675
- prop = node->properties ;
1676
- while (prop != NULL) {
1677
- rb_ary_push(attr_list, Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)prop));
1678
- prop = prop->next ;
1748
+ VALUE rb_properties = rb_ary_new();
1749
+ xmlAttrPtr c_property;
1750
+
1751
+ c_property = c_node->properties ;
1752
+ while (c_property != NULL) {
1753
+ rb_ary_push(rb_properties, noko_xml_node_wrap(Qnil, (xmlNodePtr)c_property));
1754
+ c_property = c_property->next ;
1679
1755
  }
1680
- }
1681
1756
 
1682
- VALUE cNokogiriXmlNode ;
1683
- VALUE cNokogiriXmlElement ;
1757
+ return rb_properties;
1758
+ }
1684
1759
 
1685
- void init_xml_node()
1760
+ void
1761
+ noko_init_xml_node()
1686
1762
  {
1687
- VALUE nokogiri = rb_define_module("Nokogiri");
1688
- VALUE xml = rb_define_module_under(nokogiri, "XML");
1689
- VALUE klass = rb_define_class_under(xml, "Node", rb_cObject);
1690
-
1691
- cNokogiriXmlNode = klass;
1692
-
1693
- cNokogiriXmlElement = rb_define_class_under(xml, "Element", klass);
1694
-
1695
- rb_define_singleton_method(klass, "new", new, -1);
1696
-
1697
- rb_define_method(klass, "add_namespace_definition", add_namespace_definition, 2);
1698
- rb_define_method(klass, "node_name", get_name, 0);
1699
- rb_define_method(klass, "document", document, 0);
1700
- rb_define_method(klass, "node_name=", set_name, 1);
1701
- rb_define_method(klass, "parent", get_parent, 0);
1702
- rb_define_method(klass, "child", child, 0);
1703
- rb_define_method(klass, "first_element_child", first_element_child, 0);
1704
- rb_define_method(klass, "last_element_child", last_element_child, 0);
1705
- rb_define_method(klass, "children", children, 0);
1706
- rb_define_method(klass, "element_children", element_children, 0);
1707
- rb_define_method(klass, "next_sibling", next_sibling, 0);
1708
- rb_define_method(klass, "previous_sibling", previous_sibling, 0);
1709
- rb_define_method(klass, "next_element", next_element, 0);
1710
- rb_define_method(klass, "previous_element", previous_element, 0);
1711
- rb_define_method(klass, "node_type", node_type, 0);
1712
- rb_define_method(klass, "path", path, 0);
1713
- rb_define_method(klass, "key?", key_eh, 1);
1714
- rb_define_method(klass, "namespaced_key?", namespaced_key_eh, 2);
1715
- rb_define_method(klass, "blank?", blank_eh, 0);
1716
- rb_define_method(klass, "attribute_nodes", attribute_nodes, 0);
1717
- rb_define_method(klass, "attribute", attr, 1);
1718
- rb_define_method(klass, "attribute_with_ns", attribute_with_ns, 2);
1719
- rb_define_method(klass, "namespace", namespace, 0);
1720
- rb_define_method(klass, "namespace_definitions", namespace_definitions, 0);
1721
- rb_define_method(klass, "namespace_scopes", namespace_scopes, 0);
1722
- rb_define_method(klass, "encode_special_chars", encode_special_chars, 1);
1723
- rb_define_method(klass, "dup", duplicate_node, -1);
1724
- rb_define_method(klass, "unlink", unlink_node, 0);
1725
- rb_define_method(klass, "internal_subset", internal_subset, 0);
1726
- rb_define_method(klass, "external_subset", external_subset, 0);
1727
- rb_define_method(klass, "create_internal_subset", create_internal_subset, 3);
1728
- rb_define_method(klass, "create_external_subset", create_external_subset, 3);
1729
- rb_define_method(klass, "pointer_id", pointer_id, 0);
1730
- rb_define_method(klass, "line", line, 0);
1731
- rb_define_method(klass, "content", get_native_content, 0);
1732
- rb_define_method(klass, "native_content=", set_native_content, 1);
1733
- rb_define_method(klass, "lang", get_lang, 0);
1734
- rb_define_method(klass, "lang=", set_lang, 1);
1735
-
1736
- rb_define_private_method(klass, "process_xincludes", process_xincludes, 1);
1737
- rb_define_private_method(klass, "in_context", in_context, 2);
1738
- rb_define_private_method(klass, "add_child_node", add_child, 1);
1739
- rb_define_private_method(klass, "add_previous_sibling_node", add_previous_sibling, 1);
1740
- rb_define_private_method(klass, "add_next_sibling_node", add_next_sibling, 1);
1741
- rb_define_private_method(klass, "replace_node", replace, 1);
1742
- rb_define_private_method(klass, "dump_html", dump_html, 0);
1743
- rb_define_private_method(klass, "native_write_to", native_write_to, 4);
1744
- rb_define_private_method(klass, "get", get, 1);
1745
- rb_define_private_method(klass, "set", set, 2);
1746
- rb_define_private_method(klass, "set_namespace", set_namespace, 1);
1747
- rb_define_private_method(klass, "compare", compare, 1);
1748
-
1749
- decorate = rb_intern("decorate");
1750
- decorate_bang = rb_intern("decorate!");
1763
+ cNokogiriXmlNode = rb_define_class_under(mNokogiriXml, "Node", rb_cObject);
1764
+
1765
+ rb_define_singleton_method(cNokogiriXmlNode, "new", rb_xml_node_new, -1);
1766
+
1767
+ rb_define_method(cNokogiriXmlNode, "add_namespace_definition", add_namespace_definition, 2);
1768
+ rb_define_method(cNokogiriXmlNode, "node_name", get_name, 0);
1769
+ rb_define_method(cNokogiriXmlNode, "document", document, 0);
1770
+ rb_define_method(cNokogiriXmlNode, "node_name=", set_name, 1);
1771
+ rb_define_method(cNokogiriXmlNode, "parent", get_parent, 0);
1772
+ rb_define_method(cNokogiriXmlNode, "child", child, 0);
1773
+ rb_define_method(cNokogiriXmlNode, "first_element_child", first_element_child, 0);
1774
+ rb_define_method(cNokogiriXmlNode, "last_element_child", last_element_child, 0);
1775
+ rb_define_method(cNokogiriXmlNode, "children", children, 0);
1776
+ rb_define_method(cNokogiriXmlNode, "element_children", element_children, 0);
1777
+ rb_define_method(cNokogiriXmlNode, "next_sibling", next_sibling, 0);
1778
+ rb_define_method(cNokogiriXmlNode, "previous_sibling", previous_sibling, 0);
1779
+ rb_define_method(cNokogiriXmlNode, "next_element", next_element, 0);
1780
+ rb_define_method(cNokogiriXmlNode, "previous_element", previous_element, 0);
1781
+ rb_define_method(cNokogiriXmlNode, "node_type", node_type, 0);
1782
+ rb_define_method(cNokogiriXmlNode, "path", path, 0);
1783
+ rb_define_method(cNokogiriXmlNode, "key?", key_eh, 1);
1784
+ rb_define_method(cNokogiriXmlNode, "namespaced_key?", namespaced_key_eh, 2);
1785
+ rb_define_method(cNokogiriXmlNode, "blank?", blank_eh, 0);
1786
+ rb_define_method(cNokogiriXmlNode, "attribute_nodes", attribute_nodes, 0);
1787
+ rb_define_method(cNokogiriXmlNode, "attribute", attr, 1);
1788
+ rb_define_method(cNokogiriXmlNode, "attribute_with_ns", attribute_with_ns, 2);
1789
+ rb_define_method(cNokogiriXmlNode, "namespace", noko_xml_node_namespace, 0);
1790
+ rb_define_method(cNokogiriXmlNode, "namespace_definitions", namespace_definitions, 0);
1791
+ rb_define_method(cNokogiriXmlNode, "namespace_scopes", namespace_scopes, 0);
1792
+ rb_define_method(cNokogiriXmlNode, "encode_special_chars", encode_special_chars, 1);
1793
+ rb_define_method(cNokogiriXmlNode, "dup", duplicate_node, -1);
1794
+ rb_define_method(cNokogiriXmlNode, "unlink", unlink_node, 0);
1795
+ rb_define_method(cNokogiriXmlNode, "internal_subset", internal_subset, 0);
1796
+ rb_define_method(cNokogiriXmlNode, "external_subset", external_subset, 0);
1797
+ rb_define_method(cNokogiriXmlNode, "create_internal_subset", create_internal_subset, 3);
1798
+ rb_define_method(cNokogiriXmlNode, "create_external_subset", create_external_subset, 3);
1799
+ rb_define_method(cNokogiriXmlNode, "pointer_id", pointer_id, 0);
1800
+ rb_define_method(cNokogiriXmlNode, "line", line, 0);
1801
+ rb_define_method(cNokogiriXmlNode, "line=", set_line, 1);
1802
+ rb_define_method(cNokogiriXmlNode, "content", get_native_content, 0);
1803
+ rb_define_method(cNokogiriXmlNode, "native_content=", set_native_content, 1);
1804
+ rb_define_method(cNokogiriXmlNode, "lang", get_lang, 0);
1805
+ rb_define_method(cNokogiriXmlNode, "lang=", set_lang, 1);
1806
+
1807
+ rb_define_private_method(cNokogiriXmlNode, "process_xincludes", process_xincludes, 1);
1808
+ rb_define_private_method(cNokogiriXmlNode, "in_context", in_context, 2);
1809
+ rb_define_private_method(cNokogiriXmlNode, "add_child_node", add_child, 1);
1810
+ rb_define_private_method(cNokogiriXmlNode, "add_previous_sibling_node", add_previous_sibling, 1);
1811
+ rb_define_private_method(cNokogiriXmlNode, "add_next_sibling_node", add_next_sibling, 1);
1812
+ rb_define_private_method(cNokogiriXmlNode, "replace_node", replace, 1);
1813
+ rb_define_private_method(cNokogiriXmlNode, "dump_html", dump_html, 0);
1814
+ rb_define_private_method(cNokogiriXmlNode, "native_write_to", native_write_to, 4);
1815
+ rb_define_private_method(cNokogiriXmlNode, "get", get, 1);
1816
+ rb_define_private_method(cNokogiriXmlNode, "set", set, 2);
1817
+ rb_define_private_method(cNokogiriXmlNode, "set_namespace", set_namespace, 1);
1818
+ rb_define_private_method(cNokogiriXmlNode, "compare", compare, 1);
1819
+
1820
+ id_decorate = rb_intern("decorate");
1821
+ id_decorate_bang = rb_intern("decorate!");
1751
1822
  }
1752
1823
 
1753
1824
  /* vim: set noet sw=4 sws=4 */