libxml-ruby 3.0.0 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY +37 -0
  3. data/MANIFEST +34 -34
  4. data/README.rdoc +65 -36
  5. data/Rakefile +21 -3
  6. data/ext/libxml/extconf.rb +30 -26
  7. data/ext/libxml/ruby_libxml.h +0 -8
  8. data/ext/libxml/ruby_xml.c +40 -0
  9. data/ext/libxml/ruby_xml_document.c +1 -5
  10. data/ext/libxml/ruby_xml_dtd.c +6 -8
  11. data/ext/libxml/ruby_xml_encoding.c +1 -13
  12. data/ext/libxml/ruby_xml_encoding.h +0 -3
  13. data/ext/libxml/ruby_xml_error.c +1 -1
  14. data/ext/libxml/ruby_xml_error.h +1 -1
  15. data/ext/libxml/ruby_xml_io.c +14 -18
  16. data/ext/libxml/ruby_xml_io.h +1 -1
  17. data/ext/libxml/ruby_xml_node.c +16 -17
  18. data/ext/libxml/ruby_xml_parser_context.c +1 -1
  19. data/ext/libxml/ruby_xml_reader.c +7 -2
  20. data/ext/libxml/ruby_xml_schema.c +44 -66
  21. data/ext/libxml/ruby_xml_schema_element.c +15 -14
  22. data/ext/libxml/ruby_xml_schema_type.c +66 -93
  23. data/ext/libxml/ruby_xml_version.h +4 -4
  24. data/ext/libxml/ruby_xml_writer.c +189 -192
  25. data/lib/libxml/schema/element.rb +0 -8
  26. data/lib/libxml/schema/type.rb +0 -8
  27. data/lib/libxml/schema.rb +0 -19
  28. data/lib/libxml-ruby.rb +30 -0
  29. data/lib/libxml.rb +3 -28
  30. data/libxml-ruby.gemspec +5 -4
  31. data/setup.rb +0 -1
  32. data/test/model/cwm_1_0.xml +11336 -0
  33. data/test/{tc_attr.rb → test_attr.rb} +18 -18
  34. data/test/{tc_attr_decl.rb → test_attr_decl.rb} +8 -8
  35. data/test/{tc_attributes.rb → test_attributes.rb} +10 -10
  36. data/test/{tc_canonicalize.rb → test_canonicalize.rb} +35 -39
  37. data/test/test_deprecated_require.rb +12 -0
  38. data/test/{tc_document.rb → test_document.rb} +31 -24
  39. data/test/test_document_write.rb +146 -0
  40. data/test/{tc_dtd.rb → test_dtd.rb} +26 -25
  41. data/test/{tc_encoding.rb → test_encoding.rb} +20 -17
  42. data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +3 -3
  43. data/test/test_error.rb +178 -0
  44. data/test/test_helper.rb +4 -11
  45. data/test/{tc_html_parser.rb → test_html_parser.rb} +31 -30
  46. data/test/test_html_parser_context.rb +23 -0
  47. data/test/test_namespace.rb +60 -0
  48. data/test/{tc_namespaces.rb → test_namespaces.rb} +29 -38
  49. data/test/{tc_node.rb → test_node.rb} +37 -31
  50. data/test/{tc_node_cdata.rb → test_node_cdata.rb} +10 -10
  51. data/test/{tc_node_comment.rb → test_node_comment.rb} +6 -6
  52. data/test/{tc_node_copy.rb → test_node_copy.rb} +3 -4
  53. data/test/{tc_node_edit.rb → test_node_edit.rb} +20 -21
  54. data/test/{tc_node_pi.rb → test_node_pi.rb} +8 -10
  55. data/test/{tc_node_text.rb → test_node_text.rb} +8 -9
  56. data/test/{tc_node_write.rb → test_node_write.rb} +16 -26
  57. data/test/test_node_xlink.rb +28 -0
  58. data/test/{tc_parser.rb → test_parser.rb} +72 -75
  59. data/test/{tc_parser_context.rb → test_parser_context.rb} +38 -44
  60. data/test/{tc_properties.rb → test_properties.rb} +5 -5
  61. data/test/test_reader.rb +364 -0
  62. data/test/{tc_relaxng.rb → test_relaxng.rb} +11 -11
  63. data/test/{tc_sax_parser.rb → test_sax_parser.rb} +38 -31
  64. data/test/{tc_schema.rb → test_schema.rb} +40 -33
  65. data/test/test_suite.rb +39 -40
  66. data/test/{tc_traversal.rb → test_traversal.rb} +4 -4
  67. data/test/{tc_writer.rb → test_writer.rb} +95 -74
  68. data/test/{tc_xinclude.rb → test_xinclude.rb} +3 -3
  69. data/test/test_xml.rb +263 -0
  70. data/test/{tc_xpath.rb → test_xpath.rb} +25 -25
  71. data/test/{tc_xpath_context.rb → test_xpath_context.rb} +5 -5
  72. data/test/{tc_xpath_expression.rb → test_xpath_expression.rb} +7 -7
  73. data/test/{tc_xpointer.rb → test_xpointer.rb} +15 -15
  74. metadata +91 -102
  75. data/test/tc_deprecated_require.rb +0 -12
  76. data/test/tc_document_write.rb +0 -195
  77. data/test/tc_error.rb +0 -178
  78. data/test/tc_html_parser_context.rb +0 -23
  79. data/test/tc_namespace.rb +0 -61
  80. data/test/tc_node_xlink.rb +0 -28
  81. data/test/tc_reader.rb +0 -358
  82. data/test/tc_xml.rb +0 -225
