libxml-ruby 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY +18 -0
  3. data/MANIFEST +34 -34
  4. data/README.rdoc +14 -1
  5. data/Rakefile +18 -8
  6. data/ext/libxml/ruby_xml_error.c +1 -1
  7. data/ext/libxml/ruby_xml_error.h +1 -1
  8. data/ext/libxml/ruby_xml_node.c +15 -16
  9. data/ext/libxml/ruby_xml_reader.c +7 -2
  10. data/ext/libxml/ruby_xml_schema.c +44 -66
  11. data/ext/libxml/ruby_xml_schema_element.c +15 -14
  12. data/ext/libxml/ruby_xml_schema_type.c +66 -93
  13. data/ext/libxml/ruby_xml_version.h +3 -3
  14. data/lib/libxml/schema.rb +0 -19
  15. data/lib/libxml/schema/element.rb +0 -8
  16. data/lib/libxml/schema/type.rb +0 -8
  17. data/libxml-ruby.gemspec +3 -2
  18. data/setup.rb +0 -1
  19. data/test/model/cwm_1_0.xml +11336 -0
  20. data/test/{tc_attr.rb → test_attr.rb} +1 -1
  21. data/test/{tc_attr_decl.rb → test_attr_decl.rb} +1 -1
  22. data/test/{tc_attributes.rb → test_attributes.rb} +1 -1
  23. data/test/{tc_canonicalize.rb → test_canonicalize.rb} +32 -28
  24. data/test/{tc_deprecated_require.rb → test_deprecated_require.rb} +0 -0
  25. data/test/{tc_document.rb → test_document.rb} +3 -3
  26. data/test/{tc_document_write.rb → test_document_write.rb} +1 -1
  27. data/test/{tc_dtd.rb → test_dtd.rb} +6 -6
  28. data/test/{tc_encoding.rb → test_encoding.rb} +6 -3
  29. data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +1 -1
  30. data/test/{tc_error.rb → test_error.rb} +1 -1
  31. data/test/test_helper.rb +0 -2
  32. data/test/{tc_html_parser.rb → test_html_parser.rb} +3 -2
  33. data/test/{tc_html_parser_context.rb → test_html_parser_context.rb} +1 -1
  34. data/test/{tc_namespace.rb → test_namespace.rb} +3 -4
  35. data/test/{tc_namespaces.rb → test_namespaces.rb} +5 -14
  36. data/test/{tc_node.rb → test_node.rb} +2 -2
  37. data/test/{tc_node_cdata.rb → test_node_cdata.rb} +1 -1
  38. data/test/{tc_node_comment.rb → test_node_comment.rb} +1 -1
  39. data/test/{tc_node_copy.rb → test_node_copy.rb} +2 -3
  40. data/test/{tc_node_edit.rb → test_node_edit.rb} +5 -6
  41. data/test/{tc_node_pi.rb → test_node_pi.rb} +2 -4
  42. data/test/{tc_node_text.rb → test_node_text.rb} +4 -5
  43. data/test/{tc_node_write.rb → test_node_write.rb} +1 -1
  44. data/test/{tc_node_xlink.rb → test_node_xlink.rb} +1 -1
  45. data/test/{tc_parser.rb → test_parser.rb} +7 -6
  46. data/test/{tc_parser_context.rb → test_parser_context.rb} +8 -8
  47. data/test/{tc_properties.rb → test_properties.rb} +1 -1
  48. data/test/{tc_reader.rb → test_reader.rb} +30 -20
  49. data/test/{tc_relaxng.rb → test_relaxng.rb} +2 -2
  50. data/test/{tc_sax_parser.rb → test_sax_parser.rb} +3 -3
  51. data/test/{tc_schema.rb → test_schema.rb} +18 -11
  52. data/test/test_suite.rb +38 -38
  53. data/test/{tc_traversal.rb → test_traversal.rb} +1 -1
  54. data/test/{tc_writer.rb → test_writer.rb} +1 -1
  55. data/test/{tc_xinclude.rb → test_xinclude.rb} +1 -1
  56. data/test/{tc_xml.rb → test_xml.rb} +61 -36
  57. data/test/{tc_xpath.rb → test_xpath.rb} +4 -4
  58. data/test/{tc_xpath_context.rb → test_xpath_context.rb} +1 -1
  59. data/test/{tc_xpath_expression.rb → test_xpath_expression.rb} +2 -2
  60. data/test/{tc_xpointer.rb → test_xpointer.rb} +1 -1
  61. metadata +84 -95
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 865194cd65ca9ad9a3ccc047d89b5a68186ef97f
4
- data.tar.gz: 7d29d8cb6cd5d40cba78f171ac92d61f3b48d1d1
2
+ SHA256:
3
+ metadata.gz: 81e91ce08249acf16aa724c8aee17e94f86c384d8f9564d983dcd23f91ab9649
4
+ data.tar.gz: d3f48115d66b97da8a9cda69efc5ca261974795906a98d60256eddd1c5f4d8ec
5
5
  SHA512:
