libxml-ruby 0.6.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +122 -0
- data/LICENSE +23 -0
- data/README +144 -0
- data/ext/libxml/cbg.c +76 -0
- data/ext/libxml/extconf.rb +308 -0
- data/ext/libxml/libxml.c +62 -0
- data/ext/libxml/ruby_libxml.h +93 -0
- data/ext/libxml/ruby_xml_attr.c +405 -0
- data/ext/libxml/ruby_xml_attr.h +19 -0
- data/ext/libxml/ruby_xml_document.c +1111 -0
- data/ext/libxml/ruby_xml_document.h +27 -0
- data/ext/libxml/ruby_xml_dtd.c +168 -0
- data/ext/libxml/ruby_xml_dtd.h +17 -0
- data/ext/libxml/ruby_xml_html_parser.c +449 -0
- data/ext/libxml/ruby_xml_html_parser.h +29 -0
- data/ext/libxml/ruby_xml_input_cbg.c +158 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_node.c +2410 -0
- data/ext/libxml/ruby_xml_node.h +27 -0
- data/ext/libxml/ruby_xml_node_set.c +170 -0
- data/ext/libxml/ruby_xml_node_set.h +20 -0
- data/ext/libxml/ruby_xml_ns.c +153 -0
- data/ext/libxml/ruby_xml_ns.h +21 -0
- data/ext/libxml/ruby_xml_parser.c +1425 -0
- data/ext/libxml/ruby_xml_parser.h +31 -0
- data/ext/libxml/ruby_xml_parser_context.c +750 -0
- data/ext/libxml/ruby_xml_parser_context.h +22 -0
- data/ext/libxml/ruby_xml_reader.c +900 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_sax_parser.c +485 -0
- data/ext/libxml/ruby_xml_sax_parser.h +56 -0
- data/ext/libxml/ruby_xml_schema.c +146 -0
- data/ext/libxml/ruby_xml_schema.h +16 -0
- data/ext/libxml/ruby_xml_state.c +113 -0
- data/ext/libxml/ruby_xml_state.h +12 -0
- data/ext/libxml/ruby_xml_tree.c +43 -0
- data/ext/libxml/ruby_xml_tree.h +12 -0
- data/ext/libxml/ruby_xml_xinclude.c +20 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +243 -0
- data/ext/libxml/ruby_xml_xpath.h +23 -0
- data/ext/libxml/ruby_xml_xpath_context.c +118 -0
- data/ext/libxml/ruby_xml_xpath_context.h +20 -0
- data/ext/libxml/ruby_xml_xpath_object.c +293 -0
- data/ext/libxml/ruby_xml_xpath_object.h +28 -0
- data/ext/libxml/ruby_xml_xpointer.c +100 -0
- data/ext/libxml/ruby_xml_xpointer.h +27 -0
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -0
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -0
- data/ext/libxml/sax_parser_callbacks.inc +213 -0
- data/ext/libxml/version.h +9 -0
- data/lib/libxml.rb +125 -0
- data/lib/libxml_ruby.so +0 -0
- data/lib/xml/libxml.rb +5 -0
- 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 -0
- data/test/etc_doc_to_s.rb +19 -0
- data/test/ets_copy_bug.rb +21 -0
- data/test/ets_copy_bug2.rb +32 -0
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +15 -0
- data/test/ets_doc_to_s.rb +21 -0
- data/test/ets_gpx.rb +26 -0
- data/test/ets_node_gc.rb +21 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +9 -0
- data/test/gc.log +0 -0
- data/test/merge_bug.rb +55 -0
- data/test/schema-test.rb +74 -0
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -0
- data/test/tc_xml_document_write.rb +24 -0
- data/test/tc_xml_document_write2.rb +54 -0
- data/test/tc_xml_document_write3.rb +96 -0
- data/test/tc_xml_html_parser.rb +63 -0
- data/test/tc_xml_node.rb +59 -0
- data/test/tc_xml_node2.rb +25 -0
- data/test/tc_xml_node3.rb +27 -0
- data/test/tc_xml_node4.rb +86 -0
- data/test/tc_xml_node5.rb +52 -0
- data/test/tc_xml_node6.rb +27 -0
- data/test/tc_xml_node7.rb +35 -0
- data/test/tc_xml_node8.rb +32 -0
- data/test/tc_xml_node9.rb +32 -0
- data/test/tc_xml_node_copy.rb +40 -0
- data/test/tc_xml_node_set.rb +24 -0
- data/test/tc_xml_node_set2.rb +37 -0
- data/test/tc_xml_node_text.rb +17 -0
- data/test/tc_xml_node_xlink.rb +28 -0
- data/test/tc_xml_parser.rb +190 -0
- data/test/tc_xml_parser2.rb +16 -0
- data/test/tc_xml_parser3.rb +23 -0
- data/test/tc_xml_parser4.rb +33 -0
- data/test/tc_xml_parser5.rb +27 -0
- data/test/tc_xml_parser6.rb +23 -0
- data/test/tc_xml_parser7.rb +28 -0
- data/test/tc_xml_parser8.rb +32 -0
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -0
- data/test/tc_xml_reader.rb +112 -0
- data/test/tc_xml_sax_parser.rb +104 -0
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -0
- data/test/tc_xml_xpath.rb +38 -0
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -0
- 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 +224 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
|
5
|
+
class TC_XML_Document < Test::Unit::TestCase
|
6
|
+
def setup()
|
7
|
+
xp = XML::Parser.new()
|
8
|
+
assert_instance_of(XML::Parser, xp)
|
9
|
+
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
10
|
+
assert_equal(str, xp.string = str)
|
11
|
+
@doc = xp.parse
|
12
|
+
assert_instance_of(XML::Document, @doc)
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown()
|
16
|
+
@doc = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_libxml_document_find()
|
20
|
+
set = @doc.find('/ruby_array/fixnum')
|
21
|
+
assert_instance_of(XML::XPath::Object, set)
|
22
|
+
assert_raise(NoMethodError) {
|
23
|
+
xpt = set.xpath
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_ruby_xml_document_compression()
|
28
|
+
if XML::Parser::enabled_zlib?
|
29
|
+
0.upto(9) do |i|
|
30
|
+
assert_equal(i, @doc.compression = i)
|
31
|
+
assert_equal(i, @doc.compression)
|
32
|
+
end
|
33
|
+
|
34
|
+
9.downto(0) do |i|
|
35
|
+
assert_equal(i, @doc.compression = i)
|
36
|
+
assert_equal(i, @doc.compression)
|
37
|
+
end
|
38
|
+
|
39
|
+
10.upto(20) do |i|
|
40
|
+
# assert_equal(9, @doc.compression = i)
|
41
|
+
assert_equal(i, @doc.compression = i) # This works around a bug in Ruby 1.8
|
42
|
+
assert_equal(9, @doc.compression)
|
43
|
+
end
|
44
|
+
|
45
|
+
-1.downto(-10) do |i|
|
46
|
+
# assert_equal(0, @doc.compression = i)
|
47
|
+
assert_equal(i, @doc.compression = i) # FIXME This bug should get fixed ASAP
|
48
|
+
assert_equal(0, @doc.compression)
|
49
|
+
end
|
50
|
+
end # if ...enabled_zlib?
|
51
|
+
end # test_ruby_xml_document_compression()
|
52
|
+
end # TC_XML_Document
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Document_Write < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
@doc = XML::Document.new('1.0')
|
7
|
+
assert_instance_of(XML::Document, @doc)
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown()
|
11
|
+
@doc = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_ruby_xml_document_write_initialize()
|
15
|
+
assert_instance_of(XML::Document, XML::Document.new())
|
16
|
+
assert_equal('1.0', @doc.version)
|
17
|
+
end # def test_ruby_xml_document_initialize()
|
18
|
+
|
19
|
+
def test_ruby_xml_document_write_initialize2()
|
20
|
+
doc = XML::Document.new('6.9')
|
21
|
+
assert_instance_of(XML::Document, doc)
|
22
|
+
assert_equal('6.9', doc.version)
|
23
|
+
end # def test_ruby_xml_document_initialize2()
|
24
|
+
end # TC_XML_Document_Write
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Document_Write2 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
@doc = XML::Document.new('1.0')
|
7
|
+
assert_instance_of(XML::Document, @doc)
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown()
|
11
|
+
@doc = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_ruby_xml_document_write_root()
|
15
|
+
xml = "<?xml version=\"1.0\"?>\n<rubynet/>\n"
|
16
|
+
@doc.root = XML::Node.new('rubynet')
|
17
|
+
assert_instance_of(XML::Node, @doc.root)
|
18
|
+
assert_instance_of(XML::Document, @doc.root.doc)
|
19
|
+
assert_equal(xml, @doc.to_s)
|
20
|
+
end # def test_ruby_xml_document_write_root()
|
21
|
+
|
22
|
+
def test_ruby_xml_document_write_root2()
|
23
|
+
xml = "<?xml version=\"1.0\"?>\n<rubynet/>\n"
|
24
|
+
@doc.root = XML::Node.new('rubynet')
|
25
|
+
assert_instance_of(XML::Node, @doc.root)
|
26
|
+
assert_instance_of(XML::Document, @doc.root.doc)
|
27
|
+
assert_equal(xml, @doc.to_s(false))
|
28
|
+
end # def test_ruby_xml_document_write_root()
|
29
|
+
|
30
|
+
def test_ruby_xml_document_write_root3()
|
31
|
+
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rubynet/>\n"
|
32
|
+
@doc.root = XML::Node.new('rubynet')
|
33
|
+
@doc.encoding = 'UTF-8'
|
34
|
+
assert_instance_of(XML::Node, @doc.root)
|
35
|
+
assert_instance_of(XML::Document, @doc.root.doc)
|
36
|
+
assert_equal(xml, @doc.to_s)
|
37
|
+
end # def test_ruby_xml_document_write_root()
|
38
|
+
|
39
|
+
def test_ruby_xml_document_write_root4()
|
40
|
+
xml = "<?xml version=\"1.0\"?>\n<rubynet/>\n"
|
41
|
+
@doc.root = XML::Node.new('rubynet')
|
42
|
+
assert_instance_of(XML::Node, @doc.root)
|
43
|
+
assert_instance_of(XML::Document, @doc.root.doc)
|
44
|
+
assert_equal(xml, @doc.to_s(false))
|
45
|
+
end # def test_ruby_xml_document_write_root()
|
46
|
+
|
47
|
+
def test_ruby_xml_document_write_root5()
|
48
|
+
xml = "<?xml version=\"1.0\"?>\n<rubynet/>\n"
|
49
|
+
@doc.root = XML::Node.new('rubynet')
|
50
|
+
assert_instance_of(XML::Node, @doc.root)
|
51
|
+
assert_instance_of(XML::Document, @doc.root.doc)
|
52
|
+
assert_equal(xml, @doc.to_s(true))
|
53
|
+
end # def test_ruby_xml_document_write_root()
|
54
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Document_Write3 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
@doc = XML::Document.new('1.0')
|
7
|
+
assert_instance_of(XML::Document, @doc)
|
8
|
+
@doc.root = XML::Node.new('rubynet')
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown()
|
12
|
+
@doc = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_ruby_xml_document_write_child()
|
16
|
+
xml = "<?xml version=\"1.0\"?>\n<rubynet>\n <pkg/>\n</rubynet>\n"
|
17
|
+
@doc.root.child = XML::Node.new('pkg')
|
18
|
+
assert_equal(xml, @doc.to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_ruby_xml_document_write_content_append()
|
22
|
+
xml = "<?xml version=\"1.0\"?>\n"
|
23
|
+
xml << "<rubynet>\n"
|
24
|
+
xml << " <pkg>\n"
|
25
|
+
xml << " <meta>\n"
|
26
|
+
xml << " <pkgname>libxml</pkgname>\n"
|
27
|
+
xml << " </meta>\n"
|
28
|
+
xml << " </pkg>\n"
|
29
|
+
xml << "</rubynet>\n"
|
30
|
+
pkg = @doc.root.child = XML::Node.new('pkg')
|
31
|
+
meta = pkg.child = XML::Node.new('meta')
|
32
|
+
assert_equal meta, meta << (pkgname = XML::Node.new('pkgname'))
|
33
|
+
pkgname << 'libxml'
|
34
|
+
assert_equal(xml, @doc.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_ruby_xml_document_write_node_search_href()
|
38
|
+
prefix = 'xlink'
|
39
|
+
uri = 'http://www.rubynet.org'
|
40
|
+
xml = "<?xml version=\"1.0\"?>\n"
|
41
|
+
xml << "<rubynet xmlns:#{prefix}=\"#{uri}\">\n"
|
42
|
+
xml << " <pkg/>\n"
|
43
|
+
xml << "</rubynet>\n"
|
44
|
+
@doc = XML::Parser.string(xml).parse
|
45
|
+
assert_equal(xml, @doc.to_s)
|
46
|
+
ns = @doc.root.search_href(uri)
|
47
|
+
assert_instance_of(XML::NS, ns)
|
48
|
+
assert_equal(uri, ns.href)
|
49
|
+
assert_equal(prefix, ns.prefix)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_ruby_xml_document_write_sibling()
|
53
|
+
xml = "<?xml version=\"1.0\"?>\n<rubynet>\n <pkg/>\n <pkg2/>\n</rubynet>\n"
|
54
|
+
child = @doc.root.child = XML::Node.new('pkg')
|
55
|
+
assert_instance_of(XML::Node, child)
|
56
|
+
child.sibling = XML::Node.new('pkg2')
|
57
|
+
assert_equal(xml, @doc.to_s)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_ruby_xml_document_write_set_doc_property()
|
61
|
+
xml = "<?xml version=\"1.0\"?>\n"
|
62
|
+
xml << "<rubynet xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"
|
63
|
+
xml << " <pkg/>\n"
|
64
|
+
xml << "</rubynet>\n"
|
65
|
+
@doc['xmlns:xlink'] = "http://www.w3.org/1999/xlink"
|
66
|
+
pkg = @doc.root.child = XML::Node.new('pkg')
|
67
|
+
assert_equal(xml, @doc.to_s)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_ruby_xml_document_write_set_node_base()
|
71
|
+
xml = "<?xml version=\"1.0\"?>\n"
|
72
|
+
xml << "<rubynet>\n"
|
73
|
+
xml << " <pkg xml:base=\"http://www.rubynet.org/\"/>\n"
|
74
|
+
xml << "</rubynet>\n"
|
75
|
+
pkg = @doc.root.child = XML::Node.new('pkg')
|
76
|
+
pkg.base = 'http://www.rubynet.org/'
|
77
|
+
assert_equal(xml, @doc.to_s)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_ruby_xml_document_write_set_node_property()
|
81
|
+
xml = "<?xml version=\"1.0\"?>\n"
|
82
|
+
xml << "<rubynet xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"
|
83
|
+
xml << " <pkg version=\"1.0\">\n"
|
84
|
+
xml << " <meta>\n"
|
85
|
+
xml << " <pkgname>libxml</pkgname>\n"
|
86
|
+
xml << " </meta>\n"
|
87
|
+
xml << " </pkg>\n"
|
88
|
+
xml << "</rubynet>\n"
|
89
|
+
@doc.root['xmlns:xlink'] = "http://www.w3.org/1999/xlink"
|
90
|
+
pkg = @doc.root.child = XML::Node.new('pkg')
|
91
|
+
pkg['version'] = '1.0'
|
92
|
+
meta = pkg.child = XML::Node.new('meta')
|
93
|
+
pkgname = meta.child = XML::Node.new('pkgname', 'libxml')
|
94
|
+
assert_equal(xml, @doc.to_s)
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_HTMLParser < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
@xp = XML::HTMLParser.new()
|
7
|
+
assert_not_nil(@xp)
|
8
|
+
str = '<html><head><meta name=keywords content=nasty></head><body>Hello<br>World</html>'
|
9
|
+
@xp.string = str
|
10
|
+
assert_equal(str, @xp.string)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown()
|
14
|
+
@xp = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_libxml_html_parser_parse()
|
18
|
+
doc = @xp.parse
|
19
|
+
|
20
|
+
assert_instance_of XML::Document, doc
|
21
|
+
|
22
|
+
root = doc.root
|
23
|
+
assert_instance_of XML::Node, root
|
24
|
+
assert_equal 'html', root.name
|
25
|
+
|
26
|
+
head = root.child
|
27
|
+
assert_instance_of XML::Node, head
|
28
|
+
assert_equal 'head', head.name
|
29
|
+
|
30
|
+
meta = head.child
|
31
|
+
assert_instance_of XML::Node, meta
|
32
|
+
assert_equal 'meta', meta.name
|
33
|
+
assert_equal 'keywords', meta[:name]
|
34
|
+
assert_equal 'nasty', meta[:content]
|
35
|
+
|
36
|
+
body = head.next
|
37
|
+
assert_instance_of XML::Node, body
|
38
|
+
assert_equal 'body', body.name
|
39
|
+
|
40
|
+
hello = body.child
|
41
|
+
# It appears that some versions of libxml2 add a layer of <p>
|
42
|
+
# cant figure our why or how, so this skips it if there
|
43
|
+
hello = hello.child if hello.name == "p"
|
44
|
+
|
45
|
+
assert_instance_of XML::Node, hello
|
46
|
+
assert_equal 'Hello', hello.content
|
47
|
+
|
48
|
+
br = hello.next
|
49
|
+
assert_instance_of XML::Node, br
|
50
|
+
assert_equal 'br', br.name
|
51
|
+
|
52
|
+
world = br.next
|
53
|
+
assert_instance_of XML::Node, world
|
54
|
+
assert_equal 'World', world.content
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_libxml_html_parser_parser_context()
|
58
|
+
doc = @xp.parse
|
59
|
+
assert_instance_of(XML::Document, doc)
|
60
|
+
assert_instance_of(XML::Parser::Context, @xp.parser_context)
|
61
|
+
assert @xp.parser_context.html?
|
62
|
+
end
|
63
|
+
end # TC_XML_HTMLParser
|
data/test/tc_xml_node.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node < 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
|
+
@root = doc.root
|
12
|
+
assert_instance_of(XML::Node, @root)
|
13
|
+
set = doc.find('/ruby_array/fixnum')
|
14
|
+
assert_instance_of(XML::XPath::Object, set)
|
15
|
+
assert_raise(NoMethodError) {
|
16
|
+
xpt = set.xpath
|
17
|
+
}
|
18
|
+
@nodes = []
|
19
|
+
set.each do |n|
|
20
|
+
@nodes.push(n)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown()
|
25
|
+
@nodes = nil
|
26
|
+
@root = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_libxml_node_class()
|
30
|
+
for n in @nodes
|
31
|
+
assert_instance_of(XML::Node, n)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_libxml_node_child_get()
|
36
|
+
assert_instance_of(TrueClass, @root.child?)
|
37
|
+
assert_instance_of(XML::Node, @root.child)
|
38
|
+
assert_equal('fixnum', @root.child.name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_libxml_node_doc()
|
42
|
+
for n in @nodes
|
43
|
+
assert_instance_of(XML::Document, n.doc) if n.document?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_libxml_node_type_name()
|
48
|
+
assert_equal('element', @nodes[0].node_type_name)
|
49
|
+
assert_equal('element', @nodes[1].node_type_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_libxml_node_find()
|
53
|
+
set = @root.find('./fixnum').set
|
54
|
+
assert_instance_of(XML::Node::Set, set)
|
55
|
+
for node in set
|
56
|
+
assert_instance_of(XML::Node, node)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end # TC_XML_Document
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node2 < 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
|
+
assert_instance_of(XML::Node, doc.root)
|
12
|
+
@root = doc.root
|
13
|
+
assert_instance_of(XML::Node, @root)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown()
|
17
|
+
@root = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_xml_node_doc_get()
|
21
|
+
GC.start
|
22
|
+
assert_instance_of(XML::Node, @root)
|
23
|
+
assert_instance_of(XML::Document, @root.doc)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node3 < 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
|
+
assert_instance_of(XML::Node, doc.root)
|
12
|
+
@root = doc.root
|
13
|
+
assert_instance_of(XML::Node, @root)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown()
|
17
|
+
@root = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_xml_node_doc_content()
|
21
|
+
assert_equal 'onetwo', @root.content
|
22
|
+
first = @root.child
|
23
|
+
|
24
|
+
assert_equal 'one', first.content
|
25
|
+
assert_equal 'two', first.next.content
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +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
|