libxml-ruby 0.6.0 → 0.7.0
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/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/mingw/mingw.rake
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# We can't use Ruby's standard build procedures
|
2
|
-
# on Windows because the Ruby executable is
|
3
|
-
# built with VC++ while here we want to build
|
4
|
-
# with MingW. So just roll our own...
|
5
|
-
|
6
|
-
require 'rake/clean'
|
7
|
-
require 'rbconfig'
|
8
|
-
|
9
|
-
RUBY_INCLUDE_DIR = Config::CONFIG["archdir"]
|
10
|
-
RUBY_BIN_DIR = Config::CONFIG["bindir"]
|
11
|
-
RUBY_LIB_DIR = Config::CONFIG["libdir"]
|
12
|
-
RUBY_SHARED_LIB = Config::CONFIG["LIBRUBY"]
|
13
|
-
RUBY_SHARED_DLL = RUBY_SHARED_LIB.gsub(/lib$/, 'dll')
|
14
|
-
|
15
|
-
CLEAN.include('*.o')
|
16
|
-
CLOBBER.include('libxml.so')
|
17
|
-
|
18
|
-
task :default => "libxml"
|
19
|
-
|
20
|
-
SRC = FileList['../ext/libxml/*.c']
|
21
|
-
OBJ = SRC.collect do |file_name|
|
22
|
-
File.basename(file_name).ext('o')
|
23
|
-
end
|
24
|
-
|
25
|
-
SRC.each do |srcfile|
|
26
|
-
objfile = File.basename(srcfile).ext('o')
|
27
|
-
file objfile => srcfile do
|
28
|
-
command = "gcc -c -fPIC -O2 -Wall -o #{objfile} -I/usr/local/include #{srcfile} -I#{RUBY_INCLUDE_DIR}"
|
29
|
-
sh "sh -c '#{command}'"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
file "libxml" => OBJ do
|
34
|
-
command = "libtool --mode=link gcc -shared -o libxml_ruby.so -L/usr/local/lib -lxml2 #{OBJ} #{RUBY_BIN_DIR}/#{RUBY_SHARED_DLL}"
|
35
|
-
sh "sh -c '#{command}'"
|
36
|
-
end
|
data/test/dtd-test.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "libxml"
|
2
|
-
|
3
|
-
xp = XML::Parser.new
|
4
|
-
xp.string = '<?xml version="1.0" encoding="utf-8"?>
|
5
|
-
<root><head a="ee" id="1">ass<buzz/></head><descr>really big ass</descr></root>'
|
6
|
-
|
7
|
-
doc = xp.parse
|
8
|
-
|
9
|
-
dtd = XML::Dtd.new('
|
10
|
-
<!ELEMENT root (head, descr)>
|
11
|
-
<!ELEMENT head (#PCDATA)>
|
12
|
-
<!ATTLIST head
|
13
|
-
id NMTOKEN #REQUIRED
|
14
|
-
a CDATA #IMPLIED
|
15
|
-
>
|
16
|
-
<!ELEMENT descr (#PCDATA)>
|
17
|
-
')
|
18
|
-
|
19
|
-
if doc.validate(dtd) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
|
20
|
-
puts "validation passed"
|
21
|
-
else
|
22
|
-
puts "validation failed"
|
23
|
-
end
|
24
|
-
|
data/test/merge_bug.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby
|
2
|
-
|
3
|
-
require 'libxml'
|
4
|
-
|
5
|
-
class XML::Node
|
6
|
-
def first_child_element
|
7
|
-
result = nil
|
8
|
-
if self.children?
|
9
|
-
self.each_child{|node_child| result = node_child if ((result.nil?) && node_child.element?) }
|
10
|
-
end
|
11
|
-
result
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
#
|
16
|
-
# Method which generates crash
|
17
|
-
#
|
18
|
-
def merge(forms)
|
19
|
-
starting_form = forms.shift
|
20
|
-
forms.inject(starting_form) do |master_form,form|
|
21
|
-
master_form.find("//body").first << form.find("//body").first.first_child_element
|
22
|
-
master_form
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# Run
|
28
|
-
# Must tell it how many times to merge a document
|
29
|
-
# On my linux box, it takes about 350 to crash it
|
30
|
-
# On my OS X box, it takes about 150
|
31
|
-
#
|
32
|
-
|
33
|
-
if (ARGV[0].to_i > 0)
|
34
|
-
count = ARGV[0].to_i
|
35
|
-
else
|
36
|
-
count = 500
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
merge_list = []
|
41
|
-
|
42
|
-
count.times do
|
43
|
-
merge_list << XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
|
44
|
-
end
|
45
|
-
|
46
|
-
result = merge(merge_list)
|
47
|
-
puts "Merged!"
|
48
|
-
|
49
|
-
#File.open(File.join(File.dirname(__FILE__), 'model', '/generated_form.xml'), "w") do |f|
|
50
|
-
# puts "Trying to write to file"
|
51
|
-
# f << result
|
52
|
-
# puts "After trying to write to file"
|
53
|
-
#end
|
54
|
-
|
55
|
-
puts "nothing left to do but print this message"
|
data/test/schema-test.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require "libxml"
|
2
|
-
|
3
|
-
xp = XML::Parser.new
|
4
|
-
xp.string = '<?xml version="1.0" encoding="utf-8"?>
|
5
|
-
|
6
|
-
<shiporder orderid="889923"
|
7
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
8
|
-
xsi:noNamespaceSchemaLocation="shiporder.xsd">
|
9
|
-
<orderperson>John Smith</orderperson>
|
10
|
-
<shipto>
|
11
|
-
<name>Ola Nordmann</name>
|
12
|
-
<address>Langgt 23</address>
|
13
|
-
<city>4000 Stavanger</city>
|
14
|
-
<country>Norway</country>
|
15
|
-
</shipto>
|
16
|
-
<item>
|
17
|
-
<title>Empire Burlesque</title>
|
18
|
-
<note>Special Edition</note>
|
19
|
-
<quantity>1</quantity>
|
20
|
-
<price>10.90</price>
|
21
|
-
</item>
|
22
|
-
<item>
|
23
|
-
<title>Hide your heart</title>
|
24
|
-
<quantity>1</quantity>
|
25
|
-
<price>9.90</price>
|
26
|
-
</item>
|
27
|
-
</shiporder>
|
28
|
-
'
|
29
|
-
|
30
|
-
doc = xp.parse
|
31
|
-
|
32
|
-
schema = XML::Schema.from_string('<?xml version="1.0" encoding="ISO-8859-1" ?>
|
33
|
-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
34
|
-
|
35
|
-
<xs:element name="shiporder">
|
36
|
-
<xs:complexType>
|
37
|
-
<xs:sequence>
|
38
|
-
<xs:element name="orderperson" type="xs:string"/>
|
39
|
-
<xs:element name="shipto">
|
40
|
-
<xs:complexType>
|
41
|
-
<xs:sequence>
|
42
|
-
<xs:element name="name" type="xs:string"/>
|
43
|
-
<xs:element name="address" type="xs:string"/>
|
44
|
-
<xs:element name="city" type="xs:string"/>
|
45
|
-
<xs:element name="country" type="xs:string"/>
|
46
|
-
</xs:sequence>
|
47
|
-
</xs:complexType>
|
48
|
-
</xs:element>
|
49
|
-
<xs:element name="item" maxOccurs="unbounded">
|
50
|
-
<xs:complexType>
|
51
|
-
<xs:sequence>
|
52
|
-
<xs:element name="title" type="xs:string"/>
|
53
|
-
<xs:element name="note" type="xs:string" minOccurs="0"/>
|
54
|
-
<xs:element name="quantity" type="xs:positiveInteger"/>
|
55
|
-
<xs:element name="price" type="xs:decimal"/>
|
56
|
-
</xs:sequence>
|
57
|
-
</xs:complexType>
|
58
|
-
</xs:element>
|
59
|
-
</xs:sequence>
|
60
|
-
<xs:attribute name="orderid" type="xs:string" use="required"/>
|
61
|
-
</xs:complexType>
|
62
|
-
</xs:element>
|
63
|
-
|
64
|
-
</xs:schema>
|
65
|
-
')
|
66
|
-
|
67
|
-
p schema
|
68
|
-
|
69
|
-
if doc.validate_schema(schema) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
|
70
|
-
puts "validation passed"
|
71
|
-
else
|
72
|
-
puts "validation failed"
|
73
|
-
end
|
74
|
-
|
data/test/tc_xml_node2.rb
DELETED
@@ -1,25 +0,0 @@
|
|
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
|
data/test/tc_xml_node3.rb
DELETED
@@ -1,27 +0,0 @@
|
|
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
|
data/test/tc_xml_node4.rb
DELETED
@@ -1,86 +0,0 @@
|
|
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
DELETED
@@ -1,52 +0,0 @@
|
|
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
DELETED
@@ -1,27 +0,0 @@
|
|
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
DELETED
@@ -1,35 +0,0 @@
|
|
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
|