lutaml-model 0.8.12 → 0.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +116 -103
  3. data/RELEASE_NOTES.adoc +3 -3
  4. data/benchmark/quick_benchmark.rb +2 -2
  5. data/benchmark/serialization_benchmark.rb +4 -4
  6. data/docs/_guides/advanced-mapping.adoc +1 -1
  7. data/docs/_guides/character-encoding.adoc +3 -3
  8. data/docs/_guides/missing-values-handling.adoc +6 -6
  9. data/docs/_guides/ooxml-examples.adoc +7 -7
  10. data/docs/_guides/opal.adoc +1 -1
  11. data/docs/_guides/value-transformations.adoc +7 -7
  12. data/docs/_guides/xml/namespace-presentation.adoc +1 -1
  13. data/docs/_guides/xml/namespace-semantics.adoc +15 -15
  14. data/docs/_guides/xml/type-namespaces.adoc +9 -9
  15. data/docs/_guides/xml-mapping.adoc +32 -26
  16. data/docs/_guides/xml-namespace-qualification.adoc +4 -4
  17. data/docs/_guides/xml-namespaces.adoc +2 -2
  18. data/docs/_guides/xml_mappings/04_xml_namespace_class.adoc +18 -18
  19. data/docs/_guides/xml_mappings/05_common_patterns.adoc +16 -16
  20. data/docs/_guides/xml_mappings/06_migration_guide.adoc +5 -5
  21. data/docs/_guides/xml_mappings/07_best_practices.adoc +11 -11
  22. data/docs/_migrations/0-8-0-namespace-restructuring.adoc +2 -2
  23. data/docs/_pages/attributes.adoc +2 -2
  24. data/docs/_pages/collections.adoc +26 -20
  25. data/docs/_pages/consolidation-mapping.adoc +4 -4
  26. data/docs/_pages/importable_models.adoc +14 -13
  27. data/docs/_pages/quick-start.adoc +1 -1
  28. data/docs/_pages/value_types.adoc +10 -10
  29. data/docs/_references/custom_registers.adoc +7 -7
  30. data/docs/_references/format-independent-features.adoc +4 -4
  31. data/docs/_references/instance-serialization.adoc +1 -1
  32. data/docs/_references/parent-root-context.adoc +3 -3
  33. data/docs/_tutorials/basic-model-definition.adoc +1 -1
  34. data/docs/_tutorials/first-xml-serialization.adoc +4 -4
  35. data/docs/_tutorials/lutaml-xml-architecture.adoc +4 -4
  36. data/docs/_tutorials/validation-basics.adoc +1 -1
  37. data/docs/_tutorials/working-with-collections.adoc +2 -2
  38. data/docs/_tutorials/xml-namespaces-basics.adoc +1 -1
  39. data/docs/_tutorials/xml-schema-primer-style-guide.adoc +29 -29
  40. data/docs/cli_compare.adoc +1 -1
  41. data/docs/index.adoc +1 -1
  42. data/docs/namespace-management.adoc +14 -14
  43. data/lib/lutaml/key_value/mapping.rb +31 -6
  44. data/lib/lutaml/model/collection.rb +11 -11
  45. data/lib/lutaml/model/error/no_root_mapping_error.rb +6 -5
  46. data/lib/lutaml/model/error/no_root_namespace_error.rb +6 -5
  47. data/lib/lutaml/model/error/type_only_mapping_error.rb +13 -0
  48. data/lib/lutaml/model/error/type_only_namespace_error.rb +12 -0
  49. data/lib/lutaml/model/version.rb +1 -1
  50. data/lib/lutaml/model.rb +3 -0
  51. data/lib/lutaml/xml/adapter/base_adapter.rb +0 -9
  52. data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +0 -1
  53. data/lib/lutaml/xml/adapter/oga_adapter.rb +0 -1
  54. data/lib/lutaml/xml/adapter/ox_adapter.rb +0 -1
  55. data/lib/lutaml/xml/adapter/rexml_adapter.rb +0 -1
  56. data/lib/lutaml/xml/adapter/xml_serializer.rb +42 -22
  57. data/lib/lutaml/xml/adapter.rb +4 -0
  58. data/lib/lutaml/xml/builder/base.rb +64 -25
  59. data/lib/lutaml/xml/builder/nokogiri.rb +0 -2
  60. data/lib/lutaml/xml/builder/oga.rb +0 -2
  61. data/lib/lutaml/xml/builder/ox.rb +0 -2
  62. data/lib/lutaml/xml/builder/rexml.rb +0 -2
  63. data/lib/lutaml/xml/builder.rb +1 -0
  64. data/lib/lutaml/xml/configurable.rb +2 -2
  65. data/lib/lutaml/xml/declaration_handler.rb +3 -105
  66. data/lib/lutaml/xml/mapping.rb +3 -3
  67. data/lib/lutaml/xml/schema/xsd/documentation.rb +1 -1
  68. data/lib/lutaml/xml/serialization/collection_ext.rb +7 -7
  69. data/lib/lutaml/xml/serialization/format_conversion.rb +1 -1
  70. data/lib/lutaml/xml/serialization/instance_methods.rb +1 -1
  71. data/lib/lutaml/xml.rb +1 -2
  72. data/lib/tasks/memory_profile.rb +2 -2
  73. data/lib/tasks/performance_benchmark.rb +5 -5
  74. data/spec/lutaml/key_value/transformation/rule_compiler_spec.rb +1 -1
  75. data/spec/lutaml/key_value/transformation/value_serializer_spec.rb +1 -1
  76. data/spec/lutaml/model/attribute_collection_spec.rb +1 -1
  77. data/spec/lutaml/model/cli_spec.rb +1 -1
  78. data/spec/lutaml/model/collection_spec.rb +1 -1
  79. data/spec/lutaml/model/collection_validation_spec.rb +6 -6
  80. data/spec/lutaml/model/consolidation_spec.rb +8 -8
  81. data/spec/lutaml/model/custom_collection_spec.rb +3 -3
  82. data/spec/lutaml/model/default_register_spec.rb +23 -23
  83. data/spec/lutaml/model/delegation_spec.rb +3 -10
  84. data/spec/lutaml/model/derived_attribute_serialization_spec.rb +1 -1
  85. data/spec/lutaml/model/dynamic_attribute_spec.rb +2 -2
  86. data/spec/lutaml/model/enum_spec.rb +1 -1
  87. data/spec/lutaml/model/group_spec.rb +12 -12
  88. data/spec/lutaml/model/lazy_collection_spec.rb +4 -4
  89. data/spec/lutaml/model/mixed_content_spec.rb +2 -2
  90. data/spec/lutaml/model/namespace_versioning_spec.rb +4 -4
  91. data/spec/lutaml/model/processing_instruction_spec.rb +11 -11
  92. data/spec/lutaml/model/register_methods_spec.rb +2 -2
  93. data/spec/lutaml/model/render_empty_spec.rb +1 -1
  94. data/spec/lutaml/model/serialize_perf_guard_spec.rb +1 -1
  95. data/spec/lutaml/model/transform_dynamic_attributes_spec.rb +1 -1
  96. data/spec/lutaml/model/transformation_builder_spec.rb +2 -2
  97. data/spec/lutaml/model/xml_decoupling_spec.rb +3 -3
  98. data/spec/lutaml/model/xsd_patterns_spec.rb +2 -3
  99. data/spec/lutaml/xml/adapter/order_spec.rb +1 -1
  100. data/spec/lutaml/xml/clear_parse_state_spec.rb +1 -1
  101. data/spec/lutaml/xml/content_model_validation_spec.rb +4 -2
  102. data/spec/lutaml/xml/doubly_defined_namespace_spec.rb +5 -5
  103. data/spec/lutaml/xml/enhanced_mapping_spec.rb +2 -1
  104. data/spec/lutaml/xml/entity_fragmentation_spec.rb +5 -5
  105. data/spec/lutaml/xml/indent_spec.rb +109 -0
  106. data/spec/lutaml/xml/line_ending_spec.rb +66 -0
  107. data/spec/lutaml/xml/mapping_finalization_guard_spec.rb +2 -2
  108. data/spec/lutaml/xml/model_transform_guard_spec.rb +4 -4
  109. data/spec/lutaml/xml/namespace_alias_spec.rb +4 -4
  110. data/spec/lutaml/xml/namespace_aware_parsing_spec.rb +3 -3
  111. data/spec/lutaml/xml/namespace_bound_element_roundtrip_spec.rb +2 -2
  112. data/spec/lutaml/xml/namespace_format_preservation_spec.rb +1 -1
  113. data/spec/lutaml/xml/namespace_inheritance_spec.rb +3 -3
  114. data/spec/lutaml/xml/namespace_preservation_spec.rb +5 -5
  115. data/spec/lutaml/xml/opal_xml_spec.rb +8 -8
  116. data/spec/lutaml/xml/pipeline_integration_spec.rb +145 -0
  117. data/spec/lutaml/xml/schema_primer_spec.rb +5 -5
  118. data/spec/lutaml/xml/transformation_spec.rb +20 -20
  119. data/spec/lutaml/xml/type_namespace/collector_spec.rb +1 -1
  120. data/spec/lutaml/xml/type_namespace/planner_spec.rb +3 -3
  121. metadata +7 -2
