libxml-ruby 0.9.7-x86-mswin32-60 → 0.9.8-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/CHANGES +53 -0
  2. data/Rakefile +1 -0
  3. data/ext/libxml/build.log +4 -0
  4. data/ext/libxml/cbg.c +86 -86
  5. data/ext/libxml/libxml.c +878 -876
  6. data/ext/libxml/ruby_libxml.h +8 -4
  7. data/ext/libxml/ruby_xml_attr.c +36 -168
  8. data/ext/libxml/ruby_xml_attr.h +2 -4
  9. data/ext/libxml/ruby_xml_attr_decl.c +177 -0
  10. data/ext/libxml/ruby_xml_attr_decl.h +13 -0
  11. data/ext/libxml/ruby_xml_attributes.c +29 -20
  12. data/ext/libxml/ruby_xml_document.c +895 -898
  13. data/ext/libxml/ruby_xml_dtd.c +18 -1
  14. data/ext/libxml/ruby_xml_dtd.h +1 -0
  15. data/ext/libxml/ruby_xml_encoding.c +116 -0
  16. data/ext/libxml/ruby_xml_encoding.h +12 -0
  17. data/ext/libxml/ruby_xml_error.c +8 -2
  18. data/ext/libxml/ruby_xml_html_parser.c +53 -74
  19. data/ext/libxml/ruby_xml_html_parser.h +2 -3
  20. data/ext/libxml/ruby_xml_html_parser_context.c +145 -0
  21. data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
  22. data/ext/libxml/ruby_xml_html_parser_options.c +48 -0
  23. data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
  24. data/ext/libxml/ruby_xml_input_cbg.c +1 -1
  25. data/ext/libxml/ruby_xml_io.c +30 -0
  26. data/ext/libxml/ruby_xml_io.h +9 -0
  27. data/ext/libxml/ruby_xml_namespace.c +34 -16
  28. data/ext/libxml/ruby_xml_namespace.h +2 -2
  29. data/ext/libxml/ruby_xml_namespaces.c +6 -6
  30. data/ext/libxml/ruby_xml_node.c +1367 -1324
  31. data/ext/libxml/ruby_xml_node.h +2 -2
  32. data/ext/libxml/ruby_xml_parser.c +26 -78
  33. data/ext/libxml/ruby_xml_parser.h +1 -1
  34. data/ext/libxml/ruby_xml_parser_context.c +284 -13
  35. data/ext/libxml/ruby_xml_parser_context.h +1 -2
  36. data/ext/libxml/ruby_xml_parser_options.c +75 -0
  37. data/ext/libxml/ruby_xml_parser_options.h +14 -0
  38. data/ext/libxml/ruby_xml_reader.c +277 -183
  39. data/ext/libxml/ruby_xml_sax_parser.c +60 -57
  40. data/ext/libxml/ruby_xml_xpath_context.c +43 -8
  41. data/ext/libxml/ruby_xml_xpath_expression.c +6 -0
  42. data/ext/libxml/ruby_xml_xpath_object.c +107 -95
  43. data/ext/libxml/ruby_xml_xpath_object.h +9 -1
  44. data/ext/libxml/ruby_xml_xpointer.c +107 -107
  45. data/ext/libxml/version.h +2 -2
  46. data/ext/mingw/libxml_ruby.dll.a +0 -0
  47. data/ext/mingw/libxml_ruby.so +0 -0
  48. data/ext/vc/libxml_ruby.vcproj +43 -3
  49. data/lib/libxml.rb +2 -3
  50. data/lib/libxml/attr.rb +71 -2
  51. data/lib/libxml/attr_decl.rb +81 -0
  52. data/lib/libxml/document.rb +78 -14
  53. data/lib/libxml/html_parser.rb +75 -42
  54. data/lib/libxml/node.rb +11 -0
  55. data/lib/libxml/parser.rb +106 -62
  56. data/lib/libxml/reader.rb +12 -0
  57. data/lib/libxml/sax_parser.rb +42 -52
  58. data/lib/libxml/xpath_object.rb +15 -0
  59. data/test/model/atom.xml +12 -12
  60. data/test/model/bands.xml +4 -4
  61. data/test/model/books.xml +146 -147
  62. data/test/model/merge_bug_data.xml +1 -1
  63. data/test/model/rubynet.xml +1 -0
  64. data/test/model/shiporder.rng +1 -1
  65. data/test/model/shiporder.xml +22 -22
  66. data/test/model/shiporder.xsd +30 -30
  67. data/test/model/xinclude.xml +1 -1
  68. data/test/{tc_node_attr.rb → tc_attr.rb} +1 -1
  69. data/test/tc_attr_decl.rb +131 -0
  70. data/test/tc_deprecated_require.rb +1 -3
  71. data/test/tc_document.rb +13 -3
  72. data/test/tc_document_write.rb +5 -5
  73. data/test/tc_dtd.rb +13 -5
  74. data/test/tc_html_parser.rb +14 -26
  75. data/test/tc_node_cdata.rb +1 -3
  76. data/test/tc_node_comment.rb +2 -4
  77. data/test/tc_node_edit.rb +2 -3
  78. data/test/tc_node_text.rb +35 -1
  79. data/test/tc_node_write.rb +3 -3
  80. data/test/tc_node_xlink.rb +2 -4
  81. data/test/tc_parser.rb +163 -70
  82. data/test/tc_parser_context.rb +103 -42
  83. data/test/tc_reader.rb +173 -45
  84. data/test/tc_relaxng.rb +2 -2
  85. data/test/tc_sax_parser.rb +48 -52
  86. data/test/tc_schema.rb +2 -2
  87. data/test/tc_xpath.rb +37 -6
  88. data/test/tc_xpath_context.rb +7 -1
  89. data/test/tc_xpath_expression.rb +1 -3
  90. data/test/tc_xpointer.rb +1 -3
  91. data/test/test_suite.rb +2 -3
  92. metadata +20 -13
  93. data/ext/libxml/ruby_xml_input.c +0 -329
  94. data/ext/libxml/ruby_xml_input.h +0 -20
  95. data/lib/libxml/parser_context.rb +0 -17
  96. data/lib/libxml/parser_options.rb +0 -25
  97. data/test/model/simple.xml +0 -7
  98. data/test/tc_input.rb +0 -13
  99. data/test/tc_well_formed.rb +0 -11
