smile-xml 1.0.0-jruby → 1.0.2-jruby
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/smile-xml.jar +0 -0
- data/src/main/java/smile/xml/AttrJ.java +160 -0
- data/src/main/java/smile/xml/AttributesJ.java +212 -0
- data/src/main/java/smile/xml/BaseJ.java +60 -0
- data/src/main/java/smile/xml/DocumentJ.java +435 -0
- data/src/main/java/smile/xml/EncodingJ.java +94 -0
- data/src/main/java/smile/xml/ErrorJ.java +162 -0
- data/src/main/java/smile/xml/NamespaceJ.java +67 -0
- data/src/main/java/smile/xml/NamespacesJ.java +62 -0
- data/src/main/java/smile/xml/NodeJ.java +1029 -0
- data/src/main/java/smile/xml/NodeSetJ.java +90 -0
- data/src/main/java/smile/xml/ParserContextJ.java +44 -0
- data/src/main/java/smile/xml/ParserJ.java +196 -0
- data/src/main/java/smile/xml/ParserOptionsJ.java +58 -0
- data/src/main/java/smile/xml/ReaderJ.java +34 -0
- data/src/main/java/smile/xml/SchemaJ.java +66 -0
- data/src/main/java/smile/xml/SmileXML.java +65 -0
- data/src/main/java/smile/xml/XmlJ.java +58 -0
- data/src/main/java/smile/xml/sax/CallbackHandler.java +113 -0
- data/src/main/java/smile/xml/sax/SaxParserCallbacksJ.java +71 -0
- data/src/main/java/smile/xml/sax/SaxParserJ.java +153 -0
- data/src/main/java/smile/xml/util/UtilJ.java +424 -0
- data/src/main/java/smile/xml/xpath/CustomNamespaceContext.java +59 -0
- data/src/main/java/smile/xml/xpath/XPathContextJ.java +154 -0
- data/src/main/java/smile/xml/xpath/XPathExpressionJ.java +62 -0
- data/src/main/java/smile/xml/xpath/XPathJ.java +36 -0
- data/src/main/java/smile/xml/xpath/XPathObjectJ.java +196 -0
- data/src/main/java/smile/xml/xpath/XPointerJ.java +32 -0
- data/src/main/ruby/xml/libxml.rb +1 -0
- data/src/main/ruby/xml.rb +5 -0
- data/src/test/ruby/etc_doc_to_s.rb +21 -0
- data/src/test/ruby/ets_doc_file.rb +17 -0
- data/src/test/ruby/ets_doc_to_s.rb +23 -0
- data/src/test/ruby/ets_gpx.rb +28 -0
- data/src/test/ruby/ets_node_gc.rb +23 -0
- data/src/test/ruby/ets_test.xml +2 -0
- data/src/test/ruby/ets_tsr.rb +11 -0
- data/src/test/ruby/model/atom.xml +13 -0
- data/src/test/ruby/model/bands.iso-8859-1.xml +5 -0
- data/src/test/ruby/model/bands.utf-8.xml +5 -0
- data/src/test/ruby/model/bands.xml +5 -0
- data/src/test/ruby/model/books.xml +146 -0
- data/src/test/ruby/model/merge_bug_data.xml +58 -0
- data/src/test/ruby/model/ruby-lang.html +238 -0
- data/src/test/ruby/model/rubynet.xml +79 -0
- data/src/test/ruby/model/shiporder.rnc +28 -0
- data/src/test/ruby/model/shiporder.rng +86 -0
- data/src/test/ruby/model/shiporder.xml +23 -0
- data/src/test/ruby/model/shiporder.xsd +31 -0
- data/src/test/ruby/model/soap.xml +27 -0
- data/src/test/ruby/model/xinclude.xml +5 -0
- data/src/test/ruby/smile_xml_test.rb +64 -0
- data/src/test/ruby/tc_attr.rb +191 -0
- data/src/test/ruby/tc_attr_decl.rb +133 -0
- data/src/test/ruby/tc_attributes.rb +135 -0
- data/src/test/ruby/tc_deprecated_require.rb +13 -0
- data/src/test/ruby/tc_document.rb +162 -0
- data/src/test/ruby/tc_document_write.rb +212 -0
- data/src/test/ruby/tc_dtd.rb +125 -0
- data/src/test/ruby/tc_error.rb +150 -0
- data/src/test/ruby/tc_html_parser.rb +140 -0
- data/src/test/ruby/tc_namespace.rb +62 -0
- data/src/test/ruby/tc_namespaces.rb +210 -0
- data/src/test/ruby/tc_node.rb +273 -0
- data/src/test/ruby/tc_node_cdata.rb +51 -0
- data/src/test/ruby/tc_node_comment.rb +33 -0
- data/src/test/ruby/tc_node_copy.rb +42 -0
- data/src/test/ruby/tc_node_edit.rb +178 -0
- data/src/test/ruby/tc_node_text.rb +73 -0
- data/src/test/ruby/tc_node_write.rb +108 -0
- data/src/test/ruby/tc_node_xlink.rb +29 -0
- data/src/test/ruby/tc_parser.rb +371 -0
- data/src/test/ruby/tc_parser_context.rb +189 -0
- data/src/test/ruby/tc_properties.rb +40 -0
- data/src/test/ruby/tc_reader.rb +306 -0
- data/src/test/ruby/tc_relaxng.rb +54 -0
- data/src/test/ruby/tc_sax_parser.rb +340 -0
- data/src/test/ruby/tc_schema.rb +59 -0
- data/src/test/ruby/tc_traversal.rb +222 -0
- data/src/test/ruby/tc_xinclude.rb +21 -0
- data/src/test/ruby/tc_xml.rb +226 -0
- data/src/test/ruby/tc_xpath.rb +210 -0
- data/src/test/ruby/tc_xpath_context.rb +80 -0
- data/src/test/ruby/tc_xpath_expression.rb +38 -0
- data/src/test/ruby/tc_xpointer.rb +74 -0
- data/src/test/ruby/test_helper.rb +23 -0
- data/src/test/ruby/test_suite.rb +41 -0
- metadata +91 -5
@@ -0,0 +1,210 @@
|
|
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
|
+
# def test_invalid_expression
|
196
|
+
# xml = LibXML::XML::Document.string('<a></a>')
|
197
|
+
#
|
198
|
+
# # Using the expression twice used to cause a Segmentation Fault
|
199
|
+
# error = assert_raise(XML::Error) do
|
200
|
+
# xml.find('//a/')
|
201
|
+
# end
|
202
|
+
# assert_equal("Error: Invalid expression.", error.to_s)
|
203
|
+
#
|
204
|
+
# # Try again - this used to cause a Segmentation Fault
|
205
|
+
# error = assert_raise(XML::Error) do
|
206
|
+
# xml.find('//a/')
|
207
|
+
# end
|
208
|
+
# assert_equal("Error: Invalid expression.", error.to_s)
|
209
|
+
# end
|
210
|
+
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
|
@@ -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
|
@@ -0,0 +1,23 @@
|
|
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
|
+
|
15
|
+
|
16
|
+
def remove_header_declaration( xml )
|
17
|
+
if xml.strip.start_with?( '<?xml')
|
18
|
+
i = xml.index( '?>', 3 )
|
19
|
+
xml[ i+2, xml.length-i ]
|
20
|
+
else
|
21
|
+
xml
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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_attr'
|
9
|
+
require './tc_attr_decl'
|
10
|
+
require './tc_attributes'
|
11
|
+
require './tc_document'
|
12
|
+
require './tc_document_write'
|
13
|
+
require './tc_dtd'
|
14
|
+
require './tc_error'
|
15
|
+
require './tc_html_parser'
|
16
|
+
require './tc_namespace'
|
17
|
+
require './tc_namespaces'
|
18
|
+
require './tc_node'
|
19
|
+
require './tc_node_cdata'
|
20
|
+
require './tc_node_comment'
|
21
|
+
require './tc_node_copy'
|
22
|
+
require './tc_node_edit'
|
23
|
+
require './tc_node_text'
|
24
|
+
require './tc_node_write'
|
25
|
+
require './tc_node_xlink'
|
26
|
+
require './tc_parser'
|
27
|
+
require './tc_parser_context'
|
28
|
+
require './tc_reader'
|
29
|
+
require './tc_relaxng'
|
30
|
+
require './tc_sax_parser'
|
31
|
+
require './tc_schema'
|
32
|
+
require './tc_traversal'
|
33
|
+
require './tc_xinclude'
|
34
|
+
require './tc_xpath'
|
35
|
+
require './tc_xpath_context'
|
36
|
+
require './tc_xpath_expression'
|
37
|
+
require './tc_xpointer'
|
38
|
+
|
39
|
+
# Compatibility
|
40
|
+
require './tc_properties'
|
41
|
+
require './tc_deprecated_require'
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: smile-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: jruby
|
7
7
|
authors:
|
8
8
|
- Andre Kullmann
|
@@ -10,11 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-06
|
13
|
+
date: 2012-07-06 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
17
|
-
email:
|
16
|
+
description: ""
|
17
|
+
email: andre [dot] kullmann [at] googlemail [dot] com
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
@@ -25,7 +25,93 @@ files:
|
|
25
25
|
- lib/smile-xml.jar
|
26
26
|
- lib/xml.rb
|
27
27
|
- lib/xml/libxml.rb
|
28
|
-
|
28
|
+
- src/main/java/smile/xml/AttributesJ.java
|
29
|
+
- src/main/java/smile/xml/AttrJ.java
|
30
|
+
- src/main/java/smile/xml/BaseJ.java
|
31
|
+
- src/main/java/smile/xml/DocumentJ.java
|
32
|
+
- src/main/java/smile/xml/EncodingJ.java
|
33
|
+
- src/main/java/smile/xml/ErrorJ.java
|
34
|
+
- src/main/java/smile/xml/NamespaceJ.java
|
35
|
+
- src/main/java/smile/xml/NamespacesJ.java
|
36
|
+
- src/main/java/smile/xml/NodeJ.java
|
37
|
+
- src/main/java/smile/xml/NodeSetJ.java
|
38
|
+
- src/main/java/smile/xml/ParserContextJ.java
|
39
|
+
- src/main/java/smile/xml/ParserJ.java
|
40
|
+
- src/main/java/smile/xml/ParserOptionsJ.java
|
41
|
+
- src/main/java/smile/xml/ReaderJ.java
|
42
|
+
- src/main/java/smile/xml/SchemaJ.java
|
43
|
+
- src/main/java/smile/xml/SmileXML.java
|
44
|
+
- src/main/java/smile/xml/XmlJ.java
|
45
|
+
- src/main/java/smile/xml/sax/CallbackHandler.java
|
46
|
+
- src/main/java/smile/xml/sax/SaxParserCallbacksJ.java
|
47
|
+
- src/main/java/smile/xml/sax/SaxParserJ.java
|
48
|
+
- src/main/java/smile/xml/util/UtilJ.java
|
49
|
+
- src/main/java/smile/xml/xpath/CustomNamespaceContext.java
|
50
|
+
- src/main/java/smile/xml/xpath/XPathContextJ.java
|
51
|
+
- src/main/java/smile/xml/xpath/XPathExpressionJ.java
|
52
|
+
- src/main/java/smile/xml/xpath/XPathJ.java
|
53
|
+
- src/main/java/smile/xml/xpath/XPathObjectJ.java
|
54
|
+
- src/main/java/smile/xml/xpath/XPointerJ.java
|
55
|
+
- src/main/ruby/xml.rb
|
56
|
+
- src/main/ruby/xml/libxml.rb
|
57
|
+
- src/test/ruby/etc_doc_to_s.rb
|
58
|
+
- src/test/ruby/ets_doc_file.rb
|
59
|
+
- src/test/ruby/ets_doc_to_s.rb
|
60
|
+
- src/test/ruby/ets_gpx.rb
|
61
|
+
- src/test/ruby/ets_node_gc.rb
|
62
|
+
- src/test/ruby/ets_test.xml
|
63
|
+
- src/test/ruby/ets_tsr.rb
|
64
|
+
- src/test/ruby/smile_xml_test.rb
|
65
|
+
- src/test/ruby/tc_attr.rb
|
66
|
+
- src/test/ruby/tc_attributes.rb
|
67
|
+
- src/test/ruby/tc_attr_decl.rb
|
68
|
+
- src/test/ruby/tc_deprecated_require.rb
|
69
|
+
- src/test/ruby/tc_document.rb
|
70
|
+
- src/test/ruby/tc_document_write.rb
|
71
|
+
- src/test/ruby/tc_dtd.rb
|
72
|
+
- src/test/ruby/tc_error.rb
|
73
|
+
- src/test/ruby/tc_html_parser.rb
|
74
|
+
- src/test/ruby/tc_namespace.rb
|
75
|
+
- src/test/ruby/tc_namespaces.rb
|
76
|
+
- src/test/ruby/tc_node.rb
|
77
|
+
- src/test/ruby/tc_node_cdata.rb
|
78
|
+
- src/test/ruby/tc_node_comment.rb
|
79
|
+
- src/test/ruby/tc_node_copy.rb
|
80
|
+
- src/test/ruby/tc_node_edit.rb
|
81
|
+
- src/test/ruby/tc_node_text.rb
|
82
|
+
- src/test/ruby/tc_node_write.rb
|
83
|
+
- src/test/ruby/tc_node_xlink.rb
|
84
|
+
- src/test/ruby/tc_parser.rb
|
85
|
+
- src/test/ruby/tc_parser_context.rb
|
86
|
+
- src/test/ruby/tc_properties.rb
|
87
|
+
- src/test/ruby/tc_reader.rb
|
88
|
+
- src/test/ruby/tc_relaxng.rb
|
89
|
+
- src/test/ruby/tc_sax_parser.rb
|
90
|
+
- src/test/ruby/tc_schema.rb
|
91
|
+
- src/test/ruby/tc_traversal.rb
|
92
|
+
- src/test/ruby/tc_xinclude.rb
|
93
|
+
- src/test/ruby/tc_xml.rb
|
94
|
+
- src/test/ruby/tc_xpath.rb
|
95
|
+
- src/test/ruby/tc_xpath_context.rb
|
96
|
+
- src/test/ruby/tc_xpath_expression.rb
|
97
|
+
- src/test/ruby/tc_xpointer.rb
|
98
|
+
- src/test/ruby/test_helper.rb
|
99
|
+
- src/test/ruby/test_suite.rb
|
100
|
+
- src/test/ruby/model/atom.xml
|
101
|
+
- src/test/ruby/model/bands.iso-8859-1.xml
|
102
|
+
- src/test/ruby/model/bands.utf-8.xml
|
103
|
+
- src/test/ruby/model/bands.xml
|
104
|
+
- src/test/ruby/model/books.xml
|
105
|
+
- src/test/ruby/model/merge_bug_data.xml
|
106
|
+
- src/test/ruby/model/ruby-lang.html
|
107
|
+
- src/test/ruby/model/rubynet.xml
|
108
|
+
- src/test/ruby/model/shiporder.rnc
|
109
|
+
- src/test/ruby/model/shiporder.rng
|
110
|
+
- src/test/ruby/model/shiporder.xml
|
111
|
+
- src/test/ruby/model/shiporder.xsd
|
112
|
+
- src/test/ruby/model/soap.xml
|
113
|
+
- src/test/ruby/model/xinclude.xml
|
114
|
+
homepage: https://github.com/areman/smile-xml
|
29
115
|
licenses: []
|
30
116
|
|
31
117
|
post_install_message:
|