6
- metadata.gz: 0b68eca1f0ff9241250a1d9ac28f9bd34e744493e50d1728f0da43568b2a478ca75ced18899e13483076fd6da88716c62a8485acda4bb84e1f42e7b018d91433
7
- data.tar.gz: dcc1043a0033995c6c0be3fc2cae266f9be82d436dd92ad7db76e616e5442353f7515a3bdb0e1ae84701eb3cb912950abadf339613215256ac0a339d2391b536
6
+ metadata.gz: aafb9a7cead282d2219162b12117b15ac0504106054f71a5c86c88490bcfcfd0f347312482699bed03b87051378fc3997c270adab84dbf50523088177f86da79
7
+ data.tar.gz: bff4aa7c451552565e9cf2a6af287c249228e63c955ee2e3e0fe89f45f86d8c5ce454c617e27aee31ca778c1fa6c56f3cd53b20664209f8a011d14560616c17a
data/HISTORY CHANGED
@@ -1,5 +1,23 @@
1
1
  = Release History
2
2
 
3
+ == 3.1.0 / 2018-02-03 Charlie Savage
4
+
5
+ * Fix segmentation fault when adding one node to another node (Charlie Savage)
6
+ * Fix deprecated "assert_equal(nil, expected)" calls. #148 and #151. (utilum)
7
+ * Remove assigned but unused variables. #150 (utilum)
8
+ * Add Gemfile. #146. (Dorian Marié)
9
+ * Remove duplicate hash key in setup.rb. #147. (Dorian Marié)
10
+ * Fix gemspec by requiring Date. #149 (utilum)
11
+ * Restore default internal encoding after tests are completed. #123 (Charlie Savage)
12
+ * Remove duplicate method definitions. #145. (Charlie Savage)
13
+ * Remove SchemaElement#minOccurs and SchemaElement#maxOccurs since they actually did not work (Charlie Savage)
14
+ * Rename test files to follow Ruby conventions (Charlie Savage)
15
+ * Fix handling of node returned by Reader#expand. #142. (Charlie Savage)
16
+ * Add Travis Build support (Charlie Savage)
17
+ * Fix Fixnum deprecation (Charlie Savage)
18
+ * Cleanup schema code (Charlie Savage)
19
+ * Update Visual Studio project to 2017 (Charlie Savage)
20
+
3
21
  == 3.0.0 / 2017-02-07 Charlie Savage
4
22
 
5
23
  * Revamp how libxml-ruby manages memory. Instead of trying to return the same ruby object for each xmlnode,
data/MANIFEST CHANGED
@@ -122,40 +122,40 @@ test/model/shiporder.xml
122
122
  test/model/shiporder.xsd
123
123
  test/model/soap.xml
124
124
  test/model/xinclude.xml
