libxml-ruby 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/{CHANGES → HISTORY} +35 -0
  2. data/LICENSE +1 -0
  3. data/MANIFEST +165 -0
  4. data/{README → README.rdoc} +2 -2
  5. data/Rakefile +47 -147
  6. data/ext/libxml/libxml.c +17 -1
  7. data/ext/libxml/ruby_libxml.h +9 -1
  8. data/ext/libxml/ruby_xml_attr.c +3 -3
  9. data/ext/libxml/ruby_xml_attr_decl.c +32 -32
  10. data/ext/libxml/ruby_xml_attributes.c +1 -1
  11. data/ext/libxml/ruby_xml_cbg.c +1 -2
  12. data/ext/libxml/ruby_xml_document.c +26 -4
  13. data/ext/libxml/ruby_xml_dtd.c +3 -3
  14. data/ext/libxml/ruby_xml_encoding.c +92 -5
  15. data/ext/libxml/ruby_xml_encoding.h +4 -0
  16. data/ext/libxml/ruby_xml_namespace.c +2 -2
  17. data/ext/libxml/ruby_xml_node.c +14 -14
  18. data/ext/libxml/ruby_xml_parser_context.c +8 -8
  19. data/ext/libxml/ruby_xml_reader.c +98 -43
  20. data/ext/libxml/ruby_xml_sax2_handler.c +13 -1
  21. data/ext/libxml/ruby_xml_sax_parser.c +4 -5
  22. data/ext/libxml/ruby_xml_version.h +5 -5
  23. data/ext/libxml/ruby_xml_xpath_context.c +9 -6
  24. data/ext/libxml/ruby_xml_xpath_object.c +1 -1
  25. data/ext/vc/libxml_ruby.sln +4 -4
  26. data/lib/libxml.rb +29 -29
  27. data/lib/libxml/attr.rb +112 -110
  28. data/lib/libxml/attr_decl.rb +2 -0
  29. data/lib/libxml/attributes.rb +13 -11
  30. data/lib/libxml/document.rb +192 -190
  31. data/lib/libxml/error.rb +89 -87
  32. data/lib/libxml/hpricot.rb +77 -75
  33. data/lib/libxml/html_parser.rb +96 -94
  34. data/lib/libxml/namespace.rb +61 -59
  35. data/lib/libxml/namespaces.rb +37 -35
  36. data/lib/libxml/node.rb +398 -384
  37. data/lib/libxml/ns.rb +21 -19
  38. data/lib/libxml/parser.rb +366 -364
  39. data/lib/libxml/properties.rb +22 -20
  40. data/lib/libxml/reader.rb +2 -0
  41. data/lib/libxml/sax_callbacks.rb +179 -177
  42. data/lib/libxml/sax_parser.rb +57 -55
  43. data/lib/libxml/tree.rb +28 -26
  44. data/lib/libxml/xpath_object.rb +15 -13
  45. data/lib/xml.rb +16 -14
  46. data/lib/xml/libxml.rb +10 -8
  47. data/libxml-ruby.gemspec +50 -0
  48. data/script/benchmark/depixelate +634 -0
  49. data/script/benchmark/hamlet.xml +9055 -0
  50. data/script/benchmark/parsecount +170 -0
  51. data/script/benchmark/sock_entries.xml +507 -0
  52. data/script/benchmark/throughput +41 -0
  53. data/script/test +6 -0
  54. data/test/etc_doc_to_s.rb +21 -19
  55. data/test/ets_doc_file.rb +17 -15
  56. data/test/ets_doc_to_s.rb +23 -21
  57. data/test/ets_gpx.rb +28 -26
  58. data/test/ets_node_gc.rb +23 -21
  59. data/test/ets_tsr.rb +11 -9
  60. data/test/model/bands.iso-8859-1.xml +5 -0
  61. data/test/model/bands.utf-8.xml +5 -0
  62. data/test/rb-magic-comment.rb +33 -0
  63. data/test/tc_attr.rb +181 -170
  64. data/test/tc_attr_decl.rb +3 -1
  65. data/test/tc_attributes.rb +134 -132
  66. data/test/tc_deprecated_require.rb +13 -11
  67. data/test/tc_document.rb +119 -113
  68. data/test/tc_document_write.rb +186 -117
  69. data/test/tc_dtd.rb +125 -123
  70. data/test/tc_error.rb +3 -1
  71. data/test/tc_html_parser.rb +139 -137
  72. data/test/tc_namespace.rb +61 -58
  73. data/test/tc_namespaces.rb +176 -173
  74. data/test/tc_node.rb +257 -180
  75. data/test/tc_node_cdata.rb +51 -49
  76. data/test/tc_node_comment.rb +33 -30
  77. data/test/tc_node_copy.rb +42 -40
  78. data/test/tc_node_edit.rb +159 -157
  79. data/test/tc_node_text.rb +71 -69
  80. data/test/tc_node_write.rb +41 -16
  81. data/test/tc_node_xlink.rb +29 -26
  82. data/test/tc_parser.rb +335 -329
  83. data/test/tc_parser_context.rb +188 -185
  84. data/test/tc_properties.rb +39 -36
  85. data/test/tc_reader.rb +297 -283
  86. data/test/tc_relaxng.rb +54 -51
  87. data/test/tc_sax_parser.rb +275 -273
  88. data/test/tc_schema.rb +53 -51
  89. data/test/tc_traversal.rb +222 -220
  90. data/test/tc_xinclude.rb +21 -19
  91. data/test/tc_xml.rb +3 -1
  92. data/test/tc_xpath.rb +195 -193
  93. data/test/tc_xpath_context.rb +80 -78
  94. data/test/tc_xpath_expression.rb +38 -35
  95. data/test/tc_xpointer.rb +74 -72
  96. data/test/test_helper.rb +14 -0
  97. data/test/test_suite.rb +39 -33
  98. metadata +65 -105
  99. data/doc/css/normal.css +0 -182
  100. data/doc/img/raze-tiny.png +0 -0
  101. data/doc/img/red-cube.jpg +0 -0
  102. data/doc/img/xml-ruby.png +0 -0
  103. data/doc/index.xml +0 -43
  104. data/doc/install.xml +0 -77
  105. data/doc/layout.rhtml +0 -38
  106. data/doc/layout.xsl +0 -67
  107. data/doc/license.xml +0 -32
  108. data/doc/log/changelog.xml +0 -1324
  109. data/doc/log/changelog.xsl +0 -42
  110. data/ext/libxml/Makefile +0 -156
  111. data/ext/libxml/extconf.h +0 -5
  112. data/ext/libxml/libxml-ruby.so.a +0 -0
  113. data/ext/libxml/libxml.o +0 -0
  114. data/ext/libxml/libxml_ruby.so +0 -0
  115. data/ext/libxml/mkmf.log +0 -129
  116. data/ext/libxml/ruby_xml.o +0 -0
  117. data/ext/libxml/ruby_xml_attr.o +0 -0
  118. data/ext/libxml/ruby_xml_attr_decl.o +0 -0
  119. data/ext/libxml/ruby_xml_attributes.o +0 -0
  120. data/ext/libxml/ruby_xml_cbg.o +0 -0
  121. data/ext/libxml/ruby_xml_document.o +0 -0
  122. data/ext/libxml/ruby_xml_dtd.o +0 -0
  123. data/ext/libxml/ruby_xml_encoding.o +0 -0
  124. data/ext/libxml/ruby_xml_error.o +0 -0
  125. data/ext/libxml/ruby_xml_html_parser.o +0 -0
  126. data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
  127. data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
  128. data/ext/libxml/ruby_xml_input_cbg.o +0 -0
  129. data/ext/libxml/ruby_xml_io.o +0 -0
  130. data/ext/libxml/ruby_xml_namespace.o +0 -0
  131. data/ext/libxml/ruby_xml_namespaces.o +0 -0
  132. data/ext/libxml/ruby_xml_node.o +0 -0
  133. data/ext/libxml/ruby_xml_parser.o +0 -0
  134. data/ext/libxml/ruby_xml_parser_context.o +0 -0
  135. data/ext/libxml/ruby_xml_parser_options.o +0 -0
  136. data/ext/libxml/ruby_xml_reader.o +0 -0
  137. data/ext/libxml/ruby_xml_relaxng.o +0 -0
  138. data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
  139. data/ext/libxml/ruby_xml_sax_parser.o +0 -0
  140. data/ext/libxml/ruby_xml_schema.o +0 -0
  141. data/ext/libxml/ruby_xml_xinclude.o +0 -0
  142. data/ext/libxml/ruby_xml_xpath.o +0 -0
  143. data/ext/libxml/ruby_xml_xpath_context.o +0 -0
  144. data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
  145. data/ext/libxml/ruby_xml_xpath_object.o +0 -0
  146. data/ext/libxml/ruby_xml_xpointer.o +0 -0