@@ -156,7 +156,7 @@ class PolyAnimalCollectionAny < Lutaml::Model::Collection
156
156
  end
157
157
 
158
158
  key_value do
159
- root "zoo"
159
+ key "zoo"
160
160
  map_instances to: :animals, polymorphic: {
161
161
  attribute: "type",
162
162
  class_map: {
@@ -10,7 +10,7 @@ module CollectionValidationTests
10
10
  attribute :category, :string
11
11
 
12
12
  xml do
13
- root "publication"
13
+ element "publication"
14
14
  map_attribute "id", to: :id
15
15
  map_element "title", to: :title
16
16
  map_element "year", to: :year
@@ -33,7 +33,7 @@ module CollectionValidationTests
33
33
  validates_uniqueness_of :id, message: "Publication IDs must be unique"
34
34
 
35
35
  xml do
36
- root "publications"
36
+ element "publications"
37
37
  map_element "publication", to: :publications
38
38
  end
39
39
 
@@ -49,7 +49,7 @@ module CollectionValidationTests
49
49
  validates_max_count 5, message: "Cannot have more than 5 publications"
50
50
 
51
51
  xml do
52
- root "publications"
52
+ element "publications"
53
53
  map_element "publication", to: :publications
54
54
  end
55
55
 
@@ -66,7 +66,7 @@ module CollectionValidationTests
66
66
  validates_all_present :year, message: "All publications must have a year"
67
67
 
68
68
  xml do
69
- root "publications"
69
+ element "publications"
70
70
  map_element "publication", to: :publications
71
71
  end
72
72
 
@@ -102,7 +102,7 @@ module CollectionValidationTests
102
102
  end
103
103
 
104
104
  xml do
105
- root "publications"
105
+ element "publications"
106
106
  map_element "publication", to: :publications
107
107
  end
108
108
 
@@ -122,7 +122,7 @@ module CollectionValidationTests
122
122
  validates_min_count 1 # Collection-level validation
123
123
 
124
124
  xml do
125
- root "publications"
125
+ element "publications"
126
126
  map_element "publication", to: :publications
127
127
  end
128
128
 
@@ -18,7 +18,7 @@ RSpec.describe "Consolidation Mapping" do
18
18
  attribute :content, :string
19
19
 
20
20
  xml do
21
- root "title"
21
+ element "title"
22
22
  map_attribute "lang", to: :lang
23
23
  map_attribute "type", to: :type_of_title
24
24
  map_content to: :content
@@ -40,7 +40,7 @@ RSpec.describe "Consolidation Mapping" do
40
40
  organizes :per_lang, ConPerLangGroup
41
41
 
42
42
  xml do
43
- root "titles"
43
+ element "titles"
44
44
  map_instances to: :items
45
45
  consolidate_map by: :lang, to: :per_lang do
46
46
  gather :lang, to: :lang
@@ -59,7 +59,7 @@ RSpec.describe "Consolidation Mapping" do
59
59
  attribute :titles, ConTitle, collection: ConTitleCollection
60
60
 
61
61
  xml do
62
- root "bibdata"
62
+ element "bibdata"
63
63
  map_element "title", to: :titles
64
64
  end
65
65
  end)
@@ -141,7 +141,7 @@ RSpec.describe "Consolidation Mapping" do
141
141
  attribute :content, :string
142
142
 
143
143
  xml do
144
- root "title"
144
+ element "title"
145
145
  map_attribute "lang", to: :lang
146
146
  map_attribute "type", to: :type_of_title
147
147
  map_content to: :content
@@ -159,7 +159,7 @@ RSpec.describe "Consolidation Mapping" do
159
159
  organizes :per_type, ConPerTypeGroup
160
160
 
161
161
  xml do
162
- root "titles"
162
+ element "titles"
163
163
  map_instances to: :items
164
164
  consolidate_map by: :type_of_title, to: :per_type do
165
165
  gather :type_of_title, to: :type_of_title
@@ -175,7 +175,7 @@ RSpec.describe "Consolidation Mapping" do
175
175
  attribute :titles, ConTitle2, collection: ConTitleCollection2
176
176
 
177
177
  xml do
178
- root "bibdata"
178
+ element "bibdata"
179
179
  map_element "title", to: :titles
180
180
  end
181
181
  end)