125
- test/tc_attr.rb
126
- test/tc_attr_decl.rb
127
- test/tc_attributes.rb
128
- test/tc_deprecated_require.rb
129
- test/tc_document.rb
130
- test/tc_document_write.rb
131
- test/tc_dtd.rb
132
- test/tc_error.rb
133
- test/tc_html_parser.rb
134
- test/tc_namespace.rb
135
- test/tc_namespaces.rb
136
- test/tc_node.rb
137
- test/tc_node_cdata.rb
138
- test/tc_node_comment.rb
139
- test/tc_node_copy.rb
140
- test/tc_node_edit.rb
141
- test/tc_node_pi.rb
142
- test/tc_node_text.rb
143
- test/tc_node_write.rb
144
- test/tc_node_xlink.rb
145
- test/tc_parser.rb
146
- test/tc_parser_context.rb
147
- test/tc_properties.rb
148
- test/tc_reader.rb
149
- test/tc_relaxng.rb
150
- test/tc_sax_parser.rb
151
- test/tc_schema.rb
152
- test/tc_traversal.rb
153
- test/tc_xinclude.rb
154
- test/tc_xml.rb
155
- test/tc_xpath.rb
156
- test/tc_xpath_context.rb
157
- test/tc_xpath_expression.rb
158
- test/tc_xpointer.rb
125
+ test/test_attr.rb
126
+ test/test_attr_decl.rb
127
+ test/test_attributes.rb
128
+ test/test_deprecated_require.rb
129
+ test/test_document.rb
130
+ test/test_document_write.rb
131
+ test/test_dtd.rb
132
+ test/test_error.rb
133
+ test/test_html_parser.rb
134
+ test/test_namespace.rb
135
+ test/test_namespaces.rb
136
+ test/test_node.rb
137
+ test/test_node_cdata.rb
138
+ test/test_node_comment.rb
139
+ test/test_node_copy.rb
140
+ test/test_node_edit.rb
141
+ test/test_node_pi.rb
142
+ test/test_node_text.rb
143
+ test/test_node_write.rb
144
+ test/test_node_xlink.rb
145
+ test/test_parser.rb
146
+ test/test_parser_context.rb
147
+ test/test_properties.rb
148
+ test/test_reader.rb
149
+ test/test_relaxng.rb
150
+ test/test_sax_parser.rb
151
+ test/test_schema.rb
152
+ test/test_traversal.rb
153
+ test/test_xinclude.rb
154
+ test/test_xml.rb
155
+ test/test_xpath.rb
156
+ test/test_xpath_context.rb
157
+ test/test_xpath_expression.rb
158
+ test/test_xpointer.rb
159
159
  test/test_suite.rb
160
160
  Rakefile
161
161
  HISTORY.rdoc
@@ -11,7 +11,7 @@ We think libxml-ruby is the best XML library for Ruby because:
11
11
  * Conformance - It passes all 1800+ tests from the OASIS XML Tests Suite
12
12
 
13
13
  == Requirements
14
- libxml-ruby requires Ruby 1.8.4 or higher. It depends on libxml2 to
14
+ libxml-ruby requires Ruby 1.8.7 or higher. It depends on libxml2 to
15
15
  function propoerly. libxml2, in turn, depends on:
16
16
 
17
17
  * libm (math routines: very standard)
@@ -118,6 +118,18 @@ libxml-ruby fully supports native, background Ruby threads. This of course
118
118
  only applies to Ruby 1.9.x and higher since earlier versions of Ruby do not
119
119
  support native threads.
120
120
 
