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.
- data/LICENSE +23 -23
- data/README +144 -144
- data/ext/libxml/extconf.rb +26 -27
- data/ext/libxml/libxml.c +7 -37
- data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
- data/ext/libxml/ruby_xml_attr.c +405 -387
- data/ext/libxml/ruby_xml_attr.h +19 -18
- data/ext/libxml/ruby_xml_document.c +1111 -1115
- data/ext/libxml/ruby_xml_document.h +27 -24
- data/ext/libxml/ruby_xml_dtd.c +168 -168
- data/ext/libxml/ruby_xml_html_parser.c +449 -450
- data/ext/libxml/ruby_xml_html_parser.h +1 -1
- data/ext/libxml/ruby_xml_input_cbg.c +158 -158
- data/ext/libxml/ruby_xml_node.c +2410 -2395
- data/ext/libxml/ruby_xml_node.h +1 -1
- data/ext/libxml/ruby_xml_node_set.c +170 -170
- data/ext/libxml/ruby_xml_node_set.h +1 -1
- data/ext/libxml/ruby_xml_ns.c +153 -153
- data/ext/libxml/ruby_xml_ns.h +1 -1
- data/ext/libxml/ruby_xml_parser.c +1425 -1422
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +750 -716
- data/ext/libxml/ruby_xml_parser_context.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +900 -896
- data/ext/libxml/ruby_xml_sax_parser.c +485 -485
- data/ext/libxml/ruby_xml_sax_parser.h +1 -1
- data/ext/libxml/ruby_xml_schema.c +146 -142
- data/ext/libxml/ruby_xml_state.c +5 -6
- data/ext/libxml/ruby_xml_state.h +1 -0
- data/ext/libxml/ruby_xml_tree.c +43 -43
- data/ext/libxml/ruby_xml_tree.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.c +20 -20
- data/ext/libxml/ruby_xml_xinclude.h +1 -1
- data/ext/libxml/ruby_xml_xpath.c +243 -252
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +118 -118
- data/ext/libxml/ruby_xml_xpath_context.h +1 -1
- data/ext/libxml/ruby_xml_xpath_object.c +43 -29
- data/ext/libxml/ruby_xml_xpath_object.h +0 -1
- data/ext/libxml/ruby_xml_xpointer.c +100 -100
- data/ext/libxml/ruby_xml_xpointer.h +1 -1
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
- data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
- data/ext/libxml/sax_parser_callbacks.inc +213 -213
- data/ext/libxml/version.h +9 -9
- data/lib/libxml.rb +24 -3
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/test/dtd-test.rb +24 -24
- data/test/etc_doc_to_s.rb +1 -3
- data/test/ets_copy_bug.rb +21 -21
- data/test/ets_copy_bug2.rb +32 -32
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +1 -0
- data/test/{model/default_validation_bug.rb → gc.log} +0 -0
- data/test/merge_bug.rb +55 -55
- data/test/schema-test.rb +74 -74
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -52
- data/test/tc_xml_document_write.rb +24 -24
- data/test/tc_xml_document_write2.rb +54 -54
- data/test/tc_xml_document_write3.rb +96 -96
- data/test/tc_xml_html_parser.rb +63 -63
- data/test/tc_xml_node.rb +59 -59
- data/test/tc_xml_node2.rb +25 -25
- data/test/tc_xml_node3.rb +27 -27
- data/test/tc_xml_node4.rb +86 -86
- data/test/tc_xml_node5.rb +52 -52
- data/test/tc_xml_node6.rb +27 -27
- data/test/tc_xml_node7.rb +35 -35
- data/test/tc_xml_node8.rb +32 -32
- data/test/tc_xml_node9.rb +32 -32
- data/test/tc_xml_node_set.rb +24 -24
- data/test/tc_xml_node_set2.rb +37 -37
- data/test/tc_xml_node_xlink.rb +28 -28
- data/test/tc_xml_parser.rb +190 -178
- data/test/tc_xml_parser2.rb +16 -17
- data/test/tc_xml_parser3.rb +23 -23
- data/test/tc_xml_parser4.rb +33 -33
- data/test/tc_xml_parser5.rb +27 -27
- data/test/tc_xml_parser6.rb +23 -23
- data/test/tc_xml_parser7.rb +28 -28
- data/test/tc_xml_parser8.rb +32 -32
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -88
- data/test/tc_xml_reader.rb +112 -109
- data/test/tc_xml_sax_parser.rb +104 -94
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -30
- data/test/tc_xml_xpath.rb +38 -38
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -78
- data/vc/libxml.sln +20 -0
- data/vc/libxml.vcproj +389 -0
- data/work/Rakefile +247 -0
- data/work/task/make +26 -0
- data/work/task/memory +37 -0
- data/work/task/rdoc +39 -0
- data/work/task/setup +1616 -0
- data/work/task/test +29 -0
- data/work/test/ets_runner.rb +33 -0
- data/work/test/libxml_test.rb +3 -0
- data/work/test/runner.rb +0 -0
- data/work/test/runner_ets.rb +33 -0
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
- metadata +158 -189
- data/MANIFEST +0 -138
- data/NOTES +0 -9
- data/Rakefile +0 -38
- data/TODO +0 -75
- data/VERSION +0 -1
- data/log/Changelog-0.txt +0 -426
- data/log/Changelog.txt +0 -435
- data/meta/project.yaml +0 -27
- data/meta/unixname +0 -1
- data/setup.rb +0 -1472
- data/site/css/normal.css +0 -182
- data/site/img/raze-tiny.png +0 -0
- data/site/img/red-cube.jpg +0 -0
- data/site/img/xml-ruby.png +0 -0
- data/site/index.xml +0 -43
- data/site/install.xml +0 -77
- data/site/layout.rhtml +0 -38
- data/site/layout.xsl +0 -67
- data/site/license.xml +0 -32
- data/site/log/changelog.xml +0 -1324
- data/site/log/changelog.xsl +0 -42
- data/test/model/merge_bug_data.xml +0 -58
- data/test/model/rubynet.xml +0 -78
- data/test/model/rubynet_project +0 -13
- data/test/model/saxtest.xml +0 -5
- data/test/model/simple.xml +0 -7
- data/test/model/xinclude.xml +0 -5
data/ext/libxml/ruby_xml_attr.c
CHANGED
@@ -1,387 +1,405 @@
|
|
1
|
-
/* $Id: ruby_xml_attr.c
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#include "
|
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,"
|
18
|
-
#endif
|
19
|
-
xmlFreeProp(rx->attr);
|
20
|
-
}
|
21
|
-
|
22
|
-
rx->attr=NULL;
|
23
|
-
}
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
28
|
-
void
|
29
|
-
ruby_xml_attr_mark(ruby_xml_attr_t *rx) {
|
30
|
-
|
31
|
-
if ( rx == NULL ) return;
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
VALUE
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
*
|
66
|
-
|
67
|
-
|
68
|
-
VALUE
|
69
|
-
|
70
|
-
|
71
|
-
xnode
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
*
|
76
|
-
*
|
77
|
-
*
|
78
|
-
|
79
|
-
|
80
|
-
VALUE
|
81
|
-
|
82
|
-
ruby_xml_attr_t
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
*
|
93
|
-
*
|
94
|
-
*
|
95
|
-
|
96
|
-
|
97
|
-
VALUE
|
98
|
-
|
99
|
-
ruby_xml_attr_t
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
*
|
110
|
-
*
|
111
|
-
*
|
112
|
-
*
|
113
|
-
|
114
|
-
|
115
|
-
VALUE
|
116
|
-
|
117
|
-
ruby_xml_attr_t
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
*
|
127
|
-
*
|
128
|
-
*
|
129
|
-
*
|
130
|
-
|
131
|
-
|
132
|
-
VALUE
|
133
|
-
|
134
|
-
ruby_xml_attr_t
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
*
|
145
|
-
*
|
146
|
-
*
|
147
|
-
|
148
|
-
|
149
|
-
VALUE
|
150
|
-
|
151
|
-
ruby_xml_attr_t
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
*
|
162
|
-
*
|
163
|
-
*
|
164
|
-
|
165
|
-
|
166
|
-
VALUE
|
167
|
-
|
168
|
-
ruby_xml_attr_t
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
*
|
178
|
-
*
|
179
|
-
*
|
180
|
-
|
181
|
-
|
182
|
-
VALUE
|
183
|
-
|
184
|
-
ruby_xml_attr_t
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
*
|
195
|
-
*
|
196
|
-
*
|
197
|
-
|
198
|
-
|
199
|
-
VALUE
|
200
|
-
|
201
|
-
ruby_xml_attr_t
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
*
|
212
|
-
*
|
213
|
-
*
|
214
|
-
|
215
|
-
|
216
|
-
VALUE
|
217
|
-
|
218
|
-
ruby_xml_attr_t
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
*
|
229
|
-
*
|
230
|
-
*
|
231
|
-
|
232
|
-
|
233
|
-
VALUE
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
*
|
241
|
-
*
|
242
|
-
*
|
243
|
-
|
244
|
-
|
245
|
-
VALUE
|
246
|
-
|
247
|
-
ruby_xml_attr_t
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
*
|
258
|
-
*
|
259
|
-
*
|
260
|
-
*
|
261
|
-
|
262
|
-
|
263
|
-
VALUE
|
264
|
-
|
265
|
-
ruby_xml_attr_t
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
*
|
276
|
-
*
|
277
|
-
*
|
278
|
-
|
279
|
-
|
280
|
-
VALUE
|
281
|
-
|
282
|
-
ruby_xml_attr_t
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
*
|
293
|
-
*
|
294
|
-
*
|
295
|
-
|
296
|
-
|
297
|
-
VALUE
|
298
|
-
|
299
|
-
ruby_xml_attr_t
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
*
|
310
|
-
*
|
311
|
-
*
|
312
|
-
|
313
|
-
|
314
|
-
VALUE
|
315
|
-
|
316
|
-
ruby_xml_attr_t
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
*
|
327
|
-
*
|
328
|
-
*
|
329
|
-
|
330
|
-
|
331
|
-
VALUE
|
332
|
-
|
333
|
-
ruby_xml_attr_t
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
*
|
344
|
-
*
|
345
|
-
*
|
346
|
-
|
347
|
-
|
348
|
-
VALUE
|
349
|
-
|
350
|
-
ruby_xml_attr_t
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
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
|
+
}
|