libxml-ruby 5.0.6 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{HISTORY → CHANGELOG.md} +875 -930
- data/LICENSE +20 -20
- data/README.md +67 -0
- data/Rakefile +13 -34
- data/ext/libxml/extconf.rb +34 -20
- data/ext/libxml/libxml.c +2 -14
- data/ext/libxml/ruby_libxml.h +1 -1
- data/ext/libxml/ruby_xml_attr.c +27 -22
- data/ext/libxml/ruby_xml_attr.h +1 -0
- data/ext/libxml/ruby_xml_attr_decl.c +19 -12
- data/ext/libxml/ruby_xml_attributes.c +18 -9
- data/ext/libxml/ruby_xml_document.c +111 -98
- data/ext/libxml/ruby_xml_document.h +1 -0
- data/ext/libxml/ruby_xml_dtd.c +49 -19
- data/ext/libxml/ruby_xml_dtd.h +1 -0
- data/ext/libxml/ruby_xml_html_parser.c +1 -1
- data/ext/libxml/ruby_xml_html_parser_context.c +19 -6
- data/ext/libxml/ruby_xml_html_parser_context.h +1 -0
- data/ext/libxml/ruby_xml_input_cbg.c +45 -17
- data/ext/libxml/ruby_xml_io.c +3 -1
- data/ext/libxml/ruby_xml_namespace.c +20 -12
- data/ext/libxml/ruby_xml_namespace.h +1 -0
- data/ext/libxml/ruby_xml_namespaces.c +40 -20
- data/ext/libxml/ruby_xml_node.c +71 -32
- data/ext/libxml/ruby_xml_node.h +2 -0
- data/ext/libxml/ruby_xml_parser.c +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +54 -47
- data/ext/libxml/ruby_xml_parser_context.h +1 -0
- data/ext/libxml/ruby_xml_reader.c +25 -15
- data/ext/libxml/ruby_xml_registry.c +31 -0
- data/ext/libxml/ruby_xml_registry.h +22 -0
- data/ext/libxml/ruby_xml_relaxng.c +21 -5
- data/ext/libxml/ruby_xml_relaxng.h +1 -0
- data/ext/libxml/ruby_xml_sax_parser.c +1 -1
- data/ext/libxml/ruby_xml_schema.c +18 -11
- data/ext/libxml/ruby_xml_schema.h +1 -0
- data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
- data/ext/libxml/ruby_xml_schema_element.c +8 -8
- data/ext/libxml/ruby_xml_schema_facet.c +7 -7
- data/ext/libxml/ruby_xml_schema_type.c +12 -19
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/ext/libxml/ruby_xml_writer.c +18 -6
- data/ext/libxml/ruby_xml_xpath.c +2 -2
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +72 -26
- data/ext/libxml/ruby_xml_xpath_expression.c +11 -5
- data/ext/libxml/ruby_xml_xpath_expression.h +1 -0
- data/ext/libxml/ruby_xml_xpath_object.c +69 -54
- data/ext/libxml/ruby_xml_xpath_object.h +3 -1
- data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
- data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
- data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
- data/lib/libxml/document.rb +0 -29
- data/lib/libxml/error.rb +30 -3
- data/lib/libxml/html_parser.rb +0 -16
- data/lib/libxml/node.rb +1 -3
- data/lib/libxml/parser.rb +0 -8
- data/lib/libxml/schema/attribute.rb +27 -19
- data/lib/libxml/schema/element.rb +20 -0
- data/lib/libxml/schema/type.rb +44 -21
- data/lib/libxml/schema.rb +47 -47
- data/lib/libxml-ruby.rb +30 -30
- data/libxml-ruby.gemspec +12 -16
- data/test/c14n/result/1-1-without-comments/example-1 +3 -3
- data/test/c14n/result/1-1-without-comments/example-2 +10 -10
- data/test/c14n/result/1-1-without-comments/example-3 +13 -13
- data/test/c14n/result/1-1-without-comments/example-4 +8 -8
- data/test/c14n/result/1-1-without-comments/example-5 +2 -2
- data/test/c14n/result/with-comments/example-1 +5 -5
- data/test/c14n/result/with-comments/example-2 +10 -10
- data/test/c14n/result/with-comments/example-3 +13 -13
- data/test/c14n/result/with-comments/example-4 +8 -8
- data/test/c14n/result/with-comments/example-5 +3 -3
- data/test/c14n/result/without-comments/example-1 +3 -3
- data/test/c14n/result/without-comments/example-2 +10 -10
- data/test/c14n/result/without-comments/example-3 +13 -13
- data/test/c14n/result/without-comments/example-4 +8 -8
- data/test/c14n/result/without-comments/example-5 +2 -2
- data/test/test_attr.rb +179 -180
- data/test/test_attr_decl.rb +131 -131
- data/test/test_attributes.rb +135 -135
- data/test/test_canonicalize.rb +122 -120
- data/test/test_document.rb +2 -4
- data/test/test_dtd.rb +12 -4
- data/test/test_encoding_sax.rb +114 -114
- data/test/test_error.rb +1 -1
- data/test/test_html_parser.rb +6 -2
- data/test/test_html_parser_context.rb +22 -22
- data/test/test_input_callbacks.rb +36 -0
- data/test/test_namespace.rb +1 -1
- data/test/test_namespaces.rb +200 -200
- data/test/test_node.rb +16 -0
- data/test/test_node_cdata.rb +50 -50
- data/test/test_node_comment.rb +32 -32
- data/test/test_node_copy.rb +40 -40
- data/test/test_node_edit.rb +176 -158
- data/test/test_node_pi.rb +37 -37
- data/test/test_node_text.rb +69 -69
- data/test/test_node_xlink.rb +28 -28
- data/test/test_parser.rb +5 -41
- data/test/test_parser_context.rb +198 -198
- data/test/test_properties.rb +38 -38
- data/test/test_reader.rb +55 -6
- data/test/test_relaxng.rb +59 -53
- data/test/test_sax_parser.rb +345 -345
- data/test/test_schema.rb +28 -0
- data/test/test_traversal.rb +152 -152
- data/test/test_writer.rb +0 -31
- data/test/test_xinclude.rb +20 -20
- data/test/test_xml.rb +3 -7
- data/test/test_xpath.rb +244 -244
- data/test/test_xpath_context.rb +87 -87
- data/test/test_xpath_expression.rb +37 -37
- metadata +32 -25
- data/README.rdoc +0 -208
- data/ext/libxml/extconf.h +0 -4
- data/ext/libxml/ruby_xml_cbg.c +0 -85
- data/lib/libxml/hpricot.rb +0 -78
- data/lib/libxml.rb +0 -5
- data/lib/xml/libxml.rb +0 -10
- data/lib/xml.rb +0 -14
- data/script/benchmark/depixelate +0 -634
- data/script/benchmark/hamlet.xml +0 -9055
- data/script/benchmark/parsecount +0 -170
- data/script/benchmark/sock_entries.xml +0 -507
- data/script/benchmark/throughput +0 -41
- data/script/test +0 -6
- data/test/test_deprecated_require.rb +0 -12
|
@@ -109,11 +109,18 @@ struct _xmlSchemaImport {
|
|
|
109
109
|
|
|
110
110
|
VALUE cXMLSchema;
|
|
111
111
|
|
|
112
|
-
static void rxml_schema_free(
|
|
112
|
+
static void rxml_schema_free(void *data)
|
|
113
113
|
{
|
|
114
|
+
xmlSchemaPtr xschema = (xmlSchemaPtr)data;
|
|
114
115
|
xmlSchemaFree(xschema);
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
const rb_data_type_t rxml_schema_type = {
|
|
119
|
+
"XML::Schema",
|
|
120
|
+
{NULL, rxml_schema_free, NULL},
|
|
121
|
+
NULL, NULL, 0
|
|
122
|
+
};
|
|
123
|
+
|
|
117
124
|
VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
|
|
118
125
|
{
|
|
119
126
|
VALUE result;
|
|
@@ -121,7 +128,7 @@ VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
|
|
|
121
128
|
if (!xschema)
|
|
122
129
|
rb_raise(rb_eArgError, "XML::Schema is required!");
|
|
123
130
|
|
|
124
|
-
result =
|
|
131
|
+
result = TypedData_Wrap_Struct(cXMLSchema, &rxml_schema_type, xschema);
|
|
125
132
|
|
|
126
133
|
/*
|
|
127
134
|
* Create these as instance variables to provide the output of inspect/to_str some
|
|
@@ -130,7 +137,7 @@ VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
|
|
|
130
137
|
rb_iv_set(result, "@target_namespace", QNIL_OR_STRING(xschema->targetNamespace));
|
|
131
138
|
rb_iv_set(result, "@name", QNIL_OR_STRING(xschema->name));
|
|
132
139
|
rb_iv_set(result, "@id", QNIL_OR_STRING(xschema->id));
|
|
133
|
-
rb_iv_set(result, "@version", QNIL_OR_STRING(xschema->
|
|
140
|
+
rb_iv_set(result, "@version", QNIL_OR_STRING(xschema->version));
|
|
134
141
|
|
|
135
142
|
return result;
|
|
136
143
|
}
|
|
@@ -179,7 +186,7 @@ static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
|
|
|
179
186
|
xmlDocPtr xdoc;
|
|
180
187
|
xmlSchemaParserCtxtPtr xparser;
|
|
181
188
|
|
|
182
|
-
|
|
189
|
+
TypedData_Get_Struct(document, xmlDoc, &rxml_document_data_type, xdoc);
|
|
183
190
|
|
|
184
191
|
xmlResetLastError();
|
|
185
192
|
xparser = xmlSchemaNewDocParserCtxt(xdoc);
|
|
@@ -219,7 +226,7 @@ static VALUE rxml_schema_document(VALUE self)
|
|
|
219
226
|
{
|
|
220
227
|
xmlSchemaPtr xschema;
|
|
221
228
|
|
|
222
|
-
|
|
229
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
223
230
|
|
|
224
231
|
return rxml_node_wrap(xmlDocGetRootElement(xschema->doc));
|
|
225
232
|
}
|
|
@@ -254,7 +261,7 @@ static VALUE rxml_schema_namespaces(VALUE self)
|
|
|
254
261
|
VALUE result;
|
|
255
262
|
xmlSchemaPtr xschema;
|
|
256
263
|
|
|
257
|
-
|
|
264
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
258
265
|
|
|
259
266
|
result = rb_ary_new();
|
|
260
267
|
xmlHashScan(xschema->schemasImports, (xmlHashScanner)scan_namespaces, (void *)result);
|
|
@@ -273,7 +280,7 @@ static VALUE rxml_schema_elements(VALUE self)
|
|
|
273
280
|
VALUE result = rb_hash_new();
|
|
274
281
|
xmlSchemaPtr xschema;
|
|
275
282
|
|
|
276
|
-
|
|
283
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
277
284
|
xmlHashScan(xschema->elemDecl, (xmlHashScanner)scan_schema_element, (void *)result);
|
|
278
285
|
|
|
279
286
|
return result;
|
|
@@ -300,7 +307,7 @@ static VALUE rxml_schema_imported_ns_elements(VALUE self)
|
|
|
300
307
|
xmlSchemaPtr xschema;
|
|
301
308
|
VALUE result = rb_hash_new();
|
|
302
309
|
|
|
303
|
-
|
|
310
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
304
311
|
|
|
305
312
|
if (xschema)
|
|
306
313
|
{
|
|
@@ -321,7 +328,7 @@ static VALUE rxml_schema_types(VALUE self)
|
|
|
321
328
|
VALUE result = rb_hash_new();
|
|
322
329
|
xmlSchemaPtr xschema;
|
|
323
330
|
|
|
324
|
-
|
|
331
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
325
332
|
|
|
326
333
|
if (xschema != NULL && xschema->typeDecl != NULL)
|
|
327
334
|
{
|
|
@@ -350,7 +357,7 @@ static VALUE rxml_schema_imported_types(VALUE self)
|
|
|
350
357
|
xmlSchemaPtr xschema;
|
|
351
358
|
VALUE result = rb_hash_new();
|
|
352
359
|
|
|
353
|
-
|
|
360
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
354
361
|
|
|
355
362
|
if (xschema)
|
|
356
363
|
{
|
|
@@ -381,7 +388,7 @@ static VALUE rxml_schema_imported_ns_types(VALUE self)
|
|
|
381
388
|
xmlSchemaPtr xschema;
|
|
382
389
|
VALUE result = rb_hash_new();
|
|
383
390
|
|
|
384
|
-
|
|
391
|
+
TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
|
|
385
392
|
|
|
386
393
|
if (xschema)
|
|
387
394
|
{
|
|
@@ -50,11 +50,11 @@ struct _xmlSchemaAttributeUseProhib {
|
|
|
50
50
|
|
|
51
51
|
VALUE cXMLSchemaAttribute;
|
|
52
52
|
|
|
53
|
-
static
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
53
|
+
static const rb_data_type_t rxml_schema_attribute_type = {
|
|
54
|
+
"XML::Schema::Attribute",
|
|
55
|
+
{NULL, NULL, NULL},
|
|
56
|
+
NULL, NULL, 0
|
|
57
|
+
};
|
|
58
58
|
|
|
59
59
|
VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr)
|
|
60
60
|
{
|
|
@@ -64,7 +64,7 @@ VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr)
|
|
|
64
64
|
if (!attr)
|
|
65
65
|
rb_raise(rb_eArgError, "XML::Schema::Attribute required!");
|
|
66
66
|
|
|
67
|
-
result =
|
|
67
|
+
result = TypedData_Wrap_Struct(cXMLSchemaAttribute, &rxml_schema_attribute_type, attr);
|
|
68
68
|
|
|
69
69
|
if (attr->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
|
|
70
70
|
tns_str = ((xmlSchemaAttributeUseProhibPtr) attr)->targetNamespace;
|
|
@@ -89,7 +89,7 @@ static VALUE rxml_schema_attribute_node(VALUE self)
|
|
|
89
89
|
{
|
|
90
90
|
xmlSchemaAttributeUsePtr attr;
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
TypedData_Get_Struct(self, xmlSchemaAttributeUse, &rxml_schema_attribute_type, attr);
|
|
93
93
|
|
|
94
94
|
return rxml_node_wrap(attr->node);
|
|
95
95
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
VALUE cXMLSchemaElement;
|
|
6
6
|
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
7
|
+
static const rb_data_type_t rxml_schema_element_type = {
|
|
8
|
+
"XML::Schema::Element",
|
|
9
|
+
{NULL, NULL, NULL},
|
|
10
|
+
NULL, NULL, 0
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelem)
|
|
14
14
|
{
|
|
@@ -17,7 +17,7 @@ VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelem)
|
|
|
17
17
|
if (!xelem)
|
|
18
18
|
rb_raise(rb_eArgError, "XML::Schema::Element is required!");
|
|
19
19
|
|
|
20
|
-
result =
|
|
20
|
+
result = TypedData_Wrap_Struct(cXMLSchemaElement, &rxml_schema_element_type, xelem);
|
|
21
21
|
|
|
22
22
|
rb_iv_set(result, "@name", QNIL_OR_STRING(xelem->name));
|
|
23
23
|
rb_iv_set(result, "@value", QNIL_OR_STRING(xelem->value));
|
|
@@ -31,7 +31,7 @@ static VALUE rxml_schema_element_node(VALUE self)
|
|
|
31
31
|
{
|
|
32
32
|
xmlSchemaElementPtr xelem;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
TypedData_Get_Struct(self, xmlSchemaElement, &rxml_schema_element_type, xelem);
|
|
35
35
|
|
|
36
36
|
return rxml_node_wrap(xelem->node);
|
|
37
37
|
}
|
|
@@ -41,7 +41,7 @@ static VALUE rxml_schema_element_annot(VALUE self)
|
|
|
41
41
|
xmlSchemaElementPtr xelem;
|
|
42
42
|
VALUE annotation = Qnil;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
TypedData_Get_Struct(self, xmlSchemaElement, &rxml_schema_element_type, xelem);
|
|
45
45
|
|
|
46
46
|
if ((xelem->annot != NULL) && (xelem->annot->content != NULL))
|
|
47
47
|
{
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
VALUE cXMLSchemaFacet;
|
|
9
9
|
|
|
10
|
-
static
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
10
|
+
static const rb_data_type_t rxml_schema_facet_type = {
|
|
11
|
+
"XML::Schema::Facet",
|
|
12
|
+
{NULL, NULL, NULL},
|
|
13
|
+
NULL, NULL, 0
|
|
14
|
+
};
|
|
15
15
|
|
|
16
16
|
VALUE rxml_wrap_schema_facet(xmlSchemaFacetPtr facet)
|
|
17
17
|
{
|
|
@@ -20,7 +20,7 @@ VALUE rxml_wrap_schema_facet(xmlSchemaFacetPtr facet)
|
|
|
20
20
|
if (!facet)
|
|
21
21
|
rb_raise(rb_eArgError, "XML::Schema::Facet required!");
|
|
22
22
|
|
|
23
|
-
result =
|
|
23
|
+
result = TypedData_Wrap_Struct(cXMLSchemaFacet, &rxml_schema_facet_type, facet);
|
|
24
24
|
|
|
25
25
|
rb_iv_set(result, "@kind", INT2NUM(facet->type));
|
|
26
26
|
rb_iv_set(result, "@value", QNIL_OR_STRING(facet->value));
|
|
@@ -35,7 +35,7 @@ static VALUE rxml_schema_facet_node(VALUE self)
|
|
|
35
35
|
{
|
|
36
36
|
xmlSchemaFacetPtr facet;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
TypedData_Get_Struct(self, xmlSchemaFacet, &rxml_schema_facet_type, facet);
|
|
39
39
|
|
|
40
40
|
return rxml_node_wrap(facet->node);
|
|
41
41
|
}
|
|
@@ -46,11 +46,11 @@ a group definition, a XML_SCHEMA_EXTRA_QNAMEREF (if a reference),
|
|
|
46
46
|
|
|
47
47
|
VALUE cXMLSchemaType;
|
|
48
48
|
|
|
49
|
-
static
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
49
|
+
static const rb_data_type_t rxml_schema_type_type = {
|
|
50
|
+
"XML::Schema::Type",
|
|
51
|
+
{NULL, NULL, NULL},
|
|
52
|
+
NULL, NULL, 0
|
|
53
|
+
};
|
|
54
54
|
|
|
55
55
|
VALUE rxml_wrap_schema_type(xmlSchemaTypePtr xtype)
|
|
56
56
|
{
|
|
@@ -59,7 +59,7 @@ VALUE rxml_wrap_schema_type(xmlSchemaTypePtr xtype)
|
|
|
59
59
|
if (!xtype)
|
|
60
60
|
rb_raise(rb_eArgError, "XML::Schema::Type required!");
|
|
61
61
|
|
|
62
|
-
result =
|
|
62
|
+
result = TypedData_Wrap_Struct(cXMLSchemaType, &rxml_schema_type_type, xtype);
|
|
63
63
|
|
|
64
64
|
rb_iv_set(result, "@name", QNIL_OR_STRING(xtype->name));
|
|
65
65
|
rb_iv_set(result, "@namespace", QNIL_OR_STRING(xtype->targetNamespace));
|
|
@@ -72,7 +72,7 @@ static VALUE rxml_schema_type_base(VALUE self)
|
|
|
72
72
|
{
|
|
73
73
|
xmlSchemaTypePtr xtype;
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype);
|
|
76
76
|
|
|
77
77
|
return (xtype->baseType != xtype) ? rxml_wrap_schema_type(xtype->baseType) : Qnil;
|
|
78
78
|
}
|
|
@@ -81,7 +81,7 @@ static VALUE rxml_schema_type_node(VALUE self)
|
|
|
81
81
|
{
|
|
82
82
|
xmlSchemaTypePtr xtype;
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype);
|
|
85
85
|
|
|
86
86
|
return (xtype->node != NULL) ? rxml_node_wrap(xtype->node) : Qnil;
|
|
87
87
|
}
|
|
@@ -93,7 +93,7 @@ static VALUE rxml_schema_type_facets(VALUE self)
|
|
|
93
93
|
VALUE result = rb_ary_new();
|
|
94
94
|
VALUE facet;
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype);
|
|
97
97
|
|
|
98
98
|
xfacet = xtype->facets;
|
|
99
99
|
|
|
@@ -112,7 +112,7 @@ static VALUE rxml_schema_type_annot(VALUE self)
|
|
|
112
112
|
VALUE result = Qnil;
|
|
113
113
|
xmlSchemaTypePtr xtype;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype);
|
|
116
116
|
|
|
117
117
|
if(xtype != NULL && xtype->annot != NULL && xtype->annot->content != NULL)
|
|
118
118
|
{
|
|
@@ -198,7 +198,7 @@ static VALUE rxml_schema_type_elements(VALUE self)
|
|
|
198
198
|
VALUE result = rb_hash_new();
|
|
199
199
|
xmlSchemaTypePtr xtype;
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype);
|
|
202
202
|
rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, result);
|
|
203
203
|
|
|
204
204
|
return result;
|
|
@@ -212,7 +212,7 @@ static VALUE rxml_schema_type_attributes(VALUE self)
|
|
|
212
212
|
xmlSchemaItemListPtr xuses;
|
|
213
213
|
int i;
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype);
|
|
216
216
|
xuses = xtype->attrUses;
|
|
217
217
|
|
|
218
218
|
if (xuses != NULL)
|
|
@@ -229,13 +229,6 @@ static VALUE rxml_schema_type_attributes(VALUE self)
|
|
|
229
229
|
|
|
230
230
|
void rxml_init_schema_type(void)
|
|
231
231
|
{
|
|
232
|
-
/* Add in infinity support for ruby 1.8.7 */
|
|
233
|
-
#if !defined(RUBY_VM) && defined(INFINITY)
|
|
234
|
-
ID infinityId = rb_intern("INFINITY");
|
|
235
|
-
if (rb_const_defined(rb_cFloat, infinityId) == Qfalse)
|
|
236
|
-
rb_define_const(rb_cFloat, "INFINITY", rb_float_new(INFINITY));
|
|
237
|
-
#endif
|
|
238
|
-
|
|
239
232
|
cXMLSchemaType = rb_define_class_under(cXMLSchema, "Type", rb_cObject);
|
|
240
233
|
rb_undef_alloc_func(cXMLSchemaType);
|
|
241
234
|
|
|
@@ -1,9 +1,9 @@
|
|
|
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 "
|
|
5
|
-
#define RUBY_LIBXML_VERNUM
|
|
6
|
-
#define RUBY_LIBXML_VER_MAJ
|
|
4
|
+
#define RUBY_LIBXML_VERSION "6.0.0"
|
|
5
|
+
#define RUBY_LIBXML_VERNUM 600
|
|
6
|
+
#define RUBY_LIBXML_VER_MAJ 6
|
|
7
7
|
#define RUBY_LIBXML_VER_MIN 0
|
|
8
|
-
#define RUBY_LIBXML_VER_MIC
|
|
8
|
+
#define RUBY_LIBXML_VER_MIC 0
|
|
9
9
|
#define RUBY_LIBXML_VER_PATCH 0
|
|
@@ -41,8 +41,9 @@ typedef struct
|
|
|
41
41
|
int closed;
|
|
42
42
|
} rxml_writer_object;
|
|
43
43
|
|
|
44
|
-
static void rxml_writer_free(
|
|
44
|
+
static void rxml_writer_free(void* data)
|
|
45
45
|
{
|
|
46
|
+
rxml_writer_object* rwo = (rxml_writer_object*)data;
|
|
46
47
|
xmlBufferPtr buffer = rwo->buffer;
|
|
47
48
|
|
|
48
49
|
rwo->closed = 1;
|
|
@@ -56,24 +57,31 @@ static void rxml_writer_free(rxml_writer_object* rwo)
|
|
|
56
57
|
xfree(rwo);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
static void rxml_writer_mark(
|
|
60
|
+
static void rxml_writer_mark(void* data)
|
|
60
61
|
{
|
|
62
|
+
rxml_writer_object* rwo = (rxml_writer_object*)data;
|
|
61
63
|
if (!NIL_P(rwo->output))
|
|
62
64
|
{
|
|
63
65
|
rb_gc_mark(rwo->output);
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
static const rb_data_type_t rxml_writer_data_type = {
|
|
70
|
+
.wrap_struct_name = "LibXML::XML::Writer",
|
|
71
|
+
.function = { .dmark = rxml_writer_mark, .dfree = rxml_writer_free },
|
|
72
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
73
|
+
};
|
|
74
|
+
|
|
67
75
|
static VALUE rxml_writer_wrap(rxml_writer_object* rwo)
|
|
68
76
|
{
|
|
69
|
-
return
|
|
77
|
+
return TypedData_Wrap_Struct(cXMLWriter, &rxml_writer_data_type, rwo);
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
static rxml_writer_object* rxml_textwriter_get(VALUE obj)
|
|
73
81
|
{
|
|
74
82
|
rxml_writer_object* rwo;
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
TypedData_Get_Struct(obj, rxml_writer_object, &rxml_writer_data_type, rwo);
|
|
77
85
|
|
|
78
86
|
return rwo;
|
|
79
87
|
}
|
|
@@ -188,6 +196,7 @@ static VALUE rxml_writer_doc(VALUE klass)
|
|
|
188
196
|
{
|
|
189
197
|
xmlDocPtr doc;
|
|
190
198
|
rxml_writer_object* rwo;
|
|
199
|
+
VALUE output, result;
|
|
191
200
|
|
|
192
201
|
rwo = ALLOC(rxml_writer_object);
|
|
193
202
|
rwo->buffer = NULL;
|
|
@@ -199,9 +208,12 @@ static VALUE rxml_writer_doc(VALUE klass)
|
|
|
199
208
|
{
|
|
200
209
|
rxml_raise(xmlGetLastError());
|
|
201
210
|
}
|
|
202
|
-
|
|
211
|
+
output = rxml_document_wrap(doc);
|
|
212
|
+
rwo->output = output;
|
|
203
213
|
|
|
204
|
-
|
|
214
|
+
result = rxml_writer_wrap(rwo);
|
|
215
|
+
RB_GC_GUARD(output);
|
|
216
|
+
return result;
|
|
205
217
|
}
|
|
206
218
|
|
|
207
219
|
/* ===== public instance methods ===== */
|
data/ext/libxml/ruby_xml_xpath.c
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
|
|
80
80
|
VALUE mXPath;
|
|
81
81
|
|
|
82
|
-
VALUE rxml_xpath_to_value(xmlXPathContextPtr xctxt, xmlXPathObjectPtr xobject)
|
|
82
|
+
VALUE rxml_xpath_to_value(VALUE document, xmlXPathContextPtr xctxt, xmlXPathObjectPtr xobject)
|
|
83
83
|
{
|
|
84
84
|
VALUE result;
|
|
85
85
|
int type;
|
|
@@ -96,7 +96,7 @@ VALUE rxml_xpath_to_value(xmlXPathContextPtr xctxt, xmlXPathObjectPtr xobject)
|
|
|
96
96
|
switch (type = xobject->type)
|
|
97
97
|
{
|
|
98
98
|
case XPATH_NODESET:
|
|
99
|
-
result = rxml_xpath_object_wrap(xctxt->doc, xobject);
|
|
99
|
+
result = rxml_xpath_object_wrap(document, xctxt->doc, xobject);
|
|
100
100
|
break;
|
|
101
101
|
case XPATH_BOOLEAN:
|
|
102
102
|
result = (xobject->boolval != 0) ? Qtrue : Qfalse;
|
data/ext/libxml/ruby_xml_xpath.h
CHANGED
|
@@ -9,7 +9,7 @@ extern VALUE mXPath;
|
|
|
9
9
|
|
|
10
10
|
void rxml_init_xpath(void);
|
|
11
11
|
|
|
12
|
-
VALUE rxml_xpath_to_value(xmlXPathContextPtr, xmlXPathObjectPtr);
|
|
12
|
+
VALUE rxml_xpath_to_value(VALUE, xmlXPathContextPtr, xmlXPathObjectPtr);
|
|
13
13
|
xmlXPathObjectPtr rxml_xpath_from_value(VALUE);
|
|
14
14
|
|
|
15
15
|
#endif
|
|
@@ -28,20 +28,39 @@
|
|
|
28
28
|
|
|
29
29
|
VALUE cXMLXPathContext;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
typedef struct rxml_xpath_context
|
|
32
32
|
{
|
|
33
|
-
|
|
33
|
+
xmlXPathContextPtr xctxt;
|
|
34
|
+
VALUE document;
|
|
35
|
+
} rxml_xpath_context;
|
|
36
|
+
|
|
37
|
+
static void rxml_xpath_context_free(void *data)
|
|
38
|
+
{
|
|
39
|
+
rxml_xpath_context *wrapper = (rxml_xpath_context *)data;
|
|
40
|
+
if (wrapper == NULL) return;
|
|
41
|
+
if (wrapper->xctxt)
|
|
42
|
+
{
|
|
43
|
+
xmlXPathFreeContext(wrapper->xctxt);
|
|
44
|
+
}
|
|
45
|
+
xfree(wrapper);
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
static void rxml_xpath_context_mark(
|
|
48
|
+
static void rxml_xpath_context_mark(void *data)
|
|
37
49
|
{
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
rxml_xpath_context *wrapper = (rxml_xpath_context *)data;
|
|
51
|
+
if (wrapper == NULL) return;
|
|
52
|
+
rb_gc_mark(wrapper->document);
|
|
40
53
|
}
|
|
41
54
|
|
|
55
|
+
static const rb_data_type_t rxml_xpath_context_data_type = {
|
|
56
|
+
.wrap_struct_name = "LibXML::XML::XPath::Context",
|
|
57
|
+
.function = { .dmark = rxml_xpath_context_mark, .dfree = rxml_xpath_context_free },
|
|
58
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
59
|
+
};
|
|
60
|
+
|
|
42
61
|
static VALUE rxml_xpath_context_alloc(VALUE klass)
|
|
43
62
|
{
|
|
44
|
-
return
|
|
63
|
+
return TypedData_Wrap_Struct(cXMLXPathContext, &rxml_xpath_context_data_type, NULL);
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
/* call-seq:
|
|
@@ -58,14 +77,29 @@ static VALUE rxml_xpath_context_alloc(VALUE klass)
|
|
|
58
77
|
static VALUE rxml_xpath_context_initialize(VALUE self, VALUE document)
|
|
59
78
|
{
|
|
60
79
|
xmlDocPtr xdoc;
|
|
80
|
+
rxml_xpath_context *wrapper;
|
|
61
81
|
|
|
62
82
|
if (rb_obj_is_kind_of(document, cXMLDocument) != Qtrue)
|
|
63
83
|
{
|
|
64
84
|
rb_raise(rb_eTypeError, "Supplied argument must be a document or node.");
|
|
65
85
|
}
|
|
66
86
|
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
TypedData_Get_Struct(document, xmlDoc, &rxml_document_data_type, xdoc);
|
|
88
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
89
|
+
|
|
90
|
+
if (wrapper == NULL)
|
|
91
|
+
{
|
|
92
|
+
wrapper = ALLOC(rxml_xpath_context);
|
|
93
|
+
wrapper->xctxt = NULL;
|
|
94
|
+
wrapper->document = document;
|
|
95
|
+
RTYPEDDATA_DATA(self) = wrapper;
|
|
96
|
+
}
|
|
97
|
+
else if (wrapper->xctxt)
|
|
98
|
+
{
|
|
99
|
+
xmlXPathFreeContext(wrapper->xctxt);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
wrapper->xctxt = xmlXPathNewContext(xdoc);
|
|
69
103
|
|
|
70
104
|
return self;
|
|
71
105
|
}
|
|
@@ -78,12 +112,10 @@ static VALUE rxml_xpath_context_initialize(VALUE self, VALUE document)
|
|
|
78
112
|
*/
|
|
79
113
|
static VALUE rxml_xpath_context_doc(VALUE self)
|
|
80
114
|
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
xdoc = ctxt->doc;
|
|
86
|
-
return rxml_document_wrap(xdoc);
|
|
115
|
+
rxml_xpath_context *wrapper;
|
|
116
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
117
|
+
if (wrapper == NULL) return Qnil;
|
|
118
|
+
return wrapper->document;
|
|
87
119
|
}
|
|
88
120
|
|
|
89
121
|
/*
|
|
@@ -97,8 +129,10 @@ static VALUE rxml_xpath_context_doc(VALUE self)
|
|
|
97
129
|
*/
|
|
98
130
|
static VALUE rxml_xpath_context_register_namespace(VALUE self, VALUE prefix, VALUE uri)
|
|
99
131
|
{
|
|
132
|
+
rxml_xpath_context *wrapper;
|
|
100
133
|
xmlXPathContextPtr ctxt;
|
|
101
|
-
|
|
134
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
135
|
+
ctxt = wrapper->xctxt;
|
|
102
136
|
|
|
103
137
|
/* Prefix could be a symbol. */
|
|
104
138
|
prefix = rb_obj_as_string(prefix);
|
|
@@ -128,21 +162,23 @@ static VALUE rxml_xpath_context_register_namespace(VALUE self, VALUE prefix, VAL
|
|
|
128
162
|
static VALUE rxml_xpath_context_register_namespaces_from_node(VALUE self,
|
|
129
163
|
VALUE node)
|
|
130
164
|
{
|
|
165
|
+
rxml_xpath_context *wrapper;
|
|
131
166
|
xmlXPathContextPtr xctxt;
|
|
132
167
|
xmlNodePtr xnode;
|
|
133
168
|
xmlNsPtr *xnsArr;
|
|
134
169
|
|
|
135
|
-
|
|
170
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
171
|
+
xctxt = wrapper->xctxt;
|
|
136
172
|
|
|
137
173
|
if (rb_obj_is_kind_of(node, cXMLDocument) == Qtrue)
|
|
138
174
|
{
|
|
139
175
|
xmlDocPtr xdoc;
|
|
140
|
-
|
|
176
|
+
TypedData_Get_Struct(node, xmlDoc, &rxml_document_data_type, xdoc);
|
|
141
177
|
xnode = xmlDocGetRootElement(xdoc);
|
|
142
178
|
}
|
|
143
179
|
else if (rb_obj_is_kind_of(node, cXMLNode) == Qtrue)
|
|
144
180
|
{
|
|
145
|
-
|
|
181
|
+
TypedData_Get_Struct(node, xmlNode, &rxml_node_data_type, xnode);
|
|
146
182
|
}
|
|
147
183
|
else
|
|
148
184
|
{
|
|
@@ -198,9 +234,11 @@ static VALUE rxml_xpath_context_register_namespaces(VALUE self, VALUE nslist)
|
|
|
198
234
|
char *cp;
|
|
199
235
|
long i;
|
|
200
236
|
VALUE rprefix, ruri;
|
|
237
|
+
rxml_xpath_context *wrapper;
|
|
201
238
|
xmlXPathContextPtr xctxt;
|
|
202
239
|
|
|
203
|
-
|
|
240
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
241
|
+
xctxt = wrapper->xctxt;
|
|
204
242
|
|
|
205
243
|
/* Need to loop through the 2nd argument and iterate through the
|
|
206
244
|
* list of namespaces that we want to allow */
|
|
@@ -249,11 +287,13 @@ static VALUE rxml_xpath_context_register_namespaces(VALUE self, VALUE nslist)
|
|
|
249
287
|
*/
|
|
250
288
|
static VALUE rxml_xpath_context_node_set(VALUE self, VALUE node)
|
|
251
289
|
{
|
|
290
|
+
rxml_xpath_context *wrapper;
|
|
252
291
|
xmlXPathContextPtr xctxt;
|
|
253
292
|
xmlNodePtr xnode;
|
|
254
293
|
|
|
255
|
-
|
|
256
|
-
|
|
294
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
295
|
+
xctxt = wrapper->xctxt;
|
|
296
|
+
TypedData_Get_Struct(node, xmlNode, &rxml_node_data_type, xnode);
|
|
257
297
|
xctxt->node = xnode;
|
|
258
298
|
return node;
|
|
259
299
|
}
|
|
@@ -268,11 +308,13 @@ static VALUE rxml_xpath_context_node_set(VALUE self, VALUE node)
|
|
|
268
308
|
*/
|
|
269
309
|
static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr)
|
|
270
310
|
{
|
|
311
|
+
rxml_xpath_context *wrapper;
|
|
271
312
|
xmlXPathContextPtr xctxt;
|
|
272
313
|
xmlXPathObjectPtr xobject;
|
|
273
314
|
xmlXPathCompExprPtr xcompexpr;
|
|
274
315
|
|
|
275
|
-
|
|
316
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
317
|
+
xctxt = wrapper->xctxt;
|
|
276
318
|
|
|
277
319
|
if (TYPE(xpath_expr) == T_STRING)
|
|
278
320
|
{
|
|
@@ -281,7 +323,7 @@ static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr)
|
|
|
281
323
|
}
|
|
282
324
|
else if (rb_obj_is_kind_of(xpath_expr, cXMLXPathExpression))
|
|
283
325
|
{
|
|
284
|
-
|
|
326
|
+
TypedData_Get_Struct(xpath_expr, xmlXPathCompExpr, &rxml_xpath_expression_data_type, xcompexpr);
|
|
285
327
|
xobject = xmlXPathCompiledEval(xcompexpr, xctxt);
|
|
286
328
|
}
|
|
287
329
|
else
|
|
@@ -290,7 +332,7 @@ static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr)
|
|
|
290
332
|
"Argument should be an instance of a String or XPath::Expression");
|
|
291
333
|
}
|
|
292
334
|
|
|
293
|
-
return rxml_xpath_to_value(xctxt, xobject);
|
|
335
|
+
return rxml_xpath_to_value(wrapper->document, xctxt, xobject);
|
|
294
336
|
}
|
|
295
337
|
|
|
296
338
|
#if LIBXML_VERSION >= 20626
|
|
@@ -308,11 +350,13 @@ static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr)
|
|
|
308
350
|
static VALUE
|
|
309
351
|
rxml_xpath_context_enable_cache(int argc, VALUE *argv, VALUE self)
|
|
310
352
|
{
|
|
353
|
+
rxml_xpath_context *wrapper;
|
|
311
354
|
xmlXPathContextPtr xctxt;
|
|
312
355
|
VALUE size;
|
|
313
356
|
int value = -1;
|
|
314
357
|
|
|
315
|
-
|
|
358
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
359
|
+
xctxt = wrapper->xctxt;
|
|
316
360
|
|
|
317
361
|
if (rb_scan_args(argc, argv, "01", &size) == 1)
|
|
318
362
|
{
|
|
@@ -334,8 +378,10 @@ rxml_xpath_context_enable_cache(int argc, VALUE *argv, VALUE self)
|
|
|
334
378
|
static VALUE
|
|
335
379
|
rxml_xpath_context_disable_cache(VALUE self)
|
|
336
380
|
{
|
|
381
|
+
rxml_xpath_context *wrapper;
|
|
337
382
|
xmlXPathContextPtr xctxt;
|
|
338
|
-
|
|
383
|
+
TypedData_Get_Struct(self, rxml_xpath_context, &rxml_xpath_context_data_type, wrapper);
|
|
384
|
+
xctxt = wrapper->xctxt;
|
|
339
385
|
|
|
340
386
|
if (xmlXPathContextSetCache(xctxt, 0, 0, 0) == -1)
|
|
341
387
|
rxml_raise(xmlGetLastError());
|