libxml-ruby 0.5.4 → 0.6.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.
- data/LICENSE +23 -23
- data/README +144 -144
- data/ext/libxml/extconf.rb +26 -27
- data/ext/libxml/libxml.c +7 -37
- data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
- data/ext/libxml/ruby_xml_attr.c +405 -387
- data/ext/libxml/ruby_xml_attr.h +19 -18
- data/ext/libxml/ruby_xml_document.c +1111 -1115
- data/ext/libxml/ruby_xml_document.h +27 -24
- data/ext/libxml/ruby_xml_dtd.c +168 -168
- data/ext/libxml/ruby_xml_html_parser.c +449 -450
- data/ext/libxml/ruby_xml_html_parser.h +1 -1
- data/ext/libxml/ruby_xml_input_cbg.c +158 -158
- data/ext/libxml/ruby_xml_node.c +2410 -2395
- data/ext/libxml/ruby_xml_node.h +1 -1
- data/ext/libxml/ruby_xml_node_set.c +170 -170
- data/ext/libxml/ruby_xml_node_set.h +1 -1
- data/ext/libxml/ruby_xml_ns.c +153 -153
- data/ext/libxml/ruby_xml_ns.h +1 -1
- data/ext/libxml/ruby_xml_parser.c +1425 -1422
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +750 -716
- data/ext/libxml/ruby_xml_parser_context.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +900 -896
- data/ext/libxml/ruby_xml_sax_parser.c +485 -485
- data/ext/libxml/ruby_xml_sax_parser.h +1 -1
- data/ext/libxml/ruby_xml_schema.c +146 -142
- data/ext/libxml/ruby_xml_state.c +5 -6
- data/ext/libxml/ruby_xml_state.h +1 -0
- data/ext/libxml/ruby_xml_tree.c +43 -43
- data/ext/libxml/ruby_xml_tree.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.c +20 -20
- data/ext/libxml/ruby_xml_xinclude.h +1 -1
- data/ext/libxml/ruby_xml_xpath.c +243 -252
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +118 -118
- data/ext/libxml/ruby_xml_xpath_context.h +1 -1
- data/ext/libxml/ruby_xml_xpath_object.c +43 -29
- data/ext/libxml/ruby_xml_xpath_object.h +0 -1
- data/ext/libxml/ruby_xml_xpointer.c +100 -100
- data/ext/libxml/ruby_xml_xpointer.h +1 -1
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
- data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
- data/ext/libxml/sax_parser_callbacks.inc +213 -213
- data/ext/libxml/version.h +9 -9
- data/lib/libxml.rb +24 -3
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/test/dtd-test.rb +24 -24
- data/test/etc_doc_to_s.rb +1 -3
- data/test/ets_copy_bug.rb +21 -21
- data/test/ets_copy_bug2.rb +32 -32
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +1 -0
- data/test/{model/default_validation_bug.rb → gc.log} +0 -0
- data/test/merge_bug.rb +55 -55
- data/test/schema-test.rb +74 -74
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -52
- data/test/tc_xml_document_write.rb +24 -24
- data/test/tc_xml_document_write2.rb +54 -54
- data/test/tc_xml_document_write3.rb +96 -96
- data/test/tc_xml_html_parser.rb +63 -63
- data/test/tc_xml_node.rb +59 -59
- data/test/tc_xml_node2.rb +25 -25
- data/test/tc_xml_node3.rb +27 -27
- data/test/tc_xml_node4.rb +86 -86
- data/test/tc_xml_node5.rb +52 -52
- data/test/tc_xml_node6.rb +27 -27
- data/test/tc_xml_node7.rb +35 -35
- data/test/tc_xml_node8.rb +32 -32
- data/test/tc_xml_node9.rb +32 -32
- data/test/tc_xml_node_set.rb +24 -24
- data/test/tc_xml_node_set2.rb +37 -37
- data/test/tc_xml_node_xlink.rb +28 -28
- data/test/tc_xml_parser.rb +190 -178
- data/test/tc_xml_parser2.rb +16 -17
- data/test/tc_xml_parser3.rb +23 -23
- data/test/tc_xml_parser4.rb +33 -33
- data/test/tc_xml_parser5.rb +27 -27
- data/test/tc_xml_parser6.rb +23 -23
- data/test/tc_xml_parser7.rb +28 -28
- data/test/tc_xml_parser8.rb +32 -32
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -88
- data/test/tc_xml_reader.rb +112 -109
- data/test/tc_xml_sax_parser.rb +104 -94
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -30
- data/test/tc_xml_xpath.rb +38 -38
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -78
- data/vc/libxml.sln +20 -0
- data/vc/libxml.vcproj +389 -0
- data/work/Rakefile +247 -0
- data/work/task/make +26 -0
- data/work/task/memory +37 -0
- data/work/task/rdoc +39 -0
- data/work/task/setup +1616 -0
- data/work/task/test +29 -0
- data/work/test/ets_runner.rb +33 -0
- data/work/test/libxml_test.rb +3 -0
- data/work/test/runner.rb +0 -0
- data/work/test/runner_ets.rb +33 -0
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
- metadata +158 -189
- data/MANIFEST +0 -138
- data/NOTES +0 -9
- data/Rakefile +0 -38
- data/TODO +0 -75
- data/VERSION +0 -1
- data/log/Changelog-0.txt +0 -426
- data/log/Changelog.txt +0 -435
- data/meta/project.yaml +0 -27
- data/meta/unixname +0 -1
- data/setup.rb +0 -1472
- data/site/css/normal.css +0 -182
- data/site/img/raze-tiny.png +0 -0
- data/site/img/red-cube.jpg +0 -0
- data/site/img/xml-ruby.png +0 -0
- data/site/index.xml +0 -43
- data/site/install.xml +0 -77
- data/site/layout.rhtml +0 -38
- data/site/layout.xsl +0 -67
- data/site/license.xml +0 -32
- data/site/log/changelog.xml +0 -1324
- data/site/log/changelog.xsl +0 -42
- data/test/model/merge_bug_data.xml +0 -58
- data/test/model/rubynet.xml +0 -78
- data/test/model/rubynet_project +0 -13
- data/test/model/saxtest.xml +0 -5
- data/test/model/simple.xml +0 -7
- data/test/model/xinclude.xml +0 -5
data/test/tc_xml_node4.rb
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node4 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.new()
|
|
7
|
-
@str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
|
8
|
-
assert_equal(@str, xp.string = @str)
|
|
9
|
-
doc = xp.parse
|
|
10
|
-
xp2=XML::Parser.new()
|
|
11
|
-
xp2.string=@str
|
|
12
|
-
@doc2 = xp2.parse
|
|
13
|
-
assert_instance_of(XML::Document, doc)
|
|
14
|
-
assert_instance_of(XML::Node, doc.root)
|
|
15
|
-
@root = doc.root
|
|
16
|
-
assert_instance_of(XML::Node, @root)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def teardown()
|
|
20
|
-
@root = nil
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_xml_node_eql?()
|
|
24
|
-
first1 = @root.child
|
|
25
|
-
first2 = @doc2.root.child
|
|
26
|
-
|
|
27
|
-
assert_not_equal first1.object_id, first2.object_id
|
|
28
|
-
assert first1.eql?(first2)
|
|
29
|
-
assert first2.eql?(first1)
|
|
30
|
-
|
|
31
|
-
assert_equal first1, first2
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_xml_node_hash()
|
|
35
|
-
first1 = @root.child
|
|
36
|
-
first2 = @doc2.root.child
|
|
37
|
-
|
|
38
|
-
assert_not_equal first1.object_id, first2.object_id
|
|
39
|
-
assert_equal first1.hash, first2.hash
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_01_xml_node_remove!()
|
|
43
|
-
first = @root.child
|
|
44
|
-
|
|
45
|
-
assert_equal 'fixnum', first.name
|
|
46
|
-
assert_equal 'fixnum', first.next.name
|
|
47
|
-
|
|
48
|
-
first.next.remove!
|
|
49
|
-
|
|
50
|
-
assert_equal 'fixnum', first.name
|
|
51
|
-
assert_equal nil, first.next
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_02_xml_node_remove!()
|
|
55
|
-
first = @root.child
|
|
56
|
-
|
|
57
|
-
assert_equal 'fixnum', first.name
|
|
58
|
-
assert_equal 'fixnum', first.next.name
|
|
59
|
-
assert_equal 'one', first.content
|
|
60
|
-
|
|
61
|
-
first.remove!
|
|
62
|
-
|
|
63
|
-
first = @root.child
|
|
64
|
-
assert_equal 'fixnum', first.name
|
|
65
|
-
assert_equal nil, first.next
|
|
66
|
-
assert_equal 'two', first.content
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# TODO need to test namespace support
|
|
70
|
-
def test_xml_node_find_first()
|
|
71
|
-
first = @root.find_first('//fixnum')
|
|
72
|
-
|
|
73
|
-
assert_equal 'one', first.content
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def test_xml_node_property_set_remove()
|
|
77
|
-
assert_equal 'booga', @root['uga']
|
|
78
|
-
@root['uga'] = nil
|
|
79
|
-
assert_equal nil , @root['uga']
|
|
80
|
-
assert_equal "<ruby_array foo=\"bar\">\n <fixnum>one</fixnum>\n <fixnum>two</fixnum>\n</ruby_array>",
|
|
81
|
-
@root.to_s
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
end
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node4 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.new()
|
|
7
|
+
@str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
|
8
|
+
assert_equal(@str, xp.string = @str)
|
|
9
|
+
doc = xp.parse
|
|
10
|
+
xp2=XML::Parser.new()
|
|
11
|
+
xp2.string=@str
|
|
12
|
+
@doc2 = xp2.parse
|
|
13
|
+
assert_instance_of(XML::Document, doc)
|
|
14
|
+
assert_instance_of(XML::Node, doc.root)
|
|
15
|
+
@root = doc.root
|
|
16
|
+
assert_instance_of(XML::Node, @root)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def teardown()
|
|
20
|
+
@root = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_xml_node_eql?()
|
|
24
|
+
first1 = @root.child
|
|
25
|
+
first2 = @doc2.root.child
|
|
26
|
+
|
|
27
|
+
assert_not_equal first1.object_id, first2.object_id
|
|
28
|
+
assert first1.eql?(first2)
|
|
29
|
+
assert first2.eql?(first1)
|
|
30
|
+
|
|
31
|
+
assert_equal first1, first2
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_xml_node_hash()
|
|
35
|
+
first1 = @root.child
|
|
36
|
+
first2 = @doc2.root.child
|
|
37
|
+
|
|
38
|
+
assert_not_equal first1.object_id, first2.object_id
|
|
39
|
+
assert_equal first1.hash, first2.hash
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_01_xml_node_remove!()
|
|
43
|
+
first = @root.child
|
|
44
|
+
|
|
45
|
+
assert_equal 'fixnum', first.name
|
|
46
|
+
assert_equal 'fixnum', first.next.name
|
|
47
|
+
|
|
48
|
+
first.next.remove!
|
|
49
|
+
|
|
50
|
+
assert_equal 'fixnum', first.name
|
|
51
|
+
assert_equal nil, first.next
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_02_xml_node_remove!()
|
|
55
|
+
first = @root.child
|
|
56
|
+
|
|
57
|
+
assert_equal 'fixnum', first.name
|
|
58
|
+
assert_equal 'fixnum', first.next.name
|
|
59
|
+
assert_equal 'one', first.content
|
|
60
|
+
|
|
61
|
+
first.remove!
|
|
62
|
+
|
|
63
|
+
first = @root.child
|
|
64
|
+
assert_equal 'fixnum', first.name
|
|
65
|
+
assert_equal nil, first.next
|
|
66
|
+
assert_equal 'two', first.content
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# TODO need to test namespace support
|
|
70
|
+
def test_xml_node_find_first()
|
|
71
|
+
first = @root.find_first('//fixnum')
|
|
72
|
+
|
|
73
|
+
assert_equal 'one', first.content
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_xml_node_property_set_remove()
|
|
77
|
+
assert_equal 'booga', @root['uga']
|
|
78
|
+
@root['uga'] = nil
|
|
79
|
+
assert_equal nil , @root['uga']
|
|
80
|
+
assert_equal "<ruby_array foo=\"bar\">\n <fixnum>one</fixnum>\n <fixnum>two</fixnum>\n</ruby_array>",
|
|
81
|
+
@root.to_s
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
end
|
data/test/tc_xml_node5.rb
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node5 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.new()
|
|
7
|
-
str = '<test><num>one</num><num>two</num><num>three</num></test>'
|
|
8
|
-
assert_equal(str, xp.string = str)
|
|
9
|
-
@doc = xp.parse
|
|
10
|
-
assert_instance_of(XML::Document, @doc)
|
|
11
|
-
@root = @doc.root
|
|
12
|
-
@num1 = @root.child
|
|
13
|
-
@num2 = @num1.next
|
|
14
|
-
@num3 = @num2.next
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_libxml_node_add_next_01
|
|
18
|
-
@num1.next = XML::Node.new('num', 'one-and-a-half')
|
|
19
|
-
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
|
20
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_libxml_node_add_next_02
|
|
24
|
-
@num2.next = XML::Node.new('num', 'two-and-a-half')
|
|
25
|
-
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
|
26
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_libxml_node_add_next_03
|
|
30
|
-
@num3.next = XML::Node.new('num', 'four')
|
|
31
|
-
assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
|
|
32
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_libxml_node_add_prev_01
|
|
36
|
-
@num1.prev = XML::Node.new('num', 'half')
|
|
37
|
-
assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
|
|
38
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_libxml_node_add_prev_02
|
|
42
|
-
@num2.prev = XML::Node.new('num', 'one-and-a-half')
|
|
43
|
-
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
|
44
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_libxml_node_add_prev_03
|
|
48
|
-
@num3.prev = XML::Node.new('num', 'two-and-a-half')
|
|
49
|
-
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
|
50
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
51
|
-
end
|
|
52
|
-
end
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node5 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.new()
|
|
7
|
+
str = '<test><num>one</num><num>two</num><num>three</num></test>'
|
|
8
|
+
assert_equal(str, xp.string = str)
|
|
9
|
+
@doc = xp.parse
|
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
|
11
|
+
@root = @doc.root
|
|
12
|
+
@num1 = @root.child
|
|
13
|
+
@num2 = @num1.next
|
|
14
|
+
@num3 = @num2.next
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_libxml_node_add_next_01
|
|
18
|
+
@num1.next = XML::Node.new('num', 'one-and-a-half')
|
|
19
|
+
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
|
20
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_libxml_node_add_next_02
|
|
24
|
+
@num2.next = XML::Node.new('num', 'two-and-a-half')
|
|
25
|
+
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
|
26
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_libxml_node_add_next_03
|
|
30
|
+
@num3.next = XML::Node.new('num', 'four')
|
|
31
|
+
assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
|
|
32
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_libxml_node_add_prev_01
|
|
36
|
+
@num1.prev = XML::Node.new('num', 'half')
|
|
37
|
+
assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
|
|
38
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_libxml_node_add_prev_02
|
|
42
|
+
@num2.prev = XML::Node.new('num', 'one-and-a-half')
|
|
43
|
+
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
|
44
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_libxml_node_add_prev_03
|
|
48
|
+
@num3.prev = XML::Node.new('num', 'two-and-a-half')
|
|
49
|
+
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
|
50
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
51
|
+
end
|
|
52
|
+
end
|
data/test/tc_xml_node6.rb
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node6 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
|
7
|
-
doc = xp.parse
|
|
8
|
-
@root = doc.root
|
|
9
|
-
assert_equal 'bar', @root['foo']
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def teardown()
|
|
13
|
-
@root = nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_xml_node_prop_get_str_sym()
|
|
17
|
-
assert_equal @root['foo'], @root[:foo]
|
|
18
|
-
assert_equal @root['uga'], @root[:uga]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_xml_node_prop_set_str_sym()
|
|
22
|
-
@root[:foo] = 'boo'
|
|
23
|
-
@root[:uga] = 'zoo'
|
|
24
|
-
assert_equal 'boo', @root['foo']
|
|
25
|
-
assert_equal 'zoo', @root['uga']
|
|
26
|
-
end
|
|
27
|
-
end
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node6 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
|
7
|
+
doc = xp.parse
|
|
8
|
+
@root = doc.root
|
|
9
|
+
assert_equal 'bar', @root['foo']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def teardown()
|
|
13
|
+
@root = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_xml_node_prop_get_str_sym()
|
|
17
|
+
assert_equal @root['foo'], @root[:foo]
|
|
18
|
+
assert_equal @root['uga'], @root[:uga]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_xml_node_prop_set_str_sym()
|
|
22
|
+
@root[:foo] = 'boo'
|
|
23
|
+
@root[:uga] = 'zoo'
|
|
24
|
+
assert_equal 'boo', @root['foo']
|
|
25
|
+
assert_equal 'zoo', @root['uga']
|
|
26
|
+
end
|
|
27
|
+
end
|
data/test/tc_xml_node7.rb
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node7 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
|
7
|
-
doc = xp.parse
|
|
8
|
-
@root = doc.root
|
|
9
|
-
assert_equal 'bar', @root['foo']
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def teardown()
|
|
13
|
-
@root = nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_xml_node_properties_traversal_bug()
|
|
17
|
-
prop = @root.properties
|
|
18
|
-
assert_instance_of XML::Attr, prop
|
|
19
|
-
assert_equal 'uga', prop.name
|
|
20
|
-
assert_equal 'booga', prop.value
|
|
21
|
-
|
|
22
|
-
prop = prop.next
|
|
23
|
-
assert_instance_of XML::Attr, prop
|
|
24
|
-
assert_equal 'foo', prop.name
|
|
25
|
-
assert_equal 'bar', prop.value
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_xml_node_properties_when_no_attributes
|
|
29
|
-
xp = XML::Parser.string("<root></root>")
|
|
30
|
-
doc = xp.parse
|
|
31
|
-
root = doc.root
|
|
32
|
-
|
|
33
|
-
assert_nil root.properties
|
|
34
|
-
end
|
|
35
|
-
end
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node7 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
|
7
|
+
doc = xp.parse
|
|
8
|
+
@root = doc.root
|
|
9
|
+
assert_equal 'bar', @root['foo']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def teardown()
|
|
13
|
+
@root = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_xml_node_properties_traversal_bug()
|
|
17
|
+
prop = @root.properties
|
|
18
|
+
assert_instance_of XML::Attr, prop
|
|
19
|
+
assert_equal 'uga', prop.name
|
|
20
|
+
assert_equal 'booga', prop.value
|
|
21
|
+
|
|
22
|
+
prop = prop.next
|
|
23
|
+
assert_instance_of XML::Attr, prop
|
|
24
|
+
assert_equal 'foo', prop.name
|
|
25
|
+
assert_equal 'bar', prop.value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_xml_node_properties_when_no_attributes
|
|
29
|
+
xp = XML::Parser.string("<root></root>")
|
|
30
|
+
doc = xp.parse
|
|
31
|
+
root = doc.root
|
|
32
|
+
|
|
33
|
+
assert_nil root.properties
|
|
34
|
+
end
|
|
35
|
+
end
|
data/test/tc_xml_node8.rb
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node8 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.new()
|
|
7
|
-
str = '<root></root>'
|
|
8
|
-
assert_equal(str, xp.string = str)
|
|
9
|
-
@doc = xp.parse
|
|
10
|
-
assert_instance_of(XML::Document, @doc)
|
|
11
|
-
@root = @doc.root
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def test_libxml_node_add_cdata_01
|
|
15
|
-
@root << XML::Node.new_cdata('mycdata')
|
|
16
|
-
assert_equal '<root><![CDATA[mycdata]]></root>',
|
|
17
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_libxml_node_add_cdata_02
|
|
21
|
-
@root << XML::Node.new_cdata('mycdata')
|
|
22
|
-
assert_equal 'cdata',
|
|
23
|
-
@root.child.node_type_name
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_libxml_node_add_cdata_03
|
|
27
|
-
@root << el = XML::Node.new_cdata('mycdata')
|
|
28
|
-
el << "_this_is_added"
|
|
29
|
-
assert_equal '<root><![CDATA[mycdata_this_is_added]]></root>',
|
|
30
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
31
|
-
end
|
|
32
|
-
end
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node8 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.new()
|
|
7
|
+
str = '<root></root>'
|
|
8
|
+
assert_equal(str, xp.string = str)
|
|
9
|
+
@doc = xp.parse
|
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
|
11
|
+
@root = @doc.root
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_libxml_node_add_cdata_01
|
|
15
|
+
@root << XML::Node.new_cdata('mycdata')
|
|
16
|
+
assert_equal '<root><![CDATA[mycdata]]></root>',
|
|
17
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_libxml_node_add_cdata_02
|
|
21
|
+
@root << XML::Node.new_cdata('mycdata')
|
|
22
|
+
assert_equal 'cdata',
|
|
23
|
+
@root.child.node_type_name
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_libxml_node_add_cdata_03
|
|
27
|
+
@root << el = XML::Node.new_cdata('mycdata')
|
|
28
|
+
el << "_this_is_added"
|
|
29
|
+
assert_equal '<root><![CDATA[mycdata_this_is_added]]></root>',
|
|
30
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
31
|
+
end
|
|
32
|
+
end
|
data/test/tc_xml_node9.rb
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node9 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.new()
|
|
7
|
-
str = '<root></root>'
|
|
8
|
-
assert_equal(str, xp.string = str)
|
|
9
|
-
@doc = xp.parse
|
|
10
|
-
assert_instance_of(XML::Document, @doc)
|
|
11
|
-
@root = @doc.root
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def test_libxml_node_add_comment_01
|
|
15
|
-
@root << XML::Node.new_comment('mycomment')
|
|
16
|
-
assert_equal '<root><!--mycomment--></root>',
|
|
17
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_libxml_node_add_comment_02
|
|
21
|
-
@root << XML::Node.new_comment('mycomment')
|
|
22
|
-
assert_equal 'comment',
|
|
23
|
-
@root.child.node_type_name
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_libxml_node_add_comment_03
|
|
27
|
-
@root << el = XML::Node.new_comment('mycomment')
|
|
28
|
-
el << "_this_is_added"
|
|
29
|
-
assert_equal '<root><!--mycomment_this_is_added--></root>',
|
|
30
|
-
@root.to_s.gsub(/\n\s*/,'')
|
|
31
|
-
end
|
|
32
|
-
end
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node9 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.new()
|
|
7
|
+
str = '<root></root>'
|
|
8
|
+
assert_equal(str, xp.string = str)
|
|
9
|
+
@doc = xp.parse
|
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
|
11
|
+
@root = @doc.root
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_libxml_node_add_comment_01
|
|
15
|
+
@root << XML::Node.new_comment('mycomment')
|
|
16
|
+
assert_equal '<root><!--mycomment--></root>',
|
|
17
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_libxml_node_add_comment_02
|
|
21
|
+
@root << XML::Node.new_comment('mycomment')
|
|
22
|
+
assert_equal 'comment',
|
|
23
|
+
@root.child.node_type_name
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_libxml_node_add_comment_03
|
|
27
|
+
@root << el = XML::Node.new_comment('mycomment')
|
|
28
|
+
el << "_this_is_added"
|
|
29
|
+
assert_equal '<root><!--mycomment_this_is_added--></root>',
|
|
30
|
+
@root.to_s.gsub(/\n\s*/,'')
|
|
31
|
+
end
|
|
32
|
+
end
|
data/test/tc_xml_node_set.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node_Set < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.new()
|
|
7
|
-
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
|
8
|
-
assert_equal(str, xp.string = str)
|
|
9
|
-
doc = xp.parse
|
|
10
|
-
assert_instance_of(XML::Document, doc)
|
|
11
|
-
@set = doc.find('/ruby_array/fixnum').set
|
|
12
|
-
assert_instance_of(XML::Node::Set, @set)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def teardown()
|
|
16
|
-
@set = nil
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_libxml_nodeset_each()
|
|
20
|
-
@set.each do |n|
|
|
21
|
-
assert_instance_of(XML::Node, n)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end # TC_XML_Document
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node_Set < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.new()
|
|
7
|
+
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
|
8
|
+
assert_equal(str, xp.string = str)
|
|
9
|
+
doc = xp.parse
|
|
10
|
+
assert_instance_of(XML::Document, doc)
|
|
11
|
+
@set = doc.find('/ruby_array/fixnum').set
|
|
12
|
+
assert_instance_of(XML::Node::Set, @set)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def teardown()
|
|
16
|
+
@set = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_libxml_nodeset_each()
|
|
20
|
+
@set.each do |n|
|
|
21
|
+
assert_instance_of(XML::Node, n)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end # TC_XML_Document
|
data/test/tc_xml_node_set2.rb
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
class TC_XML_Node_Set2 < Test::Unit::TestCase
|
|
5
|
-
def setup()
|
|
6
|
-
xp = XML::Parser.new()
|
|
7
|
-
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
|
8
|
-
assert_equal(str, xp.string = str)
|
|
9
|
-
doc = xp.parse
|
|
10
|
-
assert_instance_of(XML::Document, doc)
|
|
11
|
-
@one = doc.root.child
|
|
12
|
-
@two = @one.next
|
|
13
|
-
@set = doc.find('/ruby_array/fixnum').set
|
|
14
|
-
@emptyset = doc.find('/fixnum').set
|
|
15
|
-
assert_instance_of(XML::Node::Set, @set)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def teardown()
|
|
19
|
-
@set, @emptyset, @one, @two = [nil] * 4
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_libxml_nodeset_to_a()
|
|
23
|
-
assert_equal [@one, @two], @set.to_a
|
|
24
|
-
assert_equal [], @emptyset.to_a
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_libxml_nodeset_empty?()
|
|
28
|
-
assert ! @set.empty?
|
|
29
|
-
assert @emptyset.empty?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_libxml_nodeset_first()
|
|
33
|
-
assert_equal @one.to_s, @set.first.to_s
|
|
34
|
-
assert_equal nil, @emptyset.first
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end # TC_XML_Document
|
|
1
|
+
require "libxml"
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Node_Set2 < Test::Unit::TestCase
|
|
5
|
+
def setup()
|
|
6
|
+
xp = XML::Parser.new()
|
|
7
|
+
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
|
8
|
+
assert_equal(str, xp.string = str)
|
|
9
|
+
doc = xp.parse
|
|
10
|
+
assert_instance_of(XML::Document, doc)
|
|
11
|
+
@one = doc.root.child
|
|
12
|
+
@two = @one.next
|
|
13
|
+
@set = doc.find('/ruby_array/fixnum').set
|
|
14
|
+
@emptyset = doc.find('/fixnum').set
|
|
15
|
+
assert_instance_of(XML::Node::Set, @set)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def teardown()
|
|
19
|
+
@set, @emptyset, @one, @two = [nil] * 4
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_libxml_nodeset_to_a()
|
|
23
|
+
assert_equal [@one, @two], @set.to_a
|
|
24
|
+
assert_equal [], @emptyset.to_a
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_libxml_nodeset_empty?()
|
|
28
|
+
assert ! @set.empty?
|
|
29
|
+
assert @emptyset.empty?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_libxml_nodeset_first()
|
|
33
|
+
assert_equal @one.to_s, @set.first.to_s
|
|
34
|
+
assert_equal nil, @emptyset.first
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end # TC_XML_Document
|