@@ -7,7 +7,6 @@
7
7
 
8
8
  #include <ruby.h>
9
9
  #include <rubyio.h>
10
- #include <util.h>
11
10
  #include <libxml/parser.h>
12
11
  #include <libxml/parserInternals.h>
13
12
  #include <libxml/debugXML.h>
@@ -60,17 +59,24 @@
60
59
  #include <libxml/xpointer.h>
61
60
  #endif
62
61
 
62
+ #include "ruby_xml_io.h"
63
63
  #include "ruby_xml_error.h"
64
- #include "ruby_xml_input.h"
64
+ #include "ruby_xml_encoding.h"
65
65
  #include "ruby_xml_state.h"
66
66
  #include "ruby_xml_attributes.h"
67
67
  #include "ruby_xml_attr.h"
68
+ #include "ruby_xml_attr_decl.h"
68
69
  #include "ruby_xml_document.h"
69
70
  #include "ruby_xml_node.h"
70
71
  #include "ruby_xml_namespace.h"
71
72
  #include "ruby_xml_namespaces.h"
72
73
  #include "ruby_xml_parser.h"
74
+ #include "ruby_xml_parser_options.h"
73
75
  #include "ruby_xml_parser_context.h"
76
+ #include "ruby_xml_html_parser.h"
77
+ #include "ruby_xml_html_parser_options.h"
78
+ #include "ruby_xml_html_parser_context.h"
79
+ #include "ruby_xml_reader.h"
74
80
  #include "ruby_xml_sax2_handler.h"
75
81
  #include "ruby_xml_sax_parser.h"
76
82
  #include "ruby_xml_xinclude.h"
@@ -83,8 +89,6 @@
83
89
  #include "ruby_xml_dtd.h"
84
90
  #include "ruby_xml_schema.h"
85
91
  #include "ruby_xml_relaxng.h"
86
- #include "ruby_xml_html_parser.h"
87
- #include "ruby_xml_reader.h"
88
92
 
89
93
  extern VALUE mLibXML;