@@ -247,7 +247,7 @@ RSpec.describe "Consolidation Mapping" do
247
247
  organizes :entries, group_class
248
248
 
249
249
  xml do
250
- root "test"
250
+ element "test"
251
251
  consolidate_map by: :lang, to: :entries do
252
252
  gather :lang, to: :lang
253
253
  dispatch_by :type do
@@ -276,7 +276,7 @@ RSpec.describe "Consolidation Mapping" do
276
276
  organizes :entries, entry_class
277
277
 
278
278
  xml do
279
- root "test"
279
+ element "test"
280
280
  consolidate_map by: :pattern, to: :entries do
281
281
  map_element "member", to: :name
282
282
  map_element "member_key", to: :key
@@ -66,7 +66,7 @@ module CustomCollection
66
66
  end
67
67
 
68
68
  key_value do
69
- root "items"
69
+ key "items"
70
70
  map_instances to: :items
71
71
  end
72
72
  end
@@ -138,7 +138,7 @@ module CustomCollection
138
138
  end
139
139
 
140
140
  key_value do
141
- root "items"
141
+ key "items"
142
142
  map "items", to: :items, value_map: {
143
143
  from: { empty: :empty, omitted: :omitted, nil: :nil },
144
144
  to: { empty: :empty, omitted: :omitted, nil: :nil },
@@ -205,7 +205,7 @@ module CustomCollection
205
205
  end
206
206
 
207
207
  key_value do
208
- root "items"
208
+ key "items"
209
209
 
210
210
  map_instances to: :items
211
211
  end
@@ -85,7 +85,7 @@ RSpec.describe "lutaml_default_register" do
85
85
  attribute :value, :string
86
86
 
87
87
  xml do
88
- root "test"
88
+ element "test"
89
89
  map_element "value", to: :value
90
90
  end
91
91
  end
@@ -105,7 +105,7 @@ RSpec.describe "lutaml_default_register" do
105
105
  attribute :name, :string
106
106
 
107
107
  xml do
108
- root "regular"
108
+ element "regular"
109
109
  end
110
110
  end
111
111
 
@@ -135,7 +135,7 @@ RSpec.describe "lutaml_default_register" do
135
135
  attribute :name, :string
136
136
 
137
137
  xml do
138
- root "test"
138
+ element "test"
139
139
  map_element "name", to: :name
140
140
  end
141
141
  end
@@ -160,7 +160,7 @@ RSpec.describe "lutaml_default_register" do
160
160
  attribute :name, :string
161
161
 
162
162
  xml do
163
- root "regular"
163
+ element "regular"
164
164
  end
165
165
  end
166
166
 
@@ -180,7 +180,7 @@ RSpec.describe "lutaml_default_register" do
180
180
  attribute :value, :string
181
181
 
182
182
  xml do
183
- root "child"
183
+ element "child"
184
184
  map_element "value", to: :value
185
185
  end
186
186
  end
@@ -195,7 +195,7 @@ RSpec.describe "lutaml_default_register" do
195
195
  attribute :child, child_klass
196
196
 
197
197
  xml do
198
- root "parent"
198
+ element "parent"
199
199
  map_element "child", to: :child
200
200
  end
201
201
  end
@@ -258,7 +258,7 @@ RSpec.describe "lutaml_default_register" do
258
258
  attribute :value, :string
259
259
 
260
260
  xml do
261
- root "math"
261
+ element "math"
262
262
  map_element "value", to: :value
263
263
  end
264
264
  end
@@ -267,7 +267,7 @@ RSpec.describe "lutaml_default_register" do
267
267
  attribute :value, :string
268
268
 
269
269
  xml do
270
- root "math"
270
+ element "math"
271
271
  map_element "value", to: :value
272
272
  end
273
273
  end
@@ -432,7 +432,7 @@ RSpec.describe "lutaml_default_register" do
432
432
  attribute :mmultiscripts_value, :mmultiscripts, collection: true
433
433
 
434
434
  xml do
435
- root "math"
435
+ element "math"
436
436
  map_element "mmultiscripts", to: :mmultiscripts_value
437
437
  end
438
438
  end
@@ -445,7 +445,7 @@ RSpec.describe "lutaml_default_register" do
445
445
  attribute :math, math_class
446
446
 
447
447
  xml do
448
- root "doc"
448
+ element "doc"
449
449
  map_element "math", to: :math
450
450
  end
451
451
  end
@@ -477,7 +477,7 @@ RSpec.describe "lutaml_default_register" do
477
477
  attribute :mi_value, :string
478
478
 
479
479
  xml do
480
- root "mmultiscripts"
480
+ element "mmultiscripts"
481
481
  map_element "mi", to: :mi_value
482
482
  end
483
483
  end
@@ -490,7 +490,7 @@ RSpec.describe "lutaml_default_register" do
490
490
  attribute :mmultiscripts_value, mmultiscripts_class, collection: true
491
491
 
492
492
  xml do
493
- root "math"
493
+ element "math"
494
494
  map_element "mmultiscripts", to: :mmultiscripts_value
495
495
  end
496
496
  end
@@ -504,7 +504,7 @@ RSpec.describe "lutaml_default_register" do
504
504
  attribute :math, math_class
505
505
 
506
506
  xml do
507
- root "doc"
507
+ element "doc"
508
508
  map_attribute "id", to: :id
509
509
  map_element "math", to: :math
510
510
  end
@@ -563,7 +563,7 @@ RSpec.describe "lutaml_default_register" do
563
563
  attribute :value, :string
564
564
 
565
565
  xml do
566
- root "mi"
566
+ element "mi"
567
567
  map_content to: :value
568
568
  end
569
569
  end
@@ -573,7 +573,7 @@ RSpec.describe "lutaml_default_register" do
573
573
  attribute :value, :string
574
574
 
575
575
  xml do
576
- root "mi"
576
+ element "mi"
577
577
  map_content to: :value
578
578
  end
579
579
  end
@@ -588,7 +588,7 @@ RSpec.describe "lutaml_default_register" do
588
588
  attribute :mi_value, standard_mi, collection: true
589
589
 
590
590
  xml do
591
- root "math"
591
+ element "math"
592
592
  map_element "mi", to: :mi_value
593
593
  end
594
594
  end
@@ -626,7 +626,7 @@ RSpec.describe "lutaml_default_register" do
626
626
  attribute :value, :string
627
627
 
628
628
  xml do
629
- root "mi"
629
+ element "mi"
630
630
  map_content to: :value
631
631
  end
632
632
  end
@@ -728,7 +728,7 @@ RSpec.describe "lutaml_default_register" do
728
728
  attribute :value, :string
729
729
 
730
730
  xml do
731
- root "inner"
731
+ element "inner"
732
732
  map_content to: :value
733
733
  end
734
734
  end
@@ -746,7 +746,7 @@ RSpec.describe "lutaml_default_register" do
746
746
  attribute :inner, :inner_element
747
747
 
748
748
  xml do
749
- root "child"
749
+ element "child"
750
750
  map_element "inner", to: :inner
751
751
  end
752
752
  end
@@ -756,7 +756,7 @@ RSpec.describe "lutaml_default_register" do
756
756
  attribute :child_elem, child_class
757
757
 
758
758
  xml do
759
- root "parent"
759
+ element "parent"
760
760
  map_element "child", to: :child_elem
761
761
  end
762
762
  end
@@ -774,7 +774,7 @@ RSpec.describe "lutaml_default_register" do
774
774
  attribute :content, :string
775
775
 
776
776
  xml do
777
- root "item"
777
+ element "item"
778
778
  map_content to: :content
779
779
  end
780
780
  end
@@ -790,7 +790,7 @@ RSpec.describe "lutaml_default_register" do
790
790
  attribute :items, :inner_element, collection: true
791
791
 
792
792
  xml do
793
- root "items"
793
+ element "items"
794
794
  map_element "item", to: :items
795
795
  end
796
796
  end
@@ -799,7 +799,7 @@ RSpec.describe "lutaml_default_register" do
799
799
  attribute :container, child_class
800
800
 
801
801
  xml do
802
- root "doc"
802
+ element "doc"
803
803
  map_element "items", to: :container
804
804
  end
805
805
  end
@@ -266,23 +266,16 @@ RSpec.describe Delegation do
266
266
  expect(xml_data).not_to include("<?xml")
267
267
  end
268
268
 
269
- it "provides XML declaration with default version" \
269
+ it "provides XML declaration with default version and encoding" \
270
270
  "if declaration: true option provided" do
271
271
  xml_data = delegation.to_xml(pretty: true, declaration: true)
272
- expect(xml_data).to include('<?xml version="1.0"?>')
272
+ expect(xml_data).to include('<?xml version="1.0" encoding="UTF-8"?>')
273
273
  end
274
274
 
275
275
  it "provides XML declaration with specified version" \
276
276
  "if declaration: '1.1' option provided" do
277
277
  xml_data = delegation.to_xml(pretty: true, declaration: "1.1")
278
- expect(xml_data).to include('<?xml version="1.1"?>')
279
- end
280
-
281
- it "provides XML declaration without encoding" \
282
- "if encoding option not provided" do
283
- xml_data = delegation.to_xml(pretty: true, declaration: true)
284
- expect(xml_data).to include('<?xml version="1.0"?>')
285
- expect(xml_data).not_to include("encoding=")
278
+ expect(xml_data).to include('<?xml version="1.1" encoding="UTF-8"?>')
286
279
  end
287
280
 
288
281
  it "provides XML declaration with UTF-8 encoding" \
@@ -7,7 +7,7 @@ module DerivedAttributeSerializationSpec
7
7
  attribute :computed_val, :string, method: :computed_value
8
8
 
9
9
  xml do
10
- root "parent"
10
+ element "parent"
11
11
  map_attribute "computed-val", to: :computed_val, render_default: true
12
12
  end
13
13
 
@@ -32,7 +32,7 @@ RSpec.describe "Dynamic attribute addition after register imports" do
32
32
  attribute :name, :string
33
33
 
34
34
  xml do
35
- root "BaseModel"
35
+ element "BaseModel"
36
36
  namespace DynAttrTestNamespace
37
37
  map_element "Name", to: :name
38
38
  end
@@ -44,7 +44,7 @@ RSpec.describe "Dynamic attribute addition after register imports" do
44
44
  attribute :code, :string
45
45
 
46
46
  xml do
47
- root "ExtensionModel"
47
+ element "ExtensionModel"
48
48
  namespace DynAttrTestNamespace
49
49
  map_element "Code", to: :code
50
50
  end
@@ -14,7 +14,7 @@ module EnumSpec
14
14
  attribute :char, :string
15
15
 
16
16
  xml do
17
- root "test"
17
+ element "test"
18
18
  map_attribute "align", to: :align
19
19
  map_attribute "char", to: :char
20
20
  end
@@ -213,7 +213,7 @@ module GroupSpec
213
213
  end
214
214
 
215
215
  RSpec.describe "Group" do
216
- context "when serializing and deserializing import model having no_root" do
216
+ context "when serializing and deserializing imported type-only models" do
217
217
  let(:xml) do
218
218
  # W3C Rule: Namespaces can be declared at point of use (local) or at root (hoisted).
219
219
  # Implementation prefers default format for cleaner output when creating new instances.
@@ -262,28 +262,28 @@ RSpec.describe "Group" do
262
262
  end
263
263
  end
264
264
 
265
- context "with no_root" do
265
+ context "with type-only model (no element declared)" do
266
266
  let(:mapper) { GroupSpec::CeramicCollection }
267
267
 
268
- it "raises error if root-less class used directly for parsing" do
268
+ it "raises error if type-only class used directly for parsing" do
269
269
  xml = <<~XML
270
270
  <type>Data</type>
271
271
  <name>Smith</name>
272
272
  XML
273
273
 
274
274
  expect { GroupSpec::Ceramic.from_xml(xml) }.to raise_error(
275
- Lutaml::Model::NoRootMappingError,
276
- "GroupSpec::Ceramic has `no_root`, it allowed only for reusable models",
275
+ Lutaml::Model::TypeOnlyMappingError,
276
+ /type-only model/,
277
277
  )
278
278
  end
279
279
 
280
- context "deserializing XML" do
280
+ context "serializing XML" do
281
281
  let(:ceramic) { GroupSpec::Ceramic.new(type: "Data", name: "Starc") }
282
282
 
283
- it "raises error for root_less class" do
283
+ it "raises error for type-only class" do
284
284
  expect { ceramic.to_xml }.to raise_error(
285
- Lutaml::Model::NoRootMappingError,
286
- "GroupSpec::Ceramic has `no_root`, it allowed only for reusable models",
285
+ Lutaml::Model::TypeOnlyMappingError,
286
+ /type-only model/,
287
287
  )
288
288
  end
289
289
  end
@@ -553,7 +553,7 @@ RSpec.describe "Group" do
553
553
  "Cannot import a model `GroupSpec::GroupWithRoot` with a root element")
