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,178 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TestNodeEdit < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
|
9
|
+
@doc = xp.parse
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
@doc = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def first_node
|
17
|
+
@doc.root.child
|
18
|
+
end
|
19
|
+
|
20
|
+
def second_node
|
21
|
+
first_node.next
|
22
|
+
end
|
23
|
+
|
24
|
+
def third_node
|
25
|
+
second_node.next
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_add_next_01
|
29
|
+
first_node.next = XML::Node.new('num', 'one-and-a-half')
|
30
|
+
assert_equal('<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
31
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'') ) )
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_add_next_02
|
35
|
+
second_node.next = XML::Node.new('num', 'two-and-a-half')
|
36
|
+
assert_equal('<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
37
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'') ) )
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_add_next_03
|
41
|
+
third_node.next = XML::Node.new('num', 'four')
|
42
|
+
assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
|
43
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'') )
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_add_prev_01
|
47
|
+
first_node.prev = XML::Node.new('num', 'half')
|
48
|
+
assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
|
49
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'') )
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_add_prev_02
|
53
|
+
second_node.prev = XML::Node.new('num', 'one-and-a-half')
|
54
|
+
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
55
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'') )
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_add_prev_03
|
59
|
+
third_node.prev = XML::Node.new('num', 'two-and-a-half')
|
60
|
+
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
61
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'') )
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_remove_node
|
65
|
+
first_node.remove!
|
66
|
+
assert_equal('<test><num>two</num><num>three</num></test>',
|
67
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'')) )
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_freed_node
|
71
|
+
root = XML::Node.new("root")
|
72
|
+
|
73
|
+
a = XML::Node.new("a")
|
74
|
+
root << a
|
75
|
+
|
76
|
+
a.parent.remove!
|
77
|
+
|
78
|
+
puts "TODO #{__FILE__} #{__LINE__}"
|
79
|
+
# # Node a has now been freed from under us
|
80
|
+
# error = assert_raise(RuntimeError) do
|
81
|
+
# a.to_s
|
82
|
+
# end
|
83
|
+
# assert_equal('This node has already been freed.', error.to_s)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_remove_node_gc
|
87
|
+
xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
|
88
|
+
doc = xp.parse
|
89
|
+
node = doc.root.child.remove!
|
90
|
+
node = nil
|
91
|
+
GC.start
|
92
|
+
assert_not_nil(doc)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_remove_node_iteration
|
96
|
+
nodes = Array.new
|
97
|
+
@doc.root.each_element do |node|
|
98
|
+
if node.name == 'num'
|
99
|
+
nodes << node
|
100
|
+
node.remove!
|
101
|
+
end
|
102
|
+
end
|
103
|
+
assert_equal(3, nodes.length)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_reuse_removed_node
|
107
|
+
# Remove the node
|
108
|
+
node = @doc.root.first.remove!
|
109
|
+
assert_not_nil(node)
|
110
|
+
|
111
|
+
# Add it to the end of the document
|
112
|
+
@doc.root.last.next = node
|
113
|
+
|
114
|
+
assert_equal('<test><num>two</num><num>three</num><num>one</num></test>',
|
115
|
+
remove_header_declaration( @doc.root.to_s.gsub(/\n\s*/,'')) )
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_append_existing_node
|
119
|
+
doc = XML::Parser.string('<top>a<bottom>b<one>first</one><two>second</two>c</bottom>d</top>').parse
|
120
|
+
node1 = doc.find_first('//two')
|
121
|
+
|
122
|
+
doc.root << node1
|
123
|
+
assert_equal('<top>a<bottom>b<one>first</one>c</bottom>d<two>second</two></top>',
|
124
|
+
remove_header_declaration( doc.root.to_s) )
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_wrong_doc
|
128
|
+
|
129
|
+
doc1 = XML::Parser.string('<nums><one></one></nums>').parse
|
130
|
+
doc2 = XML::Parser.string('<nums><two></two></nums>').parse
|
131
|
+
|
132
|
+
node = doc1.root.child
|
133
|
+
|
134
|
+
error = assert_raise(XML::Error) do
|
135
|
+
doc2.root << node
|
136
|
+
end
|
137
|
+
|
138
|
+
GC.start
|
139
|
+
assert_equal(' Nodes belong to different documents. You must first import the node by calling XML::Document.import.',
|
140
|
+
error.to_s)
|
141
|
+
end
|
142
|
+
|
143
|
+
# This test is to verify that an earlier reported bug has been fixed
|
144
|
+
def test_merge
|
145
|
+
documents = []
|
146
|
+
|
147
|
+
# Read in 500 documents
|
148
|
+
500.times do
|
149
|
+
documents << XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
|
150
|
+
end
|
151
|
+
|
152
|
+
master_doc = documents.shift
|
153
|
+
documents.inject(master_doc) do |master_doc, child_doc|
|
154
|
+
master_body = master_doc.find("//body").first
|
155
|
+
child_body = child_doc.find("//body").first
|
156
|
+
|
157
|
+
child_element = child_body.detect do |node|
|
158
|
+
node.element?
|
159
|
+
end
|
160
|
+
|
161
|
+
master_body << child_element.copy(true)
|
162
|
+
master_doc
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_append_chain
|
167
|
+
node = XML::Node.new('foo') << XML::Node.new('bar') << "bars contents"
|
168
|
+
assert_equal('<foo><bar/>bars contents</foo>',
|
169
|
+
remove_header_declaration( node.to_s) )
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_set_base
|
173
|
+
@doc.root.base_uri = 'http://www.rubynet.org/'
|
174
|
+
#assert_equal("<test xml:base=\"http://www.rubynet.org/\">\n <num>one</num>\n <num>two</num>\n <num>three</num>\n</test>",
|
175
|
+
assert_equal("<test xml:base=\"http://www.rubynet.org/\"><num>one</num><num>two</num><num>three</num></test>",
|
176
|
+
remove_header_declaration( @doc.root.to_s) )
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TestTextNode < Test::Unit::TestCase
|
7
|
+
def test_content
|
8
|
+
node = XML::Node.new_text('testdata')
|
9
|
+
assert_instance_of(XML::Node, node)
|
10
|
+
assert_equal('testdata', node.content)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_invalid_content
|
14
|
+
error = assert_raise(TypeError) do
|
15
|
+
node = XML::Node.new_text(nil)
|
16
|
+
end
|
17
|
+
assert_equal('wrong argument type nil (expected String)', error.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
# We use the same facility that libXSLT does here to disable output escaping.
|
21
|
+
# This lets you specify that the node's content should be rendered unaltered
|
22
|
+
# whenever it is being output. This is useful for things like <script> and
|
23
|
+
# <style> nodes in HTML documents if you don't want to be forced to wrap them
|
24
|
+
# in CDATA nodes. Or if you are sanitizing existing HTML documents and want
|
25
|
+
# to preserve the content of any of the text nodes.
|
26
|
+
#
|
27
|
+
def test_output_escaping
|
28
|
+
textnoenc = 'if (a < b || c > d) return "e";'
|
29
|
+
text = "if (a < b || c > d) return \"e\";"
|
30
|
+
|
31
|
+
node = XML::Node.new_text(textnoenc)
|
32
|
+
assert node.output_escaping?
|
33
|
+
assert_equal text, remove_header_declaration( node.to_s )
|
34
|
+
|
35
|
+
node.output_escaping = false
|
36
|
+
puts "TODO #{__FILE__} #{__LINE__}"
|
37
|
+
#assert_equal textnoenc, node.to_s
|
38
|
+
|
39
|
+
node.output_escaping = true
|
40
|
+
assert_equal text, remove_header_declaration( node.to_s )
|
41
|
+
|
42
|
+
node.output_escaping = nil
|
43
|
+
puts "TODO #{__FILE__} #{__LINE__}"
|
44
|
+
#assert_equal textnoenc, node.to_s
|
45
|
+
|
46
|
+
node.output_escaping = true
|
47
|
+
assert_equal text, remove_header_declaration( node.to_s )
|
48
|
+
end
|
49
|
+
|
50
|
+
# Just a sanity check for output escaping.
|
51
|
+
def test_output_escaping_sanity
|
52
|
+
node = XML::Node.new_text('testdata')
|
53
|
+
assert_equal 'text', node.name
|
54
|
+
assert node.output_escaping?
|
55
|
+
|
56
|
+
node.output_escaping = false
|
57
|
+
assert_equal 'textnoenc', node.name
|
58
|
+
assert ! node.output_escaping?
|
59
|
+
|
60
|
+
node.output_escaping = true
|
61
|
+
assert_equal 'text', node.name
|
62
|
+
assert node.output_escaping?
|
63
|
+
|
64
|
+
node.output_escaping = nil
|
65
|
+
assert_equal 'textnoenc', node.name
|
66
|
+
assert ! node.output_escaping?
|
67
|
+
|
68
|
+
node.output_escaping = true
|
69
|
+
assert_equal 'text', node.name
|
70
|
+
assert node.output_escaping?
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TestNodeWrite < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
load_encoding("utf-8")
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
XML.default_keep_blanks = true
|
13
|
+
@doc = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_encoding(name)
|
17
|
+
@encoding = Encoding.find(name) if defined?(Encoding)
|
18
|
+
@file_name = "model/bands.#{name.downcase}.xml"
|
19
|
+
|
20
|
+
# Strip spaces to make testing easier
|
21
|
+
XML.default_keep_blanks = false
|
22
|
+
file = File.join(File.dirname(__FILE__), @file_name)
|
23
|
+
@doc = XML::Document.file(file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_to_s_default
|
27
|
+
# Default to_s has indentation
|
28
|
+
node = @doc.root
|
29
|
+
assert_equal(Encoding::UTF_8, node.to_s.encoding) if defined?(Encoding)
|
30
|
+
assert_equal("<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
|
31
|
+
node.to_s)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_to_s_no_global_indentation
|
35
|
+
# No indentation due to global setting
|
36
|
+
node = @doc.root
|
37
|
+
XML.indent_tree_output = false
|
38
|
+
assert_equal("<bands genre=\"metal\">\n<m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n<iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
|
39
|
+
node.to_s)
|
40
|
+
ensure
|
41
|
+
XML.indent_tree_output = true
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_to_s_no_indentation
|
45
|
+
# No indentation due to local setting
|
46
|
+
node = @doc.root
|
47
|
+
assert_equal("<bands genre=\"metal\"><m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>",
|
48
|
+
node.to_s(:indent => false))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_to_s_level
|
52
|
+
# No indentation due to local setting
|
53
|
+
node = @doc.root
|
54
|
+
assert_equal("<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n </bands>",
|
55
|
+
node.to_s(:level => 1))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_to_s_encoding
|
59
|
+
# Test encodings
|
60
|
+
node = @doc.root
|
61
|
+
|
62
|
+
# UTF8:
|
63
|
+
# ö - c3 b6 in hex, \303\266 in octal
|
64
|
+
# ü - c3 bc in hex, \303\274 in octal
|
65
|
+
value = node.to_s(:encoding => XML::Encoding::UTF_8)
|
66
|
+
assert_equal(Encoding::UTF_8, node.to_s.encoding) if defined?(Encoding)
|
67
|
+
assert_equal("<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
|
68
|
+
value)
|
69
|
+
|
70
|
+
# ISO_8859_1:
|
71
|
+
# ö - f6 in hex, \366 in octal
|
72
|
+
# ü - fc in hex, \374 in octal
|
73
|
+
value = node.to_s(:encoding => XML::Encoding::ISO_8859_1)
|
74
|
+
if defined?(Encoding)
|
75
|
+
assert_equal(Encoding::ISO8859_1, value.encoding)
|
76
|
+
assert_equal("<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>".force_encoding(Encoding::ISO8859_1),
|
77
|
+
value)
|
78
|
+
else
|
79
|
+
assert_equal("<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
|
80
|
+
value)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Invalid encoding
|
84
|
+
error = assert_raise(ArgumentError) do
|
85
|
+
node.to_s(:encoding => -9999)
|
86
|
+
end
|
87
|
+
assert_equal('Unknown encoding value: -9999', error.to_s)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_inner_xml
|
91
|
+
# Default to_s has indentation
|
92
|
+
node = @doc.root
|
93
|
+
|
94
|
+
if defined?(Encoding)
|
95
|
+
assert_equal(Encoding::UTF_8, node.inner_xml.encoding)
|
96
|
+
assert_equal("<m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>",
|
97
|
+
node.inner_xml)
|
98
|
+
else
|
99
|
+
assert_equal("<m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>",
|
100
|
+
node.inner_xml)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# --- Debug ---
|
105
|
+
def test_debug
|
106
|
+
assert(@doc.root.debug)
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# $Id$
|
4
|
+
require './test_helper'
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
|
8
|
+
class TC_XML_Node_XLink < Test::Unit::TestCase
|
9
|
+
def setup()
|
10
|
+
xp = XML::Parser.string('<ruby_array xmlns:xlink="http://www.w3.org/1999/xlink/namespace/"><fixnum xlink:type="simple">one</fixnum></ruby_array>')
|
11
|
+
doc = xp.parse
|
12
|
+
assert_instance_of(XML::Document, doc)
|
13
|
+
@root = doc.root
|
14
|
+
assert_instance_of(XML::Node, @root)
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown()
|
18
|
+
@root = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_xml_node_xlink()
|
22
|
+
for elem in @root.find('fixnum')
|
23
|
+
assert_instance_of(XML::Node, elem)
|
24
|
+
assert_instance_of(TrueClass, elem.xlink?)
|
25
|
+
assert_equal("simple", elem.xlink_type_name)
|
26
|
+
assert_equal(XML::Node::XLINK_TYPE_SIMPLE, elem.xlink_type)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|