90
94
  extern VALUE mXML;
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_attr.c 666 2008-12-07 00:16:50Z cfis $ */
1
+ /* $Id: ruby_xml_attr.c 739 2009-01-23 03:42:09Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -28,26 +28,16 @@ void rxml_attr_free(xmlAttrPtr xattr)
28
28
  if (!xattr)
29
29
  return;
30
30
 
31
- if (xattr != NULL)
32
- {
33
- xattr->_private = NULL;
34
- if (xattr->parent == NULL && xattr->doc == NULL)
35
- {
36
- #ifdef NODE_DEBUG
37
- fprintf(stderr,"ruby_xfree rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)rxn->node,(long)rxn->node->_private);
38
- #endif
39
- xmlFreeProp(xattr);
40
- }
31
+ xattr->_private = NULL;
41
32
 
42
- xattr = NULL;
33
+ if (xattr->parent == NULL && xattr->doc == NULL)
34
+ {
35
+ xmlFreeProp(xattr);
43
36
  }
44
37
  }
45
38
 
46
39
  void rxml_attr_mark(xmlAttrPtr xattr)
47
40
  {
48
- if (xattr == NULL)
49
- return;
50
-
51
41
  if (xattr->_private == NULL)
52
42
  {
53
43
  rb_warning("XmlAttr is not bound! (%s:%d)", __FILE__, __LINE__);
@@ -60,16 +50,14 @@ void rxml_attr_mark(xmlAttrPtr xattr)
60
50
  VALUE rxml_attr_wrap(xmlAttrPtr xattr)
61
51
  {
62
52
  VALUE result;
63
- // This node is already wrapped
53
+
54
+ /* Check if the node is already wrapped. */
64
55
  if (xattr->_private != NULL)
65
56
  return (VALUE) xattr->_private;
66
57
 
67
58
  result = Data_Wrap_Struct(cXMLAttr, rxml_attr_mark, rxml_attr_free, xattr);
68
-
69
59
  xattr->_private = (void*) result;
70
- #ifdef NODE_DEBUG
71
- fprintf(stderr,"wrap rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)xnode,(long)obj);
72
- #endif
60
+
73
61
  return result;
74
62
  }
75
63
 
@@ -141,26 +129,11 @@ static VALUE rxml_attr_child_get(VALUE self)
141
129
  xmlAttrPtr xattr;
142
130
  Data_Get_Struct(self, xmlAttr, xattr);
143
131
  if (xattr->children == NULL)
144
- return (Qnil);
132
+ return Qnil;
145
133
  else
146
- return (rxml_node_wrap(cXMLNode, (xmlNodePtr) xattr->children));
134
+ return rxml_node_wrap((xmlNodePtr) xattr->children);
147
135
  }
148
136
 
149
- /*
150
- * call-seq:
151
- * attr.child? -> (true|false)
152
- *
153
- * Returns whether this attribute has child attributes.
154
- */
155
- static VALUE rxml_attr_child_q(VALUE self)
156
- {
157
- xmlAttrPtr xattr;
158
- Data_Get_Struct(self, xmlAttr, xattr);
159
- if (xattr->children == NULL)
160
- return (Qfalse);
161
- else
162
- return (Qtrue);
163
- }
164
137
 
165
138
  /*
166
139
  * call-seq:
@@ -175,26 +148,9 @@ static VALUE rxml_attr_doc_get(VALUE self)
175
148
  xmlAttrPtr xattr;
176
149
  Data_Get_Struct(self, xmlAttr, xattr);
177
150
  if (xattr->doc == NULL)
178
- return (Qnil);
179
- else
180
- return (rxml_document_wrap(xattr->doc));
181
- }
182
-
183
- /*
184
- * call-seq:
185
- * attr.doc? -> (true|false)
186
- *
187
- * Determine whether this attribute is associated with an
188
- * XML::Document.
189
- */
190
- static VALUE rxml_attr_doc_q(VALUE self)
191
- {
192
- xmlAttrPtr xattr;
193
- Data_Get_Struct(self, xmlAttr, xattr);
194
- if (xattr->doc == NULL)
195
- return (Qfalse);
151
+ return Qnil;
196
152
  else
197
- return (Qtrue);
153
+ return rxml_document_wrap(xattr->doc);
198
154
  }
199
155
 
