nokogiri 1.10.10 → 1.13.9

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 (220) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -0
  3. data/LICENSE-DEPENDENCIES.md +1173 -884
  4. data/LICENSE.md +1 -1
  5. data/README.md +178 -96
  6. data/bin/nokogiri +63 -50
  7. data/dependencies.yml +13 -64
  8. data/ext/nokogiri/depend +38 -358
  9. data/ext/nokogiri/extconf.rb +761 -424
  10. data/ext/nokogiri/gumbo.c +584 -0
  11. data/ext/nokogiri/html4_document.c +166 -0
  12. data/ext/nokogiri/html4_element_description.c +294 -0
  13. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  14. data/ext/nokogiri/html4_sax_parser_context.c +119 -0
  15. data/ext/nokogiri/html4_sax_push_parser.c +95 -0
  16. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  17. data/ext/nokogiri/nokogiri.c +228 -91
  18. data/ext/nokogiri/nokogiri.h +199 -88
  19. data/ext/nokogiri/test_global_handlers.c +40 -0
  20. data/ext/nokogiri/xml_attr.c +17 -17
  21. data/ext/nokogiri/xml_attribute_decl.c +21 -21
  22. data/ext/nokogiri/xml_cdata.c +14 -19
  23. data/ext/nokogiri/xml_comment.c +19 -26
  24. data/ext/nokogiri/xml_document.c +296 -220
  25. data/ext/nokogiri/xml_document_fragment.c +12 -16
  26. data/ext/nokogiri/xml_dtd.c +64 -58
  27. data/ext/nokogiri/xml_element_content.c +31 -26
  28. data/ext/nokogiri/xml_element_decl.c +25 -25
  29. data/ext/nokogiri/xml_encoding_handler.c +43 -18
  30. data/ext/nokogiri/xml_entity_decl.c +37 -35
  31. data/ext/nokogiri/xml_entity_reference.c +16 -18
  32. data/ext/nokogiri/xml_namespace.c +98 -53
  33. data/ext/nokogiri/xml_node.c +1065 -653
  34. data/ext/nokogiri/xml_node_set.c +178 -166
  35. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  36. data/ext/nokogiri/xml_reader.c +277 -175
  37. data/ext/nokogiri/xml_relax_ng.c +52 -28
  38. data/ext/nokogiri/xml_sax_parser.c +112 -112
  39. data/ext/nokogiri/xml_sax_parser_context.c +112 -86
  40. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  41. data/ext/nokogiri/xml_schema.c +98 -48
  42. data/ext/nokogiri/xml_syntax_error.c +42 -21
  43. data/ext/nokogiri/xml_text.c +14 -18
  44. data/ext/nokogiri/xml_xpath_context.c +226 -115
  45. data/ext/nokogiri/xslt_stylesheet.c +265 -173
  46. data/gumbo-parser/CHANGES.md +63 -0
  47. data/gumbo-parser/Makefile +101 -0
  48. data/gumbo-parser/THANKS +27 -0
  49. data/gumbo-parser/src/Makefile +34 -0
  50. data/gumbo-parser/src/README.md +41 -0
  51. data/gumbo-parser/src/ascii.c +75 -0
  52. data/gumbo-parser/src/ascii.h +115 -0
  53. data/gumbo-parser/src/attribute.c +42 -0
  54. data/gumbo-parser/src/attribute.h +17 -0
  55. data/gumbo-parser/src/char_ref.c +22225 -0
  56. data/gumbo-parser/src/char_ref.h +29 -0
  57. data/gumbo-parser/src/char_ref.rl +2154 -0
  58. data/gumbo-parser/src/error.c +626 -0
  59. data/gumbo-parser/src/error.h +148 -0
  60. data/gumbo-parser/src/foreign_attrs.c +104 -0
  61. data/gumbo-parser/src/foreign_attrs.gperf +27 -0
  62. data/gumbo-parser/src/gumbo.h +943 -0
  63. data/gumbo-parser/src/insertion_mode.h +33 -0
  64. data/gumbo-parser/src/macros.h +91 -0
  65. data/gumbo-parser/src/parser.c +4875 -0
  66. data/gumbo-parser/src/parser.h +41 -0
  67. data/gumbo-parser/src/replacement.h +33 -0
  68. data/gumbo-parser/src/string_buffer.c +103 -0
  69. data/gumbo-parser/src/string_buffer.h +68 -0
  70. data/gumbo-parser/src/string_piece.c +48 -0
  71. data/gumbo-parser/src/svg_attrs.c +174 -0
  72. data/gumbo-parser/src/svg_attrs.gperf +77 -0
  73. data/gumbo-parser/src/svg_tags.c +137 -0
  74. data/gumbo-parser/src/svg_tags.gperf +55 -0
  75. data/gumbo-parser/src/tag.c +222 -0
  76. data/gumbo-parser/src/tag_lookup.c +382 -0
  77. data/gumbo-parser/src/tag_lookup.gperf +169 -0
  78. data/gumbo-parser/src/tag_lookup.h +13 -0
  79. data/gumbo-parser/src/token_buffer.c +79 -0
  80. data/gumbo-parser/src/token_buffer.h +71 -0
  81. data/gumbo-parser/src/token_type.h +17 -0
  82. data/gumbo-parser/src/tokenizer.c +3463 -0
  83. data/gumbo-parser/src/tokenizer.h +112 -0
  84. data/gumbo-parser/src/tokenizer_states.h +339 -0
  85. data/gumbo-parser/src/utf8.c +245 -0
  86. data/gumbo-parser/src/utf8.h +164 -0
  87. data/gumbo-parser/src/util.c +68 -0
  88. data/gumbo-parser/src/util.h +30 -0
  89. data/gumbo-parser/src/vector.c +111 -0
  90. data/gumbo-parser/src/vector.h +45 -0
  91. data/lib/nokogiri/class_resolver.rb +67 -0
  92. data/lib/nokogiri/css/node.rb +10 -8
  93. data/lib/nokogiri/css/parser.rb +397 -377
  94. data/lib/nokogiri/css/parser.y +250 -245
  95. data/lib/nokogiri/css/parser_extras.rb +54 -49
  96. data/lib/nokogiri/css/syntax_error.rb +3 -1
  97. data/lib/nokogiri/css/tokenizer.rb +5 -3
  98. data/lib/nokogiri/css/tokenizer.rex +3 -2
  99. data/lib/nokogiri/css/xpath_visitor.rb +218 -91
  100. data/lib/nokogiri/css.rb +50 -17
  101. data/lib/nokogiri/decorators/slop.rb +9 -7
  102. data/lib/nokogiri/extension.rb +31 -0
  103. data/lib/nokogiri/gumbo.rb +15 -0
  104. data/lib/nokogiri/html.rb +38 -27
  105. data/lib/nokogiri/{html → html4}/builder.rb +4 -2
  106. data/lib/nokogiri/{html → html4}/document.rb +103 -105
  107. data/lib/nokogiri/html4/document_fragment.rb +54 -0
  108. data/lib/nokogiri/{html → html4}/element_description.rb +3 -1
  109. data/lib/nokogiri/html4/element_description_defaults.rb +578 -0
  110. data/lib/nokogiri/{html → html4}/entity_lookup.rb +4 -2
  111. data/lib/nokogiri/{html → html4}/sax/parser.rb +17 -16
  112. data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
  113. data/lib/nokogiri/{html → html4}/sax/push_parser.rb +12 -11
  114. data/lib/nokogiri/html4.rb +46 -0
  115. data/lib/nokogiri/html5/document.rb +91 -0
  116. data/lib/nokogiri/html5/document_fragment.rb +83 -0
  117. data/lib/nokogiri/html5/node.rb +100 -0
  118. data/lib/nokogiri/html5.rb +478 -0
  119. data/lib/nokogiri/jruby/dependencies.rb +21 -0
  120. data/lib/nokogiri/syntax_error.rb +2 -0
  121. data/lib/nokogiri/version/constant.rb +6 -0
  122. data/lib/nokogiri/version/info.rb +222 -0
  123. data/lib/nokogiri/version.rb +3 -108
  124. data/lib/nokogiri/xml/attr.rb +6 -3
  125. data/lib/nokogiri/xml/attribute_decl.rb +3 -1
  126. data/lib/nokogiri/xml/builder.rb +74 -33
  127. data/lib/nokogiri/xml/cdata.rb +3 -1
  128. data/lib/nokogiri/xml/character_data.rb +2 -0
  129. data/lib/nokogiri/xml/document.rb +224 -86
  130. data/lib/nokogiri/xml/document_fragment.rb +46 -44
  131. data/lib/nokogiri/xml/dtd.rb +4 -2
  132. data/lib/nokogiri/xml/element_content.rb +2 -0
  133. data/lib/nokogiri/xml/element_decl.rb +3 -1
  134. data/lib/nokogiri/xml/entity_decl.rb +4 -2
  135. data/lib/nokogiri/xml/entity_reference.rb +2 -0
  136. data/lib/nokogiri/xml/namespace.rb +3 -0
  137. data/lib/nokogiri/xml/node/save_options.rb +10 -5
  138. data/lib/nokogiri/xml/node.rb +884 -378
  139. data/lib/nokogiri/xml/node_set.rb +51 -54
  140. data/lib/nokogiri/xml/notation.rb +13 -0
  141. data/lib/nokogiri/xml/parse_options.rb +22 -8
  142. data/lib/nokogiri/xml/pp/character_data.rb +9 -6
  143. data/lib/nokogiri/xml/pp/node.rb +25 -26
  144. data/lib/nokogiri/xml/pp.rb +4 -2
  145. data/lib/nokogiri/xml/processing_instruction.rb +3 -1
  146. data/lib/nokogiri/xml/reader.rb +21 -28
  147. data/lib/nokogiri/xml/relax_ng.rb +8 -2
  148. data/lib/nokogiri/xml/sax/document.rb +45 -49
  149. data/lib/nokogiri/xml/sax/parser.rb +38 -34
  150. data/lib/nokogiri/xml/sax/parser_context.rb +8 -3
  151. data/lib/nokogiri/xml/sax/push_parser.rb +6 -5
  152. data/lib/nokogiri/xml/sax.rb +6 -4
  153. data/lib/nokogiri/xml/schema.rb +19 -9
  154. data/lib/nokogiri/xml/searchable.rb +112 -72
  155. data/lib/nokogiri/xml/syntax_error.rb +6 -4
  156. data/lib/nokogiri/xml/text.rb +2 -0
  157. data/lib/nokogiri/xml/xpath/syntax_error.rb +4 -2
  158. data/lib/nokogiri/xml/xpath.rb +15 -4
  159. data/lib/nokogiri/xml/xpath_context.rb +3 -3
  160. data/lib/nokogiri/xml.rb +38 -37
  161. data/lib/nokogiri/xslt/stylesheet.rb +3 -1
  162. data/lib/nokogiri/xslt.rb +29 -20
  163. data/lib/nokogiri.rb +49 -65
  164. data/lib/xsd/xmlparser/nokogiri.rb +26 -24
  165. data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
  166. data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
  167. data/patches/libxml2/{0004-libxml2.la-is-in-top_builddir.patch → 0003-libxml2.la-is-in-top_builddir.patch} +1 -1
  168. data/patches/libxml2/0005-avoid-isnan-isinf.patch +81 -0
  169. data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
  170. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +3037 -0
  171. data/ports/archives/libxml2-2.10.3.tar.xz +0 -0
  172. data/ports/archives/libxslt-1.1.37.tar.xz +0 -0
  173. metadata +189 -142
  174. data/ext/nokogiri/html_document.c +0 -170
  175. data/ext/nokogiri/html_document.h +0 -10
  176. data/ext/nokogiri/html_element_description.c +0 -279
  177. data/ext/nokogiri/html_element_description.h +0 -10
  178. data/ext/nokogiri/html_entity_lookup.c +0 -32
  179. data/ext/nokogiri/html_entity_lookup.h +0 -8
  180. data/ext/nokogiri/html_sax_parser_context.c +0 -116
  181. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  182. data/ext/nokogiri/html_sax_push_parser.c +0 -87
  183. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  184. data/ext/nokogiri/xml_attr.h +0 -9
  185. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  186. data/ext/nokogiri/xml_cdata.h +0 -9
  187. data/ext/nokogiri/xml_comment.h +0 -9
  188. data/ext/nokogiri/xml_document.h +0 -23
  189. data/ext/nokogiri/xml_document_fragment.h +0 -10
  190. data/ext/nokogiri/xml_dtd.h +0 -10
  191. data/ext/nokogiri/xml_element_content.h +0 -10
  192. data/ext/nokogiri/xml_element_decl.h +0 -9
  193. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  194. data/ext/nokogiri/xml_entity_decl.h +0 -10
  195. data/ext/nokogiri/xml_entity_reference.h +0 -9
  196. data/ext/nokogiri/xml_io.c +0 -61
  197. data/ext/nokogiri/xml_io.h +0 -11
  198. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  199. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  200. data/ext/nokogiri/xml_namespace.h +0 -14
  201. data/ext/nokogiri/xml_node.h +0 -13
  202. data/ext/nokogiri/xml_node_set.h +0 -12
  203. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  204. data/ext/nokogiri/xml_reader.h +0 -10
  205. data/ext/nokogiri/xml_relax_ng.h +0 -9
  206. data/ext/nokogiri/xml_sax_parser.h +0 -39
  207. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  208. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  209. data/ext/nokogiri/xml_schema.h +0 -9
  210. data/ext/nokogiri/xml_syntax_error.h +0 -13
  211. data/ext/nokogiri/xml_text.h +0 -9
  212. data/ext/nokogiri/xml_xpath_context.h +0 -10
  213. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  214. data/lib/nokogiri/html/document_fragment.rb +0 -49
  215. data/lib/nokogiri/html/element_description_defaults.rb +0 -671
  216. data/lib/nokogiri/html/sax/parser_context.rb +0 -16
  217. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  218. data/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch +0 -32
  219. data/ports/archives/libxml2-2.9.10.tar.gz +0 -0
  220. data/ports/archives/libxslt-1.1.34.tar.gz +0 -0
