libxml-ruby 1.1.0-x86-mswin32-60 → 1.1.1-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.1.1 / 2009-03-10 Charlie Savage
2
+
3
+ * Fix - Only include extra html parser context methods for versions of libxml
4
+ older than 2.6.27.
5
+
1
6
  == 1.1.0 / 2009-03-09 Charlie Savage
2
7
 
3
8
  * Fix bug caused by the mark function being called on partially initialized
@@ -1,77 +1,77 @@
1
- #include "ruby_libxml.h"
2
-
3
- #if RUBY_INTERN_H
4
- #include <ruby/util.h>
5
- #else
6
- #include <util.h>
7
- #endif
8
-
9
- VALUE mLibXML;
10
-
11
- static void rxml_init_memory(void)
12
- {
13
- /* Disable for now - broke attributes.
14
- xmlGcMemSetup(
15
- (xmlFreeFunc)ruby_xfree,
16
- (xmlMallocFunc)ruby_xmalloc,
17
- (xmlMallocFunc)ruby_xmalloc,
18
- (xmlReallocFunc)ruby_xrealloc,
19
- (xmlStrdupFunc)ruby_strdup
20
- );*/
21
- }
22
-
23
- #if defined(_WIN32)
24
- __declspec(dllexport)
25
- #endif
26
- void Init_libxml_ruby(void)
27
- {
28
- /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
29
- * XML toolkit. To get started you may:
30
- *
31
- * require 'xml'
32
- * document = XML::Document.new
33
- *
34
- * However, when creating an application or library you plan to
35
- * redistribute, it is best to not add the LibXML module to the global
36
- * namespace, in which case you can either write your code like this:
37
- *
38
- * require 'libxml'
39
- * document = LibXML::XML::Document.new
40
- *
41
- * Refer to the README file to get started and the LICENSE file for
42
- * copyright and distribution information.
43
- */
44
- mLibXML = rb_define_module("LibXML");
45
-
46
- rxml_init_memory();
47
- rxml_init_xml();
48
- rxml_init_io();
49
- rxml_init_error();
50
- rxml_init_encoding();
51
- rxml_init_parser();
52
- rxml_init_parser_context();
53
- rxml_init_parser_options();
54
- rxml_init_node();
55
- rxml_init_attributes();
56
- rxml_init_attr();
57
- rxml_init_attr_decl();
58
- rxml_init_document();
59
- rxml_init_namespaces();
60
- rxml_init_namespace();
61
- rxml_init_sax_parser();
62
- rxml_init_sax2_handler();
63
- rxml_init_xinclude();
64
- rxml_init_xpath();
65
- rxml_init_xpath_object();
66
- rxml_init_xpath_context();
67
- rxml_init_xpath_expression();
68
- rxml_init_xpointer();
69
- rxml_init_html_parser();
70
- rxml_init_html_parser_options();
71
- rxml_init_html_parser_context();
72
- rxml_init_input_callbacks();
73
- rxml_init_dtd();
74
- rxml_init_schema();
75
- rxml_init_relaxng();
76
- rxml_init_reader();
77
- }
1
+ #include "ruby_libxml.h"
2
+
3
+ #if RUBY_INTERN_H
4
+ #include <ruby/util.h>
5
+ #else
6
+ #include <util.h>
7
+ #endif
8
+
9
+ VALUE mLibXML;
10
+
11
+ static void rxml_init_memory(void)
12
+ {
13
+ /* Disable for now - broke attributes.
14
+ xmlGcMemSetup(
15
+ (xmlFreeFunc)ruby_xfree,
16
+ (xmlMallocFunc)ruby_xmalloc,
17
+ (xmlMallocFunc)ruby_xmalloc,
18
+ (xmlReallocFunc)ruby_xrealloc,
19
+ (xmlStrdupFunc)ruby_strdup
20
+ );*/
21
+ }
22
+
23
+ #if defined(_WIN32)
24
+ __declspec(dllexport)
25
+ #endif
26
+ void Init_libxml_ruby(void)
27
+ {
28
+ /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
29
+ * XML toolkit. To get started you may:
30
+ *
31
+ * require 'xml'
32
+ * document = XML::Document.new
33
+ *
34
+ * However, when creating an application or library you plan to
35
+ * redistribute, it is best to not add the LibXML module to the global
36
+ * namespace, in which case you can either write your code like this:
37
+ *
38
+ * require 'libxml'
39
+ * document = LibXML::XML::Document.new
40
+ *
41
+ * Refer to the README file to get started and the LICENSE file for
42
+ * copyright and distribution information.
43
+ */
44
+ mLibXML = rb_define_module("LibXML");
45
+
46
+ rxml_init_memory();
47
+ rxml_init_xml();
48
+ rxml_init_io();
49
+ rxml_init_error();
50
+ rxml_init_encoding();
51
+ rxml_init_parser();
52
+ rxml_init_parser_context();
53
+ rxml_init_parser_options();
54
+ rxml_init_node();
55
+ rxml_init_attributes();
56
+ rxml_init_attr();
57
+ rxml_init_attr_decl();
58
+ rxml_init_document();
59
+ rxml_init_namespaces();
60
+ rxml_init_namespace();
61
+ rxml_init_sax_parser();
62
+ rxml_init_sax2_handler();
63
+ rxml_init_xinclude();
64
+ rxml_init_xpath();
65
+ rxml_init_xpath_object();
66
+ rxml_init_xpath_context();
67
+ rxml_init_xpath_expression();
68
+ rxml_init_xpointer();
69
+ rxml_init_html_parser();
70
+ rxml_init_html_parser_options();
71
+ rxml_init_html_parser_context();
72
+ rxml_init_input_callbacks();
73
+ rxml_init_dtd();
74
+ rxml_init_schema();
75
+ rxml_init_relaxng();
76
+ rxml_init_reader();
77
+ }
@@ -1,352 +1,352 @@
1
- /* $Id: ruby_xml_attr.c 758 2009-01-25 20:36:03Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- /*
6
- * Document-class: LibXML::XML::Attr
7
- *
8
- * Provides access to an attribute defined on an element.
9
- *
10
- * Basic Usage:
11
- *
12
- * require 'xml'
13
- *
14
- * doc = XML::Document.new(<some_file>)
15
- * attribute = doc.root.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
16
- * attribute.name == 'href'
17
- * attribute.value == 'http://www.mydocument.com'
18
- * attribute.remove!
19
- */
20
-
21
- #include "ruby_libxml.h"
22
- #include "ruby_xml_attr.h"
23
-
24
- VALUE cXMLAttr;
25
-
26
- void rxml_attr_free(xmlAttrPtr xattr)
27
- {
28
- if (!xattr)
29
- return;
30
-
31
- xattr->_private = NULL;
32
-
33
- if (xattr->parent == NULL && xattr->doc == NULL)
34
- {
35
- xmlFreeProp(xattr);
36
- }
37
- }
38
-
39
- void rxml_attr_mark(xmlAttrPtr xattr)
40
- {
41
- /* This can happen if Ruby does a GC run after creating the
42
- new attribute but before initializing it. */
43
- if (xattr == NULL)
44
- return;
45
-
46
- if (xattr->_private == NULL)
47
- {
48
- rb_warning("XmlAttr is not bound! (%s:%d)", __FILE__, __LINE__);
49
- return;
50
- }
51
-
52
- rxml_node_mark_common((xmlNodePtr) xattr);
53
- }
54
-
55
- VALUE rxml_attr_wrap(xmlAttrPtr xattr)
56
- {
57
- VALUE result;
58
-
59
- /* Check if the node is already wrapped. */
60
- if (xattr->_private != NULL)
61
- return (VALUE) xattr->_private;
62
-
63
- result = Data_Wrap_Struct(cXMLAttr, rxml_attr_mark, rxml_attr_free, xattr);
64
- xattr->_private = (void*) result;
65
-
66
- return result;
67
- }
68
-
69
- static VALUE rxml_attr_alloc(VALUE klass)
70
- {
71
- return Data_Wrap_Struct(klass, rxml_attr_mark, rxml_attr_free, NULL);
72
- }
73
-
74
- /*
75
- * call-seq:
76
- * attr.initialize(node, "name", "value")
77
- *
78
- * Creates a new attribute for the node.
79
- *
80
- * node: The XML::Node that will contain the attribute
81
- * name: The name of the attribute
82
- * value: The value of the attribute
83
- *
84
- * attr = XML::Attr.new(doc.root, 'name', 'libxml')
85
- */
86
- static VALUE rxml_attr_initialize(int argc, VALUE *argv, VALUE self)
87
- {
88
- VALUE node = argv[0];
89
- VALUE name = argv[1];
90
- VALUE value = argv[2];
91
- VALUE ns = (argc == 4 ? argv[3] : Qnil);
92
-
93
- xmlNodePtr xnode;
94
- xmlAttrPtr xattr;
95
-
96
- if (argc < 3 || argc > 4)
97
- rb_raise(rb_eArgError, "Wrong number of arguments (3 or 4)");
98
-
99
- Check_Type(name, T_STRING);
100
- Check_Type(value, T_STRING);
101
-
102
- Data_Get_Struct(node, xmlNode, xnode);
103
-
104
- if (xnode->type != XML_ELEMENT_NODE)
105
- rb_raise(rb_eArgError, "Attributes can only be created on element nodes.");
106
-
107
- if (NIL_P(ns))
108
- {
109
- xattr = xmlNewProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value));
110
- }
111
- else
112
- {
113
- xmlNsPtr xns;
114
- Data_Get_Struct(ns, xmlNs, xns);
115
- xattr = xmlNewNsProp(xnode, xns, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value));
116
- }
117
-
118
- if (!xattr)
119
- rb_raise(rb_eRuntimeError, "Could not create attribute.");
120
-
121
- xattr->_private = (void *) self;
122
- DATA_PTR( self) = xattr;
123
- return self;
124
- }
125
-
126
- /*
127
- * call-seq:
128
- * attr.child -> node
129
- *
130
- * Obtain this attribute's child attribute(s).
131
- */
132
- static VALUE rxml_attr_child_get(VALUE self)
133
- {
134
- xmlAttrPtr xattr;
135
- Data_Get_Struct(self, xmlAttr, xattr);
136
- if (xattr->children == NULL)
137
- return Qnil;
138
- else
139
- return rxml_node_wrap((xmlNodePtr) xattr->children);
140
- }
141
-
142
-
143
- /*
144
- * call-seq:
145
- * attr.doc -> XML::Document
146
- *
147
- * Returns this attribute's document.
148
- *
149
- * doc.root.attributes.get_attribute('name').doc == doc
150
- */
151
- static VALUE rxml_attr_doc_get(VALUE self)
152
- {
153
- xmlAttrPtr xattr;
154
- Data_Get_Struct(self, xmlAttr, xattr);
155
- if (xattr->doc == NULL)
156
- return Qnil;
157
- else
158
- return rxml_document_wrap(xattr->doc);
159
- }
160
-
161
- /*
162
- * call-seq:
163
- * attr.last -> node
164
- *
165
- * Obtain the last attribute.
166
- */
167
- static VALUE rxml_attr_last_get(VALUE self)
168
- {
169
- xmlAttrPtr xattr;
170
- Data_Get_Struct(self, xmlAttr, xattr);
171
- if (xattr->last == NULL)
172
- return Qnil;
173
- else
174
- return rxml_node_wrap(xattr->last);
175
- }
176
-
177
- /*
178
- * call-seq:
179
- * attr.name -> "name"
180
- *
181
- * Obtain this attribute's name.
182
- */
183
- static VALUE rxml_attr_name_get(VALUE self)
184
- {
185
- xmlAttrPtr xattr;
186
- Data_Get_Struct(self, xmlAttr, xattr);
187
-
188
- if (xattr->name == NULL)
189
- return Qnil;
190
- else
191
- return rb_str_new2((const char*) xattr->name);
192
- }
193
-
194
- /*
195
- * call-seq:
196
- * attr.next -> node
197
- *
198
- * Obtain the next attribute.
199
- */
200
- static VALUE rxml_attr_next_get(VALUE self)
201
- {
202
- xmlAttrPtr xattr;
203
- Data_Get_Struct(self, xmlAttr, xattr);
204
- if (xattr->next == NULL)
205
- return Qnil;
206
- else
207
- return rxml_attr_wrap(xattr->next);
208
- }
209
-
210
- /*
211
- * call-seq:
212
- * attr.node_type -> num
213
- *
214
- * Obtain this node's type identifier.
215
- */
216
- static VALUE rxml_attr_node_type(VALUE self)
217
- {
218
- xmlAttrPtr xattr;
219
- Data_Get_Struct(self, xmlAttr, xattr);
220
- return INT2NUM(xattr->type);
221
- }
222
-
223
- /*
224
- * call-seq:
225
- * attr.ns -> namespace
226
- *
227
- * Obtain this attribute's associated XML::NS, if any.
228
- */
229
- static VALUE rxml_attr_ns_get(VALUE self)
230
- {
231
- xmlAttrPtr xattr;
232
- Data_Get_Struct(self, xmlAttr, xattr);
233
- if (xattr->ns == NULL)
234
- return Qnil;
235
- else
236
- return rxml_namespace_wrap(xattr->ns, NULL);
237
- }
238
-
239
- /*
240
- * call-seq:
241
- * attr.parent -> node
242
- *
243
- * Obtain this attribute node's parent.
244
- */
245
- static VALUE rxml_attr_parent_get(VALUE self)
246
- {
247
- xmlAttrPtr xattr;
248
- Data_Get_Struct(self, xmlAttr, xattr);
249
- if (xattr->parent == NULL)
250
- return Qnil;
251
- else
252
- return rxml_node_wrap(xattr->parent);
253
- }
254
-
255
- /*
256
- * call-seq:
257
- * attr.prev -> node
258
- *
259
- * Obtain the previous attribute.
260
- */
261
- static VALUE rxml_attr_prev_get(VALUE self)
262
- {
263
- xmlAttrPtr xattr;
264
- Data_Get_Struct(self, xmlAttr, xattr);
265
- if (xattr->prev == NULL)
266
- return Qnil;
267
- else
268
- return rxml_attr_wrap(xattr->prev);
269
- }
270
-
271
- /*
272
- * call-seq:
273
- * node.remove! -> nil
274
- *
275
- * Removes this attribute from it's parent.
276
- */
277
- static VALUE rxml_attr_remove_ex(VALUE self)
278
- {
279
- xmlAttrPtr xattr;
280
- Data_Get_Struct(self, xmlAttr, xattr);
281
-
282
- if (xattr->_private == NULL)
283
- xmlRemoveProp(xattr);
284
- else
285
- xmlUnlinkNode((xmlNodePtr) xattr);
286
-
287
- return Qnil;;
288
- }
289
-
290
- /*
291
- * call-seq:
292
- * attr.value -> "value"
293
- *
294
- * Obtain the value of this attribute.
295
- */
296
- VALUE rxml_attr_value_get(VALUE self)
297
- {
298
- xmlAttrPtr xattr;
299
- xmlChar *value;
300
- VALUE result = Qnil;
301
-
302
- Data_Get_Struct(self, xmlAttr, xattr);
303
- value = xmlNodeGetContent((xmlNodePtr)xattr);
304
-
305
- if (value != NULL)
306
- {
307
- result = rb_str_new2((const char*) value);
308
- xmlFree(value);
309
- }
310
- return result;
311
- }
312
-
313
- /*
314
- * call-seq:
315
- * attr.value = "value"
316
- *
317
- * Sets the value of this attribute.
318
- */
319
- VALUE rxml_attr_value_set(VALUE self, VALUE val)
320
- {
321
- xmlAttrPtr xattr;
322
-
323
- Check_Type(val, T_STRING);
324
- Data_Get_Struct(self, xmlAttr, xattr);
325
-
326
- if (xattr->ns)
327
- xmlSetNsProp(xattr->parent, xattr->ns, xattr->name,
328
- (xmlChar*) StringValuePtr(val));
329
- else
330
- xmlSetProp(xattr->parent, xattr->name, (xmlChar*) StringValuePtr(val));
331
-
332
- return (self);
333
- }
334
-
335
- void rxml_init_attr(void)
336
- {
337
- cXMLAttr = rb_define_class_under(mXML, "Attr", rb_cObject);
338
- rb_define_alloc_func(cXMLAttr, rxml_attr_alloc);
339
- rb_define_method(cXMLAttr, "initialize", rxml_attr_initialize, -1);
340
- rb_define_method(cXMLAttr, "child", rxml_attr_child_get, 0);
341
- rb_define_method(cXMLAttr, "doc", rxml_attr_doc_get, 0);
342
- rb_define_method(cXMLAttr, "last", rxml_attr_last_get, 0);
343
- rb_define_method(cXMLAttr, "name", rxml_attr_name_get, 0);
344
- rb_define_method(cXMLAttr, "next", rxml_attr_next_get, 0);
345
- rb_define_method(cXMLAttr, "node_type", rxml_attr_node_type, 0);
346
- rb_define_method(cXMLAttr, "ns", rxml_attr_ns_get, 0);
347
- rb_define_method(cXMLAttr, "parent", rxml_attr_parent_get, 0);
348
- rb_define_method(cXMLAttr, "prev", rxml_attr_prev_get, 0);
349
- rb_define_method(cXMLAttr, "remove!", rxml_attr_remove_ex, 0);
350
- rb_define_method(cXMLAttr, "value", rxml_attr_value_get, 0);
351
- rb_define_method(cXMLAttr, "value=", rxml_attr_value_set, 1);
352
- }
1
+ /* $Id: ruby_xml_attr.c 831 2009-03-09 17:46:16Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ /*
6
+ * Document-class: LibXML::XML::Attr
7
+ *
8
+ * Provides access to an attribute defined on an element.
9
+ *
10
+ * Basic Usage:
11
+ *
12
+ * require 'xml'
13
+ *
14
+ * doc = XML::Document.new(<some_file>)
15
+ * attribute = doc.root.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
16
+ * attribute.name == 'href'
17
+ * attribute.value == 'http://www.mydocument.com'
18
+ * attribute.remove!
19
+ */
20
+
21
+ #include "ruby_libxml.h"
22
+ #include "ruby_xml_attr.h"
23
+
24
+ VALUE cXMLAttr;
25
+
26
+ void rxml_attr_free(xmlAttrPtr xattr)
27
+ {
28
+ if (!xattr)
29
+ return;
30
+
31
+ xattr->_private = NULL;
32
+
33
+ if (xattr->parent == NULL && xattr->doc == NULL)
34
+ {
35
+ xmlFreeProp(xattr);
36
+ }
37
+ }
38
+
39
+ void rxml_attr_mark(xmlAttrPtr xattr)
40
+ {
41
+ /* This can happen if Ruby does a GC run after creating the
42
+ new attribute but before initializing it. */
43
+ if (xattr == NULL)
44
+ return;
45
+
46
+ if (xattr->_private == NULL)
47
+ {
48
+ rb_warning("XmlAttr is not bound! (%s:%d)", __FILE__, __LINE__);
49
+ return;
50
+ }
51
+
52
+ rxml_node_mark_common((xmlNodePtr) xattr);
53
+ }
54
+
55
+ VALUE rxml_attr_wrap(xmlAttrPtr xattr)
56
+ {
57
+ VALUE result;
58
+
59
+ /* Check if the node is already wrapped. */
60
+ if (xattr->_private != NULL)
61
+ return (VALUE) xattr->_private;
62
+
63
+ result = Data_Wrap_Struct(cXMLAttr, rxml_attr_mark, rxml_attr_free, xattr);
64
+ xattr->_private = (void*) result;
65
+
66
+ return result;
67
+ }
68
+
69
+ static VALUE rxml_attr_alloc(VALUE klass)
70
+ {
71
+ return Data_Wrap_Struct(klass, rxml_attr_mark, rxml_attr_free, NULL);
72
+ }
73
+
74
+ /*
75
+ * call-seq:
76
+ * attr.initialize(node, "name", "value")
77
+ *
78
+ * Creates a new attribute for the node.
79
+ *
80
+ * node: The XML::Node that will contain the attribute
81
+ * name: The name of the attribute
82
+ * value: The value of the attribute
83
+ *
84
+ * attr = XML::Attr.new(doc.root, 'name', 'libxml')
85
+ */
86
+ static VALUE rxml_attr_initialize(int argc, VALUE *argv, VALUE self)
87
+ {
88
+ VALUE node = argv[0];
89
+ VALUE name = argv[1];
90
+ VALUE value = argv[2];
91
+ VALUE ns = (argc == 4 ? argv[3] : Qnil);
92
+
93
+ xmlNodePtr xnode;
94
+ xmlAttrPtr xattr;
95
+
96
+ if (argc < 3 || argc > 4)
97
+ rb_raise(rb_eArgError, "Wrong number of arguments (3 or 4)");
98
+
99
+ Check_Type(name, T_STRING);
100
+ Check_Type(value, T_STRING);
101
+
102
+ Data_Get_Struct(node, xmlNode, xnode);
103
+
104
+ if (xnode->type != XML_ELEMENT_NODE)
105
+ rb_raise(rb_eArgError, "Attributes can only be created on element nodes.");
106
+
107
+ if (NIL_P(ns))
108
+ {
109
+ xattr = xmlNewProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value));
110
+ }
111
+ else
112
+ {
113
+ xmlNsPtr xns;
114
+ Data_Get_Struct(ns, xmlNs, xns);
115
+ xattr = xmlNewNsProp(xnode, xns, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value));
116
+ }
117
+
118
+ if (!xattr)
119
+ rb_raise(rb_eRuntimeError, "Could not create attribute.");
120
+
121
+ xattr->_private = (void *) self;
122
+ DATA_PTR( self) = xattr;
123
+ return self;
124
+ }
125
+
126
+ /*
127
+ * call-seq:
128
+ * attr.child -> node
129
+ *
130
+ * Obtain this attribute's child attribute(s).
131
+ */
132
+ static VALUE rxml_attr_child_get(VALUE self)
133
+ {
134
+ xmlAttrPtr xattr;
135
+ Data_Get_Struct(self, xmlAttr, xattr);
136
+ if (xattr->children == NULL)
137
+ return Qnil;
138
+ else
139
+ return rxml_node_wrap((xmlNodePtr) xattr->children);
140
+ }
141
+
142
+
143
+ /*
144
+ * call-seq:
145
+ * attr.doc -> XML::Document
146
+ *
147
+ * Returns this attribute's document.
148
+ *
149
+ * doc.root.attributes.get_attribute('name').doc == doc
150
+ */
151
+ static VALUE rxml_attr_doc_get(VALUE self)
152
+ {
153
+ xmlAttrPtr xattr;
154
+ Data_Get_Struct(self, xmlAttr, xattr);
155
+ if (xattr->doc == NULL)
156
+ return Qnil;
157
+ else
158
+ return rxml_document_wrap(xattr->doc);
159
+ }
160
+
161
+ /*
162
+ * call-seq:
163
+ * attr.last -> node
164
+ *
165
+ * Obtain the last attribute.
166
+ */
167
+ static VALUE rxml_attr_last_get(VALUE self)
168
+ {
169
+ xmlAttrPtr xattr;
170
+ Data_Get_Struct(self, xmlAttr, xattr);
171
+ if (xattr->last == NULL)
172
+ return Qnil;
173
+ else
174
+ return rxml_node_wrap(xattr->last);
175
+ }
176
+
177
+ /*
178
+ * call-seq:
179
+ * attr.name -> "name"
180
+ *
181
+ * Obtain this attribute's name.
182
+ */
183
+ static VALUE rxml_attr_name_get(VALUE self)
184
+ {
185
+ xmlAttrPtr xattr;
186
+ Data_Get_Struct(self, xmlAttr, xattr);
187
+
188
+ if (xattr->name == NULL)
189
+ return Qnil;
190
+ else
191
+ return rb_str_new2((const char*) xattr->name);
192
+ }
193
+
194
+ /*
195
+ * call-seq:
196
+ * attr.next -> node
197
+ *
198
+ * Obtain the next attribute.
199
+ */
200
+ static VALUE rxml_attr_next_get(VALUE self)
201
+ {
202
+ xmlAttrPtr xattr;
203
+ Data_Get_Struct(self, xmlAttr, xattr);
204
+ if (xattr->next == NULL)
205
+ return Qnil;
206
+ else
207
+ return rxml_attr_wrap(xattr->next);
208
+ }
209
+
210
+ /*
211
+ * call-seq:
212
+ * attr.node_type -> num
213
+ *
214
+ * Obtain this node's type identifier.
215
+ */
216
+ static VALUE rxml_attr_node_type(VALUE self)
217
+ {
218
+ xmlAttrPtr xattr;
219
+ Data_Get_Struct(self, xmlAttr, xattr);
220
+ return INT2NUM(xattr->type);
221
+ }
222
+
223
+ /*
224
+ * call-seq:
225
+ * attr.ns -> namespace
226
+ *
227
+ * Obtain this attribute's associated XML::NS, if any.
228
+ */
229
+ static VALUE rxml_attr_ns_get(VALUE self)
230
+ {
231
+ xmlAttrPtr xattr;
232
+ Data_Get_Struct(self, xmlAttr, xattr);
233
+ if (xattr->ns == NULL)
234
+ return Qnil;
235
+ else
236
+ return rxml_namespace_wrap(xattr->ns, NULL);
237
+ }
238
+
239
+ /*
240
+ * call-seq:
241
+ * attr.parent -> node
242
+ *
243
+ * Obtain this attribute node's parent.
244
+ */
245
+ static VALUE rxml_attr_parent_get(VALUE self)
246
+ {
247
+ xmlAttrPtr xattr;
248
+ Data_Get_Struct(self, xmlAttr, xattr);
249
+ if (xattr->parent == NULL)
250
+ return Qnil;
251
+ else
252
+ return rxml_node_wrap(xattr->parent);
253
+ }
254
+
255
+ /*
256
+ * call-seq:
257
+ * attr.prev -> node
258
+ *
259
+ * Obtain the previous attribute.
260
+ */
261
+ static VALUE rxml_attr_prev_get(VALUE self)
262
+ {
263
+ xmlAttrPtr xattr;
264
+ Data_Get_Struct(self, xmlAttr, xattr);
265
+ if (xattr->prev == NULL)
266
+ return Qnil;
267
+ else
268
+ return rxml_attr_wrap(xattr->prev);
269
+ }
270
+
271
+ /*
272
+ * call-seq:
273
+ * node.remove! -> nil
274
+ *
275
+ * Removes this attribute from it's parent.
276
+ */
277
+ static VALUE rxml_attr_remove_ex(VALUE self)
278
+ {
279
+ xmlAttrPtr xattr;
280
+ Data_Get_Struct(self, xmlAttr, xattr);
281
+
282
+ if (xattr->_private == NULL)
283
+ xmlRemoveProp(xattr);
284
+ else
285
+ xmlUnlinkNode((xmlNodePtr) xattr);
286
+
287
+ return Qnil;;
288
+ }
289
+
290
+ /*
291
+ * call-seq:
292
+ * attr.value -> "value"
293
+ *
294
+ * Obtain the value of this attribute.
295
+ */
296
+ VALUE rxml_attr_value_get(VALUE self)
297
+ {
298
+ xmlAttrPtr xattr;
299
+ xmlChar *value;
300
+ VALUE result = Qnil;
301
+
302
+ Data_Get_Struct(self, xmlAttr, xattr);
303
+ value = xmlNodeGetContent((xmlNodePtr)xattr);
304
+
305
+ if (value != NULL)
306
+ {
307
+ result = rb_str_new2((const char*) value);
308
+ xmlFree(value);
309
+ }
310
+ return result;
311
+ }
312
+
313
+ /*
314
+ * call-seq:
315
+ * attr.value = "value"
316
+ *
317
+ * Sets the value of this attribute.
318
+ */
319
+ VALUE rxml_attr_value_set(VALUE self, VALUE val)
320
+ {
321
+ xmlAttrPtr xattr;
322
+
323
+ Check_Type(val, T_STRING);
324
+ Data_Get_Struct(self, xmlAttr, xattr);
325
+
326
+ if (xattr->ns)
327
+ xmlSetNsProp(xattr->parent, xattr->ns, xattr->name,
328
+ (xmlChar*) StringValuePtr(val));
329
+ else
330
+ xmlSetProp(xattr->parent, xattr->name, (xmlChar*) StringValuePtr(val));
331
+
332
+ return (self);
333
+ }
334
+
335
+ void rxml_init_attr(void)
336
+ {
337
+ cXMLAttr = rb_define_class_under(mXML, "Attr", rb_cObject);
338
+ rb_define_alloc_func(cXMLAttr, rxml_attr_alloc);
339
+ rb_define_method(cXMLAttr, "initialize", rxml_attr_initialize, -1);
340
+ rb_define_method(cXMLAttr, "child", rxml_attr_child_get, 0);
341
+ rb_define_method(cXMLAttr, "doc", rxml_attr_doc_get, 0);
342
+ rb_define_method(cXMLAttr, "last", rxml_attr_last_get, 0);
343
+ rb_define_method(cXMLAttr, "name", rxml_attr_name_get, 0);
344
+ rb_define_method(cXMLAttr, "next", rxml_attr_next_get, 0);
345
+ rb_define_method(cXMLAttr, "node_type", rxml_attr_node_type, 0);
346
+ rb_define_method(cXMLAttr, "ns", rxml_attr_ns_get, 0);
347
+ rb_define_method(cXMLAttr, "parent", rxml_attr_parent_get, 0);
348
+ rb_define_method(cXMLAttr, "prev", rxml_attr_prev_get, 0);
349
+ rb_define_method(cXMLAttr, "remove!", rxml_attr_remove_ex, 0);
350
+ rb_define_method(cXMLAttr, "value", rxml_attr_value_get, 0);
351
+ rb_define_method(cXMLAttr, "value=", rxml_attr_value_set, 1);
352
+ }
@@ -20,7 +20,7 @@ static ID IO_ATTR;
20
20
  htmlNewParserCtxt (or htmlInitParserCtxt which it uses) method. htmlNewParserCtxt