554
554
  end
555
555
 
556
- it "raises error if namespace is defined with no_root" do
556
+ it "raises error if namespace is defined with deprecated no_root" do
557
557
  expect do
558
558
  Class.new(Lutaml::Model::Serializable) do
559
559
  xml do
@@ -561,8 +561,8 @@ RSpec.describe "Group" do
561
561
  namespace XmiNamespace
562
562
  end
563
563
  end
564
- end.to raise_error(Lutaml::Model::NoRootNamespaceError,
565
- "Cannot assign namespace to `no_root`")
564
+ end.to raise_error(Lutaml::Model::TypeOnlyNamespaceError,
565
+ /type-only model/)
566
566
  end
567
567
  end
568
568
 
@@ -10,7 +10,7 @@ module LazyCollectionTests
10
10
  attribute :name, :string
11
11
 
12
12
  xml do
13
- root "multi"
13
+ element "multi"
14
14
  map_element "name", to: :name
15
15
  map_element "item_a", to: :items_a
16
16
  map_element "item_b", to: :items_b
@@ -23,7 +23,7 @@ module LazyCollectionTests
23
23
  attribute :name, :string
24
24
 
25
25
  xml do
26
- root "tagged"
26
+ element "tagged"
27
27
  map_element "name", to: :name
28
28
  map_element "tag", to: :tags