@@ -1,13 +1,17 @@
1
- #include <xml_reader.h>
1
+ #include <nokogiri.h>
2
2
 
3
- static void dealloc(xmlTextReaderPtr reader)
3
+ VALUE cNokogiriXmlReader;
4
+
5
+ static void
6
+ dealloc(xmlTextReaderPtr reader)
4
7
  {
5
8
  NOKOGIRI_DEBUG_START(reader);
6
9
  xmlFreeTextReader(reader);
7
10
  NOKOGIRI_DEBUG_END(reader);
8
11
  }
9
12
 
10
- static int has_attributes(xmlTextReaderPtr reader)
13
+ static int
14
+ has_attributes(xmlTextReaderPtr reader)
11
15
  {
12
16
  /*
13
17
  * this implementation of xmlTextReaderHasAttributes explicitly includes
@@ -16,47 +20,40 @@ static int has_attributes(xmlTextReaderPtr reader)
16
20
  */
17
21
  xmlNodePtr node ;
18
22
  node = xmlTextReaderCurrentNode(reader);
19
- if (node == NULL)
20
- return(0);
23
+ if (node == NULL) {
24
+ return (0);
25
+ }
21
26
 
22
27
  if ((node->type == XML_ELEMENT_NODE) &&
23
- ((node->properties != NULL) || (node->nsDef != NULL)))
24
- return(1);
25
- return(0);
28
+ ((node->properties != NULL) || (node->nsDef != NULL))) {
29
+ return (1);
30
+ }
31
+ return (0);
26
32
  }
