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
@@ -1359,7 +1359,7 @@ Version 0.8.0 unifies the `xml do` syntax for both model classes and custom Type
1359
1359
  class Person < Lutaml::Model::Serializable
1360
1360
  xml do
1361
1361
  namespace "http://example.com/ns", "p" # Different syntax
1362
- root "person"
1362
+ element "person"
1363
1363
  end
1364
1364
  end
1365
1365
 
@@ -1485,7 +1485,7 @@ Version 0.8.0 enforces **model-centric namespace definitions**. Namespaces are d
1485
1485
  ----
1486
1486
  class Parent < Lutaml::Model::Serializable
1487
1487
  xml do
1488
- root "parent"
1488
+ element "parent"
1489
1489
  namespace "http://parent.com", "p"
1490
1490
 
1491
1491
  # ❌ Namespace on mapping - NO LONGER SUPPORTED
@@ -808,7 +808,7 @@ class ReferenceSet < Lutaml::Model::Serializable
808
808
  ]
809
809
 
810
810
  xml do
811
- root "ReferenceSet"
811
+ element "ReferenceSet"
812
812
 
813
813
  map_element "reference", to: :references, polymorphic: {
814
814
  # This refers to the attribute in the polymorphic model, you need
@@ -945,7 +945,7 @@ class SomeModel < Lutaml::Model::Serializable
945
945
  attribute :coll, :string, collection: true
946
946
 
947
947
  xml do
948
- root "some-model"
948
+ element "some-model"
949
949
  map_element 'collection', to: :coll
950
950
  end
951
951
 
@@ -145,7 +145,7 @@ class TitleDelimiterCollection < Lutaml::Model::Collection
145
145
  instances :items, :string
146
146
 
147
147
  xml do
148
- root "titles"
148
+ element "titles"
149
149
  map_attribute "title", to: :items, delimiter: "; " <1>
150
150
  end
151
151
  end
@@ -164,7 +164,7 @@ class TitleCollection < Lutaml::Model::Collection
164
164
  instances :items, :string
165
165
 
166
166
  xml do
167
- root "titles"
167
+ element "titles"
168
168
  map_attribute "title", to: :items, as_list: {
169
169
  import: ->(str) { str.split("; ") }, <1>
170
170
  export: ->(arr) { arr.join("; ") }, <2>
@@ -302,7 +302,6 @@ class TitleCollection < Lutaml::Model::Collection
302
302
  instances :titles, Title
303
303
 
304
304
  key_value do
305
- no_root # default
306
305
  map_instances to: :titles
307
306
  end
308
307
  end
@@ -382,7 +381,6 @@ class TitleCollection < Lutaml::Model::Collection
382
381
  instances :titles, Title
383
382
 
384
383
  key_value do
385
- no_root # default
386
384
  map_instances to: :titles
387
385
  end
388
386
  end
@@ -477,11 +475,11 @@ class MyCollection < Lutaml::Model::Collection
477
475
  instances :items, ModelType
478
476
 
479
477
  xml do
480
- root "name-of-xml-container-element"
478
+ element "name-of-xml-container-element"
481
479
  end
482
480
 
483
481
  key_value do
484
- root "name-of-key-value-container-element"
482
+ key "name-of-key-value-wrapper-key"
485
483
  end
486
484
  end
487
485
 
@@ -490,6 +488,15 @@ class ModelType < Lutaml::Model::Serializable
490
488
  end
491
489
  ----
492
490
 
491
+ In the `key_value` block:
492
+
493
+ - `key "key-name"` sets the wrapper key for the collection in key-value formats (JSON, YAML, TOML).
494
+ The serialized output wraps all instances under this key (e.g., `{"titles": [...]}`).
495
+ - Without a `key` call (the default), instances are serialized directly at the top level
496
+ (e.g., `["Item One", "Item Two"]`).
497
+
498
+ NOTE: Key-value formats use `key` to set the wrapper key name, and `element` for XML element names.
499
+
493
500
  A named collection can alternatively be implemented as a non-collection model
494
501
  ("Model class with an attribute") that contains the collection of instances. In
495
502
  this case, the attribute will be an Array object, which does not contain
@@ -504,7 +511,7 @@ class Title < Lutaml::Model::Serializable
504
511
  attribute :title, :string
505
512
 
506
513
  xml do
507
- root "title"
514
+ element "title"
508
515
  map_content to: :title
509
516
  end
510
517
  end
@@ -513,7 +520,7 @@ class DirectTitleCollection < Lutaml::Model::Collection
513
520
  instances :items, Title
514
521
 
515
522
  xml do
516
- root "titles"
523
+ element "titles"
517
524
  map_element "title", to: :items
518
525
  end
519
526
 
@@ -639,7 +646,7 @@ class Title < Lutaml::Model::Serializable
639
646
  attribute :title, :string
640
647
 
641
648
  xml do
642
- root "title"
649
+ element "title"
643
650
  map_element "content", to: :title
644
651
  end
645
652
 
@@ -652,12 +659,12 @@ class TitleCollection < Lutaml::Model::Collection
652
659
  instances :items, Title
653
660
 
654
661
  xml do
655
- root "titles"
662
+ element "titles"
656
663
  map_element 'title', to: :items
657
664
  end
658
665
 
659
666
  key_value do
660
- root "titles"
667
+ key "titles"
661
668
  map_instances to: :items
662
669
  end
663
670
  end
@@ -742,12 +749,12 @@ class BibliographicItem < Lutaml::Model::Serializable
742
749
  attribute :title_parts, :string, collection: StringParts
743
750
 
744
751
  xml do
745
- root "titles"
752
+ element "titles"
746
753
  map_element "title", to: :title_parts
747
754
  end
748
755
 
749
756
  key_value do
750
- root "titles"
757
+ key "titles"
751
758
  map_instances to: :title_parts
752
759
  end
753
760
 
@@ -829,7 +836,7 @@ class TitleCollection < Lutaml::Model::Collection
829
836
  instances :items, Title
830
837
 
831
838
  xml do
832
- root "title-group"
839
+ element "title-group"
833
840
  map_element "artifact", to: :items
834
841
  end
835
842
  end
@@ -838,7 +845,7 @@ class BibItem < Lutaml::Model::Serializable
838
845
  attribute :titles, TitleCollection
839
846
 
840
847
  xml do
841
- root "bibitem"
848
+ element "bibitem"
842
849
  # This overrides the collection's root "title-group"
843
850
  map_element "titles", to: :titles
844
851
  end
@@ -1367,12 +1374,11 @@ class OrderedItemCollection < Lutaml::Model::Collection
1367
1374
  ordered by: :id, order: :desc
1368
1375
 
1369
1376
  xml do
1370
- root "items"
1377
+ element "items"
1371
1378
  map_element "item", to: :items
1372
1379
  end
1373
1380
 
1374
1381
  key_value do
1375
- no_root
1376
1382
  map_instances to: :items
1377
1383
  end
1378
1384
  end
@@ -1401,7 +1407,7 @@ class ProcOrderedItemCollection < Lutaml::Model::Collection
1401
1407
  ordered by: ->(item) { [item.name.length, item.name] }, order: :asc
1402
1408
 
1403
1409
  xml do
1404
- root "items"
1410
+ element "items"
1405
1411
  map_element "item", to: :items
1406
1412
  end
1407
1413
  end
@@ -1543,7 +1549,7 @@ class ReferenceSet < Lutaml::Model::Collection
1543
1549
  ]
1544
1550
 
1545
1551
  xml do
1546
- root "ReferenceSet"
1552
+ element "ReferenceSet"
1547
1553
  map_instances to: :references, polymorphic: {
1548
1554
  attribute: "_class",
1549
1555
  class_map: {
@@ -1640,7 +1646,7 @@ class ReferenceSet < Lutaml::Model::Collection
1640
1646
  ]
1641
1647
 
1642
1648
  xml do
1643
- root "ReferenceSet"
1649
+ element "ReferenceSet"
1644
1650
  map_instances to: :references, polymorphic: {
1645
1651
  attribute: "_class",
1646
1652
  class_map: {
@@ -76,7 +76,7 @@ class TitleCollection < Lutaml::Model::Collection
76
76
  organizes :per_lang, PerLangTitleGroup
77
77
 
78
78
  xml do
79
- root "titles"
79
+ element "titles"
80
80
  map_instances to: :items
81
81
 
82
82
  consolidate_map by: :lang, to: :per_lang do
@@ -105,7 +105,7 @@ class IndividualTitle < Lutaml::Model::Serializable
105
105
  attribute :content, :string
106
106
 
107
107
  xml do
108
- root "title"
108
+ element "title"
109
109
  map_attribute "lang", to: :lang
110
110
  map_attribute "type", to: :type_of_title
111
111
  map_content to: :content
@@ -127,7 +127,7 @@ class TitleCollection < Lutaml::Model::Collection
127
127
  organizes :per_lang, PerLangTitleGroup
128
128
 
129
129
  xml do
130
- root "titles"
130
+ element "titles"
131
131
  map_instances to: :items
132
132
 
133
133
  consolidate_map by: :lang, to: :per_lang do
@@ -147,7 +147,7 @@ class Bibdata < Lutaml::Model::Serializable
147
147
  attribute :titles, IndividualTitle, collection: TitleCollection
148
148
 
149
149
  xml do
150
- root "bibdata"
150
+ element "bibdata"
151
151
  map_element "title", to: :titles
152
152
  end
153
153
  end
@@ -14,8 +14,9 @@ This feature works both with XML and key-value formats.
14
14
 
15
15
  * The import order determines how elements and attributes are overwritten.
16
16
 
17
- * An importable model with XML serialization mappings requires setting the model's
18
- XML serialization configuration with the `no_root` directive.
17
+ * An importable model with XML serialization mappings is a "type-only model" —
18
+ it has no `element` declaration in its `xml` block, meaning it can only be
19
+ used as an embedded type through a parent model.
19
20
 
20
21
  The model can be imported into another model using the following directives:
21
22
 
@@ -25,11 +26,11 @@ The model can be imported into another model using the following directives:
25
26
 
26
27
  `import_model_mappings`:: imports only mappings.
27
28
 
28
- NOTE: Models with `no_root` can only be parsed through parent models.
29
- Direct calling `NoRootModel.from_xml` will raise a `NoRootMappingError`.
29
+ NOTE: Type-only models (no `element` declaration) can only be parsed through parent models.
30
+ Directly calling `TypeOnlyModel.from_xml` will raise a `TypeOnlyMappingError`.
30
31
 
31
32
  NOTE: Namespaces are not currently supported in importable models.
32
- If `namespace` is defined with `no_root`, `NoRootNamespaceError` will be raised.
33
+ If `namespace` is defined with the deprecated `no_root`, `TypeOnlyNamespaceError` will be raised.
33
34
 
34
35
  .Importing model components using an importable model
35
36
  [example]
@@ -51,7 +52,7 @@ class GroupOfItems < Lutaml::Model::Serializable
51
52
  attribute :code, :string
52
53
 
53
54
  xml do
54
- no_root
55
+ # Type-only model - no element declaration needed
55
56
  sequence do
56
57
  map_element "name", to: :name
57
58
  map_element "type", to: :type
@@ -67,7 +68,7 @@ class ComplexType < Lutaml::Model::Serializable
67
68
  import_model_attributes GroupOfItems
68
69
 
69
70
  xml do
70
- root "GroupOfItems"
71
+ element "GroupOfItems"
71
72
 
72
73
  map_attribute "tag", to: :tag
73
74
  map_content to: :content
@@ -96,7 +97,7 @@ end
96
97
  [source,ruby]
97
98
  ----
98
99
  > parsed = GroupOfItems.from_xml(xml)
99
- > # Lutaml::Model::NoRootMappingError: "GroupOfItems has `no_root`, it allowed only for reusable models"
100
+ > # Lutaml::Model::TypeOnlyMappingError: "GroupOfItems is a type-only model (no element declared), ..."
100
101
  ----
101
102
  ====
102
103
 
@@ -124,7 +125,7 @@ class Address < Lutaml::Model::Serializable
124
125
  attribute :zip, :string
125
126
 
126
127
  xml do
127
- no_root
128
+ # Type-only model - no element declaration needed
128
129
 
129
130
  map_element :street, to: :street
130
131
  map_element :city, to: :city
@@ -137,7 +138,7 @@ class Person < Lutaml::Model::Serializable
137
138
  import_model_attributes Address
138
139
 
139
140
  xml do
140
- root "Person"
141
+ element "Person"
141
142
 
142
143
  map_element :name, to: :name
143
144
  sequence do
@@ -193,7 +194,7 @@ class ContactEmail < Lutaml::Model::Serializable
193
194
  attribute :email, :string
194
195
 
195
196
  xml do
196
- no_root
197
+ # Type-only model - no element declaration needed
197
198
 
198
199
  map_element :email, to: :email
199
200
  end
@@ -203,7 +204,7 @@ class ContactPhone < Lutaml::Model::Serializable
203
204
  attribute :phone, :string
204
205
 
205
206
  xml do
206
- no_root
207
+ # Type-only model - no element declaration needed
207
208
 
208
209
  map_element :phone, to: :phone
209
210
  end
@@ -217,7 +218,7 @@ class Person < Lutaml::Model::Serializable
217
218
  end
218
219
 
219
220
  xml do
220
- root "Person"
221
+ element "Person"
221
222
 
222
223
  map_element :email, to: :email
223
224
  map_element :phone, to: :phone
@@ -56,7 +56,7 @@ class Person < Lutaml::Model::Serializable
56
56
  attribute :age, :integer
57
57
 
58
58
  xml do
59
- root "person"
59
+ element "person"
60
60
  map_element "name", to: :name
61
61
  map_element "age", to: :age
62
62
  end
@@ -92,7 +92,7 @@ class Event < Lutaml::Model::Serializable
92
92
  attribute :start_date, :date
93
93
 
94
94
  xml do
95
- root "event"
95
+ element "event"
96
96
  map_element "startDate", to: :start_date
97
97
  end
98
98
 
@@ -150,7 +150,7 @@ class ProcessingTask < Lutaml::Model::Serializable
150
150
  attribute :processing_time, :duration
151
151
 
152
152
  xml do
153
- root "task"
153
+ element "task"
154
154
  map_element "processingTime", to: :processing_time
155
155
  end
156
156
  end
@@ -180,7 +180,7 @@ class Resource < Lutaml::Model::Serializable
180
180
  attribute :schema_location, :uri
181
181
 
182
182
  xml do
183
- root "resource"
183
+ element "resource"
184
184
  map_element "homepage", to: :homepage
185
185
  map_attribute "schemaLocation", to: :schema_location
186
186
  end
@@ -215,7 +215,7 @@ class Reference < Lutaml::Model::Serializable
215
215
  attribute :target, :qname
216
216
 
217
217
  xml do
218
- root "reference"
218
+ element "reference"
219
219
  map_attribute "type", to: :ref_type
220
220
  map_element "target", to: :target
221
221
  end
@@ -253,7 +253,7 @@ class Attachment < Lutaml::Model::Serializable
253
253
  attribute :filename, :string
254
254
 
255
255
  xml do
256
- root "attachment"
256
+ element "attachment"
257
257
  map_element "content", to: :content
258
258
  map_attribute "filename", to: :filename
259
259
  end
@@ -294,7 +294,7 @@ class Checksum < Lutaml::Model::Serializable
294
294
  attribute :algorithm, :string
295
295
 
296
296
  xml do
297
- root "checksum"
297
+ element "checksum"
298
298
  map_element "value", to: :hash_value
299
299
  map_attribute "algorithm", to: :algorithm
300
300
  end
@@ -360,7 +360,7 @@ class Article < Lutaml::Model::Serializable
360
360
  attribute :title, :string
361
361
 
362
362
  xml do
363
- root "article"
363
+ element "article"
364
364
  map_attribute "lang", to: :lang
365
365
  map_attribute "space", to: :space
366
366
  map_attribute "id", to: :id
@@ -486,7 +486,7 @@ class Task < Lutaml::Model::Serializable
486
486
  attribute :priority, :symbol
487
487
 
488
488
  xml do
489
- root "task"
489
+ element "task"
490
490
  map_element "status", to: :status
491
491
  map_element "priority", to: :priority
492
492
  end
@@ -731,7 +731,7 @@ class Address < Lutaml::Model::Serializable
731
731
 
732
732
  # Define how this complex object maps to different formats
733
733
  xml do
734
- root "Address"
734
+ element "Address"
735
735
  map_element "Street", to: :street
736
736
  map_element "City", to: :city
737
737
  map_element "PostalCode", to: :postal_code
@@ -1051,7 +1051,7 @@ end
1051
1051
  class Ceramic < Lutaml::Model::Serializable
1052
1052
  attribute :kiln_firing_time, HighPrecisionDateTime
1053
1053
  xml do
1054
- root 'ceramic'
1054
+ element "ceramic"
1055
1055
  map_element 'kilnFiringTime', to: :kiln_firing_time
1056
1056
  # ...
1057
1057
  end
@@ -449,7 +449,7 @@ module Mml
449
449
  attribute :mrow, Mrow
450
450
 
451
451
  xml do
452
- root "math"
452
+ element "math"
453
453
  end
454
454
  end
455
455
  end
@@ -545,7 +545,7 @@ class MyDocument < Lutaml::Model::Serializable
545
545
  attribute :math, Mml::V2::Math # Has lutaml_default_register = :mml_v2
546
546
 
547
547
  xml do
548
- root "document"
548
+ element "document"
549
549
  map_element "math", to: :math
550
550
  end
551
551
  end
@@ -639,7 +639,7 @@ module Mml
639
639
  attribute :mi_value, :string
640
640
 
641
641
  xml do
642
- root "mmultiscripts"
642
+ element "mmultiscripts"
643
643
  map_element "mi", to: :mi_value
644
644
  end
645
645
  end
@@ -648,7 +648,7 @@ module Mml
648
648
  attribute :mmultiscripts_value, Mmultiscripts, collection: true
649
649
 
650
650
  xml do
651
- root "math"
651
+ element "math"
652
652
  map_element "mmultiscripts", to: :mmultiscripts_value
653
653
  end
654
654
  end
@@ -665,7 +665,7 @@ class MyDocument < Lutaml::Model::Serializable
665
665
  attribute :math, Mml::Math
666
666
 
667
667
  xml do
668
- root "document"
668
+ element "document"
669
669
  map_attribute "id", to: :id
670
670
  map_element "math", to: :math
671
671
  end
@@ -704,7 +704,7 @@ class MyDocument < Lutaml::Model::Serializable
704
704
  attribute :math, Mml::V2::Math # Has lutaml_default_register = :mml_v2
705
705
 
706
706
  xml do
707
- root "document"
707
+ element "document"
708
708
  map_element "math", to: :math
709
709
  end
710
710
  end
@@ -776,7 +776,7 @@ class Article < Lutaml::Model::Serializable
776
776
  attribute :formula, Mml::V2::Math
777
777
 
778
778
  xml do
779
- root "article"
779
+ element "article"
780
780
  map_element "math", to: :formula
781
781
  end
782
782
  end
@@ -126,7 +126,7 @@ class Ceramic < Lutaml::Model::Serializable
126
126
 
127
127
  # Mapping-level transformation in XML format
128
128
  xml do
129
- root "Ceramic"
129
+ element "Ceramic"
130
130
  map_attribute "glaze-type", to: :glaze_type, transform: {
131
131
  export: ->(value) { "Traditional #{value}" },
132
132
  import: ->(value) { value.gsub("Traditional ", "") }
@@ -234,7 +234,7 @@ class Ceramic < Lutaml::Model::Serializable
234
234
 
235
235
  # Mapping-level transformation in XML format
236
236
  xml do
237
- root "Ceramic"
237
+ element "Ceramic"
238
238
  map_attribute "glaze-type", to: :glaze_type, transform: {
239
239
  export: ->(value) { "Traditional #{value}" },
240
240
  import: ->(value) { value.gsub("Traditional ", "") }
@@ -454,7 +454,7 @@ class CombinedTransformModel < Lutaml::Model::Serializable
454
454
  end
455
455
 
456
456
  xml do
457
- root "CombinedTransformModel"
457
+ element "CombinedTransformModel"
458
458
  map_element "title", to: :title, transform: SuffixTransformer
459
459
  end
460
460
  end
@@ -662,7 +662,7 @@ class Glaze < Lutaml::Model::Serializable
662
662
  attribute :firing_time, :integer, default: -> { 60 }
663
663
 
664
664
  xml do
665
- root "glaze"
665
+ element "glaze"
666
666
  map_element 'color', to: :color
667
667
  map_element 'opacity', to: :opacity, render_default: true
668
668
  map_attribute 'temperature', to: :temperature
@@ -31,7 +31,7 @@ class JapaneseCeramic < Lutaml::Model::Serializable
31
31
  attribute :description, :string
32
32
 
33
33
  xml do
34
- root 'JapaneseCeramic'
34
+ element "JapaneseCeramic"
35
35
  map_attribute 'glazeType', to: :glaze_type
36
36
  map_element 'description', to: :description
37
37
  end
@@ -34,7 +34,7 @@ class Tag < Lutaml::Model::Serializable
34
34
  attribute :text, :string
35
35
 
36
36
  xml do
37
- root "Tag"
37
+ element "Tag"
38
38
 
39
39
  map_content to: :text
40
40
  end
@@ -48,7 +48,7 @@ class Tags < Lutaml::Model::Serializable
48
48
  attribute :tag, Tag, collection: true
49
49
 
50
50
  xml do
51
- root "Tags"
51
+ element "Tags"
52
52
 
53
53
  map_element "Tag", to: :tag
54
54
  end
@@ -62,7 +62,7 @@ class Post < Lutaml::Model::Serializable
62
62
  attribute :tags, Tags, collection: true
63
63
 
64
64
  xml do
65
- root "Post"
65
+ element "Post"
66
66
  map_element "Tags", to: :tags
67
67
  end
68
68
 
@@ -121,7 +121,7 @@ class Kiln < Lutaml::Model::Serializable
121
121
  attribute :temperature, :integer
122
122
 
123
123
  xml do
124
- root 'kiln'
124
+ element "kiln"
125
125
  map_element 'brand', to: :brand
126
126
  map_element 'capacity', to: :capacity
127
127
  map_element 'temperature', to: :temperature
@@ -74,7 +74,7 @@ class Example < Lutaml::Model::Serializable
74
74
  attribute :name, :string
75
75
 
76
76
  xml do
77
- root 'example'
77
+ element "example"
78
78
  map_element 'name', to: :name
79
79
  end
80
80
  end
@@ -116,7 +116,7 @@ class Example < Lutaml::Model::Serializable
116
116
  attribute :value, :integer
117
117
 
118
118
  xml do
119
- root 'example'
119
+ element "example"
120
120
  map_attribute 'value', to: :value
121
121
  end
122
122
  end
@@ -158,7 +158,7 @@ class Example < Lutaml::Model::Serializable
158
158
  attribute :description, :string
159
159
 
160
160
  xml do
161
- root 'example'
161
+ element "example"
162
162
  map_content to: :description
163
163
  end
164
164
  end
@@ -192,7 +192,7 @@ class Ceramic < Lutaml::Model::Serializable
192
192
  attribute :temperature, :integer
193
193
 
194
194
  xml do
195
- root 'ceramic'
195
+ element "ceramic"
196
196
  map_element 'name', to: :name
197
197
  map_attribute 'temperature', to: :temperature
198
198
  map_content to: :description
@@ -576,7 +576,7 @@ end
576
576
  ```ruby
577
577
  class PurchaseOrder < Lutaml::Model::Serializable
578
578
  xml do
579
- root "purchaseOrder" # Root element name
579
+ element "purchaseOrder" # Root element name
580
580
  namespace PoNamespace # Model namespace
581
581
 
582
582
  map_element "shipTo", to: :ship_to # Map element
@@ -654,7 +654,7 @@ class Book < Lutaml::Model::Serializable
654
654
  attribute :author, Person
655
655
 
656
656
  xml do
657
- root "Book"
657
+ element "Book"
658
658
  namespace BookNamespace
659
659
  map_element "title", to: :title
660
660
  map_element "author", to: :author
@@ -979,7 +979,7 @@ class PurchaseOrder < Lutaml::Model::Serializable
979
979
  attribute :comment, :string
980
980
 
981
981
  xml do
982
- root "purchaseOrder"
982
+ element "purchaseOrder"
983
983
  namespace PoNamespace
984
984
  map_element "comment", to: :comment
985
985
  end
@@ -1062,7 +1062,7 @@ class Document < Lutaml::Model::Serializable
1062
1062
  attribute :title, DcTitleType
1063
1063
 
1064
1064
  xml do
1065
- root "document"
1065
+ element "document"
1066
1066
  map_element "title", to: :title
1067
1067
  end
1068
1068
  end
@@ -152,7 +152,7 @@ class Contact < Lutaml::Model::Serializable
152
152
  end
153
153
 
154
154
  xml do
155
- root "contact"
155
+ element "contact"
156
156
  map_element "email", to: :email
157
157
  map_element "phone", to: :phone
158
158
  end
@@ -39,7 +39,7 @@ class Studio < Lutaml::Model::Serializable
39
39
  attribute :potters, :string, collection: true
40
40
 
41
41
  xml do
42
- root 'studio'
42
+ element "studio"
43
43
  map_element 'name', to: :name
44
44
  map_element 'potter', to: :potters
45
45
  end
@@ -142,7 +142,7 @@ class PotterCollection < Lutaml::Model::Collection
142
142
  instances :potters, Potter
143
143
 
144
144
  json do
145
- root "potters"
145
+ key "potters"
146
146
  map_instances to: :potters
147
147
  end
148
148
  end