@@ -1,11 +1,11 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestSchema < Minitest::Test
6
6
  def setup
7
7
  file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
8
- @doc = XML::Document.file(file)
8
+ @doc = LibXML::XML::Document.file(file)
9
9
  end
10
10
 
11
11
  def teardown
@@ -13,17 +13,17 @@ class TestSchema < Minitest::Test
13
13
  end
14
14
 
15
15
  def schema
16
- document = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xsd'))
17
- XML::Schema.document(document)
16
+ document = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xsd'))
17
+ LibXML::XML::Schema.document(document)
18
18
  end
19
19
 
20
20
  def check_error(error)
21
21
  refute_nil(error)
22
22
  assert(error.message.match(/Error: Element 'invalid': This element is not expected. Expected is \( item \)/))
23
- assert_kind_of(XML::Error, error)
24
- assert_equal(XML::Error::SCHEMASV, error.domain)
25
- assert_equal(XML::Error::SCHEMAV_ELEMENT_CONTENT, error.code)
26
- assert_equal(XML::Error::ERROR, error.level)
23
+ assert_kind_of(LibXML::XML::Error, error)
24
+ assert_equal(LibXML::XML::Error::SCHEMASV, error.domain)
25
+ assert_equal(LibXML::XML::Error::SCHEMAV_ELEMENT_CONTENT, error.code)
26
+ assert_equal(LibXML::XML::Error::ERROR, error.level)
27
27
  assert(error.file.match(/shiporder.xml/)) if error.file
28
28
  assert_nil(error.str1)
29
29
  assert_nil(error.str2)
@@ -33,7 +33,7 @@ class TestSchema < Minitest::Test
33
33
  end
34
34
 
35
35
  def test_load_from_doc
36
- assert_instance_of(XML::Schema, schema)
36
+ assert_instance_of(LibXML::XML::Schema, schema)
37
37
  end
38
38
 
39
39
  def test_doc_valid
@@ -41,10 +41,10 @@ class TestSchema < Minitest::Test
41
41
  end
42
42
 
43
43
  def test_doc_invalid
44
- new_node = XML::Node.new('invalid', 'this will mess up validation')
44
+ new_node = LibXML::XML::Node.new('invalid', 'this will mess up validation')
45
45
  @doc.root << new_node
46
46
 
47
- error = assert_raises(XML::Error) do
47
+ error = assert_raises(LibXML::XML::Error) do
48
48
  @doc.validate_schema(schema)
49
49
  end
50
50
 
@@ -55,7 +55,7 @@ class TestSchema < Minitest::Test
55
55
  end
56
56
 
57
57
  def test_reader_valid
58
- reader = XML::Reader.string(@doc.to_s)
58
+ reader = LibXML::XML::Reader.string(@doc.to_s)
59
59
  assert(reader.schema_validate(schema))
60
60
 
61
61
  while reader.read
@@ -65,13 +65,13 @@ class TestSchema < Minitest::Test
65
65
  def test_reader_invalid
66
66
  # Set error handler
67
67
  errors = Array.new
68
- XML::Error.set_handler do |error|
68
+ LibXML::XML::Error.set_handler do |error|
69
69
  errors << error
70
70
  end
71
71
 