200
156
  /*
@@ -208,25 +164,9 @@ static VALUE rxml_attr_last_get(VALUE self)
208
164
  xmlAttrPtr xattr;
209
165
  Data_Get_Struct(self, xmlAttr, xattr);
210
166
  if (xattr->last == NULL)
211
- return (Qnil);
167
+ return Qnil;
212
168
  else
213
- return (rxml_node_wrap(cXMLNode, xattr->last));
214
- }
215
-
216
- /*
217
- * call-seq:
218
- * attr.last? -> (true|false)
219
- *
220
- * Determine whether this is the last attribute.
221
- */
222
- static VALUE rxml_attr_last_q(VALUE self)
223
- {
224
- xmlAttrPtr xattr;
225
- Data_Get_Struct(self, xmlAttr, xattr);
226
- if (xattr->last == NULL)
227
- return (Qfalse);
228
- else
229
- return (Qtrue);
169
+ return rxml_node_wrap(xattr->last);
230
170
  }
231
171
 
232
172
  /*
@@ -241,9 +181,9 @@ static VALUE rxml_attr_name_get(VALUE self)
241
181
  Data_Get_Struct(self, xmlAttr, xattr);
242
182
 
243
183
  if (xattr->name == NULL)
244
- return (Qnil);
184
+ return Qnil;
245
185
  else
246
- return (rb_str_new2((const char*) xattr->name));
186
+ return rb_str_new2((const char*) xattr->name);
247
187
  }
248
188
 
249
189
  /*
@@ -257,36 +197,22 @@ static VALUE rxml_attr_next_get(VALUE self)
257
197
  xmlAttrPtr xattr;
258
198
  Data_Get_Struct(self, xmlAttr, xattr);
259
199
  if (xattr->next == NULL)
260
- return (Qnil);
200
+ return Qnil;
261
201
  else
262
- return (rxml_attr_wrap(xattr->next));
202
+ return rxml_attr_wrap(xattr->next);
263
203
  }
264
204
 
265
205
  /*
266
206
  * call-seq:
267
- * attr.next? -> (true|false)
207
+ * attr.node_type -> num
268
208
  *
269
- * Determine whether there is a next attribute.
209
+ * Obtain this node's type identifier.
270
210
  */
271
- static VALUE rxml_attr_next_q(VALUE self)
211
+ static VALUE rxml_attr_node_type(VALUE self)
272
212
  {
273
213
  xmlAttrPtr xattr;
274
214
  Data_Get_Struct(self, xmlAttr, xattr);
275
- if (xattr->next == NULL)
276
- return (Qfalse);
277
- else
278
- return (Qtrue);
279
- }
280
-
281
- /*
282
- * call-seq:
283
- * attr.type_name -> "attribute"
284
- *
285
- * Obtain this attribute node's type name.
286
- */
287
- static VALUE rxml_attr_node_type_name(VALUE self)
288
- {
289
- return (rb_str_new2("attribute"));
215
+ return INT2NUM(xattr->type);
290
216
  }
291
217
 
292
218
  /*
@@ -300,26 +226,9 @@ static VALUE rxml_attr_ns_get(VALUE self)
300
226
  xmlAttrPtr xattr;
301
227
  Data_Get_Struct(self, xmlAttr, xattr);
302
228
  if (xattr->ns == NULL)
303
- return (Qnil);
229
+ return Qnil;
304
230
  else
305
- return (rxml_namespace_wrap(xattr->ns));
306
- }
307
-
308
- /*
309
- * call-seq:
310
- * attr.ns? -> (true|false)
311
- *
312
- * Determine whether this attribute has an associated
313
- * namespace.
314
- */
315
- static VALUE rxml_attr_ns_q(VALUE self)
316
- {
317
- xmlAttrPtr xattr;
318
- Data_Get_Struct(self, xmlAttr, xattr);
319
- if (xattr->ns == NULL)
320
- return (Qfalse);
321
- else
322
- return (Qtrue);
231
+ return rxml_namespace_wrap(xattr->ns, NULL);
323
232
  }
324
233
 
