lutaml-model 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +58 -21
- data/Gemfile +1 -0
- data/README.adoc +1112 -264
- data/lib/lutaml/model/attribute.rb +33 -10
- data/lib/lutaml/model/choice.rb +56 -0
- data/lib/lutaml/model/config.rb +1 -0
- data/lib/lutaml/model/error/choice_lower_bound_error.rb +9 -0
- data/lib/lutaml/model/error/choice_upper_bound_error.rb +9 -0
- data/lib/lutaml/model/error/import_model_with_root_error.rb +9 -0
- data/lib/lutaml/model/error/incorrect_sequence_error.rb +9 -0
- data/lib/lutaml/model/error/invalid_choice_range_error.rb +20 -0
- data/lib/lutaml/model/error/no_root_mapping_error.rb +9 -0
- data/lib/lutaml/model/error/no_root_namespace_error.rb +9 -0
- data/lib/lutaml/model/error/unknown_sequence_mapping_error.rb +9 -0
- data/lib/lutaml/model/error.rb +8 -0
- data/lib/lutaml/model/json_adapter/standard_json_adapter.rb +6 -1
- data/lib/lutaml/model/key_value_mapping.rb +3 -1
- data/lib/lutaml/model/key_value_mapping_rule.rb +4 -2
- data/lib/lutaml/model/liquefiable.rb +59 -0
- data/lib/lutaml/model/mapping_hash.rb +1 -1
- data/lib/lutaml/model/mapping_rule.rb +15 -2
- data/lib/lutaml/model/schema/xml_compiler.rb +68 -26
- data/lib/lutaml/model/schema_location.rb +7 -0
- data/lib/lutaml/model/sequence.rb +71 -0
- data/lib/lutaml/model/serialize.rb +125 -35
- data/lib/lutaml/model/type/decimal.rb +0 -4
- data/lib/lutaml/model/type/time.rb +3 -3
- data/lib/lutaml/model/utils.rb +19 -15
- data/lib/lutaml/model/validation.rb +12 -1
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model/xml_adapter/builder/oga.rb +10 -7
- data/lib/lutaml/model/xml_adapter/builder/ox.rb +20 -13
- data/lib/lutaml/model/xml_adapter/element.rb +32 -0
- data/lib/lutaml/model/xml_adapter/nokogiri_adapter.rb +8 -8
- data/lib/lutaml/model/xml_adapter/oga/element.rb +14 -13
- data/lib/lutaml/model/xml_adapter/oga_adapter.rb +86 -19
- data/lib/lutaml/model/xml_adapter/ox_adapter.rb +19 -15
- data/lib/lutaml/model/xml_adapter/xml_document.rb +74 -13
- data/lib/lutaml/model/xml_adapter/xml_element.rb +57 -3
- data/lib/lutaml/model/xml_mapping.rb +49 -7
- data/lib/lutaml/model/xml_mapping_rule.rb +8 -3
- data/lib/lutaml/model.rb +1 -0
- data/lutaml-model.gemspec +5 -0
- data/spec/benchmarks/xml_parsing_benchmark_spec.rb +75 -0
- data/spec/ceramic_spec.rb +39 -0
- data/spec/fixtures/ceramic.rb +23 -0
- data/spec/fixtures/xml/address_example_260.xsd +9 -0
- data/spec/fixtures/xml/user.xsd +10 -0
- data/spec/lutaml/model/cdata_spec.rb +4 -5
- data/spec/lutaml/model/choice_spec.rb +168 -0
- data/spec/lutaml/model/collection_spec.rb +1 -1
- data/spec/lutaml/model/custom_model_spec.rb +6 -7
- data/spec/lutaml/model/custom_serialization_spec.rb +74 -2
- data/spec/lutaml/model/defaults_spec.rb +3 -1
- data/spec/lutaml/model/delegation_spec.rb +7 -5
- data/spec/lutaml/model/enum_spec.rb +35 -0
- data/spec/lutaml/model/group_spec.rb +160 -0
- data/spec/lutaml/model/inheritance_spec.rb +25 -0
- data/spec/lutaml/model/liquefiable_spec.rb +121 -0
- data/spec/lutaml/model/mixed_content_spec.rb +80 -41
- data/spec/lutaml/model/multiple_mapping_spec.rb +22 -10
- data/spec/lutaml/model/schema/xml_compiler_spec.rb +218 -25
- data/spec/lutaml/model/sequence_spec.rb +216 -0
- data/spec/lutaml/model/transformation_spec.rb +230 -0
- data/spec/lutaml/model/type_spec.rb +138 -31
- data/spec/lutaml/model/utils_spec.rb +32 -0
- data/spec/lutaml/model/xml_adapter/oga_adapter_spec.rb +11 -7
- data/spec/lutaml/model/xml_mapping_rule_spec.rb +51 -0
- data/spec/lutaml/model/xml_mapping_spec.rb +143 -112
- metadata +67 -2
@@ -226,7 +226,8 @@ module XmlMapping
|
|
226
226
|
xml do
|
227
227
|
root "MapAllWithCustomMethod"
|
228
228
|
|
229
|
-
map_all_content to: :all_content,
|
229
|
+
map_all_content to: :all_content,
|
230
|
+
with: { to: :content_to_xml, from: :content_from_xml }
|
230
231
|
end
|
231
232
|
|
232
233
|
def content_to_xml(model, parent, doc)
|
@@ -344,6 +345,7 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
344
345
|
|
345
346
|
it "checks the attribute with and without namespace" do
|
346
347
|
parsed = XmlMapping::AttributeNamespace.from_xml(input_xml)
|
348
|
+
|
347
349
|
expect(parsed.alpha).to eq("hello")
|
348
350
|
expect(parsed.beta).to eq("bye")
|
349
351
|
expect(parsed.to_xml).to be_equivalent_to(input_xml)
|
@@ -382,12 +384,12 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
382
384
|
end
|
383
385
|
|
384
386
|
let(:oga_expected_xml) do
|
385
|
-
"<OverrideDefaultNamespacePrefix xmlns:abc=\"http://www.omg.org/spec/XMI/20131001\">"
|
386
|
-
"<abc:SameElementName App=\"hello\" xmlns:GML=\"http://www.sparxsystems.com/profiles/GML/1.0\" xmlns:CityGML=\"http://www.sparxsystems.com/profiles/CityGML/1.0\">"
|
387
|
-
"<GML:ApplicationSchema>GML App</GML:ApplicationSchema>"
|
388
|
-
"<CityGML:ApplicationSchema>CityGML App</CityGML:ApplicationSchema>"
|
389
|
-
"<abc:ApplicationSchema>App</abc:ApplicationSchema>"
|
390
|
-
"</abc:SameElementName>"
|
387
|
+
"<OverrideDefaultNamespacePrefix xmlns:abc=\"http://www.omg.org/spec/XMI/20131001\">" \
|
388
|
+
"<abc:SameElementName App=\"hello\" xmlns:GML=\"http://www.sparxsystems.com/profiles/GML/1.0\" xmlns:CityGML=\"http://www.sparxsystems.com/profiles/CityGML/1.0\">" \
|
389
|
+
"<GML:ApplicationSchema>GML App</GML:ApplicationSchema>" \
|
390
|
+
"<CityGML:ApplicationSchema>CityGML App</CityGML:ApplicationSchema>" \
|
391
|
+
"<abc:ApplicationSchema>App</abc:ApplicationSchema>" \
|
392
|
+
"</abc:SameElementName>" \
|
391
393
|
"</OverrideDefaultNamespacePrefix>"
|
392
394
|
end
|
393
395
|
|
@@ -477,34 +479,38 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
477
479
|
end
|
478
480
|
|
479
481
|
let(:expected_order) do
|
482
|
+
nokogiri_pattern = create_pattern_mapping([
|
483
|
+
["Text", "text"],
|
484
|
+
["Element", "ApplicationSchema"],
|
485
|
+
["Text", "text"],
|
486
|
+
["Element", "ApplicationSchema"],
|
487
|
+
["Text", "text"],
|
488
|
+
["Element", "ApplicationSchema"],
|
489
|
+
["Text", "text"],
|
490
|
+
])
|
491
|
+
|
492
|
+
oga_ox_pattern = create_pattern_mapping([
|
493
|
+
["Element", "ApplicationSchema"],
|
494
|
+
["Element", "ApplicationSchema"],
|
495
|
+
["Element", "ApplicationSchema"],
|
496
|
+
])
|
497
|
+
|
480
498
|
{
|
481
|
-
Lutaml::Model::XmlAdapter::NokogiriAdapter =>
|
482
|
-
|
483
|
-
|
484
|
-
"text",
|
485
|
-
"ApplicationSchema",
|
486
|
-
"text",
|
487
|
-
"ApplicationSchema",
|
488
|
-
"text",
|
489
|
-
],
|
490
|
-
Lutaml::Model::XmlAdapter::OxAdapter => [
|
491
|
-
"ApplicationSchema",
|
492
|
-
"ApplicationSchema",
|
493
|
-
"ApplicationSchema",
|
494
|
-
],
|
495
|
-
Lutaml::Model::XmlAdapter::OgaAdapter => [
|
496
|
-
"text",
|
497
|
-
"ApplicationSchema",
|
498
|
-
"text",
|
499
|
-
"ApplicationSchema",
|
500
|
-
"text",
|
501
|
-
"ApplicationSchema",
|
502
|
-
"text",
|
503
|
-
],
|
499
|
+
Lutaml::Model::XmlAdapter::NokogiriAdapter => nokogiri_pattern,
|
500
|
+
Lutaml::Model::XmlAdapter::OxAdapter => oga_ox_pattern,
|
501
|
+
Lutaml::Model::XmlAdapter::OgaAdapter => oga_ox_pattern,
|
504
502
|
}
|
505
503
|
end
|
506
504
|
|
507
|
-
let(:parsed)
|
505
|
+
let(:parsed) do
|
506
|
+
XmlMapping::SameNameDifferentNamespace.from_xml(input_xml)
|
507
|
+
end
|
508
|
+
|
509
|
+
def create_pattern_mapping(array)
|
510
|
+
array.map do |type, text|
|
511
|
+
Lutaml::Model::XmlAdapter::Element.new(type, text)
|
512
|
+
end
|
513
|
+
end
|
508
514
|
|
509
515
|
it "citygml_application_schema should be correct" do
|
510
516
|
expect(parsed.citygml_application_schema).to eq("CityGML App")
|
@@ -652,7 +658,8 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
652
658
|
|
653
659
|
it "sets the namespace for individual elements" do
|
654
660
|
expect(mapping.elements.size).to eq(3)
|
655
|
-
expect(mapping.elements[0].namespace)
|
661
|
+
expect(mapping.elements[0].namespace)
|
662
|
+
.to eq("https://example.com/ceramic/1.2")
|
656
663
|
expect(mapping.elements[0].prefix).to eq("cera")
|
657
664
|
expect(mapping.elements[1].delegate).to eq(:glaze)
|
658
665
|
end
|
@@ -674,7 +681,8 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
674
681
|
|
675
682
|
it "sets the namespace for individual attributes" do
|
676
683
|
expect(mapping.attributes.size).to eq(1)
|
677
|
-
expect(mapping.attributes[0].namespace)
|
684
|
+
expect(mapping.attributes[0].namespace)
|
685
|
+
.to eq("https://example.com/ceramic/1.2")
|
678
686
|
expect(mapping.attributes[0].prefix).to eq("cera")
|
679
687
|
end
|
680
688
|
end
|
@@ -727,7 +735,7 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
727
735
|
error_regex = /\[Lutaml::Model\] WARN: `schemaLocation` is handled by default\. No need to explecitly define at `xml_mapping_spec.rb:\d+`/
|
728
736
|
|
729
737
|
expect do
|
730
|
-
|
738
|
+
mapping.map_attribute("schemaLocation", to: :schema_location)
|
731
739
|
end.to output(error_regex).to_stderr
|
732
740
|
end
|
733
741
|
end
|
@@ -745,13 +753,32 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
745
753
|
XML
|
746
754
|
end
|
747
755
|
|
756
|
+
let(:generated_xml) do
|
757
|
+
XmlMapping::SchemaLocationOrdered.from_xml(xml).to_xml
|
758
|
+
end
|
759
|
+
|
748
760
|
it "contain schemaLocation attributes" do
|
749
|
-
expect(
|
761
|
+
expect(generated_xml).to be_equivalent_to(xml)
|
750
762
|
end
|
751
763
|
end
|
752
764
|
end
|
753
765
|
|
754
766
|
context "with multiple schemaLocations" do
|
767
|
+
let(:nested_schema_location) do
|
768
|
+
Lutaml::Model::SchemaLocation.new(
|
769
|
+
schema_location: "http://www.opengis.net/gml/3.7 http://schemas.opengis.net/gml/3.7.1/gml.xsd http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd",
|
770
|
+
prefix: "xsi",
|
771
|
+
namespace: "http://another-instance",
|
772
|
+
)
|
773
|
+
end
|
774
|
+
|
775
|
+
let(:schema_location) do
|
776
|
+
Lutaml::Model::SchemaLocation.new(
|
777
|
+
schema_location: "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd http://www.w3.org/1999/xlink http://www.w3.org/1999/xlink.xsd",
|
778
|
+
prefix: "xsi",
|
779
|
+
)
|
780
|
+
end
|
781
|
+
|
755
782
|
let(:xml) do
|
756
783
|
<<~XML
|
757
784
|
<p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
@@ -764,60 +791,39 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
764
791
|
XML
|
765
792
|
end
|
766
793
|
|
767
|
-
|
768
|
-
parsed
|
769
|
-
expect(parsed.schema_location.size).to eq(2)
|
770
|
-
expect(parsed.schema_location[0].namespace).to eq("http://www.opengis.net/gml/3.2")
|
771
|
-
expect(parsed.schema_location[0].location).to eq("http://schemas.opengis.net/gml/3.2.1/gml.xsd")
|
772
|
-
expect(parsed.schema_location[1].namespace).to eq("http://www.w3.org/1999/xlink")
|
773
|
-
expect(parsed.schema_location[1].location).to eq("http://www.w3.org/1999/xlink.xsd")
|
794
|
+
context "when deserializing" do
|
795
|
+
let(:parsed) { Paragraph.from_xml(xml) }
|
774
796
|
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
797
|
+
it "parses correctly" do
|
798
|
+
expect(parsed.schema_location.size).to eq(2)
|
799
|
+
expect(parsed.schema_location[0]).to eq(schema_location[0])
|
800
|
+
expect(parsed.schema_location[1]).to eq(schema_location[1])
|
801
|
+
end
|
780
802
|
|
781
|
-
|
782
|
-
|
783
|
-
nested_p = parsed.paragraph
|
803
|
+
it "parses nested correctly" do
|
804
|
+
nested_p = parsed.paragraph
|
784
805
|
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
expect(nested_p.schema_location[1].location).to eq("http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd")
|
806
|
+
expect(nested_p.schema_location.size).to eq(2)
|
807
|
+
expect(nested_p.schema_location[0]).to eq(nested_schema_location[0])
|
808
|
+
expect(nested_p.schema_location[1]).to eq(nested_schema_location[1])
|
809
|
+
end
|
810
|
+
end
|
791
811
|
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
schema_location: Lutaml::Model::SchemaLocation.new(
|
800
|
-
schema_location: {
|
801
|
-
"http://www.opengis.net/gml/3.2" => "http://schemas.opengis.net/gml/3.2.1/gml.xsd",
|
802
|
-
"http://www.w3.org/1999/xlink" => "http://www.w3.org/1999/xlink.xsd",
|
803
|
-
},
|
804
|
-
prefix: "xsi",
|
805
|
-
),
|
806
|
-
paragraph: Paragraph.new(
|
807
|
-
schema_location: Lutaml::Model::SchemaLocation.new(
|
808
|
-
schema_location: {
|
809
|
-
"http://www.opengis.net/gml/3.7" => "http://schemas.opengis.net/gml/3.7.1/gml.xsd",
|
810
|
-
"http://www.isotc211.org/2005/gmd" => "http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd",
|
811
|
-
},
|
812
|
-
prefix: "xsi",
|
813
|
-
namespace: "http://another-instance",
|
812
|
+
context "when serializing" do
|
813
|
+
let(:paragraph) do
|
814
|
+
Paragraph.new(
|
815
|
+
schema_location: schema_location,
|
816
|
+
paragraph: Paragraph.new(
|
817
|
+
schema_location: nested_schema_location,
|
818
|
+
text: ["Some text inside paragraph"],
|
814
819
|
),
|
815
|
-
|
816
|
-
|
817
|
-
)
|
820
|
+
)
|
821
|
+
end
|
818
822
|
|
819
|
-
|
820
|
-
|
823
|
+
it "creates XML with multiple schemaLocations" do
|
824
|
+
serialized = paragraph.to_xml
|
825
|
+
expect(serialized).to be_equivalent_to(xml)
|
826
|
+
end
|
821
827
|
end
|
822
828
|
end
|
823
829
|
|
@@ -838,10 +844,10 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
838
844
|
end
|
839
845
|
|
840
846
|
let(:expected_street) do
|
841
|
-
if Lutaml::Model::Config.xml_adapter == Lutaml::Model::XmlAdapter::
|
842
|
-
"<a>N</a>\n<p>adf</p>\n"
|
843
|
-
else
|
847
|
+
if Lutaml::Model::Config.xml_adapter == Lutaml::Model::XmlAdapter::NokogiriAdapter
|
844
848
|
"\n <a>N</a>\n <p>adf</p>\n "
|
849
|
+
else
|
850
|
+
"<a>N</a><p>adf</p>"
|
845
851
|
end
|
846
852
|
end
|
847
853
|
|
@@ -891,6 +897,16 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
891
897
|
orig_mappings.deep_dup
|
892
898
|
end
|
893
899
|
|
900
|
+
XmlMapping::WithMapAll.mappings_for(:xml).instance_variables.each do |var|
|
901
|
+
it "duplicates #{var} correctly" do
|
902
|
+
orig_mapping = XmlMapping::WithMapAll.mappings_for(:xml)
|
903
|
+
dup_mappings = orig_mapping.deep_dup
|
904
|
+
|
905
|
+
expect(orig_mapping.instance_variable_get(var))
|
906
|
+
.to eq(dup_mappings.instance_variable_get(var))
|
907
|
+
end
|
908
|
+
end
|
909
|
+
|
894
910
|
it "duplicates root_element" do
|
895
911
|
orig_root = orig_mappings.root_element
|
896
912
|
dup_root = dup_mappings.root_element
|
@@ -904,7 +920,8 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
904
920
|
dup_namespace_uri = dup_mappings.namespace_uri
|
905
921
|
|
906
922
|
expect(orig_namespace_uri).to eq(dup_namespace_uri)
|
907
|
-
expect(orig_namespace_uri.object_id)
|
923
|
+
expect(orig_namespace_uri.object_id)
|
924
|
+
.not_to eq(dup_namespace_uri.object_id)
|
908
925
|
end
|
909
926
|
|
910
927
|
it "duplicates namespace_prefix" do
|
@@ -912,7 +929,8 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
912
929
|
dup_namespace_prefix = dup_mappings.namespace_prefix
|
913
930
|
|
914
931
|
expect(orig_namespace_prefix).to eq(dup_namespace_prefix)
|
915
|
-
expect(orig_namespace_prefix.object_id)
|
932
|
+
expect(orig_namespace_prefix.object_id)
|
933
|
+
.not_to eq(dup_namespace_prefix.object_id)
|
916
934
|
end
|
917
935
|
|
918
936
|
context "when duplicating mapping" do
|
@@ -924,7 +942,8 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
924
942
|
dup_custom_methods = dup_mapping.custom_methods
|
925
943
|
|
926
944
|
expect(orig_custom_methods).to eq(dup_custom_methods)
|
927
|
-
expect(orig_custom_methods.object_id)
|
945
|
+
expect(orig_custom_methods.object_id)
|
946
|
+
.not_to eq(dup_custom_methods.object_id)
|
928
947
|
end
|
929
948
|
|
930
949
|
it "duplicates default_namespace" do
|
@@ -932,7 +951,8 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
932
951
|
dup_default_namespace = dup_mapping.default_namespace
|
933
952
|
|
934
953
|
expect(orig_default_namespace).to eq(dup_default_namespace)
|
935
|
-
expect(orig_default_namespace.object_id)
|
954
|
+
expect(orig_default_namespace.object_id)
|
955
|
+
.not_to eq(dup_default_namespace.object_id)
|
936
956
|
end
|
937
957
|
|
938
958
|
it "duplicates delegate" do
|
@@ -1064,7 +1084,11 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1064
1084
|
end
|
1065
1085
|
|
1066
1086
|
it "maps all the content including tags" do
|
1067
|
-
inner_xml = "
|
1087
|
+
inner_xml = if adapter_class.type == "ox"
|
1088
|
+
"Str<sub>2</sub> text<sup>1</sup> 123"
|
1089
|
+
else
|
1090
|
+
"Str<sub>2</sub>text<sup>1</sup>123"
|
1091
|
+
end
|
1068
1092
|
xml = "<WithMapAll>#{inner_xml}</WithMapAll>"
|
1069
1093
|
|
1070
1094
|
parsed = XmlMapping::WithMapAll.from_xml(xml)
|
@@ -1085,12 +1109,6 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1085
1109
|
DESCRIPTION
|
1086
1110
|
end
|
1087
1111
|
|
1088
|
-
let(:expected_description) do
|
1089
|
-
<<~DESCRIPTION
|
1090
|
-
I'm a <b>web developer</b> with <strong>years</strong> of <i>experience</i> in many programing languages.
|
1091
|
-
DESCRIPTION
|
1092
|
-
end
|
1093
|
-
|
1094
1112
|
let(:xml) do
|
1095
1113
|
<<~XML
|
1096
1114
|
<WithNestedMapAll age="23">
|
@@ -1102,17 +1120,6 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1102
1120
|
XML
|
1103
1121
|
end
|
1104
1122
|
|
1105
|
-
let(:expected_xml) do
|
1106
|
-
<<~XML
|
1107
|
-
<WithNestedMapAll age="23">
|
1108
|
-
<name>John Doe</name>
|
1109
|
-
<description>
|
1110
|
-
#{expected_description}
|
1111
|
-
</description>
|
1112
|
-
</WithNestedMapAll>
|
1113
|
-
XML
|
1114
|
-
end
|
1115
|
-
|
1116
1123
|
let(:parsed) do
|
1117
1124
|
XmlMapping::WithNestedMapAll.from_xml(xml)
|
1118
1125
|
end
|
@@ -1130,7 +1137,7 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1130
1137
|
end
|
1131
1138
|
|
1132
1139
|
it "round-trips xml" do
|
1133
|
-
expect(parsed.to_xml).to be_equivalent_to(
|
1140
|
+
expect(parsed.to_xml).to be_equivalent_to(xml)
|
1134
1141
|
end
|
1135
1142
|
end
|
1136
1143
|
|
@@ -1157,6 +1164,16 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1157
1164
|
XML
|
1158
1165
|
end
|
1159
1166
|
|
1167
|
+
let(:expected_oga_xml) do
|
1168
|
+
<<~XML.strip
|
1169
|
+
<SpecialCharContentWithMapAll>
|
1170
|
+
B <p>R&C</p>
|
1171
|
+
C <p>J—C</p>
|
1172
|
+
O <p>A & B </p>
|
1173
|
+
F <p>Z © </p></SpecialCharContentWithMapAll>
|
1174
|
+
XML
|
1175
|
+
end
|
1176
|
+
|
1160
1177
|
let(:expected_ox_xml) do
|
1161
1178
|
"<SpecialCharContentWithMapAll> " \
|
1162
1179
|
"B <p>R&C</p> " \
|
@@ -1166,9 +1183,19 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1166
1183
|
"</SpecialCharContentWithMapAll>\n"
|
1167
1184
|
end
|
1168
1185
|
|
1186
|
+
let(:expected_xml) do
|
1187
|
+
if adapter_class.type == "ox"
|
1188
|
+
expected_ox_xml
|
1189
|
+
elsif adapter_class.type == "oga"
|
1190
|
+
expected_oga_xml
|
1191
|
+
else
|
1192
|
+
expected_nokogiri_xml
|
1193
|
+
end
|
1194
|
+
end
|
1195
|
+
|
1169
1196
|
it "round-trips xml" do
|
1170
|
-
|
1171
|
-
expect(
|
1197
|
+
parsed = XmlMapping::SpecialCharContentWithMapAll.from_xml(xml)
|
1198
|
+
expect(parsed.to_xml).to eq(expected_xml)
|
1172
1199
|
end
|
1173
1200
|
end
|
1174
1201
|
|
@@ -1181,8 +1208,12 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
1181
1208
|
XML
|
1182
1209
|
end
|
1183
1210
|
|
1211
|
+
let(:generated_xml) do
|
1212
|
+
XmlMapping::Schema.from_xml(xml).to_xml
|
1213
|
+
end
|
1214
|
+
|
1184
1215
|
it "round-trips xml" do
|
1185
|
-
expect(
|
1216
|
+
expect(generated_xml).to be_equivalent_to(xml)
|
1186
1217
|
end
|
1187
1218
|
end
|
1188
1219
|
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: liquid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: moxml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.2
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: thor
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +94,7 @@ files:
|
|
52
94
|
- exe/lutaml-model
|
53
95
|
- lib/lutaml/model.rb
|
54
96
|
- lib/lutaml/model/attribute.rb
|
97
|
+
- lib/lutaml/model/choice.rb
|
55
98
|
- lib/lutaml/model/cli.rb
|
56
99
|
- lib/lutaml/model/comparable_model.rb
|
57
100
|
- lib/lutaml/model/comparable_nil.rb
|
@@ -59,16 +102,24 @@ files:
|
|
59
102
|
- lib/lutaml/model/config.rb
|
60
103
|
- lib/lutaml/model/constants.rb
|
61
104
|
- lib/lutaml/model/error.rb
|
105
|
+
- lib/lutaml/model/error/choice_lower_bound_error.rb
|
106
|
+
- lib/lutaml/model/error/choice_upper_bound_error.rb
|
62
107
|
- lib/lutaml/model/error/collection_count_out_of_range_error.rb
|
63
108
|
- lib/lutaml/model/error/collection_true_missing_error.rb
|
109
|
+
- lib/lutaml/model/error/import_model_with_root_error.rb
|
64
110
|
- lib/lutaml/model/error/incorrect_mapping_argument_error.rb
|
111
|
+
- lib/lutaml/model/error/incorrect_sequence_error.rb
|
112
|
+
- lib/lutaml/model/error/invalid_choice_range_error.rb
|
65
113
|
- lib/lutaml/model/error/invalid_value_error.rb
|
66
114
|
- lib/lutaml/model/error/multiple_mappings_error.rb
|
115
|
+
- lib/lutaml/model/error/no_root_mapping_error.rb
|
116
|
+
- lib/lutaml/model/error/no_root_namespace_error.rb
|
67
117
|
- lib/lutaml/model/error/pattern_not_matched_error.rb
|
68
118
|
- lib/lutaml/model/error/type/invalid_value_error.rb
|
69
119
|
- lib/lutaml/model/error/type_error.rb
|
70
120
|
- lib/lutaml/model/error/type_not_enabled_error.rb
|
71
121
|
- lib/lutaml/model/error/unknown_adapter_type_error.rb
|
122
|
+
- lib/lutaml/model/error/unknown_sequence_mapping_error.rb
|
72
123
|
- lib/lutaml/model/error/unknown_type_error.rb
|
73
124
|
- lib/lutaml/model/error/validation_error.rb
|
74
125
|
- lib/lutaml/model/json_adapter.rb
|
@@ -78,6 +129,7 @@ files:
|
|
78
129
|
- lib/lutaml/model/json_adapter/standard_json_adapter.rb
|
79
130
|
- lib/lutaml/model/key_value_mapping.rb
|
80
131
|
- lib/lutaml/model/key_value_mapping_rule.rb
|
132
|
+
- lib/lutaml/model/liquefiable.rb
|
81
133
|
- lib/lutaml/model/loggable.rb
|
82
134
|
- lib/lutaml/model/mapping_hash.rb
|
83
135
|
- lib/lutaml/model/mapping_rule.rb
|
@@ -90,6 +142,7 @@ files:
|
|
90
142
|
- lib/lutaml/model/schema/xsd_schema.rb
|
91
143
|
- lib/lutaml/model/schema/yaml_schema.rb
|
92
144
|
- lib/lutaml/model/schema_location.rb
|
145
|
+
- lib/lutaml/model/sequence.rb
|
93
146
|
- lib/lutaml/model/serializable.rb
|
94
147
|
- lib/lutaml/model/serialize.rb
|
95
148
|
- lib/lutaml/model/toml_adapter.rb
|
@@ -116,6 +169,7 @@ files:
|
|
116
169
|
- lib/lutaml/model/xml_adapter/builder/nokogiri.rb
|
117
170
|
- lib/lutaml/model/xml_adapter/builder/oga.rb
|
118
171
|
- lib/lutaml/model/xml_adapter/builder/ox.rb
|
172
|
+
- lib/lutaml/model/xml_adapter/element.rb
|
119
173
|
- lib/lutaml/model/xml_adapter/nokogiri_adapter.rb
|
120
174
|
- lib/lutaml/model/xml_adapter/oga/document.rb
|
121
175
|
- lib/lutaml/model/xml_adapter/oga/element.rb
|
@@ -134,19 +188,25 @@ files:
|
|
134
188
|
- lutaml-model.gemspec
|
135
189
|
- sig/lutaml/model.rbs
|
136
190
|
- spec/address_spec.rb
|
191
|
+
- spec/benchmarks/xml_parsing_benchmark_spec.rb
|
192
|
+
- spec/ceramic_spec.rb
|
137
193
|
- spec/fixtures/address.rb
|
194
|
+
- spec/fixtures/ceramic.rb
|
138
195
|
- spec/fixtures/person.rb
|
139
196
|
- spec/fixtures/sample_model.rb
|
140
197
|
- spec/fixtures/vase.rb
|
198
|
+
- spec/fixtures/xml/address_example_260.xsd
|
141
199
|
- spec/fixtures/xml/invalid_math_document.xml
|
142
200
|
- spec/fixtures/xml/latin_encoding.xml
|
143
201
|
- spec/fixtures/xml/math_document_schema.xsd
|
144
202
|
- spec/fixtures/xml/shift_jis.xml
|
145
203
|
- spec/fixtures/xml/special_char.xml
|
146
204
|
- spec/fixtures/xml/test_schema.xsd
|
205
|
+
- spec/fixtures/xml/user.xsd
|
147
206
|
- spec/fixtures/xml/valid_math_document.xml
|
148
207
|
- spec/lutaml/model/attribute_spec.rb
|
149
208
|
- spec/lutaml/model/cdata_spec.rb
|
209
|
+
- spec/lutaml/model/choice_spec.rb
|
150
210
|
- spec/lutaml/model/collection_spec.rb
|
151
211
|
- spec/lutaml/model/comparable_model_spec.rb
|
152
212
|
- spec/lutaml/model/custom_model_spec.rb
|
@@ -154,10 +214,12 @@ files:
|
|
154
214
|
- spec/lutaml/model/defaults_spec.rb
|
155
215
|
- spec/lutaml/model/delegation_spec.rb
|
156
216
|
- spec/lutaml/model/enum_spec.rb
|
217
|
+
- spec/lutaml/model/group_spec.rb
|
157
218
|
- spec/lutaml/model/included_spec.rb
|
158
219
|
- spec/lutaml/model/inheritance_spec.rb
|
159
220
|
- spec/lutaml/model/json_adapter_spec.rb
|
160
221
|
- spec/lutaml/model/key_value_mapping_spec.rb
|
222
|
+
- spec/lutaml/model/liquefiable_spec.rb
|
161
223
|
- spec/lutaml/model/map_all_spec.rb
|
162
224
|
- spec/lutaml/model/map_content_spec.rb
|
163
225
|
- spec/lutaml/model/mixed_content_spec.rb
|
@@ -171,10 +233,12 @@ files:
|
|
171
233
|
- spec/lutaml/model/schema/xml_compiler_spec.rb
|
172
234
|
- spec/lutaml/model/schema/xsd_schema_spec.rb
|
173
235
|
- spec/lutaml/model/schema/yaml_schema_spec.rb
|
236
|
+
- spec/lutaml/model/sequence_spec.rb
|
174
237
|
- spec/lutaml/model/serializable_spec.rb
|
175
238
|
- spec/lutaml/model/serializable_validation_spec.rb
|
176
239
|
- spec/lutaml/model/simple_model_spec.rb
|
177
240
|
- spec/lutaml/model/toml_adapter_spec.rb
|
241
|
+
- spec/lutaml/model/transformation_spec.rb
|
178
242
|
- spec/lutaml/model/type/boolean_spec.rb
|
179
243
|
- spec/lutaml/model/type/date_spec.rb
|
180
244
|
- spec/lutaml/model/type/date_time_spec.rb
|
@@ -194,6 +258,7 @@ files:
|
|
194
258
|
- spec/lutaml/model/xml_adapter/ox_adapter_spec.rb
|
195
259
|
- spec/lutaml/model/xml_adapter/xml_namespace_spec.rb
|
196
260
|
- spec/lutaml/model/xml_adapter_spec.rb
|
261
|
+
- spec/lutaml/model/xml_mapping_rule_spec.rb
|
197
262
|
- spec/lutaml/model/xml_mapping_spec.rb
|
198
263
|
- spec/lutaml/model/yaml_adapter_spec.rb
|
199
264
|
- spec/lutaml/model_spec.rb
|