We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ba9ac99 commit cb088a4Copy full SHA for cb088a4
2 files changed
lib/libxml/schema/type.rb
@@ -5,14 +5,14 @@ def kind_name
5
Schema::Types.constants.find { |k| Schema::Types.const_get(k) == kind }
6
end
7
8
- def annonymus_subtypes
+ def anonymous_subtypes
9
elements.select { |_, e| e.type.name.nil? }
10
11
12
- def annonymus_subtypes_recursively(parent=nil)
13
- annonymus_subtypes.map do |element_name, e|
+ def anonymous_subtypes_recursively(parent=nil)
+ anonymous_subtypes.map do |element_name, e|
14
[{[parent, element_name].compact.join('::') => e.type},
15
- e.type.annonymus_subtypes_recursively(element_name)]
+ e.type.anonymous_subtypes_recursively(element_name)]
16
end.flatten
17
18
test/test_schema.rb
@@ -235,4 +235,31 @@ def test_schema_attribute
235
assert_equal('1', attribute.default)
236
assert_equal('integer', attribute.type.name)
237
238
+
239
+ def test_anonymous_subtypes
240
+ type = @schema.types['shiporderType']
241
+ anon = type.anonymous_subtypes
242
243
+ assert_instance_of(Hash, anon)
244
+ assert_equal(2, anon.length)
245
+ assert_includes(anon.keys, 'shipto')
246
+ assert_includes(anon.keys, 'item')
247
248
+ anon.each_value do |element|
249
+ assert_instance_of(LibXML::XML::Schema::Element, element)
250
+ assert_nil(element.type.name)
251
+ end
252
253
254
+ def test_anonymous_subtypes_recursively
255
256
+ result = type.anonymous_subtypes_recursively
257
258
+ assert_instance_of(Array, result)
259
+ assert_operator(result.length, :>=, 2)
260
261
+ keys = result.select { |r| r.is_a?(Hash) }.flat_map(&:keys)
262
+ assert_includes(keys, 'shipto')
263
+ assert_includes(keys, 'item')
264
265
0 commit comments