libxml-ruby 1.1.3-x86-mswin32-60 → 1.1.4-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +1 -1
- data/LICENSE +22 -22
- data/README +160 -160
- data/Rakefile +0 -9
- data/ext/libxml/Makefile +156 -0
- data/ext/libxml/extconf.h +5 -0
- data/ext/libxml/extconf.rb +4 -160
- data/ext/libxml/libxml-ruby.so.a +0 -0
- data/ext/libxml/libxml.o +0 -0
- data/ext/libxml/libxml_ruby.so +0 -0
- data/ext/libxml/mkmf.log +129 -0
- data/ext/libxml/ruby_xml.o +0 -0
- data/ext/libxml/ruby_xml_attr.c +1 -1
- data/ext/libxml/ruby_xml_attr.h +1 -1
- data/ext/libxml/ruby_xml_attr.o +0 -0
- data/ext/libxml/ruby_xml_attr_decl.o +0 -0
- data/ext/libxml/ruby_xml_attributes.o +0 -0
- data/ext/libxml/ruby_xml_cbg.o +0 -0
- data/ext/libxml/ruby_xml_document.c +936 -936
- data/ext/libxml/ruby_xml_document.h +1 -1
- data/ext/libxml/ruby_xml_document.o +0 -0
- data/ext/libxml/ruby_xml_dtd.o +0 -0
- data/ext/libxml/ruby_xml_encoding.o +0 -0
- data/ext/libxml/ruby_xml_error.o +0 -0
- data/ext/libxml/ruby_xml_html_parser.c +1 -1
- data/ext/libxml/ruby_xml_html_parser.h +1 -1
- data/ext/libxml/ruby_xml_html_parser.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_input_cbg.o +0 -0
- data/ext/libxml/ruby_xml_io.o +0 -0
- data/ext/libxml/ruby_xml_namespace.c +1 -1
- data/ext/libxml/ruby_xml_namespace.h +1 -1
- data/ext/libxml/ruby_xml_namespace.o +0 -0
- data/ext/libxml/ruby_xml_namespaces.o +0 -0
- data/ext/libxml/ruby_xml_node.c +1386 -1386
- data/ext/libxml/ruby_xml_node.h +1 -1
- data/ext/libxml/ruby_xml_node.o +0 -0
- data/ext/libxml/ruby_xml_parser.c +1 -1
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser.o +0 -0
- data/ext/libxml/ruby_xml_parser_context.c +1 -1
- data/ext/libxml/ruby_xml_parser_context.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_reader.o +0 -0
- data/ext/libxml/ruby_xml_relaxng.o +0 -0
- data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
- data/ext/libxml/ruby_xml_sax_parser.c +1 -1
- data/ext/libxml/ruby_xml_sax_parser.h +1 -1
- data/ext/libxml/ruby_xml_sax_parser.o +0 -0
- data/ext/libxml/ruby_xml_schema.o +0 -0
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/ext/libxml/ruby_xml_xinclude.c +1 -1
- data/ext/libxml/ruby_xml_xinclude.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.o +0 -0
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath.o +0 -0
- data/ext/libxml/ruby_xml_xpath_context.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.o +0 -0
- data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
- data/ext/libxml/ruby_xml_xpath_object.o +0 -0
- data/ext/libxml/ruby_xml_xpointer.c +1 -1
- data/ext/libxml/ruby_xml_xpointer.h +1 -1
- data/ext/libxml/ruby_xml_xpointer.o +0 -0
- data/ext/mingw/build.rake +3 -3
- data/ext/mingw/libiconv-2.dll +0 -0
- data/ext/mingw/libxml2-2.dll +0 -0
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/lib/libxml.rb +29 -29
- data/test/model/merge_bug_data.xml +58 -58
- data/test/model/rubynet.xml +79 -79
- data/test/model/xinclude.xml +4 -4
- data/test/tc_attr.rb +170 -170
- data/test/tc_document.rb +113 -113
- data/test/tc_document_write.rb +117 -117
- data/test/tc_dtd.rb +123 -123
- data/test/tc_html_parser.rb +137 -137
- data/test/tc_node.rb +180 -180
- data/test/tc_node_cdata.rb +49 -49
- data/test/tc_node_comment.rb +30 -30
- data/test/tc_node_edit.rb +157 -157
- data/test/tc_node_xlink.rb +26 -26
- data/test/tc_parser.rb +329 -329
- data/test/tc_parser_context.rb +185 -185
- data/test/tc_reader.rb +283 -283
- data/test/tc_sax_parser.rb +273 -273
- data/test/tc_schema.rb +51 -51
- data/test/tc_xinclude.rb +19 -19
- data/test/tc_xpath.rb +193 -193
- data/test/tc_xpointer.rb +72 -72
- metadata +55 -14
- data/ext/libxml/build.log +0 -4
data/test/model/xinclude.xml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
<document xmlns:xi="http://www.w3.org/2001/XInclude">
|
3
|
-
<p>This libxml2 binding has the following project information:
|
4
|
-
<code><xi:include href="rubynet_project" parse="text"/></code></p>
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<document xmlns:xi="http://www.w3.org/2001/XInclude">
|
3
|
+
<p>This libxml2 binding has the following project information:
|
4
|
+
<code><xi:include href="rubynet_project" parse="text"/></code></p>
|
5
5
|
</document>
|
data/test/tc_attr.rb
CHANGED
@@ -1,170 +1,170 @@
|
|
1
|
-
require 'xml'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class AttrNodeTest < Test::Unit::TestCase
|
5
|
-
def setup()
|
6
|
-
xp = XML::Parser.string(<<-EOS)
|
7
|
-
<CityModel
|
8
|
-
xmlns="http://www.opengis.net/examples"
|
9
|
-
xmlns:city="http://www.opengis.net/examples"
|
10
|
-
xmlns:gml="http://www.opengis.net/gml"
|
11
|
-
xmlns:xlink="http://www.w3.org/1999/xlink"
|
12
|
-
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
|
13
|
-
xsi:schemaLocation="http://www.opengis.net/examples city.xsd">
|
14
|
-
<type>City</type>
|
15
|
-
<cityMember name="Cambridge"
|
16
|
-
xlink:type="simple"
|
17
|
-
xlink:title="Trinity Lane"
|
18
|
-
xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239"
|
19
|
-
gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
|
20
|
-
</CityModel>
|
21
|
-
EOS
|
22
|
-
|
23
|
-
@doc = xp.parse
|
24
|
-
end
|
25
|
-
|
26
|
-
def teardown()
|
27
|
-
@doc = nil
|
28
|
-
end
|
29
|
-
|
30
|
-
def city_member
|
31
|
-
@doc.find('/city:CityModel/city:cityMember').first
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_types
|
35
|
-
attribute = city_member.attributes.get_attribute('name')
|
36
|
-
assert_instance_of(XML::Attr, attribute)
|
37
|
-
assert_equal('attribute', attribute.node_type_name)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_name
|
41
|
-
attribute = city_member.attributes.get_attribute('name')
|
42
|
-
assert_equal('name', attribute.name)
|
43
|
-
|
44
|
-
attribute = city_member.attributes.get_attribute('href')
|
45
|
-
assert_equal('href', attribute.name)
|
46
|
-
assert_equal('xlink', attribute.ns.prefix)
|
47
|
-
assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
|
48
|
-
|
49
|
-
attribute = city_member.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
|
50
|
-
assert_equal('href', attribute.name)
|
51
|
-
assert_equal('xlink', attribute.ns.prefix)
|
52
|
-
assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_value
|
56
|
-
attribute = city_member.attributes.get_attribute('name')
|
57
|
-
assert_equal('Cambridge', attribute.value)
|
58
|
-
|
59
|
-
attribute = city_member.attributes.get_attribute('href')
|
60
|
-
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_set_value
|
64
|
-
attribute = city_member.attributes.get_attribute('name')
|
65
|
-
attribute.value = 'London'
|
66
|
-
assert_equal('London', attribute.value)
|
67
|
-
|
68
|
-
attribute = city_member.attributes.get_attribute('href')
|
69
|
-
attribute.value = 'http://i.have.changed'
|
70
|
-
assert_equal('http://i.have.changed', attribute.value)
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_set_nil
|
74
|
-
attribute = city_member.attributes.get_attribute('name')
|
75
|
-
assert_raise(TypeError) do
|
76
|
-
attribute.value = nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_create
|
81
|
-
attributes = city_member.attributes
|
82
|
-
assert_equal(5, attributes.length)
|
83
|
-
|
84
|
-
attr = XML::Attr.new(city_member, 'size', '50,000')
|
85
|
-
assert_instance_of(XML::Attr, attr)
|
86
|
-
|
87
|
-
attributes = city_member.attributes
|
88
|
-
assert_equal(6, attributes.length)
|
89
|
-
|
90
|
-
assert_equal(attributes['size'], '50,000')
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_create_on_node
|
94
|
-
attributes = city_member.attributes
|
95
|
-
assert_equal(5, attributes.length)
|
96
|
-
|
97
|
-
attributes['country'] = 'England'
|
98
|
-
|
99
|
-
attributes = city_member.attributes
|
100
|
-
assert_equal(6, attributes.length)
|
101
|
-
|
102
|
-
assert_equal(attributes['country'], 'England')
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_create_ns
|
106
|
-
assert_equal(5, city_member.attributes.length)
|
107
|
-
|
108
|
-
ns = XML::NS.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
|
109
|
-
attr = XML::Attr.new(city_member, 'rating', 'rocks', ns)
|
110
|
-
assert_instance_of(XML::Attr, attr)
|
111
|
-
assert_equal('rating', attr.name)
|
112
|
-
assert_equal('rocks', attr.value)
|
113
|
-
|
114
|
-
attributes = city_member.attributes
|
115
|
-
assert_equal(6, attributes.length)
|
116
|
-
|
117
|
-
assert_equal('rocks', city_member['rating'])
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_remove
|
121
|
-
attributes = city_member.attributes
|
122
|
-
assert_equal(5, attributes.length)
|
123
|
-
|
124
|
-
attribute = attributes.get_attribute('name')
|
125
|
-
assert_not_nil(attribute.parent)
|
126
|
-
assert(attribute.parent?)
|
127
|
-
|
128
|
-
attribute.remove!
|
129
|
-
assert_equal(4, attributes.length)
|
130
|
-
assert_nil(attribute.parent)
|
131
|
-
assert(!attribute.parent?)
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_first
|
135
|
-
attribute = city_member.attributes.first
|
136
|
-
assert_instance_of(XML::Attr, attribute)
|
137
|
-
assert_equal('name', attribute.name)
|
138
|
-
assert_equal('Cambridge', attribute.value)
|
139
|
-
|
140
|
-
attribute = attribute.next
|
141
|
-
assert_instance_of(XML::Attr, attribute)
|
142
|
-
assert_equal('type', attribute.name)
|
143
|
-
assert_equal('simple', attribute.value)
|
144
|
-
|
145
|
-
attribute = attribute.next
|
146
|
-
assert_instance_of(XML::Attr, attribute)
|
147
|
-
assert_equal('title', attribute.name)
|
148
|
-
assert_equal('Trinity Lane', attribute.value)
|
149
|
-
|
150
|
-
attribute = attribute.next
|
151
|
-
assert_instance_of(XML::Attr, attribute)
|
152
|
-
assert_equal('href', attribute.name)
|
153
|
-
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
154
|
-
|
155
|
-
attribute = attribute.next
|
156
|
-
assert_instance_of(XML::Attr, attribute)
|
157
|
-
assert_equal('remoteSchema', attribute.name)
|
158
|
-
assert_equal("city.xsd#xpointer(//complexType[@name='RoadType'])", attribute.value)
|
159
|
-
|
160
|
-
attribute = attribute.next
|
161
|
-
assert_nil(attribute)
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_no_attributes
|
165
|
-
element = @doc.find('/city:CityModel/city:type').first
|
166
|
-
|
167
|
-
assert_not_nil(element.attributes)
|
168
|
-
assert_equal(0, element.attributes.length)
|
169
|
-
end
|
170
|
-
end
|
1
|
+
require 'xml'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class AttrNodeTest < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.string(<<-EOS)
|
7
|
+
<CityModel
|
8
|
+
xmlns="http://www.opengis.net/examples"
|
9
|
+
xmlns:city="http://www.opengis.net/examples"
|
10
|
+
xmlns:gml="http://www.opengis.net/gml"
|
11
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
12
|
+
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
|
13
|
+
xsi:schemaLocation="http://www.opengis.net/examples city.xsd">
|
14
|
+
<type>City</type>
|
15
|
+
<cityMember name="Cambridge"
|
16
|
+
xlink:type="simple"
|
17
|
+
xlink:title="Trinity Lane"
|
18
|
+
xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239"
|
19
|
+
gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
|
20
|
+
</CityModel>
|
21
|
+
EOS
|
22
|
+
|
23
|
+
@doc = xp.parse
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown()
|
27
|
+
@doc = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def city_member
|
31
|
+
@doc.find('/city:CityModel/city:cityMember').first
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_types
|
35
|
+
attribute = city_member.attributes.get_attribute('name')
|
36
|
+
assert_instance_of(XML::Attr, attribute)
|
37
|
+
assert_equal('attribute', attribute.node_type_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_name
|
41
|
+
attribute = city_member.attributes.get_attribute('name')
|
42
|
+
assert_equal('name', attribute.name)
|
43
|
+
|
44
|
+
attribute = city_member.attributes.get_attribute('href')
|
45
|
+
assert_equal('href', attribute.name)
|
46
|
+
assert_equal('xlink', attribute.ns.prefix)
|
47
|
+
assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
|
48
|
+
|
49
|
+
attribute = city_member.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
|
50
|
+
assert_equal('href', attribute.name)
|
51
|
+
assert_equal('xlink', attribute.ns.prefix)
|
52
|
+
assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_value
|
56
|
+
attribute = city_member.attributes.get_attribute('name')
|
57
|
+
assert_equal('Cambridge', attribute.value)
|
58
|
+
|
59
|
+
attribute = city_member.attributes.get_attribute('href')
|
60
|
+
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_set_value
|
64
|
+
attribute = city_member.attributes.get_attribute('name')
|
65
|
+
attribute.value = 'London'
|
66
|
+
assert_equal('London', attribute.value)
|
67
|
+
|
68
|
+
attribute = city_member.attributes.get_attribute('href')
|
69
|
+
attribute.value = 'http://i.have.changed'
|
70
|
+
assert_equal('http://i.have.changed', attribute.value)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_set_nil
|
74
|
+
attribute = city_member.attributes.get_attribute('name')
|
75
|
+
assert_raise(TypeError) do
|
76
|
+
attribute.value = nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_create
|
81
|
+
attributes = city_member.attributes
|
82
|
+
assert_equal(5, attributes.length)
|
83
|
+
|
84
|
+
attr = XML::Attr.new(city_member, 'size', '50,000')
|
85
|
+
assert_instance_of(XML::Attr, attr)
|
86
|
+
|
87
|
+
attributes = city_member.attributes
|
88
|
+
assert_equal(6, attributes.length)
|
89
|
+
|
90
|
+
assert_equal(attributes['size'], '50,000')
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_create_on_node
|
94
|
+
attributes = city_member.attributes
|
95
|
+
assert_equal(5, attributes.length)
|
96
|
+
|
97
|
+
attributes['country'] = 'England'
|
98
|
+
|
99
|
+
attributes = city_member.attributes
|
100
|
+
assert_equal(6, attributes.length)
|
101
|
+
|
102
|
+
assert_equal(attributes['country'], 'England')
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_create_ns
|
106
|
+
assert_equal(5, city_member.attributes.length)
|
107
|
+
|
108
|
+
ns = XML::NS.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
|
109
|
+
attr = XML::Attr.new(city_member, 'rating', 'rocks', ns)
|
110
|
+
assert_instance_of(XML::Attr, attr)
|
111
|
+
assert_equal('rating', attr.name)
|
112
|
+
assert_equal('rocks', attr.value)
|
113
|
+
|
114
|
+
attributes = city_member.attributes
|
115
|
+
assert_equal(6, attributes.length)
|
116
|
+
|
117
|
+
assert_equal('rocks', city_member['rating'])
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_remove
|
121
|
+
attributes = city_member.attributes
|
122
|
+
assert_equal(5, attributes.length)
|
123
|
+
|
124
|
+
attribute = attributes.get_attribute('name')
|
125
|
+
assert_not_nil(attribute.parent)
|
126
|
+
assert(attribute.parent?)
|
127
|
+
|
128
|
+
attribute.remove!
|
129
|
+
assert_equal(4, attributes.length)
|
130
|
+
assert_nil(attribute.parent)
|
131
|
+
assert(!attribute.parent?)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_first
|
135
|
+
attribute = city_member.attributes.first
|
136
|
+
assert_instance_of(XML::Attr, attribute)
|
137
|
+
assert_equal('name', attribute.name)
|
138
|
+
assert_equal('Cambridge', attribute.value)
|
139
|
+
|
140
|
+
attribute = attribute.next
|
141
|
+
assert_instance_of(XML::Attr, attribute)
|
142
|
+
assert_equal('type', attribute.name)
|
143
|
+
assert_equal('simple', attribute.value)
|
144
|
+
|
145
|
+
attribute = attribute.next
|
146
|
+
assert_instance_of(XML::Attr, attribute)
|
147
|
+
assert_equal('title', attribute.name)
|
148
|
+
assert_equal('Trinity Lane', attribute.value)
|
149
|
+
|
150
|
+
attribute = attribute.next
|
151
|
+
assert_instance_of(XML::Attr, attribute)
|
152
|
+
assert_equal('href', attribute.name)
|
153
|
+
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
154
|
+
|
155
|
+
attribute = attribute.next
|
156
|
+
assert_instance_of(XML::Attr, attribute)
|
157
|
+
assert_equal('remoteSchema', attribute.name)
|
158
|
+
assert_equal("city.xsd#xpointer(//complexType[@name='RoadType'])", attribute.value)
|
159
|
+
|
160
|
+
attribute = attribute.next
|
161
|
+
assert_nil(attribute)
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_no_attributes
|
165
|
+
element = @doc.find('/city:CityModel/city:type').first
|
166
|
+
|
167
|
+
assert_not_nil(element.attributes)
|
168
|
+
assert_equal(0, element.attributes.length)
|
169
|
+
end
|
170
|
+
end
|
data/test/tc_document.rb
CHANGED
@@ -1,113 +1,113 @@
|
|
1
|
-
require "xml"
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
|
5
|
-
class TestDocument < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
8
|
-
assert_instance_of(XML::Parser, xp)
|
9
|
-
@doc = xp.parse
|
10
|
-
assert_instance_of(XML::Document, @doc)
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@doc = nil
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_klass
|
18
|
-
assert_instance_of(XML::Document, @doc)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_context
|
22
|
-
context = @doc.context
|
23
|
-
assert_instance_of(XML::XPath::Context, context)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_find
|
27
|
-
set = @doc.find('/ruby_array/fixnum')
|
28
|
-
assert_instance_of(XML::XPath::Object, set)
|
29
|
-
assert_raise(NoMethodError) {
|
30
|
-
xpt = set.xpath
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_compression
|
35
|
-
if XML.enabled_zlib?
|
36
|
-
0.upto(9) do |i|
|
37
|
-
assert_equal(i, @doc.compression = i)
|
38
|
-
assert_equal(i, @doc.compression)
|
39
|
-
end
|
40
|
-
|
41
|
-
9.downto(0) do |i|
|
42
|
-
assert_equal(i, @doc.compression = i)
|
43
|
-
assert_equal(i, @doc.compression)
|
44
|
-
end
|
45
|
-
|
46
|
-
10.upto(20) do |i|
|
47
|
-
# assert_equal(9, @doc.compression = i)
|
48
|
-
assert_equal(i, @doc.compression = i) # This works around a bug in Ruby 1.8
|
49
|
-
assert_equal(9, @doc.compression)
|
50
|
-
end
|
51
|
-
|
52
|
-
-1.downto(-10) do |i|
|
53
|
-
# assert_equal(0, @doc.compression = i)
|
54
|
-
assert_equal(i, @doc.compression = i) # FIXME This bug should get fixed ASAP
|
55
|
-
assert_equal(0, @doc.compression)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_version
|
61
|
-
assert_equal('1.0', @doc.version)
|
62
|
-
|
63
|
-
doc = XML::Document.new('6.9')
|
64
|
-
assert_equal('6.9', doc.version)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_write_root
|
68
|
-
@doc.root = XML::Node.new('rubynet')
|
69
|
-
assert_instance_of(XML::Node, @doc.root)
|
70
|
-
assert_instance_of(XML::Document, @doc.root.doc)
|
71
|
-
assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rubynet/>\n",
|
72
|
-
@doc.to_s(:indent => false))
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_encoding
|
76
|
-
doc = XML::Document.new
|
77
|
-
assert_equal(XML::Encoding::NONE, doc.encoding)
|
78
|
-
|
79
|
-
file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.xml'))
|
80
|
-
doc = XML::Document.file(file)
|
81
|
-
assert_equal(XML::Encoding::UTF_8, doc.encoding)
|
82
|
-
|
83
|
-
doc.encoding = XML::Encoding::ISO_8859_1
|
84
|
-
assert_equal(XML::Encoding::ISO_8859_1, doc.encoding)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_doc_node_type
|
88
|
-
assert_equal XML::Node::DOCUMENT_NODE, XML::Document.new.node_type
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_doc_node_type_name
|
92
|
-
assert_equal 'document_xml', XML::Document.new.node_type_name
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_xhtml
|
96
|
-
doc = XML::Document.new
|
97
|
-
assert ! doc.xhtml?
|
98
|
-
xhtml_dtd = XML::Dtd.new "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", nil, doc, true
|
99
|
-
assert doc.xhtml?
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_import_node
|
103
|
-
doc1 = XML::Parser.string('<nums><one></one></nums>').parse
|
104
|
-
doc2 = XML::Parser.string('<nums><two></two></nums>').parse
|
105
|
-
|
106
|
-
node = doc1.root.child
|
107
|
-
|
108
|
-
doc2.root << doc2.import(node)
|
109
|
-
|
110
|
-
assert_equal("<nums>\n <two/>\n <one/>\n</nums>",
|
111
|
-
doc2.root.to_s)
|
112
|
-
end
|
113
|
-
end
|
1
|
+
require "xml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
|
5
|
+
class TestDocument < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
8
|
+
assert_instance_of(XML::Parser, xp)
|
9
|
+
@doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@doc = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_klass
|
18
|
+
assert_instance_of(XML::Document, @doc)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_context
|
22
|
+
context = @doc.context
|
23
|
+
assert_instance_of(XML::XPath::Context, context)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_find
|
27
|
+
set = @doc.find('/ruby_array/fixnum')
|
28
|
+
assert_instance_of(XML::XPath::Object, set)
|
29
|
+
assert_raise(NoMethodError) {
|
30
|
+
xpt = set.xpath
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_compression
|
35
|
+
if XML.enabled_zlib?
|
36
|
+
0.upto(9) do |i|
|
37
|
+
assert_equal(i, @doc.compression = i)
|
38
|
+
assert_equal(i, @doc.compression)
|
39
|
+
end
|
40
|
+
|
41
|
+
9.downto(0) do |i|
|
42
|
+
assert_equal(i, @doc.compression = i)
|
43
|
+
assert_equal(i, @doc.compression)
|
44
|
+
end
|
45
|
+
|
46
|
+
10.upto(20) do |i|
|
47
|
+
# assert_equal(9, @doc.compression = i)
|
48
|
+
assert_equal(i, @doc.compression = i) # This works around a bug in Ruby 1.8
|
49
|
+
assert_equal(9, @doc.compression)
|
50
|
+
end
|
51
|
+
|
52
|
+
-1.downto(-10) do |i|
|
53
|
+
# assert_equal(0, @doc.compression = i)
|
54
|
+
assert_equal(i, @doc.compression = i) # FIXME This bug should get fixed ASAP
|
55
|
+
assert_equal(0, @doc.compression)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_version
|
61
|
+
assert_equal('1.0', @doc.version)
|
62
|
+
|
63
|
+
doc = XML::Document.new('6.9')
|
64
|
+
assert_equal('6.9', doc.version)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_write_root
|
68
|
+
@doc.root = XML::Node.new('rubynet')
|
69
|
+
assert_instance_of(XML::Node, @doc.root)
|
70
|
+
assert_instance_of(XML::Document, @doc.root.doc)
|
71
|
+
assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rubynet/>\n",
|
72
|
+
@doc.to_s(:indent => false))
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_encoding
|
76
|
+
doc = XML::Document.new
|
77
|
+
assert_equal(XML::Encoding::NONE, doc.encoding)
|
78
|
+
|
79
|
+
file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.xml'))
|
80
|
+
doc = XML::Document.file(file)
|
81
|
+
assert_equal(XML::Encoding::UTF_8, doc.encoding)
|
82
|
+
|
83
|
+
doc.encoding = XML::Encoding::ISO_8859_1
|
84
|
+
assert_equal(XML::Encoding::ISO_8859_1, doc.encoding)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_doc_node_type
|
88
|
+
assert_equal XML::Node::DOCUMENT_NODE, XML::Document.new.node_type
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_doc_node_type_name
|
92
|
+
assert_equal 'document_xml', XML::Document.new.node_type_name
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_xhtml
|
96
|
+
doc = XML::Document.new
|
97
|
+
assert ! doc.xhtml?
|
98
|
+
xhtml_dtd = XML::Dtd.new "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", nil, doc, true
|
99
|
+
assert doc.xhtml?
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_import_node
|
103
|
+
doc1 = XML::Parser.string('<nums><one></one></nums>').parse
|
104
|
+
doc2 = XML::Parser.string('<nums><two></two></nums>').parse
|
105
|
+
|
106
|
+
node = doc1.root.child
|
107
|
+
|
108
|
+
doc2.root << doc2.import(node)
|
109
|
+
|
110
|
+
assert_equal("<nums>\n <two/>\n <one/>\n</nums>",
|
111
|
+
doc2.root.to_s)
|
112
|
+
end
|
113
|
+
end
|