29
29
  end
@@ -33,7 +33,7 @@ module LazyCollectionTests
33
33
  attribute :value, :string
34
34
 
35
35
  xml do
36
- root "child"
36
+ element "child"
37
37
  map_element "value", to: :value
38
38
  end
39
39
  end
@@ -47,7 +47,7 @@ module LazyCollectionTests
47
47
  attribute :name, :string
48
48
 
49
49
  xml do
50
- root "parent"
50
+ element "parent"
51
51
  map_element "name", to: :name
52
52
  map_element "child1", to: :col_1
53
53
  map_element "child2", to: :col_2
@@ -257,7 +257,7 @@ module MixedContentSpec
257
257
  attribute :mathvariant, :string
258
258
 
259
259
  xml do
260
- root "mi"
260
+ element "mi"
261
261
  mixed_content
262
262
  map_content to: :value
263
263
  map_attribute "mathvariant", to: :mathvariant
@@ -269,7 +269,7 @@ module MixedContentSpec
269
269
  attribute :bold, :string
270
270
 
271
271
  xml do
272
- root "p"
272
+ element "p"
273
273
  mixed_content
274
274
  map_content to: :content
275
275
  map_element "b", to: :bold
@@ -93,7 +93,7 @@ RSpec.describe Lutaml::Model::ModelTreeImporter do
93
93
  attribute :value, :integer