72
- new_node = XML::Node.new('invalid', 'this will mess up validation')
72
+ new_node = LibXML::XML::Node.new('invalid', 'this will mess up validation')
73
73
  @doc.root << new_node
74
- reader = XML::Reader.string(@doc.to_s)
74
+ reader = LibXML::XML::Reader.string(@doc.to_s)
75
75
 
76
76
  # Set a schema
77
77
  assert(reader.schema_validate(schema))
@@ -85,35 +85,45 @@ class TestSchema < Minitest::Test
85
85
  check_error(error)
86
86
  assert_equal(21, error.line)
87
87
  ensure
88
- XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
88
+ LibXML::XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
89
89
  end
90
90
 
91
91
 
92
92
  # Schema meta-data tests
93
-
94
93
  def test_elements
95
94
  assert_instance_of(Hash, schema.elements)
96
95
  assert_equal(1, schema.elements.length)
97
- assert_instance_of(XML::Schema::Element, schema.elements['shiporder'])
96
+ assert_instance_of(LibXML::XML::Schema::Element, schema.elements['shiporder'])
98
97
  end
99
98
 
100
99
  def test_types
101
100
  assert_instance_of(Hash, schema.types)
102
101
  assert_equal(1, schema.types.length)
103
- assert_instance_of(XML::Schema::Type, schema.types['shiporder'])
102
+ assert_instance_of(LibXML::XML::Schema::Type, schema.types['shiporder'])
103
+ end
104
+
105
+ def test_imported_types
106
+ assert_instance_of(Hash, schema.imported_types)
107
+ assert_equal(1, schema.imported_types.length)
108
+ assert_instance_of(LibXML::XML::Schema::Type, schema.types['shiporder'])
109
+ end
110
+
111
+ def test_namespaces
112
+ assert_instance_of(Array, schema.namespaces)
113
+ assert_equal(1, schema.namespaces.length)
104
114
  end
105
115
 
106
116
  def test_schema_type
107
117
  type = schema.types['shiporder']
108
118
 
109
119
  assert_equal('shiporder', type.name)
110
- assert_equal(nil, type.namespace)
120
+ assert_nil(type.namespace)
111
121
  assert_equal("Shiporder type documentation", type.annotation)
112
- assert_instance_of(XML::Node, type.node)
113
- assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_COMPLEX, type.kind)
114
- assert_instance_of(XML::Schema::Type, type.base)
122
+ assert_instance_of(LibXML::XML::Node, type.node)
123
+ assert_equal(LibXML::XML::Schema::Types::XML_SCHEMA_TYPE_COMPLEX, type.kind)
124
+ assert_instance_of(LibXML::XML::Schema::Type, type.base)
115
125
  assert_equal("anyType", type.base.name)
116
- assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_BASIC, type.base.kind)
126
+ assert_equal(LibXML::XML::Schema::Types::XML_SCHEMA_TYPE_BASIC, type.base.kind)
117
127
 
118
128
  assert_instance_of(Hash, type.elements)
119
129
  assert_equal(3, type.elements.length)
@@ -123,17 +133,14 @@ class TestSchema < Minitest::Test
123
133
  element = schema.types['shiporder'].elements['orderperson']
124
134
 
125
135
  assert_equal('orderperson', element.name)
126
- assert_equal(nil, element.namespace)
136
+ assert_nil(element.namespace)
127
137
  assert_equal("orderperson element documentation", element.annotation)
128
- assert_equal(1, element.min_occurs)
129
- assert_equal(1, element.max_occurs)
130
-
131
138
 
132
139
  element = schema.types['shiporder'].elements['item']
133
- assert_equal(Float::INFINITY, element.max_occurs)
140
+ assert_equal('item', element.name)
134
141
 
135
142
  element = schema.types['shiporder'].elements['item'].type.elements['note']
136
- assert_equal(0, element.min_occurs)
143
+ assert_equal('note', element.name)
137
144
  assert_equal('string', element.type.name)
138
145
  end
139
146
 
@@ -142,14 +149,14 @@ class TestSchema < Minitest::Test
142
149
 
143
150
  assert_instance_of(Array, type.attributes)
144
151
  assert_equal(2, type.attributes.length)
145
- assert_instance_of(XML::Schema::Attribute, type.attributes.first)
152
+ assert_instance_of(LibXML::XML::Schema::Attribute, type.attributes.first)
146
153
  end
147
154
 
148
155
  def test_schema_attribute
