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/ets_copy_bug2.rb
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
$FAILS = []
|
|
4
|
-
|
|
5
|
-
def test( doc, doc2, iter )
|
|
6
|
-
doc.root = XML::Node.new("ccc")
|
|
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)
|
|
15
|
-
doc = XML::Document.new('1.0')
|
|
16
|
-
doc2 = XML::Document.new('1.0')
|
|
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
|
|
22
|
-
|
|
23
|
-
test2(5)
|
|
24
|
-
1000.times do |i|
|
|
25
|
-
test2(i)
|
|
26
|
-
print "\r#{i}"; $stdout.flush
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
puts "\n#{$FAILS.length} failures"
|
|
30
|
-
p $FAILS
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
require 'libxml'
|
|
2
|
+
|
|
3
|
+
$FAILS = []
|
|
4
|
+
|
|
5
|
+
def test( doc, doc2, iter )
|
|
6
|
+
doc.root = XML::Node.new("ccc")
|
|
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)
|
|
15
|
+
doc = XML::Document.new('1.0')
|
|
16
|
+
doc2 = XML::Document.new('1.0')
|
|
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
|
|
22
|
+
|
|
23
|
+
test2(5)
|
|
24
|
+
1000.times do |i|
|
|
25
|
+
test2(i)
|
|
26
|
+
print "\r#{i}"; $stdout.flush
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
puts "\n#{$FAILS.length} failures"
|
|
30
|
+
p $FAILS
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'libxml'
|
|
2
|
+
|
|
3
|
+
str = <<-STR
|
|
4
|
+
<html>
|
|
5
|
+
<body>
|
|
6
|
+
<div class="textarea" id="t1"
|
|
7
|
+
style="STATIC">werwerwerwerwer </div>
|
|
8
|
+
<div class="textarea" id="t2" style="STATIC">
|
|
9
|
+
Quisque et diam dapibus nisi bibendum blandit.
|
|
10
|
+
</div>
|
|
11
|
+
<div class="textarea" id="t3" style="STATIC">
|
|
12
|
+
<p>aaaaaaaaa</p>
|
|
13
|
+
</div>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
16
|
+
STR
|
|
17
|
+
|
|
18
|
+
XML::Parser.default_keep_blanks = false
|
|
19
|
+
xp = XML::Parser.new
|
|
20
|
+
xp.string = str
|
|
21
|
+
doc = xp.parse
|
|
22
|
+
|
|
23
|
+
xpath = "//div[@id='t1']"
|
|
24
|
+
div1 = doc.find(xpath).to_a[0]
|
|
25
|
+
printf "xxx div1: #{div1}\n"
|
|
26
|
+
|
|
27
|
+
xpath = "//div[@id='t2']"
|
|
28
|
+
div2 = doc.find(xpath).to_a[0]
|
|
29
|
+
printf "xxx div2: #{div2}\n"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
div2.each do |child|
|
|
33
|
+
#c = child.clone
|
|
34
|
+
c = child.copy(false)
|
|
35
|
+
div1.child_add(c)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
printf "xxx root: #{doc.root}\n"
|
data/test/ets_doc_file.rb
CHANGED
|
File without changes
|
data/test/merge_bug.rb
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
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"
|
|
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
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
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
|
-
|
|
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_document.rb
CHANGED
|
@@ -1,52 +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
|
|
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
|
|
@@ -1,24 +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
|
|
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
|
|
@@ -1,54 +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
|
|
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
|