94
94
 
95
95
  xml do
96
- root "Simple"
96
+ element "Simple"
97
97
  map_element "name", to: :name
98
98
  map_element "value", to: :value
99
99
  end
@@ -322,7 +322,7 @@ RSpec.describe "Context Propagation for Mixed Schema Types" do
322
322
  attribute :custom_field, :custom_type_for_context
323
323
 
324
324
  xml do
325
- root "Child"
325
+ element "Child"
326
326
  map_element "CustomField", to: :custom_field
327
327
  end
328
328
  end
@@ -341,7 +341,7 @@ RSpec.describe "Context Propagation for Mixed Schema Types" do
341
341
  attribute :child, child_klass
342
342
 
343
343
  xml do
344
- root "Parent"
344
+ element "Parent"
345
345
  map_element "Child", to: :child
346
346
  end
347
347
  end
@@ -369,7 +369,7 @@ RSpec.describe "Context Propagation for Mixed Schema Types" do
369
369
  attribute :children, child_klass, collection: true
370
370
 
371
371
  xml do
372
- root "Parent"
372
+ element "Parent"
373
373
  map_element "Child", to: :children
374
374
  end
375
375
  end
@@ -32,7 +32,7 @@ RSpec.describe "Processing Instructions" do
32
32
  attribute :pi_settings, :hash