27
33
 
28
- static void Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash)
34
+ // TODO: merge this function into the `namespaces` method implementation
35
+ static void
36
+ Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash)
29
37
  {
30
38
  xmlNsPtr ns;
31
- static char buffer[XMLNS_BUFFER_LEN] ;
32
- char *key ;
33
- size_t keylen ;
39
+ VALUE key;
34
40
 
35
- if (node->type != XML_ELEMENT_NODE) return ;
41
+ if (node->type != XML_ELEMENT_NODE) { return ; }
36
42
 
37
43
  ns = node->nsDef;
38
44
  while (ns != NULL) {
39
45
 
40
- keylen = XMLNS_PREFIX_LEN + (ns->prefix ? (strlen((const char*)ns->prefix) + 1) : 0) ;
41
- if (keylen > XMLNS_BUFFER_LEN) {
42
- key = (char*)malloc(keylen) ;
43
- } else {
44
- key = buffer ;
45
- }
46
-
46
+ key = rb_enc_str_new_cstr(XMLNS_PREFIX, rb_utf8_encoding());
47
47
  if (ns->prefix) {
48
- sprintf(key, "%s:%s", XMLNS_PREFIX, ns->prefix);
49
- } else {
50
- sprintf(key, "%s", XMLNS_PREFIX);
48
+ rb_str_cat_cstr(key, ":");
49
+ rb_str_cat_cstr(key, (const char *)ns->prefix);
51
50
  }
52
51
 
52
+ key = rb_str_conv_enc(key, rb_utf8_encoding(), rb_default_internal_encoding());
53
53
  rb_hash_aset(attr_hash,
54
- NOKOGIRI_STR_NEW2(key),
55
- (ns->href ? NOKOGIRI_STR_NEW2(ns->href) : Qnil)
56
- );
57
- if (key != buffer) {
58
- free(key);
59
- }
54
+ key,
55
+ (ns->href ? NOKOGIRI_STR_NEW2(ns->href) : Qnil)
56
+ );
60
57
  ns = ns->next ;
61
58
  }
62
59
  }
@@ -68,15 +65,16 @@ static void Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash)
68
65
  *
69
66
  * Was an attribute generated from the default value in the DTD or schema?
70
67
  */
71
- static VALUE default_eh(VALUE self)
68
+ static VALUE
69
+ default_eh(VALUE self)
72
70
  {
73
71
  xmlTextReaderPtr reader;
74
72
  int eh;
75
73
 
76
74
  Data_Get_Struct(self, xmlTextReader, reader);
77
75
  eh = xmlTextReaderIsDefault(reader);
78
- if(eh == 0) return Qfalse;
79
- if(eh == 1) return Qtrue;
76
+ if (eh == 0) { return Qfalse; }
77
+ if (eh == 1) { return Qtrue; }
80
78
 
81
79
  return Qnil;
82
80
  }
@@ -87,15 +85,16 @@ static VALUE default_eh(VALUE self)
87
85
  *
88
86
  * Does this node have a text value?
89
87
  */