@@ -1,30 +1,33 @@
1
- require "xml"
2
- require 'test/unit'
3
-
4
- class NodeCommentTest < Test::Unit::TestCase
5
- def setup
6
- xp = XML::Parser.string('<root></root>')
7
- @doc = xp.parse
8
- assert_instance_of(XML::Document, @doc)
9
- @root = @doc.root
10
- end
11
-
12
- def test_libxml_node_add_comment_01
13
- @root << XML::Node.new_comment('mycomment')
14
- assert_equal '<root><!--mycomment--></root>',
15
- @root.to_s.gsub(/\n\s*/,'')
16
- end
17
-
18
- def test_libxml_node_add_comment_02
19
- @root << XML::Node.new_comment('mycomment')
20
- assert_equal 'comment',
21
- @root.child.node_type_name
22
- end
23
-
24
- def test_libxml_node_add_comment_03
25
- @root << el = XML::Node.new_comment('mycomment')
26
- el << "_this_is_added"
27
- assert_equal '<root><!--mycomment_this_is_added--></root>',
28
- @root.to_s.gsub(/\n\s*/,'')
29
- end
30
- end
1
+ # encoding: UTF-8
2
+
3
+ require './test_helper'
4
+
5
+ require 'test/unit'
6
+
7
+ class NodeCommentTest < Test::Unit::TestCase
8
+ def setup
9
+ xp = XML::Parser.string('<root></root>')
10
+ @doc = xp.parse
11
+ assert_instance_of(XML::Document, @doc)
12
+ @root = @doc.root
13
+ end
14
+
15
+ def test_libxml_node_add_comment_01
16
+ @root << XML::Node.new_comment('mycomment')
17
+ assert_equal '<root><!--mycomment--></root>',
18
+ @root.to_s.gsub(/\n\s*/,'')
19
+ end
20
+
21
+ def test_libxml_node_add_comment_02
22
+ @root << XML::Node.new_comment('mycomment')
23
+ assert_equal 'comment',
24
+ @root.child.node_type_name
25
+ end
26
+
27
+ def test_libxml_node_add_comment_03
28
+ @root << el = XML::Node.new_comment('mycomment')
29
+ el << "_this_is_added"
30
+ assert_equal '<root><!--mycomment_this_is_added--></root>',
31
+ @root.to_s.gsub(/\n\s*/,'')
32
+ end
33
+ end
data/test/tc_node_copy.rb CHANGED
@@ -1,40 +1,42 @@
1
- require 'xml'
2
- require 'test/unit'
3
-
4
- # see mailing list archive
5
- # [libxml-devel] Segmentation fault when add the cloned/copied node
6
- # 2007/11/27 20:51
7
-
8
- class TestNodeCopy < Test::Unit::TestCase
9
- def setup
10
- str = <<-STR
11
- <html><body>
12
- <div class="textarea" id="t1" style="STATIC">foo</div>
13
- <div class="textarea" id="t2" style="STATIC">bar</div>
14
- </body></html>
15
- STR
16
-
17
- doc = XML::Parser.string(str).parse
18
-
19
- xpath = "//div"
20
- @div1 = doc.find(xpath).to_a[0]
21
- @div2 = doc.find(xpath).to_a[1]
22
- end
23
-
24
- def test_libxml_node_copy_not_segv
25
- @div2.each do |child|
26
- c = child.copy(false)
27
- @div1.child_add(c)
28
- end
29
- assert @div1.to_s =~ /foo/
30
- end
31
-
32
- def test_libxml_node_clone_not_segv
33
- @div2.each do |child|
34
- c = child.clone
35
- @div1.child_add(c)
36
- end
37
- assert @div1.to_s =~ /foo/
38
- end
39
-
40
- end # TC_XML_Node_Copy
1
+ # encoding: UTF-8
2
+
3
+ require './test_helper'
4
+ require 'test/unit'
5
+
6
+ # see mailing list archive
7
+ # [libxml-devel] Segmentation fault when add the cloned/copied node
8
+ # 2007/11/27 20:51
9
+
10
+ class TestNodeCopy < Test::Unit::TestCase
11
+ def setup
12
+ str = <<-STR
13
+ <html><body>
14
+ <div class="textarea" id="t1" style="STATIC">foo</div>
15
+ <div class="textarea" id="t2" style="STATIC">bar</div>
16
+ </body></html>
17
+ STR
18
+
19
+ doc = XML::Parser.string(str).parse
20
+
21
+ xpath = "//div"
22
+ @div1 = doc.find(xpath).to_a[0]
23
+ @div2 = doc.find(xpath).to_a[1]
24
+ end
25
+
26
+ def test_libxml_node_copy_not_segv
27
+ @div2.each do |child|
28
+ c = child.copy(false)
29
+ @div1 << c
30
+ end
31
+ assert @div1.to_s =~ /foo/
32
+ end
33
+
34
+ def test_libxml_node_clone_not_segv
35
+ @div2.each do |child|
36
+ c = child.clone
37
+ @div1 << c
38
+ end
39
+ assert @div1.to_s =~ /foo/
40
+ end
41
+
42
+ end # TC_XML_Node_Copy
data/test/tc_node_edit.rb CHANGED
@@ -1,158 +1,160 @@
1
- require 'xml'
2
- require 'test/unit'
3
-
4
- class TestNodeEdit < Test::Unit::TestCase
5
- def setup
6
- xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
7
- @doc = xp.parse
8
- end
9
-
10
- def teardown
11
- @doc = nil
12
- end
13
-
14
- def first_node
15
- @doc.root.child
16
- end
17
-
18
- def second_node
19
- first_node.next
20
- end
21
-
22
- def third_node
23
- second_node.next
24
- end
25
-
26
- def test_add_next_01
27
- first_node.next = XML::Node.new('num', 'one-and-a-half')
28
- assert_equal('<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
29
- @doc.root.to_s.gsub(/\n\s*/,''))
30
- end
31
-
32
- def test_add_next_02
33
- second_node.next = XML::Node.new('num', 'two-and-a-half')
34
- assert_equal('<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
35
- @doc.root.to_s.gsub(/\n\s*/,''))
36
- end
37
-
38
- def test_add_next_03
39
- third_node.next = XML::Node.new('num', 'four')
40
- assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
41
- @doc.root.to_s.gsub(/\n\s*/,'')
42
- end
43
-
44
- def test_add_prev_01
45
- first_node.prev = XML::Node.new('num', 'half')
46
- assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
47
- @doc.root.to_s.gsub(/\n\s*/,'')
48
- end
49
-
50
- def test_add_prev_02
51
- second_node.prev = XML::Node.new('num', 'one-and-a-half')
52
- assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
53
- @doc.root.to_s.gsub(/\n\s*/,'')
54
- end
55
-
56
- def test_add_prev_03
57
- third_node.prev = XML::Node.new('num', 'two-and-a-half')
58
- assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
59
- @doc.root.to_s.gsub(/\n\s*/,'')
60
- end
61
-
62
- def test_remove_node
63
- first_node.remove!
64
- assert_equal('<test><num>two</num><num>three</num></test>',
65
- @doc.root.to_s.gsub(/\n\s*/,''))
66
- end
67
-
68
- def test_remove_node_gc
69
- xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
70
- doc = xp.parse
71
- node = doc.root.child.remove!
72
- node = nil
73
- GC.start
74
- assert_not_nil(doc)
75
- end
76
-
77
- def test_remove_node_iteration
78
- nodes = Array.new
79
- @doc.root.each_element do |node|
80
- if node.name == 'num'
81
- nodes << node
82
- node.remove!
83
- end
84
- end
85
- assert_equal(3, nodes.length)
86
- end
87
-
88
- def test_reuse_removed_node
89
- # Remove the node
90
- node = @doc.root.first.remove!
91
- assert_not_nil(node)
92
-
93
- # Add it to the end of the documnet
94
- @doc.root.last.next = node
95
-
96
- assert_equal('<test><num>two</num><num>three</num><num>one</num></test>',
97
- @doc.root.to_s.gsub(/\n\s*/,''))
98
- end
99
-
100
- def test_append_existing_node
101
- doc = XML::Parser.string('<top>a<bottom>b<one>first</one><two>second</two>c</bottom>d</top>').parse
102
- node1 = doc.find_first('//two')
103
-
104
- doc.root << node1
105
- assert_equal('<top>a<bottom>b<one>first</one>c</bottom>d<two>second</two></top>',
106
- doc.root.to_s)
107
- end
108
-
109
- def test_wrong_doc
110
- doc1 = XML::Parser.string('<nums><one></one></nums>').parse
111
- doc2 = XML::Parser.string('<nums><two></two></nums>').parse
112
-
113
- node = doc1.root.child
114
-
115
- error = assert_raise(XML::Error) do
116
- doc2.root << node
117
- end
118
-
119
- assert_equal(' Nodes belong to different documents. You must first import the by calling XML::Document.import.',
120
- error.to_s)
121
- end
122
-
123
-
124
- # This test is to verify that an earlier reported bug has been fixed
125
- def test_merge
126
- documents = []
127
-
128
- # Read in 500 documents
129
- 500.times do
130
- documents << XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
131
- end
132
-
133
- master_doc = documents.shift
134
- documents.inject(master_doc) do |master_doc, child_doc|
135
- master_body = master_doc.find("//body").first
136
- child_body = child_doc.find("//body").first
137
-
138
- child_element = child_body.detect do |node|
139
- node.element?
140
- end
141
-
142
- master_body << child_element.copy(true)
143
- master_doc
144
- end
145
- end
146
-
147
- def test_append_chain
148
- node = XML::Node.new('foo') << XML::Node.new('bar') << "bars contents"
149
- assert_equal('<foo><bar/>bars contents</foo>',
150
- node.to_s)
151
- end
152
-
153
- def test_set_base
154
- @doc.root.base_uri = 'http://www.rubynet.org/'
155
- assert_equal("<test xml:base=\"http://www.rubynet.org/\">\n <num>one</num>\n <num>two</num>\n <num>three</num>\n</test>",
156
- @doc.root.to_s)
157
- end
1
+ # encoding: UTF-8
2
+
3
+ require './test_helper'
4
+ require 'test/unit'
5
+
6
+ class TestNodeEdit < Test::Unit::TestCase
7
+ def setup
8
+ xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
9
+ @doc = xp.parse
10
+ end
11
+
12
+ def teardown
13
+ @doc = nil
14
+ end
15
+
16
+ def first_node
17
+ @doc.root.child
18
+ end
19
+
20
+ def second_node
21
+ first_node.next
22
+ end
23
+
24
+ def third_node
25
+ second_node.next
26
+ end
27
+
28
+ def test_add_next_01
29
+ first_node.next = XML::Node.new('num', 'one-and-a-half')
30
+ assert_equal('<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
31
+ @doc.root.to_s.gsub(/\n\s*/,''))
32
+ end
33
+
34
+ def test_add_next_02
35
+ second_node.next = XML::Node.new('num', 'two-and-a-half')
36
+ assert_equal('<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
37
+ @doc.root.to_s.gsub(/\n\s*/,''))
38
+ end
39
+
40
+ def test_add_next_03
41
+ third_node.next = XML::Node.new('num', 'four')
42
+ assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
43
+ @doc.root.to_s.gsub(/\n\s*/,'')
44
+ end
45
+
46
+ def test_add_prev_01
47
+ first_node.prev = XML::Node.new('num', 'half')
48
+ assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
49
+ @doc.root.to_s.gsub(/\n\s*/,'')
50
+ end
51
+
52
+ def test_add_prev_02
53
+ second_node.prev = XML::Node.new('num', 'one-and-a-half')
54
+ assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
55
+ @doc.root.to_s.gsub(/\n\s*/,'')
56
+ end
57
+
58
+ def test_add_prev_03
59
+ third_node.prev = XML::Node.new('num', 'two-and-a-half')
60
+ assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
61
+ @doc.root.to_s.gsub(/\n\s*/,'')
62
+ end
63
+
64
+ def test_remove_node
65
+ first_node.remove!
66
+ assert_equal('<test><num>two</num><num>three</num></test>',
67
+ @doc.root.to_s.gsub(/\n\s*/,''))
68
+ end
69
+
70
+ def test_remove_node_gc
71
+ xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
72
+ doc = xp.parse
73
+ node = doc.root.child.remove!
74
+ node = nil
75
+ GC.start
76
+ assert_not_nil(doc)
77
+ end
78
+
79
+ def test_remove_node_iteration
80
+ nodes = Array.new
81
+ @doc.root.each_element do |node|
82
+ if node.name == 'num'
83
+ nodes << node
84
+ node.remove!
85
+ end
86
+ end
87
+ assert_equal(3, nodes.length)
88
+ end
89
+
90
+ def test_reuse_removed_node
91
+ # Remove the node
92
+ node = @doc.root.first.remove!
93
+ assert_not_nil(node)
94
+
95
+ # Add it to the end of the documnet
96
+ @doc.root.last.next = node
97
+
98
+ assert_equal('<test><num>two</num><num>three</num><num>one</num></test>',
99
+ @doc.root.to_s.gsub(/\n\s*/,''))
100
+ end
101
+
102
+ def test_append_existing_node
103
+ doc = XML::Parser.string('<top>a<bottom>b<one>first</one><two>second</two>c</bottom>d</top>').parse
104
+ node1 = doc.find_first('//two')
105
+
106
+ doc.root << node1
107
+ assert_equal('<top>a<bottom>b<one>first</one>c</bottom>d<two>second</two></top>',
108
+ doc.root.to_s)
109
+ end
110
+
111
+ def test_wrong_doc
112
+ doc1 = XML::Parser.string('<nums><one></one></nums>').parse
113
+ doc2 = XML::Parser.string('<nums><two></two></nums>').parse
114
+
115
+ node = doc1.root.child
116
+
117
+ error = assert_raise(XML::Error) do
118
+ doc2.root << node
119
+ end
120
+
121
+ assert_equal(' Nodes belong to different documents. You must first import the by calling XML::Document.import.',
122
+ error.to_s)
123
+ end
124
+
125
+
126
+ # This test is to verify that an earlier reported bug has been fixed
127
+ def test_merge
128
+ documents = []
129
+
130
+ # Read in 500 documents
131
+ 500.times do
132
+ documents << XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
133
+ end
134
+
135
+ master_doc = documents.shift
136
+ documents.inject(master_doc) do |master_doc, child_doc|
137
+ master_body = master_doc.find("//body").first
138
+ child_body = child_doc.find("//body").first
139
+
140
+ child_element = child_body.detect do |node|
141
+ node.element?
142
+ end
143
+
144
+ master_body << child_element.copy(true)
145
+ master_doc
146
+ end
147
+ end
148
+
149
+ def test_append_chain
150
+ node = XML::Node.new('foo') << XML::Node.new('bar') << "bars contents"
151
+ assert_equal('<foo><bar/>bars contents</foo>',
152
+ node.to_s)
153
+ end
154
+
155
+ def test_set_base
156
+ @doc.root.base_uri = 'http://www.rubynet.org/'
157
+ assert_equal("<test xml:base=\"http://www.rubynet.org/\">\n <num>one</num>\n <num>two</num>\n <num>three</num>\n</test>",
158
+ @doc.root.to_s)
159
+ end
158
160
  end