33
33
 
34
34
  xml do
35
- root "rfc"
35
+ element "rfc"
36
36
  map_element "title", to: :title
37
37
  map_processing_instruction "rfc", to: :pi_settings
38
38
  end
@@ -57,7 +57,7 @@ RSpec.describe "Processing Instructions" do
57
57
  attribute :pi_settings, :hash
58
58
 
59
59
  xml do
60
- root "rfc"
60
+ element "rfc"
61
61
  map_element "title", to: :title
62
62
  map_processing_instruction "rfc", to: :pi_settings
63
63
  end
@@ -76,7 +76,7 @@ RSpec.describe "Processing Instructions" do
76
76
  attribute :pi_settings, :hash
77
77
 
78
78
  xml do
79
- root "rfc"
79
+ element "rfc"
80
80
  map_element "title", to: :title
81
81
  map_processing_instruction "rfc", to: :pi_settings
82
82
  end
@@ -96,7 +96,7 @@ RSpec.describe "Processing Instructions" do
96
96
  attribute :xml_pis, :hash
97
97
 
98
98
  xml do
99
- root "doc"
99
+ element "doc"
100
100
  map_element "title", to: :title
101
101
  map_processing_instruction "rfc", to: :rfc_pis
102
102
  map_processing_instruction "xml-stylesheet", to: :xml_pis