90
- static VALUE value_eh(VALUE self)
88
+ static VALUE
89
+ value_eh(VALUE self)
91
90
  {
92
91
  xmlTextReaderPtr reader;
93
92
  int eh;
94
93
 
95
94
  Data_Get_Struct(self, xmlTextReader, reader);
96
95
  eh = xmlTextReaderHasValue(reader);
97
- if(eh == 0) return Qfalse;
98
- if(eh == 1) return Qtrue;
96
+ if (eh == 0) { return Qfalse; }
97
+ if (eh == 1) { return Qtrue; }
99
98
 
100
99
  return Qnil;
101
100
  }
@@ -106,15 +105,16 @@ static VALUE value_eh(VALUE self)
106
105
  *
107
106
  * Does this node have attributes?
108
107
  */
109
- static VALUE attributes_eh(VALUE self)
108
+ static VALUE
109
+ attributes_eh(VALUE self)
110
110
  {
111
111
  xmlTextReaderPtr reader;
112
112
  int eh;
113
113
 
114
114
  Data_Get_Struct(self, xmlTextReader, reader);
115
115
  eh = has_attributes(reader);
116
- if(eh == 0) return Qfalse;
117
- if(eh == 1) return Qtrue;
116
+ if (eh == 0) { return Qfalse; }
117
+ if (eh == 1) { return Qtrue; }
118
118
 
119
119
  return Qnil;
120
120
  }
@@ -125,7 +125,8 @@ static VALUE attributes_eh(VALUE self)
125
125
  *
126
126
  * Get a hash of namespaces for this Node
127
127
  */
128
- static VALUE namespaces(VALUE self)
128
+ static VALUE
129
+ namespaces(VALUE self)
129
130
  {
130
131
  xmlTextReaderPtr reader;
131
132
  xmlNodePtr ptr;
@@ -135,11 +136,12 @@ static VALUE namespaces(VALUE self)
135
136
 
136
137
  attr = rb_hash_new() ;
137
138
 
138
- if (! has_attributes(reader))
139
+ if (! has_attributes(reader)) {
139
140
  return attr ;
141
+ }
140
142
 
141
143
  ptr = xmlTextReaderExpand(reader);
142
- if(ptr == NULL) return Qnil;
144
+ if (ptr == NULL) { return Qnil; }
143
145
 
144
146
  Nokogiri_xml_node_namespaces(ptr, attr);
145
147
 
@@ -147,30 +149,86 @@ static VALUE namespaces(VALUE self)
147
149
  }
148
150
 
149
151
  /*
150
- * call-seq:
151
- * attribute_nodes
152
- *
153
- * Get a list of attributes for this Node
152
+ :call-seq: attribute_nodes() → Array<Nokogiri::XML::Attr>
153
+
154
+ Get the attributes of the current node as an Array of XML:Attr
155
+
156
+ ⚠ This method is deprecated and unsafe to use. It will be removed in a future version of Nokogiri.
157
+
158
+ See related: #attribute_hash, #attributes
154
159
  */
155
- static VALUE attribute_nodes(VALUE self)
160
+ static VALUE
161
+ rb_xml_reader_attribute_nodes(VALUE rb_reader)
156
162
  {
157
- xmlTextReaderPtr reader;
158
- xmlNodePtr ptr;
159
- VALUE attr ;
163
+ xmlTextReaderPtr c_reader;
164
+ xmlNodePtr c_node;
165
+ VALUE attr_nodes;
166
+ int j;
160
167
 
161
- Data_Get_Struct(self, xmlTextReader, reader);
168
+ // TODO: deprecated, remove in Nokogiri v1.15, see https://github.com/sparklemotion/nokogiri/issues/2598
169
+ // After removal, we can also remove all the "node_has_a_document" special handling from xml_node.c
170
+ NOKO_WARN_DEPRECATION("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead.");
162
171
 
163
- attr = rb_ary_new() ;
172
+ Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
164
173
 
165
- if (! has_attributes(reader))
166
- return attr ;
174
+ if (! has_attributes(c_reader)) {
175
+ return rb_ary_new() ;
176
+ }
167
177
 
168
- ptr = xmlTextReaderExpand(reader);
169
- if(ptr == NULL) return Qnil;
178
+ c_node = xmlTextReaderExpand(c_reader);
179
+ if (c_node == NULL) {
180
+ return Qnil;
181
+ }
170
182
 
171
- Nokogiri_xml_node_properties(ptr, attr);
183
+ attr_nodes = noko_xml_node_attrs(c_node);
172
184
 
173
- return attr ;
185
+ /* ensure that the Reader won't be GCed as long as a node is referenced */
186
+ for (j = 0 ; j < RARRAY_LEN(attr_nodes) ; j++) {
187
+ rb_iv_set(rb_ary_entry(attr_nodes, j), "@reader", rb_reader);
188
+ }
189
+
190
+ return attr_nodes;
191
+ }
192
+
193
+ /*
194
+ :call-seq: attribute_hash() → Hash<String ⇒ String>
195
+
196
+ Get the attributes of the current node as a Hash of names and values.
197
+
198
+ See related: #attributes and #namespaces
199
+ */
200
+ static VALUE
201
+ rb_xml_reader_attribute_hash(VALUE rb_reader)
202
+ {
203
+ VALUE rb_attributes = rb_hash_new();
204
+ xmlTextReaderPtr c_reader;
205
+ xmlNodePtr c_node;
206
+ xmlAttrPtr c_property;
207
+
208
+ Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
209
+
210
+ if (!has_attributes(c_reader)) {
211
+ return rb_attributes;
212
+ }
213
+
214
+ c_node = xmlTextReaderExpand(c_reader);
215
+ c_property = c_node->properties;
216
+ while (c_property != NULL) {
217
+ VALUE rb_name = NOKOGIRI_STR_NEW2(c_property->name);
218
+ VALUE rb_value = Qnil;
219
+ xmlChar *c_value = xmlNodeGetContent((xmlNode *)c_property);
220
+
221
+ if (c_value) {
222
+ rb_value = NOKOGIRI_STR_NEW2(c_value);
223
+ xmlFree(c_value);
224
+ }
225
+
226
+ rb_hash_aset(rb_attributes, rb_name, rb_value);
227
+
228
+ c_property = c_property->next;
229
+ }
230
+
231
+ return rb_attributes;
174
232
  }
175
233
 
176
234
  /*
@@ -179,7 +237,8 @@ static VALUE attribute_nodes(VALUE self)
179
237
  *
180
238
  * Get the value of attribute at +index+
181
239
  */
