tenderlove-nokogiri 0.0.0.20081001111445

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/History.txt +6 -0
  2. data/Manifest.txt +105 -0
  3. data/README.txt +51 -0
  4. data/Rakefile +70 -0
  5. data/ext/nokogiri/extconf.rb +24 -0
  6. data/ext/nokogiri/html_document.c +85 -0
  7. data/ext/nokogiri/html_document.h +10 -0
  8. data/ext/nokogiri/html_sax_parser.c +32 -0
  9. data/ext/nokogiri/html_sax_parser.h +11 -0
  10. data/ext/nokogiri/native.c +35 -0
  11. data/ext/nokogiri/native.h +32 -0
  12. data/ext/nokogiri/xml_cdata.c +36 -0
  13. data/ext/nokogiri/xml_cdata.h +9 -0
  14. data/ext/nokogiri/xml_document.c +159 -0
  15. data/ext/nokogiri/xml_document.h +10 -0
  16. data/ext/nokogiri/xml_node.c +573 -0
  17. data/ext/nokogiri/xml_node.h +13 -0
  18. data/ext/nokogiri/xml_node_set.c +90 -0
  19. data/ext/nokogiri/xml_node_set.h +9 -0
  20. data/ext/nokogiri/xml_reader.c +420 -0
  21. data/ext/nokogiri/xml_reader.h +10 -0
  22. data/ext/nokogiri/xml_sax_parser.c +161 -0
  23. data/ext/nokogiri/xml_sax_parser.h +10 -0
  24. data/ext/nokogiri/xml_text.c +25 -0
  25. data/ext/nokogiri/xml_text.h +9 -0
  26. data/ext/nokogiri/xml_xpath.c +39 -0
  27. data/ext/nokogiri/xml_xpath.h +11 -0
  28. data/ext/nokogiri/xml_xpath_context.c +69 -0
  29. data/ext/nokogiri/xml_xpath_context.h +9 -0
  30. data/ext/nokogiri/xslt_stylesheet.c +83 -0
  31. data/ext/nokogiri/xslt_stylesheet.h +9 -0
  32. data/lib/nokogiri.rb +45 -0
  33. data/lib/nokogiri/css.rb +6 -0
  34. data/lib/nokogiri/css/node.rb +95 -0
  35. data/lib/nokogiri/css/parser.rb +24 -0
  36. data/lib/nokogiri/css/parser.y +198 -0
  37. data/lib/nokogiri/css/tokenizer.rb +9 -0
  38. data/lib/nokogiri/css/tokenizer.rex +63 -0
  39. data/lib/nokogiri/css/xpath_visitor.rb +153 -0
  40. data/lib/nokogiri/decorators.rb +1 -0
  41. data/lib/nokogiri/decorators/hpricot.rb +3 -0
  42. data/lib/nokogiri/decorators/hpricot/node.rb +47 -0
  43. data/lib/nokogiri/decorators/hpricot/node_set.rb +14 -0
  44. data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +13 -0
  45. data/lib/nokogiri/hpricot.rb +46 -0
  46. data/lib/nokogiri/html.rb +64 -0
  47. data/lib/nokogiri/html/builder.rb +9 -0
  48. data/lib/nokogiri/html/document.rb +9 -0
  49. data/lib/nokogiri/html/sax/parser.rb +21 -0
  50. data/lib/nokogiri/version.rb +3 -0
  51. data/lib/nokogiri/xml.rb +29 -0
  52. data/lib/nokogiri/xml/after_handler.rb +18 -0
  53. data/lib/nokogiri/xml/before_handler.rb +32 -0
  54. data/lib/nokogiri/xml/builder.rb +79 -0
  55. data/lib/nokogiri/xml/document.rb +22 -0
  56. data/lib/nokogiri/xml/node.rb +162 -0
  57. data/lib/nokogiri/xml/node_set.rb +136 -0
  58. data/lib/nokogiri/xml/reader.rb +14 -0
  59. data/lib/nokogiri/xml/sax.rb +9 -0
  60. data/lib/nokogiri/xml/sax/document.rb +59 -0
  61. data/lib/nokogiri/xml/sax/parser.rb +33 -0
  62. data/lib/nokogiri/xml/text.rb +6 -0
  63. data/lib/nokogiri/xml/xpath.rb +6 -0
  64. data/lib/nokogiri/xslt.rb +11 -0
  65. data/lib/nokogiri/xslt/stylesheet.rb +6 -0
  66. data/nokogiri.gemspec +33 -0
  67. data/test/css/test_nthiness.rb +141 -0
  68. data/test/css/test_parser.rb +214 -0
  69. data/test/css/test_tokenizer.rb +162 -0
  70. data/test/files/staff.xml +57 -0
  71. data/test/files/staff.xslt +32 -0
  72. data/test/files/tlm.html +850 -0
  73. data/test/helper.rb +70 -0
  74. data/test/hpricot/files/basic.xhtml +17 -0
  75. data/test/hpricot/files/boingboing.html +2266 -0
  76. data/test/hpricot/files/cy0.html +3653 -0
  77. data/test/hpricot/files/immob.html +400 -0
  78. data/test/hpricot/files/pace_application.html +1320 -0
  79. data/test/hpricot/files/tenderlove.html +16 -0
  80. data/test/hpricot/files/uswebgen.html +220 -0
  81. data/test/hpricot/files/utf8.html +1054 -0
  82. data/test/hpricot/files/week9.html +1723 -0
  83. data/test/hpricot/files/why.xml +19 -0
  84. data/test/hpricot/load_files.rb +7 -0
  85. data/test/hpricot/test_alter.rb +67 -0
  86. data/test/hpricot/test_builder.rb +27 -0
  87. data/test/hpricot/test_parser.rb +412 -0
  88. data/test/hpricot/test_paths.rb +15 -0
  89. data/test/hpricot/test_preserved.rb +72 -0
  90. data/test/hpricot/test_xml.rb +26 -0
  91. data/test/html/sax/test_parser.rb +27 -0
  92. data/test/html/test_builder.rb +78 -0
  93. data/test/html/test_document.rb +22 -0
  94. data/test/test_convert_xpath.rb +173 -0
  95. data/test/test_nokogiri.rb +36 -0
  96. data/test/test_reader.rb +222 -0
  97. data/test/test_xslt_transforms.rb +29 -0
  98. data/test/xml/sax/test_parser.rb +93 -0
  99. data/test/xml/test_builder.rb +16 -0
  100. data/test/xml/test_document.rb +141 -0
  101. data/test/xml/test_node.rb +148 -0
  102. data/test/xml/test_node_set.rb +54 -0
  103. data/test/xml/test_text.rb +13 -0
  104. metadata +191 -0