325
234
  /*
@@ -333,25 +242,9 @@ static VALUE rxml_attr_parent_get(VALUE self)
333
242
  xmlAttrPtr xattr;
334
243
  Data_Get_Struct(self, xmlAttr, xattr);
335
244
  if (xattr->parent == NULL)
336
- return (Qnil);
337
- else
338
- return (rxml_node_wrap(cXMLNode, xattr->parent));
339
- }
340
-
341
- /*
342
- * call-seq:
343
- * attr.parent? -> (true|false)
344
- *
345
- * Determine whether this attribute has a parent.
346
- */
347
- static VALUE rxml_attr_parent_q(VALUE self)
348
- {
349
- xmlAttrPtr xattr;
350
- Data_Get_Struct(self, xmlAttr, xattr);
351
- if (xattr->parent == NULL)
352
- return (Qfalse);
245
+ return Qnil;
353
246
  else
354
- return (Qtrue);
247
+ return rxml_node_wrap(xattr->parent);
355
248
  }
356
249
 
357
250
  /*
@@ -365,25 +258,9 @@ static VALUE rxml_attr_prev_get(VALUE self)
365
258
  xmlAttrPtr xattr;
366
259
  Data_Get_Struct(self, xmlAttr, xattr);
367
260
  if (xattr->prev == NULL)
368
- return (Qnil);
261
+ return Qnil;
369
262
  else
370
- return (rxml_attr_wrap(xattr->prev));
371
- }
372
-
373
- /*
374
- * call-seq:
375
- * attr.prev? -> (true|false)
376
- *
377
- * Determine whether there is a previous attribute.
378
- */
379
- static VALUE rxml_attr_prev_q(VALUE self)
380
- {
381
- xmlAttrPtr xattr;
382
- Data_Get_Struct(self, xmlAttr, xattr);
383
- if (xattr->prev == NULL)
384
- return (Qfalse);
385
- else
386
- return (Qtrue);
263
+ return rxml_attr_wrap(xattr->prev);
387
264
  }
388
265
 