149
156
  attribute = schema.types['shiporder'].attributes.first
150
157
 
151
158
  assert_equal("orderid", attribute.name)
152
- assert_equal(nil, attribute.namespace)
159
+ assert_nil(attribute.namespace)
153
160
  assert_equal(1, attribute.occurs)
154
161
  assert_equal('string', attribute.type.name)
155
162
 
@@ -158,4 +165,4 @@ class TestSchema < Minitest::Test
158
165
  assert_equal('1', attribute.default)
159
166
  assert_equal('integer', attribute.type.name)
160
167
  end
161
- end
168
+ end
data/test/test_suite.rb CHANGED
@@ -5,45 +5,44 @@
5
5
  dir = File.dirname(__FILE__)
6
6
  Dir.chdir(dir)
7
7
 
8
- require './tc_attr'
9
- require './tc_attr_decl'
10
- require './tc_attributes'
11
- require './tc_canonicalize'
12
- require './tc_document'
13
- require './tc_document_write'
14
- require './tc_dtd'
15
- require './tc_error'
16
- require './tc_html_parser'
17
- require './tc_html_parser_context'
18
- require './tc_namespace'
19
- require './tc_namespaces'
20
- require './tc_node'
21
- require './tc_node_cdata'
22
- require './tc_node_comment'
23
- require './tc_node_copy'
24
- require './tc_node_edit'
25
- require './tc_node_pi'
26
- require './tc_node_text'
27
- require './tc_node_write'
28
- require './tc_node_xlink'
29
- require './tc_parser'
30
- require './tc_parser_context'
31
- require './tc_reader'
32
- require './tc_relaxng'
33
- require './tc_sax_parser'
34
- require './tc_schema'
35
- require './tc_traversal'
36
- require './tc_writer'
37
- require './tc_xinclude'
38
- require './tc_xpath'
39
- require './tc_xpath_context'
40
- require './tc_xpath_expression'
41
- require './tc_xpointer'
8
+ require './test_attr'
9
+ require './test_attr_decl'
10
+ require './test_attributes'
11
+ require './test_canonicalize'
12
+ require './test_document'
13
+ require './test_document_write'
14
+ require './test_dtd'
15
+ require './test_error'
16
+ require './test_html_parser'
17
+ require './test_html_parser_context'
18
+ require './test_namespace'
19
+ require './test_namespaces'
20
+ require './test_node'
21
+ require './test_node_cdata'
22
+ require './test_node_comment'
23
+ require './test_node_copy'
24
+ require './test_node_edit'
25
+ require './test_node_pi'
26
+ require './test_node_text'
27
+ require './test_node_write'
28
+ require './test_node_xlink'
29
+ require './test_parser'
30
+ require './test_parser_context'
31
+ require './test_reader'
32
+ require './test_relaxng'
33
+ require './test_sax_parser'
34
+ require './test_schema'
35
+ require './test_traversal'
36
+ require './test_writer'
37
+ require './test_xinclude'
38
+ require './test_xpath'
39
+ require './test_xpath_context'
40
+ require './test_xpath_expression'
41
+ require './test_xpointer'
42
+
43
+ require './test_encoding'
44
+ require './test_encoding_sax'
42
45
 
43
- if defined?(Encoding)
44
- require './tc_encoding'
45
- require './tc_encoding_sax'
46
- end
47
46
  # Compatibility
48
- require './tc_properties'
49
- require './tc_deprecated_require'
47
+ require './test_properties'
48
+ require './test_deprecated_require'
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestTranversal < Minitest::Test
6
6
  ROOT_NODES_LENGTH = 27
@@ -8,7 +8,7 @@ class TestTranversal < Minitest::Test
8
8
 
9
9
  def setup
10
10
  filename = File.join(File.dirname(__FILE__), 'model/books.xml')
11
- @doc = XML::Document.file(filename)
11
+ @doc = LibXML::XML::Document.file(filename)
12
12
  end
13
13
 
14
14
  def teardown
@@ -143,10 +143,10 @@ class TestTranversal < Minitest::Test
143
143
  end
144
144
 
145
145
  def test_doc_class
146
- assert_instance_of(XML::Document, @doc)
146
+ assert_instance_of(LibXML::XML::Document, @doc)
147
147
  end
148
148
 
149
149
  def test_root_class
150
- assert_instance_of(XML::Node, @doc.root)
150
+ assert_instance_of(LibXML::XML::Node, @doc.root)
151
151
  end
152
152
  end