libxml-ruby 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +23 -23
  2. data/README +144 -144
  3. data/ext/libxml/extconf.rb +26 -27
  4. data/ext/libxml/libxml.c +7 -37
  5. data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
  6. data/ext/libxml/ruby_xml_attr.c +405 -387
  7. data/ext/libxml/ruby_xml_attr.h +19 -18
  8. data/ext/libxml/ruby_xml_document.c +1111 -1115
  9. data/ext/libxml/ruby_xml_document.h +27 -24
  10. data/ext/libxml/ruby_xml_dtd.c +168 -168
  11. data/ext/libxml/ruby_xml_html_parser.c +449 -450
  12. data/ext/libxml/ruby_xml_html_parser.h +1 -1
  13. data/ext/libxml/ruby_xml_input_cbg.c +158 -158
  14. data/ext/libxml/ruby_xml_node.c +2410 -2395
  15. data/ext/libxml/ruby_xml_node.h +1 -1
  16. data/ext/libxml/ruby_xml_node_set.c +170 -170
  17. data/ext/libxml/ruby_xml_node_set.h +1 -1
  18. data/ext/libxml/ruby_xml_ns.c +153 -153
  19. data/ext/libxml/ruby_xml_ns.h +1 -1
  20. data/ext/libxml/ruby_xml_parser.c +1425 -1422
  21. data/ext/libxml/ruby_xml_parser.h +1 -1
  22. data/ext/libxml/ruby_xml_parser_context.c +750 -716
  23. data/ext/libxml/ruby_xml_parser_context.h +1 -1
  24. data/ext/libxml/ruby_xml_reader.c +900 -896
  25. data/ext/libxml/ruby_xml_sax_parser.c +485 -485
  26. data/ext/libxml/ruby_xml_sax_parser.h +1 -1
  27. data/ext/libxml/ruby_xml_schema.c +146 -142
  28. data/ext/libxml/ruby_xml_state.c +5 -6
  29. data/ext/libxml/ruby_xml_state.h +1 -0
  30. data/ext/libxml/ruby_xml_tree.c +43 -43
  31. data/ext/libxml/ruby_xml_tree.h +1 -1
  32. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  33. data/ext/libxml/ruby_xml_xinclude.h +1 -1
  34. data/ext/libxml/ruby_xml_xpath.c +243 -252
  35. data/ext/libxml/ruby_xml_xpath.h +1 -1
  36. data/ext/libxml/ruby_xml_xpath_context.c +118 -118
  37. data/ext/libxml/ruby_xml_xpath_context.h +1 -1
  38. data/ext/libxml/ruby_xml_xpath_object.c +43 -29
  39. data/ext/libxml/ruby_xml_xpath_object.h +0 -1
  40. data/ext/libxml/ruby_xml_xpointer.c +100 -100
  41. data/ext/libxml/ruby_xml_xpointer.h +1 -1
  42. data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
  43. data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
  44. data/ext/libxml/sax_parser_callbacks.inc +213 -213
  45. data/ext/libxml/version.h +9 -9
  46. data/lib/libxml.rb +24 -3
  47. data/mingw/libiconv-2.dll +0 -0
  48. data/mingw/libxml2-2.dll +0 -0
  49. data/mingw/libxml_ruby.so +0 -0
  50. data/mingw/mingw.rake +36 -0
  51. data/test/dtd-test.rb +24 -24
  52. data/test/etc_doc_to_s.rb +1 -3
  53. data/test/ets_copy_bug.rb +21 -21
  54. data/test/ets_copy_bug2.rb +32 -32
  55. data/test/ets_copy_bug3.rb +38 -0
  56. data/test/ets_doc_file.rb +1 -0
  57. data/test/{model/default_validation_bug.rb → gc.log} +0 -0
  58. data/test/merge_bug.rb +55 -55
  59. data/test/schema-test.rb +74 -74
  60. data/test/tc_well_formed.rb +11 -0
  61. data/test/tc_xml_document.rb +52 -52
  62. data/test/tc_xml_document_write.rb +24 -24
  63. data/test/tc_xml_document_write2.rb +54 -54
  64. data/test/tc_xml_document_write3.rb +96 -96
  65. data/test/tc_xml_html_parser.rb +63 -63
  66. data/test/tc_xml_node.rb +59 -59
  67. data/test/tc_xml_node2.rb +25 -25
  68. data/test/tc_xml_node3.rb +27 -27
  69. data/test/tc_xml_node4.rb +86 -86
  70. data/test/tc_xml_node5.rb +52 -52
  71. data/test/tc_xml_node6.rb +27 -27
  72. data/test/tc_xml_node7.rb +35 -35
  73. data/test/tc_xml_node8.rb +32 -32
  74. data/test/tc_xml_node9.rb +32 -32
  75. data/test/tc_xml_node_set.rb +24 -24
  76. data/test/tc_xml_node_set2.rb +37 -37
  77. data/test/tc_xml_node_xlink.rb +28 -28
  78. data/test/tc_xml_parser.rb +190 -178
  79. data/test/tc_xml_parser2.rb +16 -17
  80. data/test/tc_xml_parser3.rb +23 -23
  81. data/test/tc_xml_parser4.rb +33 -33
  82. data/test/tc_xml_parser5.rb +27 -27
  83. data/test/tc_xml_parser6.rb +23 -23
  84. data/test/tc_xml_parser7.rb +28 -28
  85. data/test/tc_xml_parser8.rb +32 -32
  86. data/test/tc_xml_parser9.rb +11 -0
  87. data/test/tc_xml_parser_context.rb +88 -88
  88. data/test/tc_xml_reader.rb +112 -109
  89. data/test/tc_xml_sax_parser.rb +104 -94
  90. data/test/tc_xml_sax_parser2.rb +51 -0
  91. data/test/tc_xml_xinclude.rb +30 -30
  92. data/test/tc_xml_xpath.rb +38 -38
  93. data/test/tc_xml_xpath2.rb +14 -0
  94. data/test/tc_xml_xpointer.rb +78 -78
  95. data/vc/libxml.sln +20 -0
  96. data/vc/libxml.vcproj +389 -0
  97. data/work/Rakefile +247 -0
  98. data/work/task/make +26 -0
  99. data/work/task/memory +37 -0
  100. data/work/task/rdoc +39 -0
  101. data/work/task/setup +1616 -0
  102. data/work/task/test +29 -0
  103. data/work/test/ets_runner.rb +33 -0
  104. data/work/test/libxml_test.rb +3 -0
  105. data/work/test/runner.rb +0 -0
  106. data/work/test/runner_ets.rb +33 -0
  107. data/work/vc/debug/libxml.exp +0 -0
  108. data/work/vc/debug/libxml.ilk +0 -0
  109. data/work/vc/debug/libxml.lib +0 -0
  110. data/work/vc/debug/libxml.pdb +0 -0
  111. data/work/vc/debug/libxml.so +0 -0
  112. metadata +158 -189
  113. data/MANIFEST +0 -138
  114. data/NOTES +0 -9
  115. data/Rakefile +0 -38
  116. data/TODO +0 -75
  117. data/VERSION +0 -1
  118. data/log/Changelog-0.txt +0 -426
  119. data/log/Changelog.txt +0 -435
  120. data/meta/project.yaml +0 -27
  121. data/meta/unixname +0 -1
  122. data/setup.rb +0 -1472
  123. data/site/css/normal.css +0 -182
  124. data/site/img/raze-tiny.png +0 -0
  125. data/site/img/red-cube.jpg +0 -0
  126. data/site/img/xml-ruby.png +0 -0
  127. data/site/index.xml +0 -43
  128. data/site/install.xml +0 -77
  129. data/site/layout.rhtml +0 -38
  130. data/site/layout.xsl +0 -67
  131. data/site/license.xml +0 -32
  132. data/site/log/changelog.xml +0 -1324
  133. data/site/log/changelog.xsl +0 -42
  134. data/test/model/merge_bug_data.xml +0 -58
  135. data/test/model/rubynet.xml +0 -78
  136. data/test/model/rubynet_project +0 -13
  137. data/test/model/saxtest.xml +0 -5
  138. data/test/model/simple.xml +0 -7
  139. data/test/model/xinclude.xml +0 -5