121
+ == Tests
122
+
123
+ To run tests you first need to build the shared libary:
124
+
125
+ rake compile
126
+
127
+ Once you have build the shared libary, you can then run tests using rake:
128
+
129
+ rake test
130
+
131
+ +Travis build status: {<img src="https://travis-ci.org/xml4r/libxml-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/xml4r/libxml-ruby]
132
+
121
133
  == Performance
122
134
  In addition to being feature rich and conformation, the main reason
123
135
  people use libxml-ruby is for performance. Here are the results
@@ -186,3 +198,4 @@ and are no longer in scope (since if they were the document would not be freed).
186
198
 
187
199
  == License
188
200
  See LICENSE for license information.
201
+
data/Rakefile CHANGED
@@ -16,13 +16,22 @@ spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
16
16
  task :default => [:test]
17
17
 
18
18
  # Setup compile tasks
19
- Rake::ExtensionTask.new do |ext|
20
- ext.gem_spec = spec
21
- ext.name = SO_NAME
22
- ext.ext_dir = "ext/libxml"
23
- ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
24
- ext.config_options << "--with-xml2-include=C:/msys64/mingw64/include/libxml2"
25
- ext.config_options << "--with-zlib-dir=C:/msys64/mingw64"
19
+ if RUBY_PLATFORM.match(/mswin32|mswin64|mingw32/)
20
+ Rake::ExtensionTask.new do |ext|
21
+ ext.gem_spec = spec
22
+ ext.name = SO_NAME
23
+ ext.ext_dir = "ext/libxml"
24
+ ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
25
+ ext.config_options << "--with-xml2-include=C:/msys64/mingw64/include/libxml2"
26
+ end
27
+ else
28
+ Rake::ExtensionTask.new do |ext|
29
+ ext.gem_spec = spec
30
+ ext.name = SO_NAME
31
+ ext.ext_dir = "ext/libxml"
32
+ ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
33
+ ext.config_options << "--with-xml2-include=/usr/include/libxml2"
34
+ end
26
35
  end
27
36
 
28
37
  # Setup generic gem
@@ -32,7 +41,7 @@ Gem::PackageTask.new(spec) do |pkg|
32
41
  end
33
42
 
34
43
  # Setup Windows Gem
35
- if RUBY_PLATFORM.match(/win32|mingw32/)
44
+ if RUBY_PLATFORM.match(/mswin32|mswin64|mingw32/)
36
45
  binaries = (FileList['lib/**/*.so',
37
46
  'lib/**/*dll'])
38
47
 
@@ -77,5 +86,6 @@ end
77
86
  # Test Task
78
87
  Rake::TestTask.new do |t|
79
88
  t.libs << "test"
89
+ t.test_files = FileList['test/test*.rb'] - ['test/test_suite.rb']
80
90
  t.verbose = true
81
91
  end
@@ -158,7 +158,7 @@ static VALUE rxml_error_reset_handler(VALUE self)
158
158
  return self;
159
159
  }
160
160
 
