libxml-ruby 5.0.5 → 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 -923
- data/LICENSE +20 -20
- data/README.md +67 -0
- data/Rakefile +77 -98
- data/ext/libxml/extconf.rb +34 -20
- data/ext/libxml/libxml.c +67 -79
- data/ext/libxml/ruby_libxml.h +1 -1
- data/ext/libxml/ruby_xml_attr.c +338 -333
- data/ext/libxml/ruby_xml_attr.h +13 -12
- data/ext/libxml/ruby_xml_attr_decl.c +19 -12
- data/ext/libxml/ruby_xml_attr_decl.h +11 -11
- 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 +10 -9
- data/ext/libxml/ruby_xml_html_parser.c +91 -91
- data/ext/libxml/ruby_xml_html_parser.h +10 -10
- data/ext/libxml/ruby_xml_html_parser_context.c +19 -6
- data/ext/libxml/ruby_xml_html_parser_context.h +11 -10
- data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
- data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
- data/ext/libxml/ruby_xml_input_cbg.c +45 -17
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_io.c +49 -47
- data/ext/libxml/ruby_xml_io.h +10 -10
- data/ext/libxml/ruby_xml_namespace.c +20 -12
- data/ext/libxml/ruby_xml_namespace.h +11 -10
- data/ext/libxml/ruby_xml_namespaces.c +313 -293
- data/ext/libxml/ruby_xml_namespaces.h +9 -9
- data/ext/libxml/ruby_xml_node.c +71 -32
- data/ext/libxml/ruby_xml_node.h +15 -13
- data/ext/libxml/ruby_xml_parser.c +91 -91
- data/ext/libxml/ruby_xml_parser_context.c +54 -47
- data/ext/libxml/ruby_xml_parser_context.h +11 -10
- data/ext/libxml/ruby_xml_reader.c +25 -15
- data/ext/libxml/ruby_xml_reader.h +14 -14
- 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 +9 -8
- data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
- data/ext/libxml/ruby_xml_sax_parser.c +1 -1
- data/ext/libxml/ruby_xml_sax_parser.h +10 -10
- data/ext/libxml/ruby_xml_schema.c +18 -11
- data/ext/libxml/ruby_xml_schema.h +26 -25
- data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
- data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
- data/ext/libxml/ruby_xml_schema_element.c +8 -8
- data/ext/libxml/ruby_xml_schema_element.h +11 -11
- data/ext/libxml/ruby_xml_schema_facet.c +50 -50
- data/ext/libxml/ruby_xml_schema_facet.h +9 -9
- data/ext/libxml/ruby_xml_schema_type.c +12 -19
- data/ext/libxml/ruby_xml_schema_type.h +9 -9
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/ext/libxml/ruby_xml_writer.c +1136 -1124
- data/ext/libxml/ruby_xml_writer.h +6 -6
- data/ext/libxml/ruby_xml_xinclude.c +20 -20
- data/ext/libxml/ruby_xml_xinclude.h +11 -11
- data/ext/libxml/ruby_xml_xpath.c +195 -195
- data/ext/libxml/ruby_xml_xpath.h +15 -15
- data/ext/libxml/ruby_xml_xpath_context.c +408 -362
- data/ext/libxml/ruby_xml_xpath_context.h +9 -9
- data/ext/libxml/ruby_xml_xpath_expression.c +11 -5
- data/ext/libxml/ruby_xml_xpath_expression.h +11 -10
- data/ext/libxml/ruby_xml_xpath_object.c +69 -54
- data/ext/libxml/ruby_xml_xpath_object.h +19 -17
- 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 +6 -3
- data/test/test_helper.rb +1 -0
- 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 +469 -468
- 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 +33 -27
- data/README.rdoc +0 -208
- data/ext/libxml/extconf.h +0 -3
- 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.rb +0 -5
- data/test/test_deprecated_require.rb +0 -12
data/ext/libxml/ruby_xml_io.c
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
2
|
-
|
|
3
|
-
#include "ruby_libxml.h"
|
|
4
|
-
#include <ruby/io.h>
|
|
5
|
-
|
|
6
|
-
static ID READ_METHOD;
|
|
7
|
-
static ID WRITE_METHOD;
|
|
8
|
-
|
|
9
|
-
/* This method is called by libxml when it wants to read
|
|
10
|
-
more data from a stream. We go with the duck typing
|
|
11
|
-
solution to support StringIO objects. */
|
|
12
|
-
int rxml_read_callback(void *context, char *buffer, int len)
|
|
13
|
-
{
|
|
14
|
-
VALUE io = (VALUE) context;
|
|
15
|
-
VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
|
|
16
|
-
size_t size;
|
|
17
|
-
|
|
18
|
-
if (string == Qnil)
|
|
19
|
-
return 0;
|
|
20
|
-
|
|
21
|
-
size = RSTRING_LEN(string);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
written
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
2
|
+
|
|
3
|
+
#include "ruby_libxml.h"
|
|
4
|
+
#include <ruby/io.h>
|
|
5
|
+
|
|
6
|
+
static ID READ_METHOD;
|
|
7
|
+
static ID WRITE_METHOD;
|
|
8
|
+
|
|
9
|
+
/* This method is called by libxml when it wants to read
|
|
10
|
+
more data from a stream. We go with the duck typing
|
|
11
|
+
solution to support StringIO objects. */
|
|
12
|
+
int rxml_read_callback(void *context, char *buffer, int len)
|
|
13
|
+
{
|
|
14
|
+
VALUE io = (VALUE) context;
|
|
15
|
+
VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
|
|
16
|
+
size_t size;
|
|
17
|
+
|
|
18
|
+
if (string == Qnil)
|
|
19
|
+
return 0;
|
|
20
|
+
|
|
21
|
+
size = RSTRING_LEN(string);
|
|
22
|
+
if (size > (size_t)len)
|
|
23
|
+
size = (size_t)len;
|
|
24
|
+
memcpy(buffer, StringValuePtr(string), size);
|
|
25
|
+
|
|
26
|
+
return (int)size;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
int rxml_write_callback(VALUE io, const char *buffer, int len)
|
|
30
|
+
{
|
|
31
|
+
if (rb_io_check_io(io) == Qnil)
|
|
32
|
+
{
|
|
33
|
+
// Could be StringIO
|
|
34
|
+
VALUE written, string;
|
|
35
|
+
string = rb_external_str_new_with_enc(buffer, (long)len, rb_enc_get(io));
|
|
36
|
+
written = rb_funcall(io, WRITE_METHOD, 1, string);
|
|
37
|
+
return NUM2INT(written);
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
{
|
|
41
|
+
return (int)rb_io_bufwrite(io, buffer, (size_t)len);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void rxml_init_io(void)
|
|
46
|
+
{
|
|
47
|
+
READ_METHOD = rb_intern("read");
|
|
48
|
+
WRITE_METHOD = rb_intern("write");
|
|
49
|
+
}
|
data/ext/libxml/ruby_xml_io.h
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
2
|
-
|
|
3
|
-
#ifndef __RXML_IO__
|
|
4
|
-
#define __RXML_IO__
|
|
5
|
-
|
|
6
|
-
int rxml_read_callback(void *context, char *buffer, int len);
|
|
7
|
-
int rxml_write_callback(VALUE io, const char *buffer, int len);
|
|
8
|
-
void rxml_init_io(void);
|
|
9
|
-
|
|
10
|
-
#endif
|
|
1
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
2
|
+
|
|
3
|
+
#ifndef __RXML_IO__
|
|
4
|
+
#define __RXML_IO__
|
|
5
|
+
|
|
6
|
+
int rxml_read_callback(void *context, char *buffer, int len);
|
|
7
|
+
int rxml_write_callback(VALUE io, const char *buffer, int len);
|
|
8
|
+
void rxml_init_io(void);
|
|
9
|
+
|
|
10
|
+
#endif
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
VALUE cXMLNamespace;
|
|
7
7
|
|
|
8
|
+
const rb_data_type_t rxml_namespace_type = {
|
|
9
|
+
"libxml/namespace",
|
|
10
|
+
{NULL, NULL, NULL},
|
|
11
|
+
};
|
|
12
|
+
|
|
8
13
|
/* Document-class: LibXML::XML::Namespace
|
|
9
14
|
*
|
|
10
15
|
* The Namespace class represents an XML namespace.
|
|
@@ -26,12 +31,12 @@ VALUE cXMLNamespace;
|
|
|
26
31
|
|
|
27
32
|
static VALUE rxml_namespace_alloc(VALUE klass)
|
|
28
33
|
{
|
|
29
|
-
return
|
|
34
|
+
return TypedData_Wrap_Struct(klass, &rxml_namespace_type, NULL);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
VALUE rxml_namespace_wrap(xmlNsPtr xns)
|
|
33
38
|
{
|
|
34
|
-
return
|
|
39
|
+
return TypedData_Wrap_Struct(cXMLNamespace, &rxml_namespace_type, xns);
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
|
|
@@ -50,15 +55,14 @@ static VALUE rxml_namespace_initialize(VALUE self, VALUE node, VALUE prefix,
|
|
|
50
55
|
xmlChar *xmlPrefix;
|
|
51
56
|
xmlNsPtr xns;
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
Data_Get_Struct(node, xmlNode, xnode);
|
|
58
|
+
TypedData_Get_Struct(node, xmlNode, &rxml_node_data_type, xnode);
|
|
55
59
|
xmlResetLastError();
|
|
56
60
|
|
|
57
61
|
/* Prefix can be null - that means its the default namespace */
|
|
58
62
|
xmlPrefix = NIL_P(prefix) ? NULL : (xmlChar *)StringValuePtr(prefix);
|
|
59
63
|
xns = xmlNewNs(xnode, (xmlChar*) StringValuePtr(href), xmlPrefix);
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
RTYPEDDATA_DATA(self) = xns;
|
|
62
66
|
return self;
|
|
63
67
|
}
|
|
64
68
|
|
|
@@ -75,7 +79,7 @@ static VALUE rxml_namespace_initialize(VALUE self, VALUE node, VALUE prefix,
|
|
|
75
79
|
static VALUE rxml_namespace_href_get(VALUE self)
|
|
76
80
|
{
|
|
77
81
|
xmlNsPtr xns;
|
|
78
|
-
|
|
82
|
+
TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
|
|
79
83
|
if (xns->href == NULL)
|
|
80
84
|
return Qnil;
|
|
81
85
|
else
|
|
@@ -91,7 +95,7 @@ static VALUE rxml_namespace_href_get(VALUE self)
|
|
|
91
95
|
static VALUE rxml_namespace_node_type(VALUE self)
|
|
92
96
|
{
|
|
93
97
|
xmlNsPtr xns;
|
|
94
|
-
|
|
98
|
+
TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
|
|
95
99
|
return INT2NUM(xns->type);
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -110,7 +114,7 @@ static VALUE rxml_namespace_node_type(VALUE self)
|
|
|
110
114
|
static VALUE rxml_namespace_prefix_get(VALUE self)
|
|
111
115
|
{
|
|
112
116
|
xmlNsPtr xns;
|
|
113
|
-
|
|
117
|
+
TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
|
|
114
118
|
if (xns->prefix == NULL)
|
|
115
119
|
return Qnil;
|
|
116
120
|
else
|
|
@@ -132,11 +136,15 @@ static VALUE rxml_namespace_prefix_get(VALUE self)
|
|
|
132
136
|
static VALUE rxml_namespace_next(VALUE self)
|
|
133
137
|
{
|
|
134
138
|
xmlNsPtr xns;
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
|
|
140
|
+
/* Guard against libxml2's XPath hack where xns->next stores a parent
|
|
141
|
+
element pointer instead of the next namespace (see xmlXPathNodeSetAddNs
|
|
142
|
+
in xpath.c). xmlNs.type and xmlNode.type share the same struct offset,
|
|
143
|
+
so checking the type is safe even when next points to an xmlNode. */
|
|
144
|
+
if (xns == NULL || xns->next == NULL || xns->next->type != XML_LOCAL_NAMESPACE)
|
|
137
145
|
return (Qnil);
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
|
|
147
|
+
return rxml_namespace_wrap(xns->next);
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
void rxml_init_namespace(void)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
2
|
-
|
|
3
|
-
#ifndef __RXML_NAMESPACE__
|
|
4
|
-
#define __RXML_NAMESPACE__
|
|
5
|
-
|
|
6
|
-
extern VALUE cXMLNamespace;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
2
|
+
|
|
3
|
+
#ifndef __RXML_NAMESPACE__
|
|
4
|
+
#define __RXML_NAMESPACE__
|
|
5
|
+
|
|
6
|
+
extern VALUE cXMLNamespace;
|
|
7
|
+
extern const rb_data_type_t rxml_namespace_type;
|
|
8
|
+
|
|
9
|
+
void rxml_init_namespace(void);
|
|
10
|
+
VALUE rxml_namespace_wrap(xmlNsPtr xns);
|
|
11
|
+
#endif
|