@@ -1,387 +1,405 @@
1
- /* $Id: ruby_xml_attr.c 225 2007-12-07 04:58:09Z transami $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #include "libxml.h"
6
- #include "ruby_xml_attr.h"
7
-
8
- VALUE cXMLAttr;
9
-
10
- void ruby_xml_attr_free(ruby_xml_attr_t *rx) {
11
- if (rx == NULL ) return;
12
-
13
- if (rx->attr != NULL ) {
14
- rx->attr->_private=NULL;
15
- if (rx->attr->parent == NULL && rx->attr->doc == NULL ) {
16
- #ifdef NODE_DEBUG
17
- fprintf(stderr,"free rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)rxn->node,(long)rxn->node->_private);
18
- #endif
19
- xmlFreeProp(rx->attr);
20
- }
21
-
22
- rx->attr=NULL;
23
- }
24
-
25
- free(rx);
26
- }
27
-
28
- void
29
- ruby_xml_attr_mark(ruby_xml_attr_t *rx) {
30
- xmlNodePtr node;
31
- if ( rx == NULL ) return;
32
- if ( rx->attr == NULL ) return;
33
-
34
- if (rx->attr->_private == NULL ) {
35
- rb_warning("XmlAttr is not bound! (%s:%d)",
36
- __FILE__,__LINE__);
37
- return;
38
- }
39
-
40
- ruby_xml_node_mark_common(rx->attr);
41
- }
42
-
43
- VALUE
44
- ruby_xml_attr_wrap(VALUE class, xmlAttrPtr xnode)
45
- {
46
- VALUE obj;
47
- ruby_xml_attr_t *rx;
48
-
49
- // This node is already wrapped
50
- if (xnode->_private != NULL)
51
- return (VALUE)xnode->_private;
52
-
53
- obj=Data_Make_Struct(class,ruby_xml_attr_t,ruby_xml_attr_mark,
54
- ruby_xml_attr_free,rx);
55
-
56
- rx->attr=xnode;
57
- xnode->_private=(void*)obj;
58
- #ifdef NODE_DEBUG
59
- fprintf(stderr,"wrap rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)xnode,(long)obj);
60
- #endif
61
- return obj;
62
- }
63
-
64
- /*
65
- * Only use this when a xmlAttr has just been created since
66
- * oblitterates the _private. Not exposed to ruby interp.
67
- */
68
- VALUE
69
- ruby_xml_attr_new(VALUE class, xmlAttrPtr xnode)
70
- {
71
- xnode->_private=NULL;
72
- return ruby_xml_attr_wrap(class,xnode);
73
- }
74
- /*
75
- * call-seq:
76
- * attr.child => node
77
- *
78
- * Obtain this attribute's child attribute(s).
79
- */
80
- VALUE
81
- ruby_xml_attr_child_get(VALUE self) {
82
- ruby_xml_attr_t *rxa;
83
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
84
- if (rxa->attr->children == NULL)
85
- return(Qnil);
86
- else
87
- return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->children));
88
- }
89
-
90
-
91
- /*
92
- * call-seq:
93
- * attr.child? => (true|false)
94
- *
95
- * Determine whether this attribute has child attributes.
96
- */
97
- VALUE
98
- ruby_xml_attr_child_q(VALUE self) {
99
- ruby_xml_attr_t *rxa;
100
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
101
- if (rxa->attr->children == NULL)
102
- return(Qfalse);
103
- else
104
- return(Qtrue);
105
- }
106
-
107
-
108
- /*
109
- * call-seq:
110
- * attr.doc => document
111
- *
112
- * Obtain the XML::Document this attribute is associated with,
113
- * if any.
114
- */
115
- VALUE
116
- ruby_xml_attr_doc_get(VALUE self) {
117
- ruby_xml_attr_t *rxa;
118
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
119
- if (rxa->attr->doc == NULL)
120
- return(Qnil);
121
- else
122
- return(ruby_xml_document_wrap(cXMLDocument, rxa->attr->doc));
123
- }
124
-
125
- /*
126
- * call-seq:
127
- * attr.doc? => (true|false)
128
- *
129
- * Determine whether this attribute is associated with an
130
- * XML::Document.
131
- */
132
- VALUE
133
- ruby_xml_attr_doc_q(VALUE self) {
134
- ruby_xml_attr_t *rxa;
135
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
136
- if (rxa->attr->doc == NULL)
137
- return(Qfalse);
138
- else
139
- return(Qtrue);
140
- }
141
-
142
-
143
- /*
144
- * call-seq:
145
- * attr.last => node
146
- *
147
- * Obtain the last attribute.
148
- */
149
- VALUE
150
- ruby_xml_attr_last_get(VALUE self) {
151
- ruby_xml_attr_t *rxa;
152
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
153
- if (rxa->attr->last == NULL)
154
- return(Qnil);
155
- else
156
- return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->last));
157
- }
158
-
159
-
160
- /*
161
- * call-seq:
162
- * attr.last? => (true|false)
163
- *
164
- * Determine whether this is the last attribute.
165
- */
166
- VALUE
167
- ruby_xml_attr_last_q(VALUE self) {
168
- ruby_xml_attr_t *rxa;
169
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
170
- if (rxa->attr->last == NULL)
171
- return(Qfalse);
172
- else
173
- return(Qtrue);
174
- }
175
-
176
- /*
177
- * call-seq:
178
- * attr.name => "name"
179
- *
180
- * Obtain this attribute's name.
181
- */
182
- VALUE
183
- ruby_xml_attr_name_get(VALUE self) {
184
- ruby_xml_attr_t *rxa;
185
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
186
-
187
- if (rxa->attr->name == NULL)
188
- return(Qnil);
189
- else
190
- return(rb_str_new2((const char*)rxa->attr->name));
191
- }
192
-
193
- /*
194
- * call-seq:
195
- * attr.next => node
196
- *
197
- * Obtain the next attribute.
198
- */
199
- VALUE
200
- ruby_xml_attr_next_get(VALUE self) {
201
- ruby_xml_attr_t *rxa;
202
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
203
- if (rxa->attr->next == NULL)
204
- return(Qnil);
205
- else
206
- return(ruby_xml_attr_wrap(cXMLAttr, rxa->attr->next));
207
- }
208
-
209
-
210
- /*
211
- * call-seq:
212
- * attr.next? => (true|false)
213
- *
214
- * Determine whether there is a next attribute.
215
- */
216
- VALUE
217
- ruby_xml_attr_next_q(VALUE self) {
218
- ruby_xml_attr_t *rxa;
219
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
220
- if (rxa->attr->next == NULL)
221
- return(Qfalse);
222
- else
223
- return(Qtrue);
224
- }
225
-
226
-
227
- /*
228
- * call-seq:
229
- * attr.type_name => "attribute"
230
- *
231
- * Obtain this attribute node's type name.
232
- */
233
- VALUE
234
- ruby_xml_attr_node_type_name(VALUE self) {
235
- return(rb_str_new2("attribute"));
236
- }
237
-
238
-
239
- /*
240
- * call-seq:
241
- * attr.ns => namespace
242
- *
243
- * Obtain this attribute's associated XML::NS, if any.
244
- */
245
- VALUE
246
- ruby_xml_attr_ns_get(VALUE self) {
247
- ruby_xml_attr_t *rxa;
248
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
249
- if (rxa->attr->ns == NULL)
250
- return(Qnil);
251
- else
252
- return(ruby_xml_ns_new2(cXMLNS, NULL, rxa->attr->ns));
253
- }
254
-
255
-
256
- /*
257
- * call-seq:
258
- * attr.ns? => (true|false)
259
- *
260
- * Determine whether this attribute has an associated
261
- * namespace.
262
- */
263
- VALUE
264
- ruby_xml_attr_ns_q(VALUE self) {
265
- ruby_xml_attr_t *rxa;
266
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
267
- if (rxa->attr->ns == NULL)
268
- return(Qfalse);
269
- else
270
- return(Qtrue);
271
- }
272
-
273
-
274
- /*
275
- * call-seq:
276
- * attr.parent => node
277
- *
278
- * Obtain this attribute node's parent.
279
- */
280
- VALUE
281
- ruby_xml_attr_parent_get(VALUE self) {
282
- ruby_xml_attr_t *rxa;
283
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
284
- if (rxa->attr->parent == NULL)
285
- return(Qnil);
286
- else
287
- return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->parent));
288
- }
289
-
290
-
291
- /*
292
- * call-seq:
293
- * attr.parent? => (true|false)
294
- *
295
- * Determine whether this attribute has a parent.
296
- */
297
- VALUE
298
- ruby_xml_attr_parent_q(VALUE self) {
299
- ruby_xml_attr_t *rxa;
300
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
301
- if (rxa->attr->parent == NULL)
302
- return(Qfalse);
303
- else
304
- return(Qtrue);
305
- }
306
-
307
-
308
- /*
309
- * call-seq:
310
- * attr.prev => node
311
- *
312
- * Obtain the previous attribute.
313
- */
314
- VALUE
315
- ruby_xml_attr_prev_get(VALUE self) {
316
- ruby_xml_attr_t *rxa;
317
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
318
- if (rxa->attr->prev == NULL)
319
- return(Qnil);
320
- else
321
- return(ruby_xml_attr_wrap(cXMLAttr, rxa->attr->prev));
322
- }
323
-
324
-
325
- /*
326
- * call-seq:
327
- * attr.prev? => (true|false)
328
- *
329
- * Determine whether there is a previous attribute.
330
- */
331
- VALUE
332
- ruby_xml_attr_prev_q(VALUE self) {
333
- ruby_xml_attr_t *rxa;
334
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
335
- if (rxa->attr->prev == NULL)
336
- return(Qfalse);
337
- else
338
- return(Qtrue);
339
- }
340
-
341
-
342
- /*
343
- * call-seq:
344
- * attr.value => "value"
345
- *
346
- * Obtain the value of this attribute.
347
- */
348
- VALUE
349
- ruby_xml_attr_value(VALUE self) {
350
- ruby_xml_attr_t *rxa;
351
- xmlChar *value;
352
-
353
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
354
- if (ruby_xml_attr_parent_q(self) == Qtrue) {
355
- value = xmlGetProp(rxa->attr->parent, rxa->attr->name);
356
- if (value != NULL)
357
- return(rb_str_new2((const char*)value));
358
- }
359
- return(Qnil);
360
- }
361
-
362
- // Rdoc needs to know
363
- #ifdef RDOC_NEVER_DEFINED
364
- mXML = rb_define_module("XML");
365
- #endif
366
-
367
- void
368
- ruby_init_xml_attr(void) {
369
- cXMLAttr = rb_define_class_under(mXML, "Attr", rb_cObject);
370
- rb_define_method(cXMLAttr, "child", ruby_xml_attr_child_get, 0);
371
- rb_define_method(cXMLAttr, "child?", ruby_xml_attr_child_q, 0);
372
- rb_define_method(cXMLAttr, "doc", ruby_xml_attr_doc_get, 0);
373
- rb_define_method(cXMLAttr, "doc?", ruby_xml_attr_doc_q, 0);
374
- rb_define_method(cXMLAttr, "last", ruby_xml_attr_last_get, 0);
375
- rb_define_method(cXMLAttr, "last?", ruby_xml_attr_last_q, 0);
376
- rb_define_method(cXMLAttr, "name", ruby_xml_attr_name_get, 0);
377
- rb_define_method(cXMLAttr, "next", ruby_xml_attr_next_get, 0);
378
- rb_define_method(cXMLAttr, "next?", ruby_xml_attr_next_q, 0);
379
- rb_define_method(cXMLAttr, "node_type_name", ruby_xml_attr_node_type_name, 0);
380
- rb_define_method(cXMLAttr, "ns", ruby_xml_attr_ns_get, 0);
381
- rb_define_method(cXMLAttr, "ns?", ruby_xml_attr_ns_q, 0);
382
- rb_define_method(cXMLAttr, "parent", ruby_xml_attr_parent_get, 0);
383
- rb_define_method(cXMLAttr, "parent?", ruby_xml_attr_parent_q, 0);
384
- rb_define_method(cXMLAttr, "prev", ruby_xml_attr_prev_get, 0);
385
- rb_define_method(cXMLAttr, "prev?", ruby_xml_attr_prev_q, 0);
386
- rb_define_method(cXMLAttr, "value", ruby_xml_attr_value, 0);
387
- }
1
+ /* $Id: ruby_xml_attr.c 300 2008-07-01 19:14:15Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_attr.h"
7
+
8
+ VALUE cXMLAttr;
9
+
10
+ void ruby_xml_attr_free(ruby_xml_attr_t *rx) {
11
+ if (rx == NULL ) return;
12
+
13
+ if (rx->attr != NULL ) {
14
+ rx->attr->_private=NULL;
15
+ if (rx->attr->parent == NULL && rx->attr->doc == NULL ) {
16
+ #ifdef NODE_DEBUG
17
+ fprintf(stderr,"ruby_xfree rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)rxn->node,(long)rxn->node->_private);
18
+ #endif
19
+ xmlFreeProp(rx->attr);
20
+ }
21
+
22
+ rx->attr=NULL;
23
+ }
24
+
25
+ ruby_xfree(rx);
26
+ }
27
+
28
+ void
29
+ ruby_xml_attr_mark(ruby_xml_attr_t *rx) {
30
+ if ( rx == NULL ) return;
31
+ if ( rx->attr == NULL ) return;
32
+
33
+ if (rx->attr->_private == NULL ) {
34
+ rb_warning("XmlAttr is not bound! (%s:%d)",
35
+ __FILE__,__LINE__);
36
+ return;
37
+ }
38
+
39
+ ruby_xml_node_mark_common((xmlNodePtr)rx->attr);
40
+ }
41
+
42
+ VALUE
43
+ ruby_xml_attr_wrap(VALUE class, xmlAttrPtr xnode)
44
+ {
45
+ VALUE obj;
46
+ ruby_xml_attr_t *rx;
47
+
48
+ // This node is already wrapped
49
+ if (xnode->_private != NULL)
50
+ return (VALUE)xnode->_private;
51
+
52
+ obj=Data_Make_Struct(class,ruby_xml_attr_t,ruby_xml_attr_mark,
53
+ ruby_xml_attr_free,rx);
54
+
55
+ rx->attr=xnode;
56
+ xnode->_private=(void*)obj;
57
+ #ifdef NODE_DEBUG
58
+ fprintf(stderr,"wrap rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)xnode,(long)obj);
59
+ #endif
60
+ return obj;
61
+ }
62
+
63
+ /*
64
+ * Only use this when a xmlAttr has just been created since
65
+ * oblitterates the _private. Not exposed to ruby interp.
66
+ */
67
+ VALUE
68
+ ruby_xml_attr_new(VALUE class, xmlAttrPtr xnode)
69
+ {
70
+ xnode->_private=NULL;
71
+ return ruby_xml_attr_wrap(class,xnode);
72
+ }
73
+ /*
74
+ * call-seq:
75
+ * attr.child => node
76
+ *
77
+ * Obtain this attribute's child attribute(s).
78
+ */
79
+ VALUE
80
+ ruby_xml_attr_child_get(VALUE self) {
81
+ ruby_xml_attr_t *rxa;
82
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
83
+ if (rxa->attr->children == NULL)
84
+ return(Qnil);
85
+ else
86
+ return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->children));
87
+ }
88
+
89
+
90
+ /*
91
+ * call-seq:
92
+ * attr.child? => (true|false)
93
+ *
94
+ * Determine whether this attribute has child attributes.
95
+ */
96
+ VALUE
97
+ ruby_xml_attr_child_q(VALUE self) {
98
+ ruby_xml_attr_t *rxa;
99
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
100
+ if (rxa->attr->children == NULL)
101
+ return(Qfalse);
102
+ else
103
+ return(Qtrue);
104
+ }
105
+
106
+
107
+ /*
108
+ * call-seq:
109
+ * attr.doc => document
110
+ *
111
+ * Obtain the XML::Document this attribute is associated with,
112
+ * if any.
113
+ */
114
+ VALUE
115
+ ruby_xml_attr_doc_get(VALUE self) {
116
+ ruby_xml_attr_t *rxa;
117
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
118
+ if (rxa->attr->doc == NULL)
119
+ return(Qnil);
120
+ else
121
+ return(ruby_xml_document_wrap(rxa->attr->doc));
122
+ }
123
+
124
+ /*
125
+ * call-seq:
126
+ * attr.doc? => (true|false)
127
+ *
128
+ * Determine whether this attribute is associated with an
129
+ * XML::Document.
130
+ */
131
+ VALUE
132
+ ruby_xml_attr_doc_q(VALUE self) {
133
+ ruby_xml_attr_t *rxa;
134
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
135
+ if (rxa->attr->doc == NULL)
136
+ return(Qfalse);
137
+ else
138
+ return(Qtrue);
139
+ }
140
+
141
+
142
+ /*
143
+ * call-seq:
144
+ * attr.last => node
145
+ *
146
+ * Obtain the last attribute.
147
+ */
148
+ VALUE
149
+ ruby_xml_attr_last_get(VALUE self) {
150
+ ruby_xml_attr_t *rxa;
151
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
152
+ if (rxa->attr->last == NULL)
153
+ return(Qnil);
154
+ else
155
+ return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->last));
156
+ }
157
+
158
+
159
+ /*
160
+ * call-seq:
161
+ * attr.last? => (true|false)
162
+ *
163
+ * Determine whether this is the last attribute.
164
+ */
165
+ VALUE
166
+ ruby_xml_attr_last_q(VALUE self) {
167
+ ruby_xml_attr_t *rxa;
168
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
169
+ if (rxa->attr->last == NULL)
170
+ return(Qfalse);
171
+ else
172
+ return(Qtrue);
173
+ }
174
+
175
+ /*
176
+ * call-seq:
177
+ * attr.name => "name"
178
+ *
179
+ * Obtain this attribute's name.
180
+ */
181
+ VALUE
182
+ ruby_xml_attr_name_get(VALUE self) {
183
+ ruby_xml_attr_t *rxa;
184
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
185
+
186
+ if (rxa->attr->name == NULL)
187
+ return(Qnil);
188
+ else
189
+ return(rb_str_new2((const char*)rxa->attr->name));
190
+ }
191
+
192
+ /*
193
+ * call-seq:
194
+ * attr.next => node
195
+ *
196
+ * Obtain the next attribute.
197
+ */
198
+ VALUE
199
+ ruby_xml_attr_next_get(VALUE self) {
200
+ ruby_xml_attr_t *rxa;
201
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
202
+ if (rxa->attr->next == NULL)
203
+ return(Qnil);
204
+ else
205
+ return(ruby_xml_attr_wrap(cXMLAttr, rxa->attr->next));
206
+ }
207
+
208
+
209
+ /*
210
+ * call-seq:
211
+ * attr.next? => (true|false)
212
+ *
213
+ * Determine whether there is a next attribute.
214
+ */
215
+ VALUE
216
+ ruby_xml_attr_next_q(VALUE self) {
217
+ ruby_xml_attr_t *rxa;
218
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
219
+ if (rxa->attr->next == NULL)
220
+ return(Qfalse);
221
+ else
222
+ return(Qtrue);
223
+ }
224
+
225
+
226
+ /*
227
+ * call-seq:
228
+ * attr.type_name => "attribute"
229
+ *
230
+ * Obtain this attribute node's type name.
231
+ */
232
+ VALUE
233
+ ruby_xml_attr_node_type_name(VALUE self) {
234
+ return(rb_str_new2("attribute"));
235
+ }
236
+
237
+
238
+ /*
239
+ * call-seq:
240
+ * attr.ns => namespace
241
+ *
242
+ * Obtain this attribute's associated XML::NS, if any.
243
+ */
244
+ VALUE
245
+ ruby_xml_attr_ns_get(VALUE self) {
246
+ ruby_xml_attr_t *rxa;
247
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
248
+ if (rxa->attr->ns == NULL)
249
+ return(Qnil);
250
+ else
251
+ return(ruby_xml_ns_new2(cXMLNS, Qnil, rxa->attr->ns));
252
+ }
253
+
254
+
255
+ /*
256
+ * call-seq:
257
+ * attr.ns? => (true|false)
258
+ *
259
+ * Determine whether this attribute has an associated
260
+ * namespace.
261
+ */
262
+ VALUE
263
+ ruby_xml_attr_ns_q(VALUE self) {
264
+ ruby_xml_attr_t *rxa;
265
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
266
+ if (rxa->attr->ns == NULL)
267
+ return(Qfalse);
268
+ else
269
+ return(Qtrue);
270
+ }
271
+
272
+
273
+ /*
274
+ * call-seq:
275
+ * attr.parent => node
276
+ *
277
+ * Obtain this attribute node's parent.
278
+ */
279
+ VALUE
280
+ ruby_xml_attr_parent_get(VALUE self) {
281
+ ruby_xml_attr_t *rxa;
282
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
283
+ if (rxa->attr->parent == NULL)
284
+ return(Qnil);
285
+ else
286
+ return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->parent));
287
+ }
288
+
289
+
290
+ /*
291
+ * call-seq:
292
+ * attr.parent? => (true|false)
293
+ *
294
+ * Determine whether this attribute has a parent.
295
+ */
296
+ VALUE
297
+ ruby_xml_attr_parent_q(VALUE self) {
298
+ ruby_xml_attr_t *rxa;
299
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
300
+ if (rxa->attr->parent == NULL)
301
+ return(Qfalse);
302
+ else
303
+ return(Qtrue);
304
+ }
305
+
306
+
307
+ /*
308
+ * call-seq:
309
+ * attr.prev => node
310
+ *
311
+ * Obtain the previous attribute.
312
+ */
313
+ VALUE
314
+ ruby_xml_attr_prev_get(VALUE self) {
315
+ ruby_xml_attr_t *rxa;
316
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
317
+ if (rxa->attr->prev == NULL)
318
+ return(Qnil);
319
+ else
320
+ return(ruby_xml_attr_wrap(cXMLAttr, rxa->attr->prev));
321
+ }
322
+
323
+
324
+ /*
325
+ * call-seq:
326
+ * attr.prev? => (true|false)
327
+ *
328
+ * Determine whether there is a previous attribute.
329
+ */
330
+ VALUE
331
+ ruby_xml_attr_prev_q(VALUE self) {
332
+ ruby_xml_attr_t *rxa;
333
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
334
+ if (rxa->attr->prev == NULL)
335
+ return(Qfalse);
336
+ else
337
+ return(Qtrue);
338
+ }
339
+
340
+
341
+ /*
342
+ * call-seq:
343
+ * node.remove! => nil
344
+ *
345
+ * Removes this attribute from it's parent.
346
+ */
347
+ VALUE
348
+ ruby_xml_attr_remove_ex(VALUE self) {
349
+ ruby_xml_attr_t *rxa;
350
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
351
+ xmlUnlinkNode(rxa->attr);
352
+ return(Qnil);
353
+ }
354
+
355
+ /*
356
+ * call-seq:
357
+ * attr.value => "value"
358
+ *
359
+ * Obtain the value of this attribute.
360
+ */
361
+ VALUE
362
+ ruby_xml_attr_value(VALUE self) {
363
+ ruby_xml_attr_t *rxa;
364
+ xmlChar *value;
365
+ VALUE result = Qnil;
366
+
367
+ Data_Get_Struct(self, ruby_xml_attr_t, rxa);
368
+ if (ruby_xml_attr_parent_q(self) == Qtrue) {
369
+ value = xmlGetProp(rxa->attr->parent, rxa->attr->name);
370
+ if (value != NULL)
371
+ {
372
+ result = rb_str_new2((const char*)value);
373
+ xmlFree(value);
374
+ }
375
+ }
376
+ return(result);
377
+ }
378
+
379
+ // Rdoc needs to know
380
+ #ifdef RDOC_NEVER_DEFINED
381
+ mXML = rb_define_module("XML");
382
+ #endif
383
+
384
+ void
385
+ ruby_init_xml_attr(void) {
386
+ cXMLAttr = rb_define_class_under(mXML, "Attr", rb_cObject);
387
+ rb_define_method(cXMLAttr, "child", ruby_xml_attr_child_get, 0);
388
+ rb_define_method(cXMLAttr, "child?", ruby_xml_attr_child_q, 0);
389
+ rb_define_method(cXMLAttr, "doc", ruby_xml_attr_doc_get, 0);
390
+ rb_define_method(cXMLAttr, "doc?", ruby_xml_attr_doc_q, 0);
391
+ rb_define_method(cXMLAttr, "last", ruby_xml_attr_last_get, 0);
392
+ rb_define_method(cXMLAttr, "last?", ruby_xml_attr_last_q, 0);
393
+ rb_define_method(cXMLAttr, "name", ruby_xml_attr_name_get, 0);
394
+ rb_define_method(cXMLAttr, "next", ruby_xml_attr_next_get, 0);
395
+ rb_define_method(cXMLAttr, "next?", ruby_xml_attr_next_q, 0);
396
+ rb_define_method(cXMLAttr, "node_type_name", ruby_xml_attr_node_type_name, 0);
397
+ rb_define_method(cXMLAttr, "ns", ruby_xml_attr_ns_get, 0);
398
+ rb_define_method(cXMLAttr, "ns?", ruby_xml_attr_ns_q, 0);
399
+ rb_define_method(cXMLAttr, "parent", ruby_xml_attr_parent_get, 0);
400
+ rb_define_method(cXMLAttr, "parent?", ruby_xml_attr_parent_q, 0);
401
+ rb_define_method(cXMLAttr, "prev", ruby_xml_attr_prev_get, 0);
402
+ rb_define_method(cXMLAttr, "prev?", ruby_xml_attr_prev_q, 0);
403
+ rb_define_method(cXMLAttr, "remove!", ruby_xml_attr_remove_ex, 0);
404
+ rb_define_method(cXMLAttr, "value", ruby_xml_attr_value, 0);
405
+ }