libxml-ruby 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +42 -0
- data/README +123 -117
- data/doc/classes/XML.html +226 -0
- data/doc/classes/XML/Attr.html +969 -0
- data/doc/classes/XML/Attributes.html +487 -0
- data/doc/classes/XML/Document.html +1423 -0
- data/doc/classes/XML/Dtd.html +159 -0
- data/doc/classes/XML/Error.html +111 -0
- data/doc/classes/XML/HTMLParser.html +330 -0
- data/doc/classes/XML/InputCallbacks.html +154 -0
- data/doc/classes/XML/NS.html +366 -0
- data/doc/classes/XML/Node.html +3292 -0
- data/doc/classes/XML/Node/FailedModify.html +111 -0
- data/doc/classes/XML/Node/Set.html +435 -0
- data/doc/classes/XML/Node/SetNamespace.html +111 -0
- data/doc/classes/XML/Node/UnknownType.html +111 -0
- data/doc/classes/XML/Parser.html +2178 -0
- data/doc/classes/XML/Parser/Context.html +1233 -0
- data/doc/classes/XML/Parser/ParseError.html +111 -0
- data/doc/classes/XML/Reader.html +2173 -0
- data/doc/classes/XML/SaxParser.html +396 -0
- data/doc/classes/XML/SiblingEnum.html +142 -0
- data/doc/classes/XML/State.html +118 -0
- data/doc/classes/XML/Tree.html +224 -0
- data/doc/classes/XML/XInclude.html +117 -0
- data/doc/classes/XML/XInclude/Error.html +111 -0
- data/doc/classes/XML/XMLParserOptions.html +198 -0
- data/doc/classes/XML/XPath.html +269 -0
- data/doc/classes/XML/XPath/Context.html +193 -0
- data/doc/classes/XML/XPath/InvalidPath.html +111 -0
- data/doc/classes/XML/XPath/Object.html +439 -0
- data/doc/classes/XML/XPointer.html +164 -0
- data/doc/classes/XML/XPointer/Context.html +117 -0
- data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
- data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
- data/doc/classes/singleton.html +114 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGES.html +375 -0
- data/doc/files/LICENSE.html +133 -0
- data/doc/files/README.html +279 -0
- data/doc/files/VERSION.html +107 -0
- data/doc/files/ext/libxml/cbg_c.html +101 -0
- data/doc/files/ext/libxml/libxml_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
- data/doc/files/lib/libxml_rb.html +115 -0
- data/doc/files/lib/xml/libxml_rb.html +114 -0
- data/doc/fr_class_index.html +60 -0
- data/doc/fr_file_index.html +56 -0
- data/doc/fr_method_index.html +373 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/ext/libxml/cbg.c +76 -76
- data/ext/libxml/extconf.rb +308 -308
- data/ext/libxml/libxml.c +58 -62
- data/ext/libxml/ruby_libxml.h +1 -0
- data/ext/libxml/ruby_xml_attr.c +201 -113
- data/ext/libxml/ruby_xml_attr.h +6 -9
- data/ext/libxml/ruby_xml_attributes.c +268 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_document.c +80 -66
- data/ext/libxml/ruby_xml_dtd.c +2 -2
- data/ext/libxml/ruby_xml_dtd.h +17 -17
- data/ext/libxml/ruby_xml_html_parser.c +18 -19
- data/ext/libxml/ruby_xml_html_parser.h +29 -29
- data/ext/libxml/ruby_xml_input_cbg.c +6 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_node.c +438 -536
- data/ext/libxml/ruby_xml_node.h +17 -27
- data/ext/libxml/ruby_xml_node_set.c +10 -9
- data/ext/libxml/ruby_xml_node_set.h +20 -20
- data/ext/libxml/ruby_xml_ns.c +60 -69
- data/ext/libxml/ruby_xml_ns.h +12 -21
- data/ext/libxml/ruby_xml_parser.c +54 -53
- data/ext/libxml/ruby_xml_parser.h +31 -31
- data/ext/libxml/ruby_xml_parser_context.c +37 -91
- data/ext/libxml/ruby_xml_parser_context.h +20 -22
- data/ext/libxml/ruby_xml_reader.h +14 -14
- data/ext/libxml/ruby_xml_sax_parser.c +55 -55
- data/ext/libxml/ruby_xml_sax_parser.h +56 -56
- data/ext/libxml/ruby_xml_schema.c +44 -51
- data/ext/libxml/ruby_xml_schema.h +16 -16
- data/ext/libxml/ruby_xml_state.c +35 -96
- data/ext/libxml/ruby_xml_state.h +2 -3
- data/ext/libxml/ruby_xml_tree.h +12 -12
- data/ext/libxml/ruby_xml_xinclude.h +13 -13
- data/ext/libxml/ruby_xml_xpath.c +57 -18
- data/ext/libxml/ruby_xml_xpath.h +23 -23
- data/ext/libxml/ruby_xml_xpath_context.c +11 -7
- data/ext/libxml/ruby_xml_xpath_context.h +20 -20
- data/ext/libxml/ruby_xml_xpath_object.c +9 -16
- data/ext/libxml/ruby_xml_xpath_object.h +4 -10
- data/ext/libxml/ruby_xml_xpointer.c +11 -11
- data/ext/libxml/ruby_xml_xpointer.h +27 -27
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
- data/ext/libxml/version.h +2 -2
- data/lib/libxml.rb +134 -125
- data/lib/libxml_ruby.so +0 -0
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/test/ets_copy_bug.rb +1 -1
- data/test/ets_copy_bug2.rb +16 -27
- data/test/ets_doc_to_s.rb +1 -1
- data/test/ets_gpx.rb +1 -1
- data/test/ets_node_gc.rb +1 -1
- data/test/ets_tsr.rb +1 -1
- data/test/tc_well_formed.rb +1 -1
- data/test/tc_xml_attributes.rb +106 -0
- data/test/tc_xml_document.rb +10 -10
- data/test/tc_xml_document_write3.rb +1 -1
- data/test/tc_xml_dtd.rb +49 -0
- data/test/tc_xml_html_parser.rb +3 -3
- data/test/tc_xml_node.rb +69 -33
- data/test/tc_xml_node_attr.rb +170 -0
- data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
- data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
- data/test/tc_xml_node_edit.rb +91 -0
- data/test/tc_xml_parser.rb +97 -50
- data/test/tc_xml_parser_context.rb +61 -23
- data/test/tc_xml_schema.rb +39 -0
- data/test/tc_xml_xinclude.rb +5 -6
- data/test/tc_xml_xpath.rb +51 -27
- data/test/test_suite.rb +27 -0
- data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
- data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
- metadata +106 -54
- data/mingw/mingw.rake +0 -36
- data/test/dtd-test.rb +0 -24
- data/test/merge_bug.rb +0 -55
- data/test/schema-test.rb +0 -74
- data/test/tc_xml_node2.rb +0 -25
- data/test/tc_xml_node3.rb +0 -27
- data/test/tc_xml_node4.rb +0 -86
- data/test/tc_xml_node5.rb +0 -52
- data/test/tc_xml_node6.rb +0 -27
- data/test/tc_xml_node7.rb +0 -35
- data/test/tc_xml_parser2.rb +0 -16
- data/test/tc_xml_parser3.rb +0 -23
- data/test/tc_xml_parser4.rb +0 -33
- data/test/tc_xml_parser5.rb +0 -27
- data/test/tc_xml_parser6.rb +0 -23
- data/test/tc_xml_parser7.rb +0 -28
- data/test/tc_xml_parser8.rb +0 -32
- data/test/tc_xml_parser9.rb +0 -11
- data/test/tc_xml_xpath2.rb +0 -14
- 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
data/lib/libxml_ruby.so
CHANGED
Binary file
|
data/mingw/libiconv-2.dll
CHANGED
Binary file
|
data/mingw/libxml2-2.dll
CHANGED
Binary file
|
data/mingw/libxml_ruby.so
CHANGED
Binary file
|
data/test/ets_copy_bug.rb
CHANGED
data/test/ets_copy_bug2.rb
CHANGED
@@ -1,32 +1,21 @@
|
|
1
1
|
require 'libxml'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
iter.times { |i|
|
8
|
-
doc.root.child_add(doc2.root)
|
9
|
-
# doc.root << doc2.root.copy(true)
|
10
|
-
}
|
11
|
-
return doc
|
12
|
-
end
|
13
|
-
|
14
|
-
def test2(iter)
|
3
|
+
# This will cause a segmentation fault by
|
4
|
+
# freeing a xml_node_object twice. Haven't
|
5
|
+
# figured out why this is happening yet.
|
6
|
+
2.times do
|
15
7
|
doc = XML::Document.new('1.0')
|
16
|
-
|
17
|
-
doc2.root = XML::Node.new("aaa")
|
18
|
-
ret = test( doc, doc2, iter )
|
19
|
-
li=ret.find('aaa').length
|
20
|
-
$FAILS << [li,iter] unless li == iter
|
21
|
-
end
|
8
|
+
doc.root = XML::Node.new("header")
|
22
9
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
doc2 = XML::Document.new('1.0')
|
11
|
+
doc2.root = XML::Node.new("footer")
|
12
|
+
|
13
|
+
4000.times do
|
14
|
+
doc.root << doc2.root.copy(false)
|
15
|
+
end
|
16
|
+
|
17
|
+
nodes = doc.find('/header/footer')
|
18
|
+
nodes = nil
|
19
|
+
|
27
20
|
end
|
28
|
-
|
29
|
-
puts "\n#{$FAILS.length} failures"
|
30
|
-
p $FAILS
|
31
|
-
|
32
|
-
|
21
|
+
puts 'hi'
|
data/test/ets_doc_to_s.rb
CHANGED
data/test/ets_gpx.rb
CHANGED
data/test/ets_node_gc.rb
CHANGED
data/test/ets_tsr.rb
CHANGED
data/test/tc_well_formed.rb
CHANGED
@@ -0,0 +1,106 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class AttributesTest < 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
|
+
<cityMember name="Cambridge"
|
15
|
+
xlink:type="simple"
|
16
|
+
xlink:title="Trinity Lane"
|
17
|
+
xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239"
|
18
|
+
gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
|
19
|
+
</CityModel>
|
20
|
+
EOS
|
21
|
+
|
22
|
+
@doc = xp.parse
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown()
|
26
|
+
@doc = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def city_member
|
30
|
+
@doc.find('/city:CityModel/city:cityMember').first
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_attributes
|
34
|
+
attributes = city_member.attributes
|
35
|
+
assert_instance_of(XML::Attributes, attributes)
|
36
|
+
assert_equal(5, attributes.length)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_each
|
40
|
+
attributes = city_member.attributes
|
41
|
+
length = attributes.inject(0) do |result, attr|
|
42
|
+
assert_instance_of(XML::Attr, attr)
|
43
|
+
result + 1
|
44
|
+
end
|
45
|
+
assert_equal(5, length)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_get_attribute
|
49
|
+
attributes = city_member.attributes
|
50
|
+
|
51
|
+
attr = attributes.get_attribute('name')
|
52
|
+
assert_instance_of(XML::Attr, attr)
|
53
|
+
|
54
|
+
attr = attributes.get_attribute('does_not_exist')
|
55
|
+
assert_nil(attr)
|
56
|
+
|
57
|
+
attr = attributes.get_attribute('name')
|
58
|
+
assert_instance_of(XML::Attr, attr)
|
59
|
+
|
60
|
+
attr = attributes.get_attribute('href')
|
61
|
+
assert_instance_of(XML::Attr, attr)
|
62
|
+
assert_instance_of(XML::NS, attr.ns)
|
63
|
+
assert_equal('xlink', attr.ns.prefix)
|
64
|
+
assert_equal('http://www.w3.org/1999/xlink', attr.ns.href)
|
65
|
+
|
66
|
+
attr = attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
|
67
|
+
assert_instance_of(XML::Attr, attr)
|
68
|
+
|
69
|
+
attr = attributes.get_attribute_ns('http://www.opengis.net/gml', 'remoteSchema')
|
70
|
+
assert_instance_of(XML::Attr, attr)
|
71
|
+
|
72
|
+
attr = attributes.get_attribute_ns('http://i.dont.exist', 'nor do i')
|
73
|
+
assert_nil(attr)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_get_values
|
77
|
+
assert_equal('Cambridge', city_member[:name])
|
78
|
+
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', city_member[:href])
|
79
|
+
|
80
|
+
attributes = city_member.attributes
|
81
|
+
assert_equal('Cambridge', attributes[:name])
|
82
|
+
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attributes[:href])
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_set_values
|
86
|
+
city_member[:name] = 'London'
|
87
|
+
assert_equal('London', city_member[:name])
|
88
|
+
|
89
|
+
city_member[:href] = 'foo'
|
90
|
+
assert_equal('foo', city_member[:href])
|
91
|
+
|
92
|
+
attributes = city_member.attributes
|
93
|
+
|
94
|
+
attributes[:name] = 'London'
|
95
|
+
assert_equal('London', attributes[:name])
|
96
|
+
|
97
|
+
attributes[:href] = 'foo'
|
98
|
+
assert_equal('foo', attributes[:href])
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_str_sym()
|
102
|
+
attributes = city_member.attributes
|
103
|
+
assert_equal('Cambridge', attributes[:name])
|
104
|
+
assert_equal('Cambridge', attributes['name'])
|
105
|
+
end
|
106
|
+
end
|
data/test/tc_xml_document.rb
CHANGED
@@ -27,25 +27,25 @@ class TC_XML_Document < Test::Unit::TestCase
|
|
27
27
|
def test_ruby_xml_document_compression()
|
28
28
|
if XML::Parser::enabled_zlib?
|
29
29
|
0.upto(9) do |i|
|
30
|
-
|
31
|
-
|
30
|
+
assert_equal(i, @doc.compression = i)
|
31
|
+
assert_equal(i, @doc.compression)
|
32
32
|
end
|
33
33
|
|
34
34
|
9.downto(0) do |i|
|
35
|
-
|
36
|
-
|
35
|
+
assert_equal(i, @doc.compression = i)
|
36
|
+
assert_equal(i, @doc.compression)
|
37
37
|
end
|
38
38
|
|
39
39
|
10.upto(20) do |i|
|
40
|
-
|
41
|
-
|
42
|
-
|
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
43
|
end
|
44
44
|
|
45
45
|
-1.downto(-10) do |i|
|
46
|
-
|
47
|
-
|
48
|
-
|
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
49
|
end
|
50
50
|
end # if ...enabled_zlib?
|
51
51
|
end # test_ruby_xml_document_compression()
|
@@ -62,7 +62,7 @@ class TC_XML_Document_Write3 < Test::Unit::TestCase
|
|
62
62
|
xml << "<rubynet xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"
|
63
63
|
xml << " <pkg/>\n"
|
64
64
|
xml << "</rubynet>\n"
|
65
|
-
@doc['xmlns:xlink'] = "http://www.w3.org/1999/xlink"
|
65
|
+
@doc.root['xmlns:xlink'] = "http://www.w3.org/1999/xlink"
|
66
66
|
pkg = @doc.root.child = XML::Node.new('pkg')
|
67
67
|
assert_equal(xml, @doc.to_s)
|
68
68
|
end
|
data/test/tc_xml_dtd.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestDtd < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
xp = XML::Parser.string(<<-EOS)
|
7
|
+
<root>
|
8
|
+
<head a="ee" id="1">Colorado</head>
|
9
|
+
<descr>Lots of nice mountains</descr>
|
10
|
+
</root>
|
11
|
+
EOS
|
12
|
+
@doc = xp.parse
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
@doc = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def dtd
|
20
|
+
XML::Dtd.new(<<-EOS)
|
21
|
+
<!ELEMENT root (head, descr)>
|
22
|
+
<!ELEMENT head (#PCDATA)>
|
23
|
+
<!ATTLIST head
|
24
|
+
id NMTOKEN #REQUIRED
|
25
|
+
a CDATA #IMPLIED
|
26
|
+
>
|
27
|
+
<!ELEMENT descr (#PCDATA)>
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_valid
|
32
|
+
assert(@doc.validate(dtd))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_invalid
|
36
|
+
new_node = XML::Node.new('invalid', 'this will mess up validation')
|
37
|
+
@doc.root.child_add(new_node)
|
38
|
+
|
39
|
+
messages = Hash.new
|
40
|
+
assert(!@doc.validate(dtd) do |message, error|
|
41
|
+
messages[message] = error
|
42
|
+
end)
|
43
|
+
|
44
|
+
expected = {"No declaration for element invalid\n" => true,
|
45
|
+
"Element root content does not follow the DTD, expecting (head , descr), got (head descr invalid)\n" => true}
|
46
|
+
|
47
|
+
assert_equal(expected, messages)
|
48
|
+
end
|
49
|
+
end
|
data/test/tc_xml_html_parser.rb
CHANGED
@@ -54,10 +54,10 @@ class TC_XML_HTMLParser < Test::Unit::TestCase
|
|
54
54
|
assert_equal 'World', world.content
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def test_libxml_html_parser_context()
|
58
58
|
doc = @xp.parse
|
59
59
|
assert_instance_of(XML::Document, doc)
|
60
|
-
assert_instance_of(XML::Parser::Context, @xp.
|
61
|
-
|
60
|
+
assert_instance_of(XML::Parser::Context, @xp.context)
|
61
|
+
assert @xp.context.html?
|
62
62
|
end
|
63
63
|
end # TC_XML_HTMLParser
|
data/test/tc_xml_node.rb
CHANGED
@@ -1,59 +1,95 @@
|
|
1
1
|
require "libxml"
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
|
-
class
|
5
|
-
def setup
|
4
|
+
class TestNode < Test::Unit::TestCase
|
5
|
+
def setup
|
6
6
|
xp = XML::Parser.new()
|
7
7
|
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
8
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
|
9
|
+
@doc = xp.parse
|
22
10
|
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
@
|
26
|
-
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
@doc = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def nodes
|
17
|
+
@doc.find('/ruby_array/fixnum')
|
27
18
|
end
|
28
19
|
|
29
|
-
def
|
30
|
-
|
20
|
+
def test_doc_class
|
21
|
+
assert_instance_of(XML::Document, @doc)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_root_class
|
25
|
+
assert_instance_of(XML::Node, @doc.root)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_node_class
|
29
|
+
for n in nodes
|
31
30
|
assert_instance_of(XML::Node, n)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
def
|
36
|
-
|
37
|
-
assert_instance_of(XML::
|
38
|
-
assert_equal('fixnum', @root.child.name)
|
34
|
+
def test_find_class
|
35
|
+
set = @doc.find('/ruby_array/fixnum')
|
36
|
+
assert_instance_of(XML::XPath::Object, set)
|
39
37
|
end
|
40
38
|
|
41
|
-
def
|
42
|
-
|
39
|
+
def test_node_child_get
|
40
|
+
assert_instance_of(TrueClass, @doc.root.child?)
|
41
|
+
assert_instance_of(XML::Node, @doc.root.child)
|
42
|
+
assert_equal('fixnum', @doc.root.child.name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_node_doc
|
46
|
+
for n in nodes
|
43
47
|
assert_instance_of(XML::Document, n.doc) if n.document?
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
def
|
48
|
-
assert_equal('element',
|
49
|
-
assert_equal('element',
|
51
|
+
def test_node_type_name
|
52
|
+
assert_equal('element', nodes[0].node_type_name)
|
53
|
+
assert_equal('element', nodes[1].node_type_name)
|
50
54
|
end
|
51
55
|
|
52
|
-
def
|
53
|
-
set = @root.find('./fixnum').set
|
56
|
+
def test_node_find
|
57
|
+
set = @doc.root.find('./fixnum').set
|
54
58
|
assert_instance_of(XML::Node::Set, set)
|
55
59
|
for node in set
|
56
60
|
assert_instance_of(XML::Node, node)
|
57
61
|
end
|
58
62
|
end
|
59
|
-
|
63
|
+
|
64
|
+
def test_equality
|
65
|
+
node_a = @doc.find('/ruby_array/fixnum').first
|
66
|
+
node_b = @doc.root.child
|
67
|
+
assert(node_a == node_b)
|
68
|
+
assert(node_a.eql?(node_b))
|
69
|
+
assert(node_a.equal?(node_b))
|
70
|
+
|
71
|
+
xp2 = XML::Parser.new()
|
72
|
+
xp2.string = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
73
|
+
doc2 = xp2.parse
|
74
|
+
|
75
|
+
node_a2 = doc2.find('/ruby_array/fixnum').first
|
76
|
+
|
77
|
+
assert(node_a.to_s == node_a2.to_s)
|
78
|
+
assert(node_a == node_a2)
|
79
|
+
assert(node_a.eql?(node_a2))
|
80
|
+
assert(!node_a.equal?(node_a2))
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_content()
|
84
|
+
assert_equal('onetwo', @doc.root.content)
|
85
|
+
|
86
|
+
first = @doc.root.child
|
87
|
+
assert_equal('one', first.content)
|
88
|
+
assert_equal('two', first.next.content)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_base
|
92
|
+
doc = XML::Parser.string('<person />').parse
|
93
|
+
assert_nil(doc.root.base)
|
94
|
+
end
|
95
|
+
end
|