161
- void rxml_raise(xmlErrorPtr xerror)
161
+ NORETURN(void rxml_raise(xmlErrorPtr xerror))
162
162
  {
163
163
  /* Wrap error up as Ruby object and send it off to ruby */
164
164
  VALUE error = rxml_error_wrap(xerror);
@@ -7,6 +7,6 @@ extern VALUE eXMLError;
7
7
 
8
8
  void rxml_init_error();
9
9
  VALUE rxml_error_wrap(xmlErrorPtr xerror);
10
- void rxml_raise(xmlErrorPtr xerror);
10
+ NORETURN(void rxml_raise(xmlErrorPtr xerror));
11
11
 
12
12
  #endif
@@ -57,7 +57,7 @@ static void rxml_node_free(xmlNodePtr xnode)
57
57
 
58
58
  void rxml_node_manage(xmlNodePtr xnode, VALUE node)
59
59
  {
60
- RDATA(node)->dfree = rxml_node_free;
60
+ RDATA(node)->dfree = (RUBY_DATA_FUNC)rxml_node_free;
61
61
  xnode->_private = (void*)node;
62
62
  }
63
63
 
@@ -83,8 +83,11 @@ void rxml_node_mark(xmlNodePtr xnode)
83
83
  {
84
84
  if (xnode->doc)
85
85
  {
86
- VALUE doc = (VALUE)xnode->doc->_private;
87
- rb_gc_mark(doc);
86
+ if (xnode->doc->_private)
87
+ {
88
+ VALUE doc = (VALUE)xnode->doc->_private;
89
+ rb_gc_mark(doc);
90
+ }
88
91
  }
89
92
  else if (xnode->parent)
90
93
  {
@@ -120,8 +123,7 @@ VALUE rxml_node_wrap(xmlNodePtr xnode)
120
123
 
121
124
  static VALUE rxml_node_alloc(VALUE klass)
122
125
  {
123
- /* Ruby is responsible for freeing this node not libxml but don't set
124
- up mark and free yet until we assign the node. */
126
+ // This node was created from Ruby so we are responsible for freeing it not libxml
125
127
  return Data_Wrap_Struct(klass, rxml_node_mark, rxml_node_free, NULL);
126
128
  }
127
129
 
@@ -312,21 +314,18 @@ static VALUE rxml_node_modify_dom(VALUE self, VALUE target,
312
314
 
313
315
  xmlUnlinkNode(xtarget);
314
316
 
315
- /* This target node could be freed here. */
317
+ // Target is about to have a parent, so stop having ruby manage it.
318
+ rxml_node_unmanage(xtarget, target);
319
+
320
+ // This target node could be freed here and be replaced by a different node
316
321
  xresult = xmlFunc(xnode, xtarget);
317
322
 
318
323
  if (!xresult)
319
- rxml_raise(&xmlLastError);
320
-
321
- /* Was the target freed? If yes, then wrap the new node */
322
- if (xresult != xtarget)
323
- {
324
- RDATA(target)->data = xresult;
325
- }
324
+ rxml_raise(&xmlLastError);
326
325
 
327
- // Target now has a parent so ruby should no longer manage its memory
328
- rxml_node_unmanage(xresult, target);
329
- xtarget->_private = NULL;
326
+ /* Assume the target was freed, we need to fix up the ruby object to point to the
327
+ newly returned node. */
328
+ RDATA(target)->data = xresult;
330
329
 
331
330
  return target;
332
331
  }
@@ -23,7 +23,7 @@
23
23
  * reader = XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
24
24
  * reader.read
25
25
  * assert_equal('foo', reader.name)
26
- * assert_equal(nil, reader.value)
26
+ * assert_nil(reader.value)
27
27
  *
28
28
  * 3.times do |i|
29
29
  * reader.read
@@ -995,7 +995,12 @@ static VALUE rxml_reader_expand(VALUE self)
995
995
  }
996
996
  else
997
997
  {
998
- return rxml_node_wrap(xnode);
998
+ /* We cannot call rxml_node_wrap here because its sets up a mark function
999
+ for the node. But according to the libxml docs (http://xmlsoft.org/html/libxml-xmlreader.html#xmlTextReaderExpand)
1000
+ this is only valid until the next xmlTextReaderRead call. At that point the node is freed (from reading
1001
+ the libxml2 source code. So don't set a mark or free function, because they will get called in the next
1002
+ garbage collection run and cause a segfault.*/
1003
+ return Data_Wrap_Struct(cXMLNode, NULL, NULL, xnode);
999
1004
  }
1000
1005
  }
1001
1006
 
@@ -8,7 +8,6 @@
8
8
  #include "ruby_xml_schema_attribute.h"
9
9
  #include "ruby_xml_schema_facet.h"
10
10
 
11
-
12
11
  /*
13
12
  * Document-class: LibXML::XML::Schema
14
13
  *
@@ -152,7 +151,6 @@ static VALUE rxml_schema_id(VALUE self)
152
151
  QNIL_OR_STRING(xschema->id)
153
152
  }
154
153
 
155
-
156
154
  static VALUE rxml_schema_document(VALUE self)
157
155
  {
158
156
  xmlSchemaPtr xschema;
@@ -162,21 +160,20 @@ static VALUE rxml_schema_document(VALUE self)
162
160
  return rxml_node_wrap(xmlDocGetRootElement(xschema->doc));
163
161
  }
164
162
 
165
- static void storeNs(xmlSchemaImportPtr import, VALUE self, xmlChar *nsname)
163
+ static void scan_namespaces(xmlSchemaImportPtr ximport, VALUE array, xmlChar *nsname)
166
164
  {
167
- VALUE schemas;
168
165
  xmlNodePtr xnode;
169
166
  xmlNsPtr xns;
170
167
 
171
- schemas = rb_iv_get(self, "@namespaces");
172
- if (import->doc) {
173
- xnode = xmlDocGetRootElement(import->doc);
174
-
168
+ if (ximport->doc)
169
+ {
170
+ xnode = xmlDocGetRootElement(ximport->doc);
175
171
  xns = xnode->nsDef;
176
172
 
177
- while (xns) {
178
- VALUE anamespace = rxml_namespace_wrap(xns);
179
- rb_ary_push(schemas, anamespace);
173
+ while (xns)
174
+ {
175
+ VALUE namespace = rxml_namespace_wrap(xns);
176
+ rb_ary_push(array, namespace);
180
177
  xns = xns->next;
181
178
  }
182
179
  }
@@ -184,95 +181,76 @@ static void storeNs(xmlSchemaImportPtr import, VALUE self, xmlChar *nsname)
184
181
 
185
182
  static VALUE rxml_schema_namespaces(VALUE self)
186
183
  {
187
- VALUE schemas;
184
+ VALUE result;
188
185
  xmlSchemaPtr xschema;
189
186
 
190
187
  Data_Get_Struct(self, xmlSchema, xschema);
191
188
 
192
- if (rb_iv_get(self, "@namespaces") == Qnil) {
193
- schemas = rb_ary_new();
194
- rb_iv_set(self, "@namespaces", schemas);
195
- xmlHashScan(xschema->schemasImports, (xmlHashScanner) storeNs, (void *)self);
196
- }
189
+ result = rb_ary_new();
190
+ xmlHashScan(xschema->schemasImports, (xmlHashScanner)scan_namespaces, (void *)result);
197
191
 
198
- return rb_iv_get(self, "@namespaces");
192
+ return result;
199
193
  }
200
194
 
201
- static void storeType(xmlSchemaTypePtr type, VALUE self, xmlChar *name)
195
+ static void scan_element(xmlSchemaElementPtr xelement, VALUE hash, xmlChar *name)
202
196
  {
203
- VALUE types;
204
- VALUE rtype;
205
-
206
- types = rb_iv_get(self, "@types");
207
- rtype = rxml_wrap_schema_type(type);
208
-
209
- rb_hash_aset(types, rb_str_new2((const char*)name), rtype);
197
+ VALUE element = rxml_wrap_schema_element(xelement);
198
+ rb_hash_aset(hash, rb_str_new2((const char*)name), element);
210
199
  }
211
200
 
212
- static VALUE rxml_schema_collect_types(VALUE self);
213
-
214
- static VALUE rxml_schema_types(VALUE self)
201
+ static VALUE rxml_schema_elements(VALUE self)
215
202
  {
216
- VALUE types;
203
+ VALUE result = rb_hash_new();
217
204
  xmlSchemaPtr xschema;
218
205
 
219
206
  Data_Get_Struct(self, xmlSchema, xschema);
207
+ xmlHashScan(xschema->elemDecl, (xmlHashScanner)scan_element, (void *)result);
220
208
 
221
- if (rb_iv_get(self, "@types") == Qnil) {
222
- types = rb_hash_new();
223
- rb_iv_set(self, "@types", types);
224
- rxml_schema_collect_types(self);
225
- if(xschema != NULL && xschema->typeDecl != NULL)
226
- xmlHashScan(xschema->typeDecl, (xmlHashScanner) storeType, (void *)self);
227
- }
228
-
229
- return rb_iv_get(self, "@types");
209
+ return result;
230
210
  }
231
211
 
232
- static void storeElement(xmlSchemaElementPtr element, VALUE self, xmlChar *name)
212
+ static void scan_type(xmlSchemaTypePtr xtype, VALUE hash, xmlChar *name)
233
213
  {
234
- VALUE elements;
235
- VALUE relement;
236
-
237
- elements = rb_iv_get(self, "@elements");
238
- relement = rxml_wrap_schema_element(element);
239
- rb_hash_aset(elements, rb_str_new2((const char*)name), relement);
214
+ VALUE type = rxml_wrap_schema_type(xtype);
215
+ rb_hash_aset(hash, rb_str_new2((const char*)name), type);
240
216
  }
241
217
 
242
- static VALUE rxml_schema_elements(VALUE self)
218
+ static VALUE rxml_schema_types(VALUE self)
243
219
  {
244
- VALUE elements;
245
- xmlSchemaPtr xschema;
220
+ VALUE result = rb_hash_new();
221
+ xmlSchemaPtr xschema;
246
222
 
247
- Data_Get_Struct(self, xmlSchema, xschema);
223
+ Data_Get_Struct(self, xmlSchema, xschema);
248
224
 
249
- if (rb_iv_get(self, "@elements") == Qnil) {
250
- elements = rb_hash_new();
251
- rb_iv_set(self, "@elements", elements);
252
- xmlHashScan(xschema->elemDecl, (xmlHashScanner) storeElement, (void *)self);
253
- }
225
+ if (xschema != NULL && xschema->typeDecl != NULL)
226
+ {
227
+ xmlHashScan(xschema->typeDecl, (xmlHashScanner)scan_type, (void *)result);
228
+ }
254
229
 
255
- return rb_iv_get(self, "@elements");
230
+ return result;
256
231
  }
257
232
 
258
- static void collectSchemaTypes(xmlSchemaImportPtr import, VALUE self)
233
+ static void collect_imported_types(xmlSchemaImportPtr import, VALUE result)
259
234
  {
260
- if (import->imported && import->schema) {
261
- xmlHashScan(import->schema->typeDecl, (xmlHashScanner) storeType, (void *)self);
235
+ if (import->imported && import->schema)
236
+ {
237
+ xmlHashScan(import->schema->typeDecl, (xmlHashScanner)scan_type, (void *)result);
262
238
  }
263
239
  }
264
240
 
265
- static VALUE rxml_schema_collect_types(VALUE self)
241
+ static VALUE rxml_schema_imported_types(VALUE self)
266
242
  {
267
243
  xmlSchemaPtr xschema;
244
+ VALUE result = rb_hash_new();
268
245
 
269
246
  Data_Get_Struct(self, xmlSchema, xschema);
270
247
 
271
- if(xschema){
272
- xmlHashScan(xschema->schemasImports, (xmlHashScanner) collectSchemaTypes, (void *)self);
248
+ if (xschema)
249
+ {
250
+ xmlHashScan(xschema->schemasImports, (xmlHashScanner)collect_imported_types, (void *)result);
273
251
  }
274
252
 
275
- return Qnil;
253
+ return result;
276
254
  }
277
255
 
278
256
  void rxml_init_schema(void)
@@ -288,10 +266,10 @@ void rxml_init_schema(void)
288
266
  rb_define_method(cXMLSchema, "version", rxml_schema_version, 0);
289
267
  rb_define_method(cXMLSchema, "document", rxml_schema_document, 0);
290
268
 
291
- rb_define_method(cXMLSchema, "_namespaces", rxml_schema_namespaces, 0);
292
- rb_define_method(cXMLSchema, "_collect_types", rxml_schema_collect_types, 0);
293
- rb_define_method(cXMLSchema, "types", rxml_schema_types, 0);
294
269
  rb_define_method(cXMLSchema, "elements", rxml_schema_elements, 0);
270
+ rb_define_method(cXMLSchema, "imported_types", rxml_schema_imported_types, 0);
271
+ rb_define_method(cXMLSchema, "namespaces", rxml_schema_namespaces, 0);
272
+ rb_define_method(cXMLSchema, "types", rxml_schema_types, 0);
295
273
 
296
274
  rxml_init_schema_facet();
297
275
  rxml_init_schema_element();