182
- static VALUE attribute_at(VALUE self, VALUE index)
240
+ static VALUE
241
+ attribute_at(VALUE self, VALUE index)
183
242
  {
184
243
  xmlTextReaderPtr reader;
185
244
  xmlChar *value;
@@ -187,14 +246,14 @@ static VALUE attribute_at(VALUE self, VALUE index)
187
246
 
188
247
  Data_Get_Struct(self, xmlTextReader, reader);
189
248
 
190
- if(NIL_P(index)) return Qnil;
249
+ if (NIL_P(index)) { return Qnil; }
191
250
  index = rb_Integer(index);
192
251
 
193
252
  value = xmlTextReaderGetAttributeNo(
194
- reader,
195
- (int)NUM2INT(index)
196
- );
197
- if(value == NULL) return Qnil;
253
+ reader,
254
+ (int)NUM2INT(index)
255
+ );
256
+ if (value == NULL) { return Qnil; }
198
257
 
199
258
  rb_value = NOKOGIRI_STR_NEW2(value);
200
259
  xmlFree(value);
@@ -207,7 +266,8 @@ static VALUE attribute_at(VALUE self, VALUE index)
207
266
  *
208
267
  * Get the value of attribute named +name+
209
268
  */
210
- static VALUE reader_attribute(VALUE self, VALUE name)
269
+ static VALUE
270
+ reader_attribute(VALUE self, VALUE name)
211
271
  {
212
272
  xmlTextReaderPtr reader;
213
273
  xmlChar *value ;
@@ -215,11 +275,11 @@ static VALUE reader_attribute(VALUE self, VALUE name)
215
275
 
216
276
  Data_Get_Struct(self, xmlTextReader, reader);
217
277
 
218
- if(NIL_P(name)) return Qnil;
278
+ if (NIL_P(name)) { return Qnil; }
219
279
  name = StringValue(name) ;
220
280
 
221
- value = xmlTextReaderGetAttribute(reader, (xmlChar*)StringValueCStr(name));
222
- if(value == NULL) return Qnil;
281
+ value = xmlTextReaderGetAttribute(reader, (xmlChar *)StringValueCStr(name));
282
+ if (value == NULL) { return Qnil; }
223
283
 
224
284
  rb_value = NOKOGIRI_STR_NEW2(value);
225
285
  xmlFree(value);
@@ -232,14 +292,15 @@ static VALUE reader_attribute(VALUE self, VALUE name)
232
292
  *
233
293
  * Get the number of attributes for the current node
234
294
  */
235
- static VALUE attribute_count(VALUE self)
295
+ static VALUE
296
+ attribute_count(VALUE self)
236
297
  {
237
298
  xmlTextReaderPtr reader;
238
299
  int count;
239
300
 
240
301
  Data_Get_Struct(self, xmlTextReader, reader);
241
302
  count = xmlTextReaderAttributeCount(reader);
242
- if(count == -1) return Qnil;
303
+ if (count == -1) { return Qnil; }
243
304
 
244
305
  return INT2NUM((long)count);
245
306
  }
@@ -250,14 +311,15 @@ static VALUE attribute_count(VALUE self)
250
311
  *
251
312
  * Get the depth of the node
252
313
  */
253
- static VALUE depth(VALUE self)
314
+ static VALUE
315
+ depth(VALUE self)
254
316
  {
255
317
  xmlTextReaderPtr reader;
256
318
  int depth;
257
319
 
258
320
  Data_Get_Struct(self, xmlTextReader, reader);
259
321
  depth = xmlTextReaderDepth(reader);
260
- if(depth == -1) return Qnil;
322
+ if (depth == -1) { return Qnil; }
261
323
 
262
324
  return INT2NUM((long)depth);
263
325
  }
@@ -268,14 +330,15 @@ static VALUE depth(VALUE self)
268
330
  *
269
331
  * Get the XML version of the document being read
270
332
  */
271
- static VALUE xml_version(VALUE self)
333
+ static VALUE
334
+ xml_version(VALUE self)
272
335
  {
273
336
  xmlTextReaderPtr reader;
274
337
  const char *version;
275
338
 
276
339
  Data_Get_Struct(self, xmlTextReader, reader);
277
340
  version = (const char *)xmlTextReaderConstXmlVersion(reader);
278
- if(version == NULL) return Qnil;
341
+ if (version == NULL) { return Qnil; }
279
342
 
280
343
  return NOKOGIRI_STR_NEW2(version);
281
344
  }
@@ -286,14 +349,15 @@ static VALUE xml_version(VALUE self)
286
349
  *
287
350
  * Get the xml:lang scope within which the node resides.
288
351
  */
289
- static VALUE lang(VALUE self)
352
+ static VALUE
353
+ lang(VALUE self)
290
354
  {
291
355
  xmlTextReaderPtr reader;
292
356
  const char *lang;
293
357
 
294
358
  Data_Get_Struct(self, xmlTextReader, reader);
295
359
  lang = (const char *)xmlTextReaderConstXmlLang(reader);
296
- if(lang == NULL) return Qnil;
360
+ if (lang == NULL) { return Qnil; }
297
361
 
298
362
  return NOKOGIRI_STR_NEW2(lang);
299
363
  }
@@ -304,14 +368,15 @@ static VALUE lang(VALUE self)
304
368
  *
305
369
  * Get the text value of the node if present. Returns a utf-8 encoded string.
306
370
  */
307
- static VALUE value(VALUE self)
371
+ static VALUE
372
+ value(VALUE self)
308
373
  {
309
374
  xmlTextReaderPtr reader;
310
375
  const char *value;
311
376
 
312
377
  Data_Get_Struct(self, xmlTextReader, reader);
313
378
  value = (const char *)xmlTextReaderConstValue(reader);
314
- if(value == NULL) return Qnil;
379
+ if (value == NULL) { return Qnil; }
315
380
 
316
381
  return NOKOGIRI_STR_NEW2(value);
317
382
  }
@@ -322,14 +387,15 @@ static VALUE value(VALUE self)
322
387
  *
323
388
  * Get the shorthand reference to the namespace associated with the node.
324
389
  */
325
- static VALUE prefix(VALUE self)
390
+ static VALUE
391
+ prefix(VALUE self)
326
392
  {
327
393
  xmlTextReaderPtr reader;
328
394
  const char *prefix;
329
395
 
330
396
  Data_Get_Struct(self, xmlTextReader, reader);
331
397
  prefix = (const char *)xmlTextReaderConstPrefix(reader);
332
- if(prefix == NULL) return Qnil;
398
+ if (prefix == NULL) { return Qnil; }
333
399
 
334
400
  return NOKOGIRI_STR_NEW2(prefix);
335
401
  }
@@ -340,14 +406,15 @@ static VALUE prefix(VALUE self)
340
406
  *
341
407
  * Get the URI defining the namespace associated with the node
342
408
  */
343
- static VALUE namespace_uri(VALUE self)
409
+ static VALUE
410
+ namespace_uri(VALUE self)
344
411
  {
345
412
  xmlTextReaderPtr reader;
346
413
  const char *uri;
347
414
 
348
415
  Data_Get_Struct(self, xmlTextReader, reader);
349
416
  uri = (const char *)xmlTextReaderConstNamespaceUri(reader);
350
- if(uri == NULL) return Qnil;
417
+ if (uri == NULL) { return Qnil; }
351
418
 
352
419
  return NOKOGIRI_STR_NEW2(uri);
353
420
  }
@@ -358,14 +425,15 @@ static VALUE namespace_uri(VALUE self)
358
425
  *
359
426
  * Get the local name of the node
360
427
  */
361
- static VALUE local_name(VALUE self)
428
+ static VALUE
429
+ local_name(VALUE self)
362
430
  {
363
431
  xmlTextReaderPtr reader;
364
432
  const char *name;
365
433
 
366
434
  Data_Get_Struct(self, xmlTextReader, reader);
367
435
  name = (const char *)xmlTextReaderConstLocalName(reader);
368
- if(name == NULL) return Qnil;
436
+ if (name == NULL) { return Qnil; }
369
437
 
370
438
  return NOKOGIRI_STR_NEW2(name);
371
439
  }
@@ -376,14 +444,15 @@ static VALUE local_name(VALUE self)
376
444
  *
377
445
  * Get the name of the node. Returns a utf-8 encoded string.
378
446
  */
379
- static VALUE name(VALUE self)
447
+ static VALUE
448
+ name(VALUE self)
380
449
  {
381
450
  xmlTextReaderPtr reader;
382
451
  const char *name;
383
452
 
384
453
  Data_Get_Struct(self, xmlTextReader, reader);
385
454
  name = (const char *)xmlTextReaderConstName(reader);
386
- if(name == NULL) return Qnil;
455
+ if (name == NULL) { return Qnil; }
387
456
 
388
457
  return NOKOGIRI_STR_NEW2(name);
389
458
  }
@@ -394,16 +463,24 @@ static VALUE name(VALUE self)
394
463
  *
395
464
  * Get the xml:base of the node
396
465
  */
397
- static VALUE base_uri(VALUE self)
466
+ static VALUE
467
+ rb_xml_reader_base_uri(VALUE rb_reader)
398
468
  {
399
- xmlTextReaderPtr reader;
400
- const char * base_uri;
469
+ VALUE rb_base_uri;
470
+ xmlTextReaderPtr c_reader;
471
+ xmlChar *c_base_uri;
401
472
 
402
- Data_Get_Struct(self, xmlTextReader, reader);
403
- base_uri = (const char *)xmlTextReaderBaseUri(reader);
404
- if (base_uri == NULL) return Qnil;
473
+ Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
474
+
475
+ c_base_uri = xmlTextReaderBaseUri(c_reader);
476
+ if (c_base_uri == NULL) {
477
+ return Qnil;
478
+ }
479
+
480
+ rb_base_uri = NOKOGIRI_STR_NEW2(c_base_uri);
481
+ xmlFree(c_base_uri);
405
482
 
406
- return NOKOGIRI_STR_NEW2(base_uri);
483
+ return rb_base_uri;
407
484
  }
408
485
 
409
486
  /*
@@ -412,7 +489,8 @@ static VALUE base_uri(VALUE self)
412
489
  *
413
490
  * Get the state of the reader
414
491
  */
415
- static VALUE state(VALUE self)
492
+ static VALUE
493
+ state(VALUE self)
416
494
  {
417
495
  xmlTextReaderPtr reader;
418
496
  Data_Get_Struct(self, xmlTextReader, reader);
@@ -425,7 +503,8 @@ static VALUE state(VALUE self)
425
503
  *
426
504
  * Get the type of readers current node
427
505
  */
428
- static VALUE node_type(VALUE self)
506
+ static VALUE
507
+ node_type(VALUE self)
429
508
  {
430
509
  xmlTextReaderPtr reader;
431
510
  Data_Get_Struct(self, xmlTextReader, reader);
@@ -438,7 +517,8 @@ static VALUE node_type(VALUE self)
438
517
  *
439
518
  * Move the Reader forward through the XML document.
440
519
  */
441
- static VALUE read_more(VALUE self)
520
+ static VALUE
521
+ read_more(VALUE self)
442
522
  {
443
523
  xmlTextReaderPtr reader;
444
524
  xmlErrorPtr error;
@@ -453,14 +533,15 @@ static VALUE read_more(VALUE self)
453
533
  ret = xmlTextReaderRead(reader);
454
534
  xmlSetStructuredErrorFunc(NULL, NULL);
455
535
 
456
- if(ret == 1) return self;
457
- if(ret == 0) return Qnil;
536
+ if (ret == 1) { return self; }
537
+ if (ret == 0) { return Qnil; }
458
538
 
459
539
  error = xmlGetLastError();
460
- if(error)
540
+ if (error) {
461
541
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
462
- else
542
+ } else {
463
543
  rb_raise(rb_eRuntimeError, "Error pulling: %d", ret);
544
+ }
464
545
 
465
546
  return Qnil;
466
547
  }
@@ -472,10 +553,11 @@ static VALUE read_more(VALUE self)
472
553
  * Read the contents of the current node, including child nodes and markup.
473
554
  * Returns a utf-8 encoded string.
474
555
  */
475
- static VALUE inner_xml(VALUE self)
556
+ static VALUE
557
+ inner_xml(VALUE self)
476
558
  {
477
559
  xmlTextReaderPtr reader;
478
- xmlChar* value;
560
+ xmlChar *value;
479
561
  VALUE str;
480
562
 
481
563
  Data_Get_Struct(self, xmlTextReader, reader);
@@ -483,8 +565,8 @@ static VALUE inner_xml(VALUE self)
483
565
  value = xmlTextReaderReadInnerXml(reader);
484
566
 
485
567
  str = Qnil;
486
- if(value) {
487
- str = NOKOGIRI_STR_NEW2((char*)value);
568
+ if (value) {
569
+ str = NOKOGIRI_STR_NEW2((char *)value);
488
570
  xmlFree(value);
489
571
  }
490
572
 
@@ -498,7 +580,8 @@ static VALUE inner_xml(VALUE self)
498
580
  * Read the current node and its contents, including child nodes and markup.
499
581
  * Returns a utf-8 encoded string.
500
582
  */
501
- static VALUE outer_xml(VALUE self)
583
+ static VALUE
584
+ outer_xml(VALUE self)
502
585
  {
503
586
  xmlTextReaderPtr reader;
504
587
  xmlChar *value;
@@ -508,8 +591,8 @@ static VALUE outer_xml(VALUE self)
508
591
 
509
592
  value = xmlTextReaderReadOuterXml(reader);
510
593
 
511
- if(value) {
512
- str = NOKOGIRI_STR_NEW2((char*)value);
594
+ if (value) {
595
+ str = NOKOGIRI_STR_NEW2((char *)value);
513
596
  xmlFree(value);
514
597
  }
515
598
  return str;
@@ -521,31 +604,32 @@ static VALUE outer_xml(VALUE self)
521
604
  *
522
605
  * Create a new reader that parses +string+
523
606
  */
524
- static VALUE from_memory(int argc, VALUE *argv, VALUE klass)
607
+ static VALUE
608
+ from_memory(int argc, VALUE *argv, VALUE klass)
525
609
  {
526
610
  VALUE rb_buffer, rb_url, encoding, rb_options;
527
611
  xmlTextReaderPtr reader;
528
- const char * c_url = NULL;
529
- const char * c_encoding = NULL;
612
+ const char *c_url = NULL;
613
+ const char *c_encoding = NULL;
530
614
  int c_options = 0;
531
615
  VALUE rb_reader, args[3];
532
616
 
533
617
  rb_scan_args(argc, argv, "13", &rb_buffer, &rb_url, &encoding, &rb_options);
534
618
 
535
- if (!RTEST(rb_buffer)) rb_raise(rb_eArgError, "string cannot be nil");
536
- if (RTEST(rb_url)) c_url = StringValueCStr(rb_url);
537
- if (RTEST(encoding)) c_encoding = StringValueCStr(encoding);
538
- if (RTEST(rb_options)) c_options = (int)NUM2INT(rb_options);
619
+ if (!RTEST(rb_buffer)) { rb_raise(rb_eArgError, "string cannot be nil"); }
620
+ if (RTEST(rb_url)) { c_url = StringValueCStr(rb_url); }
621
+ if (RTEST(encoding)) { c_encoding = StringValueCStr(encoding); }
622
+ if (RTEST(rb_options)) { c_options = (int)NUM2INT(rb_options); }
539
623
 
540
624
  reader = xmlReaderForMemory(
541
- StringValuePtr(rb_buffer),
542
- (int)RSTRING_LEN(rb_buffer),
543
- c_url,
544
- c_encoding,
545
- c_options
546
- );
547
-
548
- if(reader == NULL) {
625
+ StringValuePtr(rb_buffer),
626
+ (int)RSTRING_LEN(rb_buffer),
627
+ c_url,
628
+ c_encoding,
629
+ c_options
630
+ );
631
+
632
+ if (reader == NULL) {
549
633
  xmlFreeTextReader(reader);
550
634
  rb_raise(rb_eRuntimeError, "couldn't create a parser");
551
635
  }
@@ -565,32 +649,33 @@ static VALUE from_memory(int argc, VALUE *argv, VALUE klass)
565
649
  *
566
650
  * Create a new reader that parses +io+
567
651
  */
568
- static VALUE from_io(int argc, VALUE *argv, VALUE klass)
652
+ static VALUE
653
+ from_io(int argc, VALUE *argv, VALUE klass)
569
654
  {
570
655
  VALUE rb_io, rb_url, encoding, rb_options;
571
656
  xmlTextReaderPtr reader;
572
- const char * c_url = NULL;
573
- const char * c_encoding = NULL;
657
+ const char *c_url = NULL;
658
+ const char *c_encoding = NULL;
574
659
  int c_options = 0;
575
660
  VALUE rb_reader, args[3];
576
661
 
577
662
  rb_scan_args(argc, argv, "13", &rb_io, &rb_url, &encoding, &rb_options);
578
663
 
579
- if (!RTEST(rb_io)) rb_raise(rb_eArgError, "io cannot be nil");
580
- if (RTEST(rb_url)) c_url = StringValueCStr(rb_url);
581
- if (RTEST(encoding)) c_encoding = StringValueCStr(encoding);
582
- if (RTEST(rb_options)) c_options = (int)NUM2INT(rb_options);
664
+ if (!RTEST(rb_io)) { rb_raise(rb_eArgError, "io cannot be nil"); }
665
+ if (RTEST(rb_url)) { c_url = StringValueCStr(rb_url); }
666
+ if (RTEST(encoding)) { c_encoding = StringValueCStr(encoding); }
667
+ if (RTEST(rb_options)) { c_options = (int)NUM2INT(rb_options); }
583
668
 
584
669
  reader = xmlReaderForIO(
585
- (xmlInputReadCallback)io_read_callback,
586
- (xmlInputCloseCallback)io_close_callback,
587
- (void *)rb_io,
588
- c_url,
589
- c_encoding,
590
- c_options
591
- );
592
-
593
- if(reader == NULL) {
670
+ (xmlInputReadCallback)noko_io_read,
671
+ (xmlInputCloseCallback)noko_io_close,
672
+ (void *)rb_io,
673
+ c_url,
674
+ c_encoding,
675
+ c_options
676
+ );
677
+
678
+ if (reader == NULL) {
594
679
  xmlFreeTextReader(reader);
595
680
  rb_raise(rb_eRuntimeError, "couldn't create a parser");
596
681
  }
@@ -610,59 +695,76 @@ static VALUE from_io(int argc, VALUE *argv, VALUE klass)
610
695
  *
611
696
  * Returns true if the current node is empty, otherwise false.
612
697
  */
613
- static VALUE empty_element_p(VALUE self)
698
+ static VALUE
699
+ empty_element_p(VALUE self)
614
700
  {
615
701
  xmlTextReaderPtr reader;
616
702
 
617
703
  Data_Get_Struct(self, xmlTextReader, reader);
618
704
 
619
- if(xmlTextReaderIsEmptyElement(reader))
705
+ if (xmlTextReaderIsEmptyElement(reader)) {
620
706
  return Qtrue;
707
+ }
621
708
 
622
709
  return Qfalse;
623
710
  }
624
711
 
625
- VALUE cNokogiriXmlReader;
626
-
627
- void init_xml_reader()
712
+ static VALUE
713
+ rb_xml_reader_encoding(VALUE rb_reader)
628
714
  {
629
- VALUE module = rb_define_module("Nokogiri");
630
- VALUE xml = rb_define_module_under(module, "XML");
715
+ xmlTextReaderPtr c_reader;
716
+ const char *parser_encoding;
717
+ VALUE constructor_encoding;
718
+
719
+ constructor_encoding = rb_iv_get(rb_reader, "@encoding");
720
+ if (RTEST(constructor_encoding)) {
721
+ return constructor_encoding;
722
+ }
631
723
 
724
+ Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
725
+ parser_encoding = (const char *)xmlTextReaderConstEncoding(c_reader);
726
+ if (parser_encoding == NULL) { return Qnil; }
727
+ return NOKOGIRI_STR_NEW2(parser_encoding);
728
+ }
729
+
730
+ void
731
+ noko_init_xml_reader()
732
+ {
632
733
  /*
633
734
  * The Reader parser allows you to effectively pull parse an XML document.
634
735
  * Once instantiated, call Nokogiri::XML::Reader#each to iterate over each
635
736
  * node. Note that you may only iterate over the document once!
636
737
  */
637
- VALUE klass = rb_define_class_under(xml, "Reader", rb_cObject);
638
-
639
- cNokogiriXmlReader = klass;
640
-
641
- rb_define_singleton_method(klass, "from_memory", from_memory, -1);
642
- rb_define_singleton_method(klass, "from_io", from_io, -1);
643
-
644
- rb_define_method(klass, "read", read_more, 0);
645
- rb_define_method(klass, "inner_xml", inner_xml, 0);
646
- rb_define_method(klass, "outer_xml", outer_xml, 0);
647
- rb_define_method(klass, "state", state, 0);
648
- rb_define_method(klass, "node_type", node_type, 0);
649
- rb_define_method(klass, "name", name, 0);
650
- rb_define_method(klass, "local_name", local_name, 0);
651
- rb_define_method(klass, "namespace_uri", namespace_uri, 0);
652
- rb_define_method(klass, "prefix", prefix, 0);
653
- rb_define_method(klass, "value", value, 0);
654
- rb_define_method(klass, "lang", lang, 0);
655
- rb_define_method(klass, "xml_version", xml_version, 0);
656
- rb_define_method(klass, "depth", depth, 0);
657
- rb_define_method(klass, "attribute_count", attribute_count, 0);
658
- rb_define_method(klass, "attribute", reader_attribute, 1);
659
- rb_define_method(klass, "namespaces", namespaces, 0);
660
- rb_define_method(klass, "attribute_at", attribute_at, 1);
661
- rb_define_method(klass, "empty_element?", empty_element_p, 0);
662
- rb_define_method(klass, "attributes?", attributes_eh, 0);
663
- rb_define_method(klass, "value?", value_eh, 0);
664
- rb_define_method(klass, "default?", default_eh, 0);
665
- rb_define_method(klass, "base_uri", base_uri, 0);
666
-
667
- rb_define_private_method(klass, "attr_nodes", attribute_nodes, 0);
738
+ cNokogiriXmlReader = rb_define_class_under(mNokogiriXml, "Reader", rb_cObject);
739
+
740
+ rb_undef_alloc_func(cNokogiriXmlReader);
741
+
742
+ rb_define_singleton_method(cNokogiriXmlReader, "from_memory", from_memory, -1);
743
+ rb_define_singleton_method(cNokogiriXmlReader, "from_io", from_io, -1);
744
+
745
+ rb_define_method(cNokogiriXmlReader, "attribute", reader_attribute, 1);
746
+ rb_define_method(cNokogiriXmlReader, "attribute_at", attribute_at, 1);
747
+ rb_define_method(cNokogiriXmlReader, "attribute_count", attribute_count, 0);
748
+ rb_define_method(cNokogiriXmlReader, "attribute_nodes", rb_xml_reader_attribute_nodes, 0);
749
+ rb_define_method(cNokogiriXmlReader, "attribute_hash", rb_xml_reader_attribute_hash, 0);
750
+ rb_define_method(cNokogiriXmlReader, "attributes?", attributes_eh, 0);
751
+ rb_define_method(cNokogiriXmlReader, "base_uri", rb_xml_reader_base_uri, 0);
752
+ rb_define_method(cNokogiriXmlReader, "default?", default_eh, 0);
753
+ rb_define_method(cNokogiriXmlReader, "depth", depth, 0);
754
+ rb_define_method(cNokogiriXmlReader, "empty_element?", empty_element_p, 0);
755
+ rb_define_method(cNokogiriXmlReader, "encoding", rb_xml_reader_encoding, 0);
756
+ rb_define_method(cNokogiriXmlReader, "inner_xml", inner_xml, 0);
757
+ rb_define_method(cNokogiriXmlReader, "lang", lang, 0);
758
+ rb_define_method(cNokogiriXmlReader, "local_name", local_name, 0);
759
+ rb_define_method(cNokogiriXmlReader, "name", name, 0);
760
+ rb_define_method(cNokogiriXmlReader, "namespace_uri", namespace_uri, 0);
761
+ rb_define_method(cNokogiriXmlReader, "namespaces", namespaces, 0);
762
+ rb_define_method(cNokogiriXmlReader, "node_type", node_type, 0);
763
+ rb_define_method(cNokogiriXmlReader, "outer_xml", outer_xml, 0);
764
+ rb_define_method(cNokogiriXmlReader, "prefix", prefix, 0);
765
+ rb_define_method(cNokogiriXmlReader, "read", read_more, 0);
766
+ rb_define_method(cNokogiriXmlReader, "state", state, 0);
767
+ rb_define_method(cNokogiriXmlReader, "value", value, 0);
768
+ rb_define_method(cNokogiriXmlReader, "value?", value_eh, 0);
769
+ rb_define_method(cNokogiriXmlReader, "xml_version", xml_version, 0);
668
770
  }