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
|
@@ -10,7 +10,7 @@ module CollectionValidationTests
|
|
|
10
10
|
attribute :category, :string
|
|
11
11
|
|
|
12
12
|
xml do
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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" \
|
|
@@ -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
|
-
|
|
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
|
-
|
|
47
|
+
element "ExtensionModel"
|
|
48
48
|
namespace DynAttrTestNamespace
|
|
49
49
|
map_element "Code", to: :code
|
|
50
50
|
end
|
|
@@ -213,7 +213,7 @@ module GroupSpec
|
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
RSpec.describe "Group" do
|
|
216
|
-
context "when serializing and deserializing
|
|
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
|
|
265
|
+
context "with type-only model (no element declared)" do
|
|
266
266
|
let(:mapper) { GroupSpec::CeramicCollection }
|
|
267
267
|
|
|
268
|
-
it "raises error if
|
|
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::
|
|
276
|
-
|
|
275
|
+
Lutaml::Model::TypeOnlyMappingError,
|
|
276
|
+
/type-only model/,
|
|
277
277
|
)
|
|
278
278
|
end
|
|
279
279
|
|
|
280
|
-
context "
|
|
280
|
+
context "serializing XML" do
|
|
281
281
|
let(:ceramic) { GroupSpec::Ceramic.new(type: "Data", name: "Starc") }
|
|
282
282
|
|
|
283
|
-
it "raises error for
|
|
283
|
+
it "raises error for type-only class" do
|
|
284
284
|
expect { ceramic.to_xml }.to raise_error(
|
|
285
|
-
Lutaml::Model::
|
|
286
|
-
|
|
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::
|
|
565
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
336
|
+
element "rfc"
|
|
337
337
|
map_element "title", to: :title
|
|
338
338
|
map_processing_instruction "rfc", to: :rfc_pis
|
|
339
339
|
end
|