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.
- checksums.yaml +4 -4
- data/README.adoc +116 -103
- data/RELEASE_NOTES.adoc +3 -3
- data/benchmark/quick_benchmark.rb +2 -2
- data/benchmark/serialization_benchmark.rb +4 -4
- data/docs/_guides/advanced-mapping.adoc +1 -1
- data/docs/_guides/character-encoding.adoc +3 -3
- data/docs/_guides/missing-values-handling.adoc +6 -6
- data/docs/_guides/ooxml-examples.adoc +7 -7
- data/docs/_guides/opal.adoc +1 -1
- data/docs/_guides/value-transformations.adoc +7 -7
- data/docs/_guides/xml/namespace-presentation.adoc +1 -1
- data/docs/_guides/xml/namespace-semantics.adoc +15 -15
- data/docs/_guides/xml/type-namespaces.adoc +9 -9
- data/docs/_guides/xml-mapping.adoc +32 -26
- data/docs/_guides/xml-namespace-qualification.adoc +4 -4
- data/docs/_guides/xml-namespaces.adoc +2 -2
- data/docs/_guides/xml_mappings/04_xml_namespace_class.adoc +18 -18
- data/docs/_guides/xml_mappings/05_common_patterns.adoc +16 -16
- data/docs/_guides/xml_mappings/06_migration_guide.adoc +5 -5
- data/docs/_guides/xml_mappings/07_best_practices.adoc +11 -11
- data/docs/_migrations/0-8-0-namespace-restructuring.adoc +2 -2
- data/docs/_pages/attributes.adoc +2 -2
- data/docs/_pages/collections.adoc +26 -20
- data/docs/_pages/consolidation-mapping.adoc +4 -4
- data/docs/_pages/importable_models.adoc +14 -13
- data/docs/_pages/quick-start.adoc +1 -1
- data/docs/_pages/value_types.adoc +10 -10
- data/docs/_references/custom_registers.adoc +7 -7
- data/docs/_references/format-independent-features.adoc +4 -4
- data/docs/_references/instance-serialization.adoc +1 -1
- data/docs/_references/parent-root-context.adoc +3 -3
- data/docs/_tutorials/basic-model-definition.adoc +1 -1
- data/docs/_tutorials/first-xml-serialization.adoc +4 -4
- data/docs/_tutorials/lutaml-xml-architecture.adoc +4 -4
- data/docs/_tutorials/validation-basics.adoc +1 -1
- data/docs/_tutorials/working-with-collections.adoc +2 -2
- data/docs/_tutorials/xml-namespaces-basics.adoc +1 -1
- data/docs/_tutorials/xml-schema-primer-style-guide.adoc +29 -29
- data/docs/cli_compare.adoc +1 -1
- data/docs/index.adoc +1 -1
- data/docs/namespace-management.adoc +14 -14
- data/lib/lutaml/key_value/mapping.rb +31 -6
- data/lib/lutaml/model/collection.rb +11 -11
- data/lib/lutaml/model/error/no_root_mapping_error.rb +6 -5
- data/lib/lutaml/model/error/no_root_namespace_error.rb +6 -5
- data/lib/lutaml/model/error/type_only_mapping_error.rb +13 -0
- data/lib/lutaml/model/error/type_only_namespace_error.rb +12 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model.rb +3 -0
- data/lib/lutaml/xml/adapter/base_adapter.rb +0 -9
- data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +0 -1
- data/lib/lutaml/xml/adapter/oga_adapter.rb +0 -1
- data/lib/lutaml/xml/adapter/ox_adapter.rb +0 -1
- data/lib/lutaml/xml/adapter/rexml_adapter.rb +0 -1
- data/lib/lutaml/xml/adapter/xml_serializer.rb +42 -22
- data/lib/lutaml/xml/adapter.rb +4 -0
- data/lib/lutaml/xml/builder/base.rb +64 -25
- data/lib/lutaml/xml/builder/nokogiri.rb +0 -2
- data/lib/lutaml/xml/builder/oga.rb +0 -2
- data/lib/lutaml/xml/builder/ox.rb +0 -2
- data/lib/lutaml/xml/builder/rexml.rb +0 -2
- data/lib/lutaml/xml/builder.rb +1 -0
- data/lib/lutaml/xml/configurable.rb +2 -2
- data/lib/lutaml/xml/declaration_handler.rb +3 -105
- data/lib/lutaml/xml/mapping.rb +3 -3
- data/lib/lutaml/xml/schema/xsd/documentation.rb +1 -1
- data/lib/lutaml/xml/serialization/collection_ext.rb +7 -7
- data/lib/lutaml/xml/serialization/format_conversion.rb +1 -1
- data/lib/lutaml/xml/serialization/instance_methods.rb +1 -1
- data/lib/lutaml/xml.rb +1 -2
- data/lib/tasks/memory_profile.rb +2 -2
- data/lib/tasks/performance_benchmark.rb +5 -5
- data/spec/lutaml/key_value/transformation/rule_compiler_spec.rb +1 -1
- data/spec/lutaml/key_value/transformation/value_serializer_spec.rb +1 -1
- data/spec/lutaml/model/attribute_collection_spec.rb +1 -1
- data/spec/lutaml/model/cli_spec.rb +1 -1
- data/spec/lutaml/model/collection_spec.rb +1 -1
- data/spec/lutaml/model/collection_validation_spec.rb +6 -6
- data/spec/lutaml/model/consolidation_spec.rb +8 -8
- data/spec/lutaml/model/custom_collection_spec.rb +3 -3
- data/spec/lutaml/model/default_register_spec.rb +23 -23
- data/spec/lutaml/model/delegation_spec.rb +3 -10
- data/spec/lutaml/model/derived_attribute_serialization_spec.rb +1 -1
- data/spec/lutaml/model/dynamic_attribute_spec.rb +2 -2
- data/spec/lutaml/model/enum_spec.rb +1 -1
- data/spec/lutaml/model/group_spec.rb +12 -12
- data/spec/lutaml/model/lazy_collection_spec.rb +4 -4
- data/spec/lutaml/model/mixed_content_spec.rb +2 -2
- data/spec/lutaml/model/namespace_versioning_spec.rb +4 -4
- data/spec/lutaml/model/processing_instruction_spec.rb +11 -11
- data/spec/lutaml/model/register_methods_spec.rb +2 -2
- data/spec/lutaml/model/render_empty_spec.rb +1 -1
- data/spec/lutaml/model/serialize_perf_guard_spec.rb +1 -1
- data/spec/lutaml/model/transform_dynamic_attributes_spec.rb +1 -1
- data/spec/lutaml/model/transformation_builder_spec.rb +2 -2
- data/spec/lutaml/model/xml_decoupling_spec.rb +3 -3
- data/spec/lutaml/model/xsd_patterns_spec.rb +2 -3
- data/spec/lutaml/xml/adapter/order_spec.rb +1 -1
- data/spec/lutaml/xml/clear_parse_state_spec.rb +1 -1
- data/spec/lutaml/xml/content_model_validation_spec.rb +4 -2
- data/spec/lutaml/xml/doubly_defined_namespace_spec.rb +5 -5
- data/spec/lutaml/xml/enhanced_mapping_spec.rb +2 -1
- data/spec/lutaml/xml/entity_fragmentation_spec.rb +5 -5
- data/spec/lutaml/xml/indent_spec.rb +109 -0
- data/spec/lutaml/xml/line_ending_spec.rb +66 -0
- data/spec/lutaml/xml/mapping_finalization_guard_spec.rb +2 -2
- data/spec/lutaml/xml/model_transform_guard_spec.rb +4 -4
- data/spec/lutaml/xml/namespace_alias_spec.rb +4 -4
- data/spec/lutaml/xml/namespace_aware_parsing_spec.rb +3 -3
- data/spec/lutaml/xml/namespace_bound_element_roundtrip_spec.rb +2 -2
- data/spec/lutaml/xml/namespace_format_preservation_spec.rb +1 -1
- data/spec/lutaml/xml/namespace_inheritance_spec.rb +3 -3
- data/spec/lutaml/xml/namespace_preservation_spec.rb +5 -5
- data/spec/lutaml/xml/opal_xml_spec.rb +8 -8
- data/spec/lutaml/xml/pipeline_integration_spec.rb +145 -0
- data/spec/lutaml/xml/schema_primer_spec.rb +5 -5
- data/spec/lutaml/xml/transformation_spec.rb +20 -20
- data/spec/lutaml/xml/type_namespace/collector_spec.rb +1 -1
- data/spec/lutaml/xml/type_namespace/planner_spec.rb +3 -3
- metadata +7 -2
|
@@ -174,7 +174,8 @@ class Paragraph < Lutaml::Model::Serializable
|
|
|
174
174
|
attribute :italic, :string
|
|
175
175
|
|
|
176
176
|
xml do
|
|
177
|
-
|
|
177
|
+
element 'p'
|
|
178
|
+
mixed_content # DEPRECATED - use mixed_content method instead
|
|
178
179
|
map_element 'bold', to: :bold
|
|
179
180
|
map_element 'i', to: :italic
|
|
180
181
|
end
|
|
@@ -206,19 +207,22 @@ end
|
|
|
206
207
|
|
|
207
208
|
NOTE: Type-only models can only be parsed when embedded in parent models, not
|
|
208
209
|
standalone. Attempting to call `Address.from_xml(xml)` will raise
|
|
209
|
-
`
|
|
210
|
+
`TypeOnlyMappingError`.
|
|
210
211
|
|
|
211
212
|
// TODO: This understanding is wrong -- a type can declare attributes,
|
|
212
213
|
// we need to fix this.
|
|
213
214
|
|
|
214
|
-
The `
|
|
215
|
-
|
|
216
|
-
Syntax:
|
|
215
|
+
The modern pattern is to omit the `element` declaration entirely for
|
|
216
|
+
type-only models. The `no_root` method is deprecated.
|
|
217
217
|
|
|
218
|
+
.Syntax for type-only models (modern pattern)
|
|
218
219
|
[source,ruby]
|
|
219
220
|
----
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
class Address < Lutaml::Model::Serializable
|
|
222
|
+
xml do
|
|
223
|
+
# No element declaration - type-only model
|
|
224
|
+
map_element 'street', to: :street
|
|
225
|
+
end
|
|
222
226
|
end
|
|
223
227
|
----
|
|
224
228
|
|
|
@@ -227,14 +231,14 @@ end
|
|
|
227
231
|
----
|
|
228
232
|
class Address < Lutaml::Model::Serializable
|
|
229
233
|
xml do
|
|
230
|
-
no_root # DEPRECATED
|
|
234
|
+
no_root # DEPRECATED - omit element declaration instead
|
|
231
235
|
map_element 'street', to: :street
|
|
232
236
|
end
|
|
233
237
|
end
|
|
234
238
|
----
|
|
235
239
|
|
|
236
|
-
When
|
|
237
|
-
element there cannot be attributes.
|
|
240
|
+
When a model has no element declaration, only `map_element` can be used
|
|
241
|
+
because without a root element there cannot be attributes.
|
|
238
242
|
|
|
239
243
|
[example]
|
|
240
244
|
====
|
|
@@ -245,7 +249,7 @@ class NameAndCode < Lutaml::Model::Serializable
|
|
|
245
249
|
attribute :code, :string
|
|
246
250
|
|
|
247
251
|
xml do
|
|
248
|
-
|
|
252
|
+
# Type-only model - no element declaration needed
|
|
249
253
|
map_element "code", to: :code
|
|
250
254
|
map_element "name", to: :name
|
|
251
255
|
end
|
|
@@ -450,7 +454,8 @@ To specify mixed content, the `mixed: true` option needs to be set at the
|
|
|
450
454
|
[source,ruby]
|
|
451
455
|
----
|
|
452
456
|
xml do
|
|
453
|
-
|
|
457
|
+
element 'xml_element_name'
|
|
458
|
+
mixed_content
|
|
454
459
|
end
|
|
455
460
|
----
|
|
456
461
|
|
|
@@ -464,7 +469,8 @@ class Paragraph < Lutaml::Model::Serializable
|
|
|
464
469
|
attribute :italic, :string
|
|
465
470
|
|
|
466
471
|
xml do
|
|
467
|
-
|
|
472
|
+
element 'p'
|
|
473
|
+
mixed_content
|
|
468
474
|
|
|
469
475
|
map_element 'bold', to: :bold
|
|
470
476
|
map_element 'i', to: :italic
|
|
@@ -655,7 +661,7 @@ class Example < Lutaml::Model::Serializable
|
|
|
655
661
|
attribute :name, :string
|
|
656
662
|
|
|
657
663
|
xml do
|
|
658
|
-
|
|
664
|
+
element "example"
|
|
659
665
|
map_element 'name', to: :name
|
|
660
666
|
end
|
|
661
667
|
end
|
|
@@ -687,7 +693,7 @@ class RecordDate < Lutaml::Model::Serializable
|
|
|
687
693
|
attribute :content, :string
|
|
688
694
|
|
|
689
695
|
xml do
|
|
690
|
-
|
|
696
|
+
element "recordDate"
|
|
691
697
|
map_content to: :content
|
|
692
698
|
end
|
|
693
699
|
end
|
|
@@ -696,7 +702,7 @@ class OriginInfo < Lutaml::Model::Serializable
|
|
|
696
702
|
attribute :date_issued, RecordDate, collection: true
|
|
697
703
|
|
|
698
704
|
xml do
|
|
699
|
-
|
|
705
|
+
element "originInfo"
|
|
700
706
|
map_element "dateIssued", to: :date_issued
|
|
701
707
|
end
|
|
702
708
|
end
|
|
@@ -867,7 +873,7 @@ class Example < Lutaml::Model::Serializable
|
|
|
867
873
|
attribute :value, :integer
|
|
868
874
|
|
|
869
875
|
xml do
|
|
870
|
-
|
|
876
|
+
element "example"
|
|
871
877
|
map_attribute 'value', to: :value
|
|
872
878
|
end
|
|
873
879
|
end
|
|
@@ -910,7 +916,7 @@ class Attribute < Lutaml::Model::Serializable
|
|
|
910
916
|
attribute :value, TechXmiIntegerType
|
|
911
917
|
|
|
912
918
|
xml do
|
|
913
|
-
|
|
919
|
+
element "example"
|
|
914
920
|
map_attribute 'value', to: :value
|
|
915
921
|
end
|
|
916
922
|
end
|
|
@@ -1070,7 +1076,7 @@ class Example < Lutaml::Model::Serializable
|
|
|
1070
1076
|
attribute :description, :string
|
|
1071
1077
|
|
|
1072
1078
|
xml do
|
|
1073
|
-
|
|
1079
|
+
element "example"
|
|
1074
1080
|
map_content to: :description
|
|
1075
1081
|
end
|
|
1076
1082
|
end
|
|
@@ -1213,7 +1219,7 @@ class Example < Lutaml::Model::Serializable
|
|
|
1213
1219
|
attribute :note, :string
|
|
1214
1220
|
|
|
1215
1221
|
xml do
|
|
1216
|
-
|
|
1222
|
+
element "example"
|
|
1217
1223
|
map_element :name, to: :name, cdata: true
|
|
1218
1224
|
map_content to: :description, cdata: true
|
|
1219
1225
|
map_element :title, to: :title, cdata: false
|
|
@@ -1260,7 +1266,7 @@ changes.
|
|
|
1260
1266
|
[source,ruby]
|
|
1261
1267
|
----
|
|
1262
1268
|
xml do
|
|
1263
|
-
|
|
1269
|
+
element "rfc"
|
|
1264
1270
|
map_element "title", to: :title
|
|
1265
1271
|
map_processing_instruction "rfc", to: :pi_settings
|
|
1266
1272
|
end
|
|
@@ -1293,7 +1299,7 @@ to different attributes:
|
|
|
1293
1299
|
[source,ruby]
|
|
1294
1300
|
----
|
|
1295
1301
|
xml do
|
|
1296
|
-
|
|
1302
|
+
element "doc"
|
|
1297
1303
|
map_processing_instruction "rfc", to: :rfc_pis
|
|
1298
1304
|
map_processing_instruction "xml-stylesheet", to: :stylesheet_pis
|
|
1299
1305
|
end
|
|
@@ -1309,7 +1315,7 @@ content string is stored as-is:
|
|
|
1309
1315
|
attribute :rfc_pis, :string, collection: true
|
|
1310
1316
|
|
|
1311
1317
|
xml do
|
|
1312
|
-
|
|
1318
|
+
element "rfc"
|
|
1313
1319
|
map_processing_instruction "rfc", to: :rfc_pis
|
|
1314
1320
|
end
|
|
1315
1321
|
----
|
|
@@ -1341,7 +1347,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
1341
1347
|
attribute :temperature, :integer
|
|
1342
1348
|
|
|
1343
1349
|
xml do
|
|
1344
|
-
|
|
1350
|
+
element "ceramic"
|
|
1345
1351
|
map_element 'name', to: :name
|
|
1346
1352
|
map_attribute 'temperature', to: :temperature
|
|
1347
1353
|
map_content to: :description
|
|
@@ -1465,7 +1471,7 @@ class Contact < Lutaml::Model::Serializable
|
|
|
1465
1471
|
attribute :email, EmailType
|
|
1466
1472
|
|
|
1467
1473
|
xml do
|
|
1468
|
-
|
|
1474
|
+
element "contact"
|
|
1469
1475
|
map_element 'email', to: :email # Uses EmailNamespace automatically
|
|
1470
1476
|
end
|
|
1471
1477
|
end
|
|
@@ -1553,7 +1559,7 @@ class Properties < Lutaml::Model::Serializable
|
|
|
1553
1559
|
attribute :template, :string
|
|
1554
1560
|
|
|
1555
1561
|
xml do
|
|
1556
|
-
|
|
1562
|
+
element "Properties"
|
|
1557
1563
|
namespace AppNamespace
|
|
1558
1564
|
map_element "Template", to: :template
|
|
1559
1565
|
end
|
|
@@ -305,7 +305,7 @@ class Parent < Lutaml::Model::Serializable
|
|
|
305
305
|
|
|
306
306
|
xml do
|
|
307
307
|
namespace MyNamespace
|
|
308
|
-
|
|
308
|
+
element "parent"
|
|
309
309
|
map_element "child", to: :value
|
|
310
310
|
end
|
|
311
311
|
end
|
|
@@ -340,7 +340,7 @@ class Parent < Lutaml::Model::Serializable
|
|
|
340
340
|
|
|
341
341
|
xml do
|
|
342
342
|
namespace MyNamespace
|
|
343
|
-
|
|
343
|
+
element "parent"
|
|
344
344
|
map_element "child", to: :value
|
|
345
345
|
end
|
|
346
346
|
end
|
|
@@ -480,7 +480,7 @@ class Child < Lutaml::Model::Serializable
|
|
|
480
480
|
attribute :value, :string
|
|
481
481
|
xml do
|
|
482
482
|
namespace NS
|
|
483
|
-
|
|
483
|
+
element "child"
|
|
484
484
|
map_element "value", to: :value
|
|
485
485
|
end
|
|
486
486
|
end
|
|
@@ -489,7 +489,7 @@ class Parent < Lutaml::Model::Serializable
|
|
|
489
489
|
attribute :child, Child
|
|
490
490
|
xml do
|
|
491
491
|
namespace NS
|
|
492
|
-
|
|
492
|
+
element "parent"
|
|
493
493
|
map_element "child", to: :child
|
|
494
494
|
end
|
|
495
495
|
end
|
|
@@ -483,7 +483,7 @@ class Document < Lutaml::Model::Serializable
|
|
|
483
483
|
attribute :content, :string
|
|
484
484
|
|
|
485
485
|
xml do
|
|
486
|
-
|
|
486
|
+
element "doc"
|
|
487
487
|
map_attribute "lang", to: :lang
|
|
488
488
|
map_attribute "space", to: :space
|
|
489
489
|
map_content to: :content
|
|
@@ -761,7 +761,7 @@ class Article < Lutaml::Model::Serializable
|
|
|
761
761
|
attribute :content, :string
|
|
762
762
|
|
|
763
763
|
xml do
|
|
764
|
-
|
|
764
|
+
element "article"
|
|
765
765
|
map_attribute "lang", to: :lang
|
|
766
766
|
map_attribute "space", to: :space
|
|
767
767
|
map_attribute "id", to: :id
|
|
@@ -430,7 +430,7 @@ class ProcessingTask < Lutaml::Model::Serializable
|
|
|
430
430
|
attribute :processing_time, :duration
|
|
431
431
|
|
|
432
432
|
xml do
|
|
433
|
-
|
|
433
|
+
element "task"
|
|
434
434
|
map_element "processingTime", to: :processing_time
|
|
435
435
|
end
|
|
436
436
|
end
|
|
@@ -465,7 +465,7 @@ class Resource < Lutaml::Model::Serializable
|
|
|
465
465
|
attribute :schema_location, :uri
|
|
466
466
|
|
|
467
467
|
xml do
|
|
468
|
-
|
|
468
|
+
element "resource"
|
|
469
469
|
map_element "homepage", to: :homepage
|
|
470
470
|
map_attribute "schemaLocation", to: :schema_location
|
|
471
471
|
end
|
|
@@ -500,7 +500,7 @@ class Reference < Lutaml::Model::Serializable
|
|
|
500
500
|
attribute :target, :qname
|
|
501
501
|
|
|
502
502
|
xml do
|
|
503
|
-
|
|
503
|
+
element "reference"
|
|
504
504
|
map_attribute "type", to: :ref_type
|
|
505
505
|
map_element "target", to: :target
|
|
506
506
|
end
|
|
@@ -538,7 +538,7 @@ class Attachment < Lutaml::Model::Serializable
|
|
|
538
538
|
attribute :filename, :string
|
|
539
539
|
|
|
540
540
|
xml do
|
|
541
|
-
|
|
541
|
+
element "attachment"
|
|
542
542
|
map_element "content", to: :content
|
|
543
543
|
map_attribute "filename", to: :filename
|
|
544
544
|
end
|
|
@@ -579,7 +579,7 @@ class Checksum < Lutaml::Model::Serializable
|
|
|
579
579
|
attribute :algorithm, :string
|
|
580
580
|
|
|
581
581
|
xml do
|
|
582
|
-
|
|
582
|
+
element "checksum"
|
|
583
583
|
map_element "value", to: :hash_value
|
|
584
584
|
map_attribute "algorithm", to: :algorithm
|
|
585
585
|
end
|
|
@@ -710,7 +710,7 @@ class Contact < Lutaml::Model::Serializable
|
|
|
710
710
|
attribute :email, EmailType
|
|
711
711
|
|
|
712
712
|
xml do
|
|
713
|
-
|
|
713
|
+
element "contact"
|
|
714
714
|
map_element 'email', to: :email # Uses EmailNamespace automatically
|
|
715
715
|
end
|
|
716
716
|
end
|
|
@@ -744,7 +744,7 @@ class CustomModel < Lutaml::Model::Serializable
|
|
|
744
744
|
attribute :value, :string
|
|
745
745
|
|
|
746
746
|
xml do
|
|
747
|
-
|
|
747
|
+
element "customElement"
|
|
748
748
|
map_element 'value', to: :value
|
|
749
749
|
end
|
|
750
750
|
end
|
|
@@ -789,7 +789,7 @@ class Document < Lutaml::Model::Serializable
|
|
|
789
789
|
attribute :content, :string # Regular attribute, no type namespace
|
|
790
790
|
|
|
791
791
|
xml do
|
|
792
|
-
|
|
792
|
+
element "document"
|
|
793
793
|
|
|
794
794
|
map_element 'title', to: :title # Becomes <dc:title> from Type
|
|
795
795
|
map_element 'creator', to: :creator # Becomes <dc:creator> from Type
|
|
@@ -953,7 +953,7 @@ class DctermsCreatedType < Lutaml::Model::Serializable
|
|
|
953
953
|
attribute :type, XsiTypeType
|
|
954
954
|
|
|
955
955
|
xml do
|
|
956
|
-
|
|
956
|
+
element "created"
|
|
957
957
|
# This becomes xsi:type from XsiTypeType
|
|
958
958
|
map_attribute 'type', to: :type
|
|
959
959
|
map_content to: :value
|
|
@@ -967,7 +967,7 @@ class DctermsModifiedType < Lutaml::Model::Serializable
|
|
|
967
967
|
attribute :type, XsiTypeType
|
|
968
968
|
|
|
969
969
|
xml do
|
|
970
|
-
|
|
970
|
+
element "modified"
|
|
971
971
|
map_attribute 'type', to: :type
|
|
972
972
|
map_content to: :value
|
|
973
973
|
end
|
|
@@ -985,7 +985,7 @@ class CoreProperties < Lutaml::Model::Serializable
|
|
|
985
985
|
attribute :modified, DctermsModifiedType
|
|
986
986
|
|
|
987
987
|
xml do
|
|
988
|
-
|
|
988
|
+
element "coreProperties"
|
|
989
989
|
|
|
990
990
|
# Type namespaces automatically applied
|
|
991
991
|
map_element 'title', to: :title # Becomes <dc:title>
|
|
@@ -1078,7 +1078,7 @@ class Model < Lutaml::Model::Serializable
|
|
|
1078
1078
|
attribute :value, DefaultType
|
|
1079
1079
|
|
|
1080
1080
|
xml do
|
|
1081
|
-
|
|
1081
|
+
element "model"
|
|
1082
1082
|
|
|
1083
1083
|
# Case 1: Type namespace used (no explicit namespace)
|
|
1084
1084
|
map_element 'value1', to: :value
|
|
@@ -1119,7 +1119,7 @@ class Product < Lutaml::Model::Serializable
|
|
|
1119
1119
|
attribute :schema_type, XsiTypeType
|
|
1120
1120
|
|
|
1121
1121
|
xml do
|
|
1122
|
-
|
|
1122
|
+
element "product"
|
|
1123
1123
|
map_attribute 'id', to: :id # Unqualified: id="..."
|
|
1124
1124
|
map_attribute 'type', to: :schema_type # Qualified: xsi:type="..."
|
|
1125
1125
|
end
|
|
@@ -1371,7 +1371,7 @@ class Document < Lutaml::Model::Serializable
|
|
|
1371
1371
|
attribute :creator, DcCreatorType
|
|
1372
1372
|
|
|
1373
1373
|
xml do
|
|
1374
|
-
|
|
1374
|
+
element "document"
|
|
1375
1375
|
map_element 'title', to: :title
|
|
1376
1376
|
map_element 'creator', to: :creator
|
|
1377
1377
|
end
|
|
@@ -1401,7 +1401,7 @@ class Document < Lutaml::Model::Serializable
|
|
|
1401
1401
|
attribute :creator, DcCreatorType
|
|
1402
1402
|
|
|
1403
1403
|
xml do
|
|
1404
|
-
|
|
1404
|
+
element "document"
|
|
1405
1405
|
map_element 'title', to: :title
|
|
1406
1406
|
map_element 'creator', to: :creator
|
|
1407
1407
|
end
|
|
@@ -1530,7 +1530,7 @@ class Vcard < Lutaml::Model::Serializable
|
|
|
1530
1530
|
attribute :title, DcTitleType
|
|
1531
1531
|
|
|
1532
1532
|
xml do
|
|
1533
|
-
|
|
1533
|
+
element "vCard"
|
|
1534
1534
|
namespace VcardNamespace
|
|
1535
1535
|
namespace_scope [VcardNamespace, DcNamespace] <1>
|
|
1536
1536
|
|
|
@@ -1612,7 +1612,7 @@ class Vcard < Lutaml::Model::Serializable
|
|
|
1612
1612
|
attribute :created, DctermsCreatedType
|
|
1613
1613
|
|
|
1614
1614
|
xml do
|
|
1615
|
-
|
|
1615
|
+
element "vCard"
|
|
1616
1616
|
namespace VcardNamespace
|
|
1617
1617
|
namespace_scope [VcardNamespace, DcNamespace, DctermsNamespace] <1>
|
|
1618
1618
|
|
|
@@ -1676,7 +1676,7 @@ class Vcard < Lutaml::Model::Serializable
|
|
|
1676
1676
|
attribute :created, DctermsCreatedType
|
|
1677
1677
|
|
|
1678
1678
|
xml do
|
|
1679
|
-
|
|
1679
|
+
element "vCard"
|
|
1680
1680
|
namespace VcardNamespace
|
|
1681
1681
|
namespace_scope [VcardNamespace, DcNamespace] <1>
|
|
1682
1682
|
|
|
@@ -21,7 +21,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
21
21
|
attribute :temperature, :integer
|
|
22
22
|
|
|
23
23
|
xml do
|
|
24
|
-
|
|
24
|
+
element "ceramic"
|
|
25
25
|
map_element 'name', to: :name
|
|
26
26
|
map_attribute 'temperature', to: :temperature
|
|
27
27
|
map_content to: :description
|
|
@@ -58,7 +58,7 @@ class Glaze < Lutaml::Model::Serializable
|
|
|
58
58
|
attribute :temperature, :integer
|
|
59
59
|
|
|
60
60
|
xml do
|
|
61
|
-
|
|
61
|
+
element "Glaze"
|
|
62
62
|
map_element 'color', to: :color
|
|
63
63
|
map_element 'temperature', to: :temperature
|
|
64
64
|
end
|
|
@@ -69,7 +69,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
69
69
|
attribute :glaze, Glaze
|
|
70
70
|
|
|
71
71
|
xml do
|
|
72
|
-
|
|
72
|
+
element "Ceramic"
|
|
73
73
|
map_element 'Type', to: :type
|
|
74
74
|
map_element 'Glaze', to: :glaze
|
|
75
75
|
end
|
|
@@ -102,7 +102,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
102
102
|
attribute :glaze, :string
|
|
103
103
|
|
|
104
104
|
xml do
|
|
105
|
-
|
|
105
|
+
element "Ceramic"
|
|
106
106
|
namespace 'http://example.com/ceramic'
|
|
107
107
|
map_element 'Type', to: :type
|
|
108
108
|
map_element 'Glaze', to: :glaze
|
|
@@ -131,7 +131,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
131
131
|
attribute :glaze, :string
|
|
132
132
|
|
|
133
133
|
xml do
|
|
134
|
-
|
|
134
|
+
element "Ceramic"
|
|
135
135
|
namespace 'http://example.com/ceramic', 'cer'
|
|
136
136
|
map_element 'Type', to: :type
|
|
137
137
|
map_element 'Glaze', to: :glaze
|
|
@@ -1146,7 +1146,7 @@ class Example < Lutaml::Model::Serializable
|
|
|
1146
1146
|
attribute :note, :string
|
|
1147
1147
|
|
|
1148
1148
|
xml do
|
|
1149
|
-
|
|
1149
|
+
element "example"
|
|
1150
1150
|
map_element :name, to: :name, cdata: true
|
|
1151
1151
|
map_content to: :description, cdata: true
|
|
1152
1152
|
map_element :title, to: :title, cdata: false
|
|
@@ -1327,7 +1327,7 @@ class CeramicCollection < Lutaml::Model::Serializable
|
|
|
1327
1327
|
attribute :items, Ceramic, collection: true
|
|
1328
1328
|
|
|
1329
1329
|
xml do
|
|
1330
|
-
|
|
1330
|
+
element "ceramics"
|
|
1331
1331
|
map_element 'ceramic', to: :items
|
|
1332
1332
|
end
|
|
1333
1333
|
end
|
|
@@ -1354,7 +1354,7 @@ class TitleCollection < Lutaml::Model::Collection
|
|
|
1354
1354
|
instances :items, :string
|
|
1355
1355
|
|
|
1356
1356
|
xml do
|
|
1357
|
-
|
|
1357
|
+
element "titles"
|
|
1358
1358
|
map_attribute "title", to: :items, delimiter: "; "
|
|
1359
1359
|
end
|
|
1360
1360
|
end
|
|
@@ -1387,7 +1387,7 @@ class JapaneseCeramic < Lutaml::Model::Serializable
|
|
|
1387
1387
|
attribute :description, :string
|
|
1388
1388
|
|
|
1389
1389
|
xml do
|
|
1390
|
-
|
|
1390
|
+
element "JapaneseCeramic"
|
|
1391
1391
|
map_attribute 'glazeType', to: :glaze_type
|
|
1392
1392
|
map_element 'description', to: :description
|
|
1393
1393
|
end
|
|
@@ -1444,7 +1444,7 @@ class Address < Lutaml::Model::Serializable
|
|
|
1444
1444
|
attribute :zip, :string
|
|
1445
1445
|
|
|
1446
1446
|
xml do
|
|
1447
|
-
|
|
1447
|
+
# Type-only model - no element declaration needed
|
|
1448
1448
|
|
|
1449
1449
|
map_element :street, to: :street
|
|
1450
1450
|
map_element :city, to: :city
|
|
@@ -1457,7 +1457,7 @@ class Person < Lutaml::Model::Serializable
|
|
|
1457
1457
|
import_model_attributes Address
|
|
1458
1458
|
|
|
1459
1459
|
xml do
|
|
1460
|
-
|
|
1460
|
+
element "Person"
|
|
1461
1461
|
|
|
1462
1462
|
map_element :name, to: :name
|
|
1463
1463
|
sequence do
|
|
@@ -1617,14 +1617,14 @@ end
|
|
|
1617
1617
|
# Use in document model
|
|
1618
1618
|
class Document < Lutaml::Model::Serializable
|
|
1619
1619
|
namespace DocumentNamespace
|
|
1620
|
-
|
|
1620
|
+
|
|
1621
1621
|
attribute :title, DcTitleType
|
|
1622
1622
|
attribute :creator, DcCreatorType
|
|
1623
1623
|
attribute :content, :string
|
|
1624
1624
|
|
|
1625
1625
|
xml do
|
|
1626
|
-
|
|
1627
|
-
|
|
1626
|
+
element "document"
|
|
1627
|
+
|
|
1628
1628
|
map_element 'title', to: :title # Uses DublinCoreNamespace
|
|
1629
1629
|
map_element 'creator', to: :creator # Uses DublinCoreNamespace
|
|
1630
1630
|
map_element 'content', to: :content # No type namespace
|
|
@@ -1704,7 +1704,7 @@ class Vcard < Lutaml::Model::Serializable
|
|
|
1704
1704
|
attribute :created, DctermsCreatedType
|
|
1705
1705
|
|
|
1706
1706
|
xml do
|
|
1707
|
-
|
|
1707
|
+
element "vCard"
|
|
1708
1708
|
namespace_scope [VcardNamespace, DcNamespace, DctermsNamespace] <1>
|
|
1709
1709
|
|
|
1710
1710
|
map_element "version", to: :version
|
|
@@ -1764,7 +1764,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
1764
1764
|
attribute :color, :string
|
|
1765
1765
|
|
|
1766
1766
|
xml do
|
|
1767
|
-
|
|
1767
|
+
element "Ceramic"
|
|
1768
1768
|
namespace CeramicNamespace
|
|
1769
1769
|
map_element 'Type', to: :type # Inherits parent namespace (qualified)
|
|
1770
1770
|
map_element 'Glaze', to: :glaze
|
|
@@ -147,7 +147,7 @@ For models with complex namespace requirements:
|
|
|
147
147
|
|
|
148
148
|
Replace `root()` with `element()` for clarity:
|
|
149
149
|
|
|
150
|
-
1. Change `
|
|
150
|
+
1. Change `element "element-name"` to `element 'element-name'`
|
|
151
151
|
2. Move `mixed: true` to use `mixed_content` method
|
|
152
152
|
3. Move `ordered: true` to use `ordered` method
|
|
153
153
|
|
|
@@ -476,7 +476,7 @@ end
|
|
|
476
476
|
class DcTitleType < Lutaml::Model::Type::String
|
|
477
477
|
namespace DublinCoreNamespace # ⚠️ DEPRECATED
|
|
478
478
|
xsd_type 'titleType'
|
|
479
|
-
|
|
479
|
+
|
|
480
480
|
def self.cast(value)
|
|
481
481
|
super(value)
|
|
482
482
|
end
|
|
@@ -484,7 +484,7 @@ end
|
|
|
484
484
|
|
|
485
485
|
class Document < Lutaml::Model::Serializable
|
|
486
486
|
attribute :title, DcTitleType
|
|
487
|
-
|
|
487
|
+
|
|
488
488
|
xml do
|
|
489
489
|
root 'document'
|
|
490
490
|
map_element 'title', to: :title
|
|
@@ -503,7 +503,7 @@ end
|
|
|
503
503
|
class DcTitleType < Lutaml::Model::Type::String
|
|
504
504
|
xml_namespace DublinCoreNamespace # ✅ CURRENT
|
|
505
505
|
xsd_type 'titleType'
|
|
506
|
-
|
|
506
|
+
|
|
507
507
|
def self.cast(value)
|
|
508
508
|
super(value)
|
|
509
509
|
end
|
|
@@ -511,7 +511,7 @@ end
|
|
|
511
511
|
|
|
512
512
|
class Document < Lutaml::Model::Serializable
|
|
513
513
|
attribute :title, DcTitleType
|
|
514
|
-
|
|
514
|
+
|
|
515
515
|
xml do
|
|
516
516
|
root 'document'
|
|
517
517
|
map_element 'title', to: :title
|
|
@@ -46,14 +46,14 @@ end
|
|
|
46
46
|
# Repeat namespace details in every model
|
|
47
47
|
class Model1 < Lutaml::Model::Serializable
|
|
48
48
|
xml do
|
|
49
|
-
|
|
49
|
+
element "model1"
|
|
50
50
|
namespace 'https://example.com/project/v1', 'proj'
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
class Model2 < Lutaml::Model::Serializable
|
|
55
55
|
xml do
|
|
56
|
-
|
|
56
|
+
element "model2"
|
|
57
57
|
namespace 'https://example.com/project/v1', 'proj'
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -134,7 +134,7 @@ class Document < Lutaml::Model::Serializable
|
|
|
134
134
|
attribute :creator, DcCreatorType
|
|
135
135
|
|
|
136
136
|
xml do
|
|
137
|
-
|
|
137
|
+
element "document"
|
|
138
138
|
map_element 'title', to: :title # dc:title automatically
|
|
139
139
|
map_element 'creator', to: :creator # dc:creator automatically
|
|
140
140
|
end
|
|
@@ -145,7 +145,7 @@ class BookMetadata < Lutaml::Model::Serializable
|
|
|
145
145
|
attribute :creator, DcCreatorType
|
|
146
146
|
|
|
147
147
|
xml do
|
|
148
|
-
|
|
148
|
+
element "book"
|
|
149
149
|
map_element 'title', to: :title # dc:title automatically
|
|
150
150
|
map_element 'creator', to: :creator # dc:creator automatically
|
|
151
151
|
end
|
|
@@ -162,7 +162,7 @@ class Document < Lutaml::Model::Serializable
|
|
|
162
162
|
attribute :creator, :string
|
|
163
163
|
|
|
164
164
|
xml do
|
|
165
|
-
|
|
165
|
+
element "document"
|
|
166
166
|
# Repetitive and error-prone
|
|
167
167
|
map_element 'title', to: :title,
|
|
168
168
|
namespace: 'http://purl.org/dc/elements/1.1/', prefix: 'dc'
|
|
@@ -181,7 +181,7 @@ end
|
|
|
181
181
|
# Consolidate frequently-used namespaces at root
|
|
182
182
|
class Vcard < Lutaml::Model::Serializable
|
|
183
183
|
xml do
|
|
184
|
-
|
|
184
|
+
element "vCard"
|
|
185
185
|
namespace VcardNamespace
|
|
186
186
|
namespace_scope [VcardNamespace, DcNamespace, DctermsNamespace]
|
|
187
187
|
|
|
@@ -206,7 +206,7 @@ end
|
|
|
206
206
|
# Without namespace_scope for multi-namespace documents
|
|
207
207
|
class Vcard < Lutaml::Model::Serializable
|
|
208
208
|
xml do
|
|
209
|
-
|
|
209
|
+
element "vCard"
|
|
210
210
|
namespace VcardNamespace
|
|
211
211
|
# No namespace_scope
|
|
212
212
|
|
|
@@ -236,7 +236,7 @@ class Ceramic < Lutaml::Model::Serializable
|
|
|
236
236
|
element 'ceramic'
|
|
237
237
|
namespace CeramicNamespace
|
|
238
238
|
# namespace_scope [CeramicNamespace] # NOT NEEDED - only one namespace
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
map_element 'type', to: :type
|
|
241
241
|
map_element 'glaze', to: :glaze
|
|
242
242
|
end
|
|
@@ -250,7 +250,7 @@ end
|
|
|
250
250
|
# Keep rarely-used namespaces local for clarity
|
|
251
251
|
class Document < Lutaml::Model::Serializable
|
|
252
252
|
xml do
|
|
253
|
-
|
|
253
|
+
element "document"
|
|
254
254
|
namespace DocumentNamespace
|
|
255
255
|
namespace_scope [DocumentNamespace] # Only frequently used
|
|
256
256
|
|
|
@@ -284,7 +284,7 @@ end
|
|
|
284
284
|
----
|
|
285
285
|
class Model < Lutaml::Model::Serializable
|
|
286
286
|
xml do
|
|
287
|
-
|
|
287
|
+
element "model" # Backward compatible, still works
|
|
288
288
|
map_element 'attr', to: :attr
|
|
289
289
|
end
|
|
290
290
|
end
|
|
@@ -441,7 +441,7 @@ end
|
|
|
441
441
|
----
|
|
442
442
|
class RichText < Lutaml::Model::Serializable
|
|
443
443
|
xml do
|
|
444
|
-
|
|
444
|
+
element "text", mixed: true # DEPRECATED - use mixed_content instead
|
|
445
445
|
map_element 'b', to: :bold
|
|
446
446
|
end
|
|
447
447
|
end
|