@@ -120,7 +120,7 @@ RSpec.describe "Processing Instructions" do
120
120
  attribute :pi_settings, :hash
121
121
 
122
122
  xml do
123
- root "rfc"
123
+ element "rfc"
124
124
  map_element "title", to: :title
125
125
  map_processing_instruction "rfc", to: :pi_settings
126
126
  end
@@ -143,7 +143,7 @@ RSpec.describe "Processing Instructions" do
143
143
  attribute :title, :string
144
144
 
145
145
  xml do
146
- root "doc"
146
+ element "doc"
147
147
  map_element "title", to: :title
148
148
  end
149
149
  end
@@ -238,7 +238,7 @@ RSpec.describe "Processing Instructions" do
238
238
  attribute :pi_settings, :hash
239
239
 
240
240
  xml do
241
- root "rfc"
241
+ element "rfc"
242
242
  map_element "title", to: :title
243
243
  map_processing_instruction "rfc", to: :pi_settings
244
244
  end
@@ -266,7 +266,7 @@ RSpec.describe "Processing Instructions" do
266
266
  attribute :pi_settings, :hash
267
267
 
268
268
  xml do
269
- root "rfc"
269
+ element "rfc"
270
270
  map_element "title", to: :title
271
271
  map_processing_instruction "rfc", to: :pi_settings
272
272
  end
@@ -284,7 +284,7 @@ RSpec.describe "Processing Instructions" do
284
284
  attribute :stylesheet_pis, :hash
285
285
 
286
286
  xml do
287
- root "doc"
287
+ element "doc"
288
288
  map_element "title", to: :title
289
289
  map_processing_instruction "rfc", to: :rfc_pis
290
290
  map_processing_instruction "xml-stylesheet", to: :stylesheet_pis
@@ -312,7 +312,7 @@ RSpec.describe "Processing Instructions" do
312
312
  attribute :db_pis, :hash
313
313
 
314
314
  xml do
315
- root "book"
315
+ element "book"
316
316
  map_element "title", to: :title
317
317
  map_processing_instruction "db", to: :db_pis
318
318
  end
@@ -333,7 +333,7 @@ RSpec.describe "Processing Instructions" do
333
333
  attribute :rfc_pis, :string, collection: true
334
334
 
335
335
  xml do
336
- root "rfc"
336
+ element "rfc"
337
337
  map_element "title", to: :title
338
338
  map_processing_instruction "rfc", to: :rfc_pis
339
339
  end