389
266
  /*
@@ -402,7 +279,7 @@ static VALUE rxml_attr_remove_ex(VALUE self)
402
279
  else
403
280
  xmlUnlinkNode((xmlNodePtr) xattr);
404
281
 
405
- return (Qnil);
282
+ return Qnil;;
406
283
  }
407
284
 
408
285
  /*
@@ -418,16 +295,14 @@ VALUE rxml_attr_value_get(VALUE self)
418
295
  VALUE result = Qnil;
419
296
 
420
297
  Data_Get_Struct(self, xmlAttr, xattr);
421
- if (rxml_attr_parent_q(self) == Qtrue)
298
+ value = xmlNodeGetContent((xmlNodePtr)xattr);
299
+
300
+ if (value != NULL)
422
301
  {
423
- value = xmlGetProp(xattr->parent, xattr->name);
424
- if (value != NULL)
425
- {
426
- result = rb_str_new2((const char*) value);
427
- xmlFree(value);
428
- }
302
+ result = rb_str_new2((const char*) value);
303
+ xmlFree(value);
429
304
  }
430
- return (result);
305
+ return result;
431
306
  }
432
307
 
433
308
  /*
@@ -464,21 +339,14 @@ void ruby_init_xml_attr(void)
464
339
  rb_define_alloc_func(cXMLAttr, rxml_attr_alloc);
465
340
  rb_define_method(cXMLAttr, "initialize", rxml_attr_initialize, -1);
466
341
  rb_define_method(cXMLAttr, "child", rxml_attr_child_get, 0);
467
- rb_define_method(cXMLAttr, "child?", rxml_attr_child_q, 0);
468
342
  rb_define_method(cXMLAttr, "doc", rxml_attr_doc_get, 0);
469
- rb_define_method(cXMLAttr, "doc?", rxml_attr_doc_q, 0);
470
343
  rb_define_method(cXMLAttr, "last", rxml_attr_last_get, 0);
471
- rb_define_method(cXMLAttr, "last?", rxml_attr_last_q, 0);
472
344
  rb_define_method(cXMLAttr, "name", rxml_attr_name_get, 0);
473
345
  rb_define_method(cXMLAttr, "next", rxml_attr_next_get, 0);
474
- rb_define_method(cXMLAttr, "next?", rxml_attr_next_q, 0);
475
- rb_define_method(cXMLAttr, "node_type_name", rxml_attr_node_type_name, 0);
346
+ rb_define_method(cXMLAttr, "node_type", rxml_attr_node_type, 0);
476
347
  rb_define_method(cXMLAttr, "ns", rxml_attr_ns_get, 0);
477
- rb_define_method(cXMLAttr, "ns?", rxml_attr_ns_q, 0);
478
348
  rb_define_method(cXMLAttr, "parent", rxml_attr_parent_get, 0);
479
- rb_define_method(cXMLAttr, "parent?", rxml_attr_parent_q, 0);
480
349
  rb_define_method(cXMLAttr, "prev", rxml_attr_prev_get, 0);
481
- rb_define_method(cXMLAttr, "prev?", rxml_attr_prev_q, 0);
482
350
  rb_define_method(cXMLAttr, "remove!", rxml_attr_remove_ex, 0);
483
351
  rb_define_method(cXMLAttr, "value", rxml_attr_value_get, 0);
484
352
  rb_define_method(cXMLAttr, "value=", rxml_attr_value_set, 1);
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_attr.h 666 2008-12-07 00:16:50Z cfis $ */
1
+ /* $Id: ruby_xml_attr.h 712 2009-01-20 08:08:52Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -8,9 +8,7 @@
8
8
  extern VALUE cXMLAttr;
9
9
 
10
10
  void ruby_init_xml_attr(void);
11
- VALUE rxml_attr_new(xmlAttrPtr xattr);
11
+ VALUE rxml_attr_wrap(xmlAttrPtr xattr);
12
12
  VALUE rxml_attr_value_get(VALUE self);
13
13
  VALUE rxml_attr_value_set(VALUE self, VALUE val);
14
- void rxml_attr_free(xmlAttrPtr xattr);
15
- VALUE rxml_attr_wrap(xmlAttrPtr xattr);
16
14
  #endif
@@ -0,0 +1,177 @@
1
+ /* $Id: ruby_xml_attr.c 666 2008-12-07 00:16:50Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ /*
6
+ * Document-class: LibXML::XML::AttrDecl
7
+ *
8
+ * At attribute declaration is used in XML::Dtds to define
9
+ * what attributes are allowed on an element. An attribute
10
+ * declaration defines an attribues name, data type and default
11
+ * value (if any).
12
+ */
13
+
14
+ #include "ruby_libxml.h"
15
+
16
+ VALUE cXMLAttrDecl;
17
+
18
+ void rxml_attr_decl_mark(xmlAttributePtr xattribute)
19
+ {
20
+ if (xattribute->_private == NULL)
21
+ {
22
+ rb_warning("AttrDecl is not bound! (%s:%d)", __FILE__, __LINE__);
23
+ return;
24
+ }
25
+
26
+ rxml_node_mark_common((xmlNodePtr) xattribute);
27
+ }
28
+
29
+ VALUE rxml_attr_decl_wrap(xmlAttributePtr xattribute)
30
+ {
31
+ VALUE result;
32
+
33
+ // This node is already wrapped
34
+ if (xattribute->_private != NULL)
35
+ return (VALUE) xattribute->_private;
36
+
37
+ result = Data_Wrap_Struct(cXMLAttrDecl, rxml_attr_decl_mark, NULL, xattribute);
38
+
39
+ xattribute->_private = (void*) result;
40
+
41
+ return result;
42
+ }
43
+
44
+ /*
45
+ * call-seq:
46
+ * attr_decl.doc -> XML::Document
47
+ *
48
+ * Returns this attribute declaration's document.
49
+ */
50
+ static VALUE rxml_attr_decl_doc_get(VALUE self)
51
+ {
52
+ xmlAttributePtr xattribute;
53
+ Data_Get_Struct(self, xmlAttribute, xattribute);
54
+ if (xattribute->doc == NULL)
55
+ return Qnil;
56
+ else
57
+ return rxml_document_wrap(xattribute->doc);
58
+ }
59
+
60
+
61
+ /*
62
+ * call-seq:
63
+ * attr_decl.name -> "name"
64
+ *
65
+ * Obtain this attribute declaration's name.
66
+ */
67
+ static VALUE rxml_attr_decl_name_get(VALUE self)
68
+ {
69
+ xmlAttributePtr xattribute;
70
+ Data_Get_Struct(self, xmlAttribute, xattribute);
71
+
72
+ if (xattribute->name == NULL)
73
+ return Qnil;
74
+ else
75
+ return rb_str_new2((const char*) xattribute->name);
76
+ }
77
+
78
+ /*
79
+ * call-seq:
80
+ * attr_decl.next -> XML::AttrDecl
81
+ *
82
+ * Obtain the next attribute declaration.
83
+ */
84
+ static VALUE rxml_attr_decl_next_get(VALUE self)
85
+ {
86
+ xmlAttributePtr xattribute;
87
+ Data_Get_Struct(self, xmlAttribute, xattribute);
88
+ if (xattribute->next == NULL)
89
+ return Qnil;
90
+ else
91
+ return rxml_attr_decl_wrap((xmlAttributePtr)xattribute->next);
92
+ }
93
+
94
+ /*
95
+ * call-seq:
96
+ * attr_decl.type -> num
97
+ *
98
+ * Obtain this attribute declaration's type node type.
99
+ */
100
+ static VALUE rxml_attr_decl_node_type(VALUE self)
101
+ {
102
+ xmlAttrPtr xattr;
103
+ Data_Get_Struct(self, xmlAttr, xattr);
104
+ return INT2NUM(xattr->type);
105
+ }
106
+
107
+ /*
108
+ * call-seq:
109
+ * attr_decl.parent -> XML::Dtd
110
+ *
111
+ * Obtain this attribute declaration's parent which
112
+ * is an instance of a XML::DTD.
113
+ */
114
+ static VALUE rxml_attr_decl_parent_get(VALUE self)
115
+ {
116
+ xmlAttributePtr xattribute;
117
+ Data_Get_Struct(self, xmlAttribute, xattribute);
118
+
119
+ if (xattribute->parent == NULL)
120
+ return Qnil;
121
+ else
122
+ return rxml_dtd_wrap(xattribute->parent);
123
+ }
124
+
125
+ /*
126
+ * call-seq:
127
+ * attr_decl.prev -> (XML::AttrDecl | XML::ElementDecl)
128
+ *
129
+ * Obtain the previous attribute declaration or the owning
130
+ * element declration (not implemented).
131
+ */
132
+ static VALUE rxml_attr_decl_prev_get(VALUE self)
133
+ {
134
+ xmlAttributePtr xattribute;
135
+ Data_Get_Struct(self, xmlAttribute, xattribute);
136
+
137
+ if (xattribute->prev == NULL)
138
+ return Qnil;
139
+ else
140
+ return rxml_attr_decl_wrap((xmlAttributePtr)xattribute->prev);
141
+ }
142
+
143
+ /*
144
+ * call-seq:
145
+ * attr_decl.value -> "value"
146
+ *
147
+ * Obtain the default value of this attribute declaration.
148
+ */
149
+ VALUE rxml_attr_decl_value_get(VALUE self)
150
+ {
151
+ xmlAttributePtr xattribute;
152
+
153
+ Data_Get_Struct(self, xmlAttribute, xattribute);
154
+
155
+ if (xattribute->defaultValue)
156
+ return rb_str_new2((const char *)xattribute->defaultValue);
157
+ else
158
+ return Qnil;
159
+ }
160
+
161
+ // Rdoc needs to know
162
+ #ifdef RDOC_NEVER_DEFINED
163
+ mLibXML = rb_define_module("LibXML");
164
+ mXML = rb_define_module_under(mLibXML, "XML");
165
+ #endif
166
+
167
+ void ruby_init_xml_attr_decl(void)
168
+ {
169
+ cXMLAttrDecl = rb_define_class_under(mXML, "AttrDecl", rb_cObject);
170
+ rb_define_method(cXMLAttrDecl, "doc", rxml_attr_decl_doc_get, 0);
171
+ rb_define_method(cXMLAttrDecl, "name", rxml_attr_decl_name_get, 0);
172
+ rb_define_method(cXMLAttrDecl, "next", rxml_attr_decl_next_get, 0);
173
+ rb_define_method(cXMLAttrDecl, "node_type", rxml_attr_decl_node_type, 0);
174
+ rb_define_method(cXMLAttrDecl, "parent", rxml_attr_decl_parent_get, 0);
175
+ rb_define_method(cXMLAttrDecl, "prev", rxml_attr_decl_prev_get, 0);
176
+ rb_define_method(cXMLAttrDecl, "value", rxml_attr_decl_value_get, 0);
177
+ }