libxml-ruby 2.0.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +516 -0
- data/LICENSE +23 -0
- data/MANIFEST +165 -0
- data/README.rdoc +161 -0
- data/Rakefile +82 -0
- data/ext/libxml/extconf.rb +122 -0
- data/ext/libxml/libxml.c +93 -0
- data/ext/libxml/ruby_libxml.h +101 -0
- data/ext/libxml/ruby_xml.c +893 -0
- data/ext/libxml/ruby_xml.h +10 -0
- data/ext/libxml/ruby_xml_attr.c +352 -0
- data/ext/libxml/ruby_xml_attr.h +14 -0
- data/ext/libxml/ruby_xml_attr_decl.c +171 -0
- data/ext/libxml/ruby_xml_attr_decl.h +13 -0
- data/ext/libxml/ruby_xml_attributes.c +277 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_cbg.c +85 -0
- data/ext/libxml/ruby_xml_document.c +958 -0
- data/ext/libxml/ruby_xml_document.h +17 -0
- data/ext/libxml/ruby_xml_dtd.c +257 -0
- data/ext/libxml/ruby_xml_dtd.h +9 -0
- data/ext/libxml/ruby_xml_encoding.c +221 -0
- data/ext/libxml/ruby_xml_encoding.h +16 -0
- data/ext/libxml/ruby_xml_error.c +1004 -0
- data/ext/libxml/ruby_xml_error.h +14 -0
- data/ext/libxml/ruby_xml_html_parser.c +92 -0
- data/ext/libxml/ruby_xml_html_parser.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_input_cbg.c +191 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_io.c +30 -0
- data/ext/libxml/ruby_xml_io.h +9 -0
- data/ext/libxml/ruby_xml_namespace.c +170 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespaces.c +295 -0
- data/ext/libxml/ruby_xml_namespaces.h +11 -0
- data/ext/libxml/ruby_xml_node.c +1386 -0
- data/ext/libxml/ruby_xml_node.h +13 -0
- data/ext/libxml/ruby_xml_parser.c +94 -0
- data/ext/libxml/ruby_xml_parser.h +14 -0
- data/ext/libxml/ruby_xml_parser_context.c +982 -0
- data/ext/libxml/ruby_xml_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_parser_options.c +68 -0
- data/ext/libxml/ruby_xml_parser_options.h +14 -0
- data/ext/libxml/ruby_xml_reader.c +1057 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_relaxng.c +111 -0
- data/ext/libxml/ruby_xml_relaxng.h +10 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +334 -0
- data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
- data/ext/libxml/ruby_xml_sax_parser.c +136 -0
- data/ext/libxml/ruby_xml_sax_parser.h +12 -0
- data/ext/libxml/ruby_xml_schema.c +159 -0
- data/ext/libxml/ruby_xml_schema.h +11 -0
- data/ext/libxml/ruby_xml_version.h +9 -0
- data/ext/libxml/ruby_xml_xinclude.c +18 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +107 -0
- data/ext/libxml/ruby_xml_xpath.h +12 -0
- data/ext/libxml/ruby_xml_xpath_context.c +390 -0
- data/ext/libxml/ruby_xml_xpath_context.h +11 -0
- data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
- data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
- data/ext/libxml/ruby_xml_xpath_object.c +336 -0
- data/ext/libxml/ruby_xml_xpath_object.h +19 -0
- data/ext/libxml/ruby_xml_xpointer.c +101 -0
- data/ext/libxml/ruby_xml_xpointer.h +13 -0
- data/ext/mingw/Rakefile +34 -0
- data/ext/mingw/build.rake +41 -0
- data/ext/vc/libxml_ruby.sln +26 -0
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/lib/libxml.rb +30 -0
- data/lib/libxml/attr.rb +113 -0
- data/lib/libxml/attr_decl.rb +80 -0
- data/lib/libxml/attributes.rb +14 -0
- data/lib/libxml/document.rb +192 -0
- data/lib/libxml/error.rb +90 -0
- data/lib/libxml/hpricot.rb +78 -0
- data/lib/libxml/html_parser.rb +96 -0
- data/lib/libxml/namespace.rb +62 -0
- data/lib/libxml/namespaces.rb +38 -0
- data/lib/libxml/node.rb +399 -0
- data/lib/libxml/ns.rb +22 -0
- data/lib/libxml/parser.rb +367 -0
- data/lib/libxml/properties.rb +23 -0
- data/lib/libxml/reader.rb +29 -0
- data/lib/libxml/sax_callbacks.rb +180 -0
- data/lib/libxml/sax_parser.rb +58 -0
- data/lib/libxml/tree.rb +29 -0
- data/lib/libxml/xpath_object.rb +16 -0
- data/lib/xml.rb +16 -0
- data/lib/xml/libxml.rb +10 -0
- data/libxml-ruby.gemspec +50 -0
- data/script/benchmark/depixelate +634 -0
- data/script/benchmark/hamlet.xml +9055 -0
- data/script/benchmark/parsecount +170 -0
- data/script/benchmark/sock_entries.xml +507 -0
- data/script/benchmark/throughput +41 -0
- data/script/test +6 -0
- data/setup.rb +1585 -0
- data/test/etc_doc_to_s.rb +21 -0
- data/test/ets_doc_file.rb +17 -0
- data/test/ets_doc_to_s.rb +23 -0
- data/test/ets_gpx.rb +28 -0
- data/test/ets_node_gc.rb +23 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +11 -0
- data/test/model/atom.xml +13 -0
- data/test/model/bands.iso-8859-1.xml +5 -0
- data/test/model/bands.utf-8.xml +5 -0
- data/test/model/bands.xml +5 -0
- data/test/model/books.xml +146 -0
- data/test/model/merge_bug_data.xml +58 -0
- data/test/model/ruby-lang.html +238 -0
- data/test/model/rubynet.xml +79 -0
- data/test/model/rubynet_project +1 -0
- data/test/model/shiporder.rnc +28 -0
- data/test/model/shiporder.rng +86 -0
- data/test/model/shiporder.xml +23 -0
- data/test/model/shiporder.xsd +31 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/rb-magic-comment.rb +33 -0
- data/test/tc_attr.rb +181 -0
- data/test/tc_attr_decl.rb +133 -0
- data/test/tc_attributes.rb +135 -0
- data/test/tc_deprecated_require.rb +13 -0
- data/test/tc_document.rb +119 -0
- data/test/tc_document_write.rb +187 -0
- data/test/tc_dtd.rb +125 -0
- data/test/tc_error.rb +138 -0
- data/test/tc_html_parser.rb +140 -0
- data/test/tc_namespace.rb +62 -0
- data/test/tc_namespaces.rb +177 -0
- data/test/tc_node.rb +258 -0
- data/test/tc_node_cdata.rb +51 -0
- data/test/tc_node_comment.rb +33 -0
- data/test/tc_node_copy.rb +42 -0
- data/test/tc_node_edit.rb +160 -0
- data/test/tc_node_text.rb +71 -0
- data/test/tc_node_write.rb +108 -0
- data/test/tc_node_xlink.rb +29 -0
- data/test/tc_parser.rb +336 -0
- data/test/tc_parser_context.rb +189 -0
- data/test/tc_properties.rb +39 -0
- data/test/tc_reader.rb +298 -0
- data/test/tc_relaxng.rb +54 -0
- data/test/tc_sax_parser.rb +276 -0
- data/test/tc_schema.rb +53 -0
- data/test/tc_traversal.rb +222 -0
- data/test/tc_xinclude.rb +21 -0
- data/test/tc_xml.rb +226 -0
- data/test/tc_xpath.rb +195 -0
- data/test/tc_xpath_context.rb +80 -0
- data/test/tc_xpath_expression.rb +38 -0
- data/test/tc_xpointer.rb +74 -0
- data/test/test_helper.rb +14 -0
- data/test/test_suite.rb +39 -0
- metadata +254 -0
data/test/tc_xpath.rb
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestXPath < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
@doc = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_doc_find
|
17
|
+
nodes = @doc.find('/soap:Envelope')
|
18
|
+
assert_instance_of(XML::XPath::Object, nodes)
|
19
|
+
assert_equal(1, nodes.length)
|
20
|
+
assert_equal(nodes.xpath_type, XML::XPath::NODESET)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_doc_find_first
|
24
|
+
node = @doc.find_first('/soap:Envelope/soap:Body')
|
25
|
+
assert_instance_of(XML::Node, node)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_ns
|
29
|
+
nodes = @doc.find('//ns1:IdAndName', 'ns1:http://domain.somewhere.com')
|
30
|
+
assert_equal(3, nodes.length)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_ns_array
|
34
|
+
nodes = @doc.find('//ns1:IdAndName', ['ns1:http://domain.somewhere.com'])
|
35
|
+
assert_equal(3, nodes.length)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_default_ns1
|
39
|
+
# Find all nodes with http://services.somewhere.com namespace
|
40
|
+
nodes = @doc.find('//*[namespace-uri()="http://services.somewhere.com"]')
|
41
|
+
assert_equal(2, nodes.length)
|
42
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
43
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_default_ns2
|
47
|
+
# Find all nodes with http://services.somewhere.com namespace
|
48
|
+
nodes = @doc.find('//ns:*', 'ns:http://services.somewhere.com')
|
49
|
+
assert_equal(2, nodes.length)
|
50
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
51
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
52
|
+
|
53
|
+
# Get getManufacturerNamesResponse node
|
54
|
+
nodes = @doc.find('//ns:getManufacturerNamesResponse', 'ns:http://services.somewhere.com')
|
55
|
+
assert_equal(1, nodes.length)
|
56
|
+
|
57
|
+
# Get IdAndName node
|
58
|
+
nodes = @doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
|
59
|
+
['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
|
60
|
+
assert_equal(3, nodes.length)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_default_ns3
|
64
|
+
# Find all nodes with http://services.somewhere.com namespace
|
65
|
+
nodes = @doc.find('//ns:*', 'ns' => 'http://services.somewhere.com')
|
66
|
+
assert_equal(2, nodes.length)
|
67
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
68
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_default_ns4
|
72
|
+
# Find all nodes with http://services.somewhere.com namespace
|
73
|
+
nodes = @doc.find('//ns:*', :ns => 'http://services.somewhere.com')
|
74
|
+
assert_equal(2, nodes.length)
|
75
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
76
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_default_ns5
|
80
|
+
# Find all nodes with http://services.somewhere.com namespace
|
81
|
+
XML::Namespace.new(@doc.root, 'ns', 'http://services.somewhere.com')
|
82
|
+
nodes = @doc.find('//ns:*')
|
83
|
+
assert_equal(2, nodes.length)
|
84
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
85
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_attribute_ns
|
89
|
+
# Pull all nodes with http://services.somewhere.com namespace
|
90
|
+
nodes = @doc.find('@soap:encodingStyle')
|
91
|
+
assert_equal(1, nodes.length)
|
92
|
+
assert_equal('encodingStyle', nodes.first.name)
|
93
|
+
assert_equal('http://www.w3.org/2001/12/soap-encoding', nodes.first.value)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_register_default_ns
|
97
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/atom.xml'))
|
98
|
+
|
99
|
+
# No namespace has been yet defined
|
100
|
+
assert_raise(XML::Error) do
|
101
|
+
node = doc.find("atom:title")
|
102
|
+
end
|
103
|
+
|
104
|
+
node = doc.find('atom:title', 'atom:http://www.w3.org/2005/Atom')
|
105
|
+
assert_not_nil(node)
|
106
|
+
|
107
|
+
# Register namespace
|
108
|
+
doc.root.namespaces.default_prefix = 'atom'
|
109
|
+
node = doc.find("atom:title")
|
110
|
+
assert_not_nil(node)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_node_find
|
114
|
+
nodes = @doc.find('//ns1:IdAndName', 'ns1:http://domain.somewhere.com')
|
115
|
+
node = nodes.first
|
116
|
+
|
117
|
+
# Since we are searching on the node, don't have to register namespace
|
118
|
+
nodes = node.find('ns1:name')
|
119
|
+
assert_equal(1, nodes.length)
|
120
|
+
assert_equal(nodes.first.object_id, nodes.last.object_id, 'First and last should be the same')
|
121
|
+
assert_equal('name', nodes.first.name)
|
122
|
+
assert_equal('man1', nodes.first.content)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_node_find_first
|
126
|
+
node = @doc.find_first('//ns1:IdAndName', 'ns1:http://domain.somewhere.com')
|
127
|
+
|
128
|
+
# Since we are searching on the node, don't have to register namespace
|
129
|
+
node = node.find_first('ns1:name')
|
130
|
+
assert_equal('name', node.name)
|
131
|
+
assert_equal('man1', node.content)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_node_no_doc
|
135
|
+
node = XML::Node.new('header', 'some content')
|
136
|
+
assert_raise(TypeError) do
|
137
|
+
node = node.find_first('/header')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_memory
|
142
|
+
# This sometimes causes a segmentation fault because
|
143
|
+
# an xml document is sometimes freed before the
|
144
|
+
# xpath_object used to query it. When the xpath_object
|
145
|
+
# is free, it iterates over its results which are pointers
|
146
|
+
# to the document's nodes. A segmentation fault then happens.
|
147
|
+
|
148
|
+
1000.times do
|
149
|
+
doc = XML::Document.new('1.0')
|
150
|
+
doc.root = XML::Node.new("header")
|
151
|
+
|
152
|
+
1000.times do
|
153
|
+
doc.root << XML::Node.new("footer")
|
154
|
+
end
|
155
|
+
|
156
|
+
nodes = doc.find('/header/footer')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Test that document doesn't get freed before nodes
|
161
|
+
def test_xpath_free
|
162
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
163
|
+
nodes = doc.find('//*')
|
164
|
+
GC.start
|
165
|
+
assert_equal('Envelope', nodes.first.name)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_xpath_namespace_nodes
|
169
|
+
doc = XML::Document.string('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml"><entry/></feed>')
|
170
|
+
nodes = doc.find('//atom:entry|namespace::*', :atom => "http://www.w3.org/2005/Atom")
|
171
|
+
assert_equal(4, nodes.length)
|
172
|
+
|
173
|
+
node = nodes[0]
|
174
|
+
assert_equal(XML::Node::ELEMENT_NODE, node.node_type)
|
175
|
+
|
176
|
+
node = nodes[1]
|
177
|
+
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
178
|
+
|
179
|
+
node = nodes[2]
|
180
|
+
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
181
|
+
|
182
|
+
node = nodes[3]
|
183
|
+
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Test to make sure we don't get nil on empty results.
|
187
|
+
# This is also to test that we don't segfault due to our C code getting a NULL pointer
|
188
|
+
# and not handling it properly.
|
189
|
+
def test_xpath_empty_result
|
190
|
+
doc = XML::Document.string('<html><body><p>Welcome to XHTML land!</p></body></html>')
|
191
|
+
nodes = doc.find("//object/param[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'wmode']")
|
192
|
+
assert_not_nil nodes
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require "tempfile"
|
5
|
+
require "test/unit"
|
6
|
+
|
7
|
+
class TestXPathContext < Test::Unit::TestCase
|
8
|
+
SOAP_PREFIX = 'soap'
|
9
|
+
SOAP_URI = 'http://schemas.xmlsoap.org/soap/envelope/'
|
10
|
+
|
11
|
+
NS0_PREFIX = 'ns0'
|
12
|
+
NS0_URI = 'http://services.somewhere.com'
|
13
|
+
|
14
|
+
def setup
|
15
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
16
|
+
@context = XML::XPath::Context.new(doc)
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown()
|
20
|
+
@context = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
#def test_no_ns
|
24
|
+
#assert_raise(XML::XPath::InvalidPath) do
|
25
|
+
#@context.find('/soap:Envelope')
|
26
|
+
#end
|
27
|
+
#end
|
28
|
+
|
29
|
+
def test_ns_register
|
30
|
+
@context.register_namespace(SOAP_PREFIX, SOAP_URI)
|
31
|
+
@context.register_namespace(NS0_PREFIX, NS0_URI)
|
32
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
33
|
+
assert_equal(1, nodes.length)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_ns_register_string
|
37
|
+
@context.register_namespaces("#{SOAP_PREFIX}:#{SOAP_URI}")
|
38
|
+
@context.register_namespaces("#{NS0_PREFIX}:#{NS0_URI}")
|
39
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
40
|
+
assert_equal(1, nodes.length)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_ns_register_array
|
44
|
+
@context.register_namespaces(["#{SOAP_PREFIX}:#{SOAP_URI}", "#{NS0_PREFIX}:#{NS0_URI}"])
|
45
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
46
|
+
assert_equal(1, nodes.length)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_ns_register_hash
|
50
|
+
@context.register_namespaces(SOAP_PREFIX => SOAP_URI,
|
51
|
+
NS0_PREFIX => NS0_URI)
|
52
|
+
|
53
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
54
|
+
assert_equal(1, nodes.length)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_ns_register_node
|
58
|
+
@context.register_namespaces_from_node(@context.doc.root)
|
59
|
+
nodes = @context.find('/soap:Envelope')
|
60
|
+
assert_equal(1, nodes.length)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_node
|
64
|
+
@context.register_namespaces_from_node(@context.doc.root)
|
65
|
+
|
66
|
+
nodes = @context.find('soap:Body')
|
67
|
+
assert_equal(0, nodes.length)
|
68
|
+
|
69
|
+
|
70
|
+
@context.node = @context.doc.root.child.next
|
71
|
+
nodes = @context.find('soap:Body')
|
72
|
+
assert_equal(0, nodes.length)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_cache
|
76
|
+
@context.enable_cache
|
77
|
+
@context.enable_cache(10)
|
78
|
+
@context.disable_cache
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestXPathExpression < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
10
|
+
@doc = xp.parse
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@doc = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_nodes
|
18
|
+
expr = XML::XPath::Expression.compile('/ruby_array/fixnum')
|
19
|
+
set = @doc.find(expr)
|
20
|
+
assert_instance_of(XML::XPath::Object, set)
|
21
|
+
assert_equal(2, set.size)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_find_class
|
25
|
+
expr = XML::XPath::Expression.new('/ruby_array/fixnum')
|
26
|
+
set = @doc.find(expr)
|
27
|
+
assert_instance_of(XML::XPath::Object, set)
|
28
|
+
assert_equal(2, set.size)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find_invalid
|
32
|
+
error = assert_raise(TypeError) do
|
33
|
+
set = @doc.find(999)
|
34
|
+
end
|
35
|
+
assert_equal('Argument should be an intance of a String or XPath::Expression',
|
36
|
+
error.to_s)
|
37
|
+
end
|
38
|
+
end
|
data/test/tc_xpointer.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require "test/unit"
|
5
|
+
|
6
|
+
class TC_XML_XPointer < Test::Unit::TestCase
|
7
|
+
def setup()
|
8
|
+
xp = XML::Parser.string('<!DOCTYPE ra [<!ELEMENT ra (foo+)><!ATTLIST ra id ID #IMPLIED><!ELEMENT foo (#PCDATA)><!ATTLIST foo id ID #IMPLIED>]><ra id="start"><foo id="one">one</foo><foo id="two">two</foo><foo id="three">three</foo></ra>')
|
9
|
+
@doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
11
|
+
@root = @doc.root
|
12
|
+
assert_instance_of(XML::Node, @root)
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown()
|
16
|
+
@doc = nil
|
17
|
+
@root = nil
|
18
|
+
@xptr = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_libxml_xpointer_id
|
22
|
+
xptr = @root.pointer('xpointer(id("two"))')
|
23
|
+
assert_instance_of(XML::XPath::Object, xptr)
|
24
|
+
xptr.each do |node|
|
25
|
+
# It seems from the spec that the pointer should
|
26
|
+
# be the whole node, rather than just the ID attr.
|
27
|
+
assert_equal('two', node.content)
|
28
|
+
assert_instance_of(XML::Node, node)
|
29
|
+
assert_equal('two', node['id'])
|
30
|
+
end
|
31
|
+
|
32
|
+
# FIXME: Not sure at all about this kind of range
|
33
|
+
if ENV['NOTWORKING']
|
34
|
+
@xptr = @root.pointer('xpointer(id("two")) xpointer(id("three"))')
|
35
|
+
assert_instance_of(XML::XPath, @xptr)
|
36
|
+
assert_instance_of(XML::Node::Set, @xptr.set)
|
37
|
+
assert_equal(2, @xptr.set.length)
|
38
|
+
for n in @xptr.set
|
39
|
+
assert_match(/two|three/, n.to_s)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# FIXME: There is a bug in these ranges...
|
45
|
+
if ENV['NOTWORKING']
|
46
|
+
def test_libxml_xpointer_range()
|
47
|
+
nstart = nend = nil
|
48
|
+
@xptr = @root.pointer('xpointer(id("one"))').set
|
49
|
+
@xptr.each{|n| nstart = n}
|
50
|
+
assert_instance_of(XML::Node, nstart)
|
51
|
+
@xptr = @root.pointer('xpointer(id("three"))').set
|
52
|
+
@xptr.each{|n| nend = n}
|
53
|
+
assert_instance_of(XML::Node, nend)
|
54
|
+
range = XML::XPointer.range(nstart, nend)
|
55
|
+
assert_instance_of(XML::XPath, range)
|
56
|
+
assert_instance_of(XML::Node::Set, range.set)
|
57
|
+
|
58
|
+
for n in range.set
|
59
|
+
assert_match(/one|two|three/, n.to_s)
|
60
|
+
end
|
61
|
+
assert_equal(3, range.set.length)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# def test_libxml_xpointer_start_point()
|
66
|
+
# @xptr = @root.pointer('xpointer(start-point("one"))')
|
67
|
+
# assert_instance_of(XML::XPath, @xptr)
|
68
|
+
# set = @xptr.set
|
69
|
+
# assert_instance_of(XML::Node::Set, set)
|
70
|
+
# for n in set
|
71
|
+
# assert_match(/one|two|three/, n.to_s)
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# To make testing/debugging easier, test within this source tree versus an installed gem
|
4
|
+
|
5
|
+
dir = File.dirname(__FILE__)
|
6
|
+
root = File.expand_path(File.join(dir, '..'))
|
7
|
+
lib = File.expand_path(File.join(root, 'lib'))
|
8
|
+
ext = File.expand_path(File.join(root, 'ext', 'libxml'))
|
9
|
+
|
10
|
+
$LOAD_PATH << lib
|
11
|
+
$LOAD_PATH << ext
|
12
|
+
|
13
|
+
require 'xml'
|
14
|
+
|
data/test/test_suite.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Change to current directory so relative
|
4
|
+
# requires work.
|
5
|
+
dir = File.dirname(__FILE__)
|
6
|
+
Dir.chdir(dir)
|
7
|
+
|
8
|
+
require './tc_attributes'
|
9
|
+
require './tc_attr'
|
10
|
+
require './tc_attr_decl'
|
11
|
+
require './tc_document'
|
12
|
+
require './tc_document_write'
|
13
|
+
require './tc_dtd'
|
14
|
+
require './tc_html_parser'
|
15
|
+
require './tc_namespaces'
|
16
|
+
require './tc_namespace'
|
17
|
+
require './tc_node'
|
18
|
+
require './tc_node_cdata'
|
19
|
+
require './tc_node_comment'
|
20
|
+
require './tc_node_copy'
|
21
|
+
require './tc_node_edit'
|
22
|
+
require './tc_node_text'
|
23
|
+
require './tc_node_write'
|
24
|
+
require './tc_node_xlink'
|
25
|
+
require './tc_parser'
|
26
|
+
require './tc_parser_context'
|
27
|
+
require './tc_reader'
|
28
|
+
require './tc_relaxng'
|
29
|
+
require './tc_sax_parser'
|
30
|
+
require './tc_schema'
|
31
|
+
require './tc_traversal'
|
32
|
+
require './tc_xinclude'
|
33
|
+
require './tc_xpath'
|
34
|
+
require './tc_xpath_expression'
|
35
|
+
require './tc_xpointer'
|
36
|
+
|
37
|
+
# Compatibility
|
38
|
+
require './tc_properties'
|
39
|
+
require './tc_deprecated_require'
|
metadata
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: libxml-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 2.0.0
|
6
|
+
platform: x86-mingw32
|
7
|
+
authors:
|
8
|
+
- Ross Bamform
|
9
|
+
- Wai-Sun Chia
|
10
|
+
- Sean Chittenden
|
11
|
+
- Dan Janwoski
|
12
|
+
- Anurag Priyam
|
13
|
+
- Charlie Savage
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-16 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: " The Libxml-Ruby project provides Ruby language bindings for the GNOME\n Libxml2 XML toolkit. It is free software, released under the MIT License.\n Libxml-ruby's primary advantage over REXML is performance - if speed\n is your need, these are good libraries to consider, as demonstrated\n by the informal benchmark below.\n"
|
23
|
+
email:
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions:
|
27
|
+
- ext/libxml/extconf.rb
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- HISTORY
|
32
|
+
- LICENSE
|
33
|
+
- libxml-ruby.gemspec
|
34
|
+
- MANIFEST
|
35
|
+
- Rakefile
|
36
|
+
- README.rdoc
|
37
|
+
- setup.rb
|
38
|
+
- ext/libxml/ruby_libxml.h
|
39
|
+
- ext/libxml/ruby_xml.h
|
40
|
+
- ext/libxml/ruby_xml_attr.h
|
41
|
+
- ext/libxml/ruby_xml_attributes.h
|
42
|
+
- ext/libxml/ruby_xml_attr_decl.h
|
43
|
+
- ext/libxml/ruby_xml_document.h
|
44
|
+
- ext/libxml/ruby_xml_dtd.h
|
45
|
+
- ext/libxml/ruby_xml_encoding.h
|
46
|
+
- ext/libxml/ruby_xml_error.h
|
47
|
+
- ext/libxml/ruby_xml_html_parser.h
|
48
|
+
- ext/libxml/ruby_xml_html_parser_context.h
|
49
|
+
- ext/libxml/ruby_xml_html_parser_options.h
|
50
|
+
- ext/libxml/ruby_xml_input_cbg.h
|
51
|
+
- ext/libxml/ruby_xml_io.h
|
52
|
+
- ext/libxml/ruby_xml_namespace.h
|
53
|
+
- ext/libxml/ruby_xml_namespaces.h
|
54
|
+
- ext/libxml/ruby_xml_node.h
|
55
|
+
- ext/libxml/ruby_xml_parser.h
|
56
|
+
- ext/libxml/ruby_xml_parser_context.h
|
57
|
+
- ext/libxml/ruby_xml_parser_options.h
|
58
|
+
- ext/libxml/ruby_xml_reader.h
|
59
|
+
- ext/libxml/ruby_xml_relaxng.h
|
60
|
+
- ext/libxml/ruby_xml_sax2_handler.h
|
61
|
+
- ext/libxml/ruby_xml_sax_parser.h
|
62
|
+
- ext/libxml/ruby_xml_schema.h
|
63
|
+
- ext/libxml/ruby_xml_version.h
|
64
|
+
- ext/libxml/ruby_xml_xinclude.h
|
65
|
+
- ext/libxml/ruby_xml_xpath.h
|
66
|
+
- ext/libxml/ruby_xml_xpath_context.h
|
67
|
+
- ext/libxml/ruby_xml_xpath_expression.h
|
68
|
+
- ext/libxml/ruby_xml_xpath_object.h
|
69
|
+
- ext/libxml/ruby_xml_xpointer.h
|
70
|
+
- ext/libxml/libxml.c
|
71
|
+
- ext/libxml/ruby_xml.c
|
72
|
+
- ext/libxml/ruby_xml_attr.c
|
73
|
+
- ext/libxml/ruby_xml_attributes.c
|
74
|
+
- ext/libxml/ruby_xml_attr_decl.c
|
75
|
+
- ext/libxml/ruby_xml_cbg.c
|
76
|
+
- ext/libxml/ruby_xml_document.c
|
77
|
+
- ext/libxml/ruby_xml_dtd.c
|
78
|
+
- ext/libxml/ruby_xml_encoding.c
|
79
|
+
- ext/libxml/ruby_xml_error.c
|
80
|
+
- ext/libxml/ruby_xml_html_parser.c
|
81
|
+
- ext/libxml/ruby_xml_html_parser_context.c
|
82
|
+
- ext/libxml/ruby_xml_html_parser_options.c
|
83
|
+
- ext/libxml/ruby_xml_input_cbg.c
|
84
|
+
- ext/libxml/ruby_xml_io.c
|
85
|
+
- ext/libxml/ruby_xml_namespace.c
|
86
|
+
- ext/libxml/ruby_xml_namespaces.c
|
87
|
+
- ext/libxml/ruby_xml_node.c
|
88
|
+
- ext/libxml/ruby_xml_parser.c
|
89
|
+
- ext/libxml/ruby_xml_parser_context.c
|
90
|
+
- ext/libxml/ruby_xml_parser_options.c
|
91
|
+
- ext/libxml/ruby_xml_reader.c
|
92
|
+
- ext/libxml/ruby_xml_relaxng.c
|
93
|
+
- ext/libxml/ruby_xml_sax2_handler.c
|
94
|
+
- ext/libxml/ruby_xml_sax_parser.c
|
95
|
+
- ext/libxml/ruby_xml_schema.c
|
96
|
+
- ext/libxml/ruby_xml_xinclude.c
|
97
|
+
- ext/libxml/ruby_xml_xpath.c
|
98
|
+
- ext/libxml/ruby_xml_xpath_context.c
|
99
|
+
- ext/libxml/ruby_xml_xpath_expression.c
|
100
|
+
- ext/libxml/ruby_xml_xpath_object.c
|
101
|
+
- ext/libxml/ruby_xml_xpointer.c
|
102
|
+
- ext/libxml/extconf.rb
|
103
|
+
- ext/mingw/Rakefile
|
104
|
+
- ext/mingw/build.rake
|
105
|
+
- ext/vc/libxml_ruby.sln
|
106
|
+
- lib/libxml/attr.rb
|
107
|
+
- lib/libxml/attributes.rb
|
108
|
+
- lib/libxml/attr_decl.rb
|
109
|
+
- lib/libxml/document.rb
|
110
|
+
- lib/libxml/error.rb
|
111
|
+
- lib/libxml/hpricot.rb
|
112
|
+
- lib/libxml/html_parser.rb
|
113
|
+
- lib/libxml/namespace.rb
|
114
|
+
- lib/libxml/namespaces.rb
|
115
|
+
- lib/libxml/node.rb
|
116
|
+
- lib/libxml/ns.rb
|
117
|
+
- lib/libxml/parser.rb
|
118
|
+
- lib/libxml/properties.rb
|
119
|
+
- lib/libxml/reader.rb
|
120
|
+
- lib/libxml/sax_callbacks.rb
|
121
|
+
- lib/libxml/sax_parser.rb
|
122
|
+
- lib/libxml/tree.rb
|
123
|
+
- lib/libxml/xpath_object.rb
|
124
|
+
- lib/libxml.rb
|
125
|
+
- lib/xml/libxml.rb
|
126
|
+
- lib/xml.rb
|
127
|
+
- script/benchmark/depixelate
|
128
|
+
- script/benchmark/hamlet.xml
|
129
|
+
- script/benchmark/parsecount
|
130
|
+
- script/benchmark/sock_entries.xml
|
131
|
+
- script/benchmark/throughput
|
132
|
+
- script/test
|
133
|
+
- test/etc_doc_to_s.rb
|
134
|
+
- test/ets_doc_file.rb
|
135
|
+
- test/ets_doc_to_s.rb
|
136
|
+
- test/ets_gpx.rb
|
137
|
+
- test/ets_node_gc.rb
|
138
|
+
- test/ets_test.xml
|
139
|
+
- test/ets_tsr.rb
|
140
|
+
- test/model/atom.xml
|
141
|
+
- test/model/bands.iso-8859-1.xml
|
142
|
+
- test/model/bands.utf-8.xml
|
143
|
+
- test/model/bands.xml
|
144
|
+
- test/model/books.xml
|
145
|
+
- test/model/merge_bug_data.xml
|
146
|
+
- test/model/ruby-lang.html
|
147
|
+
- test/model/rubynet.xml
|
148
|
+
- test/model/rubynet_project
|
149
|
+
- test/model/shiporder.rnc
|
150
|
+
- test/model/shiporder.rng
|
151
|
+
- test/model/shiporder.xml
|
152
|
+
- test/model/shiporder.xsd
|
153
|
+
- test/model/soap.xml
|
154
|
+
- test/model/xinclude.xml
|
155
|
+
- test/rb-magic-comment.rb
|
156
|
+
- test/tc_attr.rb
|
157
|
+
- test/tc_attributes.rb
|
158
|
+
- test/tc_attr_decl.rb
|
159
|
+
- test/tc_deprecated_require.rb
|
160
|
+
- test/tc_document.rb
|
161
|
+
- test/tc_document_write.rb
|
162
|
+
- test/tc_dtd.rb
|
163
|
+
- test/tc_error.rb
|
164
|
+
- test/tc_html_parser.rb
|
165
|
+
- test/tc_namespace.rb
|
166
|
+
- test/tc_namespaces.rb
|
167
|
+
- test/tc_node.rb
|
168
|
+
- test/tc_node_cdata.rb
|
169
|
+
- test/tc_node_comment.rb
|
170
|
+
- test/tc_node_copy.rb
|
171
|
+
- test/tc_node_edit.rb
|
172
|
+
- test/tc_node_text.rb
|
173
|
+
- test/tc_node_write.rb
|
174
|
+
- test/tc_node_xlink.rb
|
175
|
+
- test/tc_parser.rb
|
176
|
+
- test/tc_parser_context.rb
|
177
|
+
- test/tc_properties.rb
|
178
|
+
- test/tc_reader.rb
|
179
|
+
- test/tc_relaxng.rb
|
180
|
+
- test/tc_sax_parser.rb
|
181
|
+
- test/tc_schema.rb
|
182
|
+
- test/tc_traversal.rb
|
183
|
+
- test/tc_xinclude.rb
|
184
|
+
- test/tc_xml.rb
|
185
|
+
- test/tc_xpath.rb
|
186
|
+
- test/tc_xpath_context.rb
|
187
|
+
- test/tc_xpath_expression.rb
|
188
|
+
- test/tc_xpointer.rb
|
189
|
+
- test/test_helper.rb
|
190
|
+
- test/test_suite.rb
|
191
|
+
- lib/1.8/libxml_ruby.so
|
192
|
+
- lib/1.9/libxml_ruby.so
|
193
|
+
has_rdoc: true
|
194
|
+
homepage: http://xml4r.github.com/libxml-ruby
|
195
|
+
licenses: []
|
196
|
+
|
197
|
+
post_install_message:
|
198
|
+
rdoc_options: []
|
199
|
+
|
200
|
+
require_paths:
|
201
|
+
- lib
|
202
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 1.8.6
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: "0"
|
214
|
+
requirements: []
|
215
|
+
|
216
|
+
rubyforge_project:
|
217
|
+
rubygems_version: 1.5.2
|
218
|
+
signing_key:
|
219
|
+
specification_version: 3
|
220
|
+
summary: Ruby Bindings for LibXML2
|
221
|
+
test_files:
|
222
|
+
- test/tc_attr.rb
|
223
|
+
- test/tc_attributes.rb
|
224
|
+
- test/tc_attr_decl.rb
|
225
|
+
- test/tc_deprecated_require.rb
|
226
|
+
- test/tc_document.rb
|
227
|
+
- test/tc_document_write.rb
|
228
|
+
- test/tc_dtd.rb
|
229
|
+
- test/tc_error.rb
|
230
|
+
- test/tc_html_parser.rb
|
231
|
+
- test/tc_namespace.rb
|
232
|
+
- test/tc_namespaces.rb
|
233
|
+
- test/tc_node.rb
|
234
|
+
- test/tc_node_cdata.rb
|
235
|
+
- test/tc_node_comment.rb
|
236
|
+
- test/tc_node_copy.rb
|
237
|
+
- test/tc_node_edit.rb
|
238
|
+
- test/tc_node_text.rb
|
239
|
+
- test/tc_node_write.rb
|
240
|
+
- test/tc_node_xlink.rb
|
241
|
+
- test/tc_parser.rb
|
242
|
+
- test/tc_parser_context.rb
|
243
|
+
- test/tc_properties.rb
|
244
|
+
- test/tc_reader.rb
|
245
|
+
- test/tc_relaxng.rb
|
246
|
+
- test/tc_sax_parser.rb
|
247
|
+
- test/tc_schema.rb
|
248
|
+
- test/tc_traversal.rb
|
249
|
+
- test/tc_xinclude.rb
|
250
|
+
- test/tc_xml.rb
|
251
|
+
- test/tc_xpath.rb
|
252
|
+
- test/tc_xpath_context.rb
|
253
|
+
- test/tc_xpath_expression.rb
|
254
|
+
- test/tc_xpointer.rb
|