21
21
  wasn't added to the libxml2 header files until 2.6.27. So the next two
22
22
  methods are simply copied from a newer version of libxml2 (2.7.2). */
23
- #if LIBXML_VERSION <= 20627
23
+ #if LIBXML_VERSION < 20627
24
24
  #define XML_CTXT_FINISH_DTD_0 0xabcd1234
25
25
  static int htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
26
26
  {
@@ -1,8 +1,8 @@
1
1
  /* Don't nuke this block! It is used for automatically updating the
2
2
  * versions below. VERSION = string formatting, VERNUM = numbered
3
3
  * version for inline testing: increment both or none at all.*/
4
- #define RUBY_LIBXML_VERSION "1.1.0"
5
- #define RUBY_LIBXML_VERNUM 110
4
+ #define RUBY_LIBXML_VERSION "1.1.1"
5
+ #define RUBY_LIBXML_VERNUM 111
6
6
  #define RUBY_LIBXML_VER_MAJ 1
7
7
  #define RUBY_LIBXML_VER_MIN 1
8
8
  #define RUBY_LIBXML_VER_MIC 0
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxml-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: x86-mswin32-60
6
6
  authors:
7
7
  - Charlie Savage
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-09 00:00:00 -06:00
12
+ date: 2009-03-10 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15