@@ -0,0 +1,13 @@
1
+ #ifndef NOKOGIRI_XML_NODE
2
+ #define NOKOGIRI_XML_NODE
3
+
4
+ #include <native.h>
5
+
6
+ void init_xml_node();
7
+ VALUE Nokogiri_wrap_xml_node(xmlNodePtr root);
8
+
9
+ extern VALUE cNokogiriXmlNode ;
10
+ VALUE Nokogiri_wrap_xml_node(xmlNodePtr node) ;
11
+ void Nokogiri_xml_node_properties(xmlNodePtr node, VALUE attr_hash) ;
12
+ void Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash) ;
13
+ #endif
@@ -0,0 +1,90 @@
1
+ #include <xml_node_set.h>
2
+ #include <libxml/xpathInternals.h>
3
+ /*
4
+ * call-seq:
5
+ * length
6
+ *
7
+ * Get the length of the node set
8
+ */
9
+ static VALUE length(VALUE self)
10
+ {
11
+ xmlNodeSetPtr node_set;
12
+ Data_Get_Struct(self, xmlNodeSet, node_set);
13
+
14
+ if(node_set)
15
+ return INT2NUM(node_set->nodeNr);
16
+
17
+ return INT2NUM(0);
18
+ }
19
+
20
+ /*
21
+ * call-seq:
22
+ * push(node)
23
+ *
24
+ * Append +node+ to the NodeSet.
25
+ */
26
+ static VALUE push(VALUE self, VALUE rb_node)
27
+ {
28
+ xmlNodeSetPtr node_set;
29
+ xmlNodePtr node;
30
+
31
+ Data_Get_Struct(self, xmlNodeSet, node_set);
32
+ Data_Get_Struct(rb_node, xmlNode, node);
33
+ xmlXPathNodeSetAdd(node_set, node);
34
+ return self;
35
+ }
36
+
37
+ /*
38
+ * call-seq:
39
+ * [](i)
40
+ *
41
+ * Get the node at index +i+
42
+ */
43
+ static VALUE index_at(VALUE self, VALUE number)
44
+ {
45
+ int i = NUM2INT(number);
46
+ xmlNodeSetPtr node_set;
47
+ Data_Get_Struct(self, xmlNodeSet, node_set);
48
+
49
+ if(i >= node_set->nodeNr || abs(i) > node_set->nodeNr)
50
+ return Qnil;
51
+
52
+ if(i < 0)
53
+ i = i + node_set->nodeNr;
54
+
55
+ return Nokogiri_wrap_xml_node(node_set->nodeTab[i]);
56
+ }
57
+
58
+ static void gc_mark(xmlNodeSetPtr node_set)
59
+ {
60
+ int j ;
61
+ for (j = 0 ; j < node_set->nodeNr ; ++j) {
62
+ if (node_set->nodeTab[j]->_private)
63
+ rb_gc_mark((VALUE)node_set->nodeTab[j]->_private);
64
+ }
65
+ }
66
+
67
+ static void deallocate(xmlNodeSetPtr node_set)
68
+ {
69
+ xmlXPathFreeNodeSet(node_set);
70
+ }
71
+
72
+ static VALUE allocate(VALUE klass)
73
+ {
74
+ return Nokogiri_wrap_xml_node_set(xmlXPathNodeSetCreate(NULL));
75
+ }
76
+
77
+ VALUE Nokogiri_wrap_xml_node_set(xmlNodeSetPtr node_set)
78
+ {
79
+ return Data_Wrap_Struct(cNokogiriXmlNodeSet, gc_mark, deallocate, node_set);
80
+ }
81
+
82
+ VALUE cNokogiriXmlNodeSet ;
83
+ void init_xml_node_set(void)
84
+ {
85
+ VALUE klass = cNokogiriXmlNodeSet = rb_eval_string("Nokogiri::XML::NodeSet");
86
+ rb_define_alloc_func(klass, allocate);
87
+ rb_define_method(klass, "length", length, 0);
88
+ rb_define_method(klass, "[]", index_at, 1);
89
+ rb_define_method(klass, "push", push, 1);
90
+ }
@@ -0,0 +1,9 @@
1
+ #ifndef NOKOGIRI_XML_NODE_SET
2
+ #define NOKOGIRI_XML_NODE_SET
3
+
4
+ #include <native.h>
5
+ void init_xml_node_set();
6
+
7
+ extern VALUE cNokogiriXmlNodeSet ;
8
+ VALUE Nokogiri_wrap_xml_node_set(xmlNodeSetPtr node_set) ;
9
+ #endif
@@ -0,0 +1,420 @@
1
+ #include <xml_reader.h>
2
+
3
+ static void dealloc(xmlTextReaderPtr reader)
4
+ {
5
+ xmlFreeTextReader(reader);
6
+ }
7
+
8
+ static int has_attributes(xmlTextReaderPtr reader)
9
+ {
10
+ /*
11
+ * this implementation of xmlTextReaderHasAttributes explicitly includes
12
+ * namespaces and properties, because some earlier versions ignore
13
+ * namespaces.
14
+ */
15
+ xmlNodePtr node ;
16
+ node = xmlTextReaderCurrentNode(reader);
17
+ if (node == NULL)
18
+ return(0);
19
+
20
+ if ((node->type == XML_ELEMENT_NODE) &&
21
+ ((node->properties != NULL) || (node->nsDef != NULL)))
22
+ return(1);
23
+ return(0);
24
+ }
25
+
26
+ /*
27
+ * call-seq:
28
+ * default?
29
+ *
30
+ * Was an attribute generated from the default value in the DTD or schema?
31
+ */
32
+ static VALUE default_eh(VALUE self)
33
+ {
34
+ xmlTextReaderPtr reader;
35
+ Data_Get_Struct(self, xmlTextReader, reader);
36
+ int eh = xmlTextReaderIsDefault(reader);
37
+ if(eh == 0) return Qfalse;
38
+ if(eh == 1) return Qtrue;
39
+
40
+ return Qnil;
41
+ }
42
+
43
+ /*
44
+ * call-seq:
45
+ * value?
46
+ *
47
+ * Does this node have a text value?
48
+ */
49
+ static VALUE value_eh(VALUE self)
50
+ {
51
+ xmlTextReaderPtr reader;
52
+ Data_Get_Struct(self, xmlTextReader, reader);
53
+ int eh = xmlTextReaderHasValue(reader);
54
+ if(eh == 0) return Qfalse;
55
+ if(eh == 1) return Qtrue;
56
+
57
+ return Qnil;
58
+ }
59
+
60
+ /*
61
+ * call-seq:
62
+ * attributes?
63
+ *
64
+ * Does this node have attributes?
65
+ */
66
+ static VALUE attributes_eh(VALUE self)
67
+ {
68
+ xmlTextReaderPtr reader;
69
+ Data_Get_Struct(self, xmlTextReader, reader);
70
+ int eh = has_attributes(reader);
71
+ if(eh == 0) return Qfalse;
72
+ if(eh == 1) return Qtrue;
73
+
74
+ return Qnil;
75
+ }
76
+
77
+ /*
78
+ * call-seq:
79
+ * attributes
80
+ *
81
+ * Get a Hash of attributes for this node
82
+ */
83
+ static VALUE attributes(VALUE self)
84
+ {
85
+ xmlTextReaderPtr reader;
86
+ VALUE attr ;
87
+
88
+ Data_Get_Struct(self, xmlTextReader, reader);
89
+
90
+ attr = rb_hash_new() ;
91
+
92
+ if (! has_attributes(reader))
93
+ return attr ;
94
+
95
+ xmlNodePtr ptr = xmlTextReaderExpand(reader);
96
+ if(ptr == NULL) return Qnil;
97
+
98
+ Nokogiri_xml_node_namespaces(ptr, attr);
99
+ Nokogiri_xml_node_properties(ptr, attr);
100
+
101
+ return attr ;
102
+ }
103
+
104
+ /*
105
+ * call-seq:
106
+ * attribute_at(index)
107
+ *
108
+ * Get the value of attribute at +index+
109
+ */
110
+ static VALUE attribute_at(VALUE self, VALUE index)
111
+ {
112
+ xmlTextReaderPtr reader;
113
+ Data_Get_Struct(self, xmlTextReader, reader);
114
+
115
+ if(index == Qnil) return Qnil;
116
+ index = rb_funcall(index, rb_intern("to_i"), 0);
117
+
118
+ xmlChar * value = xmlTextReaderGetAttributeNo(
119
+ reader,
120
+ NUM2INT(index)
121
+ );
122
+ if(value == NULL) return Qnil;
123
+
124
+ VALUE rb_value = rb_str_new2((const char *)value);
125
+ xmlFree(value);
126
+ return rb_value;
127
+ }
128
+
129
+ /*
130
+ * call-seq:
131
+ * attribute(name)
132
+ *
133
+ * Get the value of attribute named +name+
134
+ */
135
+ static VALUE reader_attribute(VALUE self, VALUE name)
136
+ {
137
+ xmlTextReaderPtr reader;
138
+ xmlChar *value ;
139
+ Data_Get_Struct(self, xmlTextReader, reader);
140
+
141
+ if(name == Qnil) return Qnil;
142
+ name = StringValue(name) ;
143
+
144
+ value = xmlTextReaderGetAttribute(reader, (xmlChar*)RSTRING(name)->ptr );
145
+ if(value == NULL) {
146
+ /* this section is an attempt to workaround older versions of libxml that
147
+ don't handle namespaces properly in all attribute-and-friends functions */
148
+ xmlChar *prefix = NULL ;
149
+ xmlChar *localname = xmlSplitQName2((xmlChar*)RSTRING(name)->ptr, &prefix);
150
+ if (localname != NULL) {
151
+ value = xmlTextReaderLookupNamespace(reader, localname);
152
+ free(localname) ;
153
+ } else {
154
+ value = xmlTextReaderLookupNamespace(reader, prefix);
155
+ }
156
+ }
157
+ if(value == NULL) return Qnil;
158
+
159
+ VALUE rb_value = rb_str_new2((const char *)value);
160
+ xmlFree(value);
161
+ return rb_value;
162
+ }
163
+
164
+ /*
165
+ * call-seq:
166
+ * attribute_count
167
+ *
168
+ * Get the number of attributes for the current node
169
+ */
170
+ static VALUE attribute_count(VALUE self)
171
+ {
172
+ xmlTextReaderPtr reader;
173
+ Data_Get_Struct(self, xmlTextReader, reader);
174
+ int count = xmlTextReaderAttributeCount(reader);
175
+ if(count == -1) return Qnil;
176
+
177
+ return INT2NUM(count);
178
+ }
179
+
180
+ /*
181
+ * call-seq:
182
+ * depth
183
+ *
184
+ * Get the depth of the node
185
+ */
186
+ static VALUE depth(VALUE self)
187
+ {
188
+ xmlTextReaderPtr reader;
189
+ Data_Get_Struct(self, xmlTextReader, reader);
190
+ int depth = xmlTextReaderDepth(reader);
191
+ if(depth == -1) return Qnil;
192
+
193
+ return INT2NUM(depth);
194
+ }
195
+
196
+ /*
197
+ * call-seq:
198
+ * encoding
199
+ *
200
+ * Get the encoding for the document
201
+ */
202
+ static VALUE encoding(VALUE self)
203
+ {
204
+ xmlTextReaderPtr reader;
205
+ Data_Get_Struct(self, xmlTextReader, reader);
206
+ const char * encoding = (const char *)xmlTextReaderConstEncoding(reader);
207
+ if(encoding == NULL) return Qnil;
208
+
209
+ return rb_str_new2(encoding);
210
+ }
211
+
212
+ /*
213
+ * call-seq:
214
+ * xml_version
215
+ *
216
+ * Get the XML version of the document being read
217
+ */
218
+ static VALUE xml_version(VALUE self)
219
+ {
220
+ xmlTextReaderPtr reader;
221
+ Data_Get_Struct(self, xmlTextReader, reader);
222
+ const char * version = (const char *)xmlTextReaderConstXmlVersion(reader);
223
+ if(version == NULL) return Qnil;
224
+
225
+ return rb_str_new2(version);
226
+ }
227
+
228
+ /*
229
+ * call-seq:
230
+ * lang
231
+ *
232
+ * Get the xml:lang scope within which the node resides.
233
+ */
234
+ static VALUE lang(VALUE self)
235
+ {
236
+ xmlTextReaderPtr reader;
237
+ Data_Get_Struct(self, xmlTextReader, reader);
238
+ const char * lang = (const char *)xmlTextReaderConstXmlLang(reader);
239
+ if(lang == NULL) return Qnil;
240
+
241
+ return rb_str_new2(lang);
242
+ }
243
+
244
+ /*
245
+ * call-seq:
246
+ * value
247
+ *
248
+ * Get the text value of the node if present
249
+ */
250
+ static VALUE value(VALUE self)
251
+ {
252
+ xmlTextReaderPtr reader;
253
+ Data_Get_Struct(self, xmlTextReader, reader);
254
+ const char * value = (const char *)xmlTextReaderConstValue(reader);
255
+ if(value == NULL) return Qnil;
256
+
257
+ return rb_str_new2(value);
258
+ }
259
+
260
+ /*
261
+ * call-seq:
262
+ * prefix
263
+ *
264
+ * Get the shorthand reference to the namespace associated with the node.
265
+ */
266
+ static VALUE prefix(VALUE self)
267
+ {
268
+ xmlTextReaderPtr reader;
269
+ Data_Get_Struct(self, xmlTextReader, reader);
270
+ const char * prefix = (const char *)xmlTextReaderConstPrefix(reader);
271
+ if(prefix == NULL) return Qnil;
272
+
273
+ return rb_str_new2(prefix);
274
+ }
275
+
276
+ /*
277
+ * call-seq:
278
+ * namespace_uri
279
+ *
280
+ * Get the URI defining the namespace associated with the node
281
+ */
282
+ static VALUE namespace_uri(VALUE self)
283
+ {
284
+ xmlTextReaderPtr reader;
285
+ Data_Get_Struct(self, xmlTextReader, reader);
286
+ const char * uri = (const char *)xmlTextReaderConstNamespaceUri(reader);
287
+ if(uri == NULL) return Qnil;
288
+
289
+ return rb_str_new2(uri);
290
+ }
291
+
292
+ /*
293
+ * call-seq:
294
+ * local_name
295
+ *
296
+ * Get the local name of the node
297
+ */
298
+ static VALUE local_name(VALUE self)
299
+ {
300
+ xmlTextReaderPtr reader;
301
+ Data_Get_Struct(self, xmlTextReader, reader);
302
+ const char * name = (const char *)xmlTextReaderConstLocalName(reader);
303
+ if(name == NULL) return Qnil;
304
+
305
+ return rb_str_new2(name);
306
+ }
307
+
308
+ /*
309
+ * call-seq:
310
+ * name
311
+ *
312
+ * Get the name of the node
313
+ */
314
+ static VALUE name(VALUE self)
315
+ {
316
+ xmlTextReaderPtr reader;
317
+ Data_Get_Struct(self, xmlTextReader, reader);
318
+ const char * name = (const char *)xmlTextReaderConstName(reader);
319
+ if(name == NULL) return Qnil;
320
+
321
+ return rb_str_new2(name);
322
+ }
323
+
324
+ /*
325
+ * call-seq:
326
+ * state
327
+ *
328
+ * Get the state of the reader
329
+ */
330
+ static VALUE state(VALUE self)
331
+ {
332
+ xmlTextReaderPtr reader;
333
+ Data_Get_Struct(self, xmlTextReader, reader);
334
+ return INT2NUM(xmlTextReaderReadState(reader));
335
+ }
336
+
337
+ /*
338
+ * call-seq:
339
+ * read
340
+ *
341
+ * Move the Reader forward through the XML document.
342
+ */
343
+ static VALUE read(VALUE self)
344
+ {
345
+ xmlTextReaderPtr reader;
346
+ Data_Get_Struct(self, xmlTextReader, reader);
347
+
348
+ int ret = xmlTextReaderRead(reader);
349
+ if(ret == 1) return self;
350
+ if(ret == 0) return Qnil;
351
+
352
+ rb_raise(rb_eRuntimeError, "Error pulling: %d", ret);
353
+ }
354
+
355
+ /*
356
+ * call-seq:
357
+ * from_memory(string, url = nil, encoding = nil, options = 0)
358
+ *
359
+ * Create a new reader that parses +string+
360
+ */
361
+ static VALUE from_memory(int argc, VALUE *argv, VALUE klass)
362
+ {
363
+ VALUE rb_buffer, rb_url, encoding, rb_options;
364
+
365
+ const char * c_url = NULL;
366
+ const char * c_encoding = NULL;
367
+ int c_options = 0;
368
+
369
+ rb_scan_args(argc, argv, "13", &rb_buffer, &rb_url, &encoding, &rb_options);
370
+
371
+ rb_buffer = StringValue(rb_buffer) ;
372
+ if (RTEST(rb_url)) c_url = StringValuePtr(rb_url);
373
+ if (RTEST(encoding)) c_encoding = StringValuePtr(rb_url);
374
+ if (RTEST(rb_options)) c_options = NUM2INT(rb_options);
375
+
376
+ xmlTextReaderPtr reader = xmlReaderForMemory(
377
+ RSTRING(rb_buffer)->ptr,
378
+ RSTRING(rb_buffer)->len,
379
+ c_url,
380
+ c_encoding,
381
+ c_options
382
+ );
383
+
384
+ if(reader == NULL) {
385
+ xmlFreeTextReader(reader);
386
+ rb_raise(rb_eRuntimeError, "couldn't create a parser");
387
+ }
388
+
389
+ return Data_Wrap_Struct(klass, NULL, dealloc, reader);
390
+ }
391
+
392
+ VALUE cNokogiriXmlReader;
393
+
394
+ void init_xml_reader()
395
+ {
396
+ VALUE module = rb_define_module("Nokogiri");
397
+ VALUE xml = rb_define_module_under(module, "XML");
398
+ VALUE klass = rb_define_class_under(xml, "Reader", rb_cObject);
399
+ cNokogiriXmlReader = klass;
400
+
401
+ rb_define_singleton_method(klass, "from_memory", from_memory, -1);
402
+ rb_define_method(klass, "read", read, 0);
403
+ rb_define_method(klass, "state", state, 0);
404
+ rb_define_method(klass, "name", name, 0);
405
+ rb_define_method(klass, "local_name", local_name, 0);
406
+ rb_define_method(klass, "namespace_uri", namespace_uri, 0);
407
+ rb_define_method(klass, "prefix", prefix, 0);
408
+ rb_define_method(klass, "value", value, 0);
409
+ rb_define_method(klass, "lang", lang, 0);
410
+ rb_define_method(klass, "xml_version", xml_version, 0);
411
+ rb_define_method(klass, "encoding", encoding, 0);
412
+ rb_define_method(klass, "depth", depth, 0);
413
+ rb_define_method(klass, "attribute_count", attribute_count, 0);
414
+ rb_define_method(klass, "attribute", reader_attribute, 1);
415
+ rb_define_method(klass, "attribute_at", attribute_at, 1);
416
+ rb_define_method(klass, "attributes", attributes, 0);
417
+ rb_define_method(klass, "attributes?", attributes_eh, 0);
418
+ rb_define_method(klass, "value?", value_eh, 0);
419
+ rb_define_method(klass, "default?", default_eh, 0);
420
+ }