lutaml-model 0.8.203 → 0.8.204

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +5 -0
  3. data/.github/workflows/lml-conformance.yml +71 -0
  4. data/.gitignore +7 -0
  5. data/README.adoc +1 -0
  6. data/docs/_guides/lml-cross-language.adoc +128 -0
  7. data/docs/_references/lml-conformance.adoc +78 -0
  8. data/docs/_references/lml-contract.adoc +290 -0
  9. data/lib/lutaml/model/lml/artifact_verifier.rb +205 -0
  10. data/lib/lutaml/model/lml/bundle.rb +171 -0
  11. data/lib/lutaml/model/lml/document.rb +46 -10
  12. data/lib/lutaml/model/lml/document_validator.rb +840 -0
  13. data/lib/lutaml/model/lml/exporter/v1_projector.rb +102 -0
  14. data/lib/lutaml/model/lml/exporter/v2_projector.rb +401 -0
  15. data/lib/lutaml/model/lml/exporter.rb +223 -87
  16. data/lib/lutaml/model/lml/graph_exporter.rb +248 -0
  17. data/lib/lutaml/model/lml/importer.rb +180 -0
  18. data/lib/lutaml/model/lml/mapping_compiler.rb +401 -0
  19. data/lib/lutaml/model/lml/materialization.rb +257 -0
  20. data/lib/lutaml/model/lml/ordered_content.rb +577 -0
  21. data/lib/lutaml/model/lml/portable_json.rb +385 -0
  22. data/lib/lutaml/model/lml/rejected_error.rb +64 -15
  23. data/lib/lutaml/model/lml/round_trip.rb +86 -0
  24. data/lib/lutaml/model/lml/value_declarations.rb +84 -0
  25. data/lib/lutaml/model/lml.rb +61 -0
  26. data/lib/lutaml/model/schema/definitions/attribute.rb +4 -2
  27. data/lib/lutaml/model/schema/registry_generator.rb +1 -1
  28. data/lib/lutaml/model/schema/renderers/member_decls.rb +1 -0
  29. data/lib/lutaml/model/schema/xml_compiler/spec_builder/members.rb +10 -0
  30. data/lib/lutaml/model/sequence.rb +7 -0
  31. data/lib/lutaml/model/version.rb +1 -1
  32. data/lib/lutaml/xml/leptris/native_emission.rb +4 -0
  33. data/lib/lutaml/xml/leptris/plan_serializer.rb +14 -9
  34. data/schema/lml/document.schema.json +179 -0
  35. data/scripts/lml/export_choices.rb +57 -0
  36. data/scripts/lml/export_conformance.rb +23 -0
  37. data/scripts/lml/export_mml.rb +253 -0
  38. data/scripts/lml/export_preservation.rb +421 -0
  39. data/scripts/lml/verify_artifacts.rb +31 -0
  40. data/spec/fixtures/lml_artifacts/model.json +1 -0
  41. data/spec/fixtures/lml_artifacts/valid.json +1 -0
  42. data/spec/fixtures/lml_artifacts/valid.sha256 +1 -0
  43. data/spec/fixtures/lml_conformance/core/index.json +1 -0
  44. data/spec/fixtures/lml_conformance/core/manifest.json +1 -0
  45. data/spec/fixtures/lml_conformance/core/schema.json +1 -0
  46. data/spec/fixtures/lml_conformance/core/schema.yaml +79 -0
  47. data/spec/fixtures/lml_conformance/float_vectors.generator.rb +60 -0
  48. data/spec/fixtures/lml_conformance/float_vectors.json +21550 -0
  49. data/spec/fixtures/lml_conformance/preservation/index.json +1 -0
  50. data/spec/fixtures/lml_conformance/preservation/manifest.json +1 -0
  51. data/spec/fixtures/lml_conformance/preservation/schema.json +1 -0
  52. data/spec/fixtures/lml_conformance/preservation/schema.yaml +319 -0
  53. data/spec/fixtures/lml_conformance/r2_refusals.generator.rb +153 -0
  54. data/spec/fixtures/lml_conformance/r2_refusals.json +1662 -0
  55. data/spec/fixtures/lml_conformance/ruby_portable_interop.generator.rb +40 -0
  56. data/spec/fixtures/lml_conformance/ruby_portable_interop.json +1 -0
  57. data/spec/fixtures/lml_contract/bundle.json +81 -0
  58. data/spec/fixtures/lml_contract/manifest.json +30 -0
  59. data/spec/fixtures/lml_contract/v1_unit.canonical.json +1 -0
  60. data/spec/fixtures/lml_contract/v1_unit.json +1 -0
  61. data/spec/fixtures/lml_contract/v2_node.canonical.json +1 -0
  62. data/spec/fixtures/lml_contract/v2_node.json +32 -0
  63. data/spec/fixtures/lml_mml/inventory.json +1 -0
  64. data/spec/fixtures/lml_mml/manifest.json +1 -0
  65. data/spec/fixtures/lml_mml/oracle.json +1 -0
  66. data/spec/fixtures/lml_mml/v3-mi-mixed.json +1 -0
  67. data/spec/fixtures/lml_mml/v3-mi-mixed.yaml +970 -0
  68. data/spec/fixtures/lml_mml/v4-mi-mixed.json +1 -0
  69. data/spec/fixtures/lml_mml/v4-mi-mixed.yaml +1516 -0
  70. data/spec/fixtures/lml_mml_materialization/replay.rb +37 -0
  71. data/spec/lutaml/model/lml_any_attribute_spec.rb +91 -0
  72. data/spec/lutaml/model/lml_artifact_verifier_spec.rb +86 -0
  73. data/spec/lutaml/model/lml_builtin_types_spec.rb +49 -0
  74. data/spec/lutaml/model/lml_conformance_spec.rb +178 -0
  75. data/spec/lutaml/model/lml_document_spec.rb +279 -0
  76. data/spec/lutaml/model/lml_export_validation_spec.rb +96 -0
  77. data/spec/lutaml/model/lml_exporter_spec.rb +127 -5
  78. data/spec/lutaml/model/lml_graph_exporter_spec.rb +205 -0
  79. data/spec/lutaml/model/lml_importer_spec.rb +290 -0
  80. data/spec/lutaml/model/lml_input_hardening_spec.rb +156 -0
  81. data/spec/lutaml/model/lml_mapping_compiler_spec.rb +256 -0
  82. data/spec/lutaml/model/lml_materialization_spec.rb +138 -0
  83. data/spec/lutaml/model/lml_mml_materialization_spec.rb +54 -0
  84. data/spec/lutaml/model/lml_mml_pilot_spec.rb +150 -0
  85. data/spec/lutaml/model/lml_model_choices_spec.rb +88 -0
  86. data/spec/lutaml/model/lml_ordered_content_spec.rb +243 -0
  87. data/spec/lutaml/model/lml_portable_json_spec.rb +310 -0
  88. data/spec/lutaml/model/lml_preservation_spec.rb +211 -0
  89. data/spec/lutaml/model/lml_review_export_spec.rb +247 -0
  90. data/spec/lutaml/model/lml_review_import_spec.rb +390 -0
  91. data/spec/lutaml/model/lml_review_misc_spec.rb +152 -0
  92. data/spec/lutaml/model/lml_review_round4_spec.rb +200 -0
  93. data/spec/lutaml/model/lml_review_round5_spec.rb +194 -0
  94. data/spec/lutaml/model/lml_ruby_interop_fixture_spec.rb +37 -0
  95. data/spec/lutaml/model/lml_shared_corpus_spec.rb +132 -0
  96. data/spec/lutaml/model/lml_value_declarations_spec.rb +128 -0
  97. data/spec/lutaml/model/schema/class_loader_spec.rb +51 -0
  98. data/spec/lutaml/model/schema/xml_compiler_runtime_spec.rb +20 -0
  99. data/spec/lutaml/model/sequence_spec.rb +48 -0
  100. data/spec/lutaml/xml/cdata_emission_spec.rb +68 -0
  101. data/spec/support/lml_any_attribute_fixtures.rb +26 -0
  102. data/spec/support/lml_conformance.rb +292 -0
  103. data/spec/support/lml_corpus.rb +75 -0
  104. data/spec/support/lml_export_fixtures.rb +190 -0
  105. data/spec/support/lml_graph_fixtures.rb +108 -0
  106. data/spec/support/lml_import_fixtures.rb +52 -0
  107. data/spec/support/lml_mapping_fixtures.rb +170 -0
  108. data/spec/support/lml_materialization_fixtures.rb +53 -0
  109. data/spec/support/lml_model_choices_fixtures.rb +150 -0
  110. data/spec/support/lml_order_fixtures.rb +151 -0
  111. metadata +92 -2
  112. data/lib/lutaml/model/schema/schema_builder/nokogiri.rb +0 -41
@@ -0,0 +1 @@
1
+ {"cases":[{"comparison":"xml_tree","expected_data":{"plain":"P","qualified":"Q"},"expected_error":null,"expected_output":"<p:record xmlns:p=\"urn:lml:preservation\">\n <p:qualified>Q</p:qualified>\n <plain>P</plain>\n</p:record>","format":"xml","id":"namespace-tree","input":"<p:record xmlns:p=\"urn:lml:preservation\"><p:qualified>Q</p:qualified><plain>P</plain></p:record>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Namespaces@default"},{"comparison":"bytes","expected_data":{"plain":"P","qualified":"Q"},"expected_error":null,"expected_output":"<p:record xmlns:p=\"urn:lml:preservation\">\n <p:qualified>Q</p:qualified>\n <plain>P</plain>\n</p:record>","format":"xml","id":"namespace-bytes","input":"<p:record xmlns:p=\"urn:lml:preservation\"><p:qualified>Q</p:qualified><plain>P</plain></p:record>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Namespaces@default"},{"comparison":"xml_tree","expected_data":{"__lml_content":[{"attribute":"text","index":0,"kind":"text"},{"attribute":"em","index":0,"kind":"element"},{"attribute":"text","index":1,"kind":"text"},{"attribute":"em","index":1,"kind":"element"},{"attribute":"text","index":2,"kind":"text"}],"em":["one","two"],"text":["before","between","after"]},"expected_error":null,"expected_output":"<mixed>before<em>one</em>between<em>two</em>after</mixed>","format":"xml","id":"mixed-order-tree","input":"<mixed>before<em>one</em>between<em>two</em>after</mixed>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Mixed@default"},{"comparison":"bytes","expected_data":{"__lml_content":[{"attribute":"text","index":0,"kind":"text"},{"attribute":"em","index":0,"kind":"element"},{"attribute":"text","index":1,"kind":"text"},{"attribute":"em","index":1,"kind":"element"},{"attribute":"text","index":2,"kind":"text"}],"em":["one","two"],"text":["before","between","after"]},"expected_error":null,"expected_output":"<mixed>before<em>one</em>between<em>two</em>after</mixed>","format":"xml","id":"mixed-order-bytes","input":"<mixed>before<em>one</em>between<em>two</em>after</mixed>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Mixed@default"},{"comparison":"xml_tree","expected_data":{"__lml_content":[{"attribute":"b","index":0,"kind":"element"},{"attribute":"a","index":0,"kind":"element"},{"attribute":"b","index":1,"kind":"element"}],"a":["two"],"b":["one","three"]},"expected_error":null,"expected_output":"<ordered>\n <b>one</b>\n <a>two</a>\n <b>three</b>\n</ordered>","format":"xml","id":"ordered-tree","input":"<ordered><b>one</b><a>two</a><b>three</b></ordered>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Ordered@default"},{"comparison":"bytes","expected_data":{"__lml_content":[{"attribute":"b","index":0,"kind":"element"},{"attribute":"a","index":0,"kind":"element"},{"attribute":"b","index":1,"kind":"element"}],"a":["two"],"b":["one","three"]},"expected_error":null,"expected_output":"<ordered>\n <b>one</b>\n <a>two</a>\n <b>three</b>\n</ordered>","format":"xml","id":"ordered-bytes","input":"<ordered><b>one</b><a>two</a><b>three</b></ordered>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Ordered@default"},{"comparison":"bytes","expected_data":{"text":"a < b & c"},"expected_error":null,"expected_output":"<cdata><![CDATA[a < b & c]]></cdata>","format":"xml","id":"cdata-bytes","input":"<cdata><![CDATA[a < b & c]]></cdata>","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Cdata@default"},{"comparison":"data","expected_data":{"fallback":{"state":"default","value":"default"},"items":{"state":"initialized_empty","value":[]},"value":{"state":"absent","value":null}},"expected_error":null,"expected_output":"{\"value\":null,\"fallback\":\"default\",\"items\":[]}","format":"json","id":"state-absent","input":"{}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::States@default"},{"comparison":"data","expected_data":{"fallback":{"state":"present","value":null},"items":{"state":"initialized_empty","value":[]},"value":{"state":"present","value":null}},"expected_error":null,"expected_output":"{\"value\":null,\"items\":[]}","format":"json","id":"state-null","input":"{\"value\":null,\"fallback\":null}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::States@default"},{"comparison":"data","expected_data":{"fallback":{"state":"default","value":"default"},"items":{"state":"present","value":[]},"value":{"state":"present","value":""}},"expected_error":null,"expected_output":"{\"value\":\"\",\"fallback\":\"default\",\"items\":[]}","format":"json","id":"state-empty","input":"{\"value\":\"\",\"items\":[]}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::States@default"},{"comparison":"data","expected_data":{"fallback":{"state":"present","value":"default"},"items":{"state":"initialized_empty","value":[]},"value":{"state":"absent","value":null}},"expected_error":null,"expected_output":"{\"value\":null,\"fallback\":\"default\",\"items\":[]}","format":"json","id":"state-explicit-default","input":"{\"fallback\":\"default\"}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::States@default"},{"comparison":"data","expected_data":{"items":["one","two"]},"expected_error":null,"expected_output":"{\"items\":[\"one\",\"two\"]}","format":"json","id":"cardinality-valid","input":"{\"items\":[\"one\",\"two\"]}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Bounded@default"},{"comparison":"data","expected_data":null,"expected_error":{"format":"json","location":"/input","model_id":"LmlPreservation::Bounded@default","reason":"invalid_document","ruby_errors":["Lutaml::Model::CollectionCountOutOfRangeError"]},"expected_output":null,"format":"json","id":"cardinality-invalid","input":"{\"items\":[\"one\",\"two\",\"three\"]}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Bounded@default"},{"comparison":"data","expected_data":null,"expected_error":{"format":"json","location":"/input","model_id":"LmlPreservation::Bounded@default","reason":"invalid_document","ruby_errors":["Lutaml::Model::CollectionCountOutOfRangeError"]},"expected_output":null,"format":"json","id":"cardinality-missing","input":"{\"items\":[]}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Bounded@default"},{"comparison":"data","expected_data":{"flag":false,"number":"2"},"expected_error":null,"expected_output":"{\"number\":2,\"flag\":false}","format":"json","id":"typed-enum-valid","input":"{\"number\":2,\"flag\":false}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::TypedEnum@default"},{"comparison":"data","expected_data":null,"expected_error":{"format":"json","location":"/input","model_id":"LmlPreservation::TypedEnum@default","reason":"invalid_document","ruby_errors":["Lutaml::Model::InvalidValueError"]},"expected_output":null,"format":"json","id":"typed-enum-invalid","input":"{\"number\":3,\"flag\":true}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::TypedEnum@default"},{"comparison":"data","expected_data":{"name":"contextual"},"expected_error":null,"expected_output":"{\"name\":\"contextual\"}","format":"json","id":"imported-context","input":"{\"name\":\"contextual\"}","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","model_id":"LmlPreservation::Imported@oracle"}],"corpus":1,"data_profile":"exact-values-decimal-v1","generation":"preservation-v1","source_expectations":[{"path":"spec/lutaml/model/mixed_content_spec.rb","sha256":"sha256:cc8b5d6752ef219e5396d3a5eeca107dff75f528754e325907d5db46195bc816"},{"path":"spec/lutaml/model/cdata_spec.rb","sha256":"sha256:7f5d2ec7eb059dcc85fb9b78ee1c4d79e33ee940bfd98d593c2e5fd3191d6316"},{"path":"spec/lutaml/model/collection_spec.rb","sha256":"sha256:3fe7c2f77a70a5336a44086bbb4b293c8ceec9234129037927972dad2104b40e"},{"path":"spec/lutaml/model/register_spec.rb","sha256":"sha256:98a87101706b10a8b083385f6feabb5139b01c23b8f4892e40b59e953c7a10a1"}],"source_revision":"8a8ef040963b7965388b01b58af33af2b0995f91","wire_profile":"ruby-native","xml_canon_profile":"expanded-names-text-v1"}
@@ -0,0 +1 @@
1
+ {"capabilities":["json","xml"],"corpora":[{"generation":"preservation-v1","sha256":"sha256:76d942557692ee653136f10fcf98e5b3beef43d9ed9a9082eb6d17002b64ddd9"}],"dependencies":[{"name":"lutaml-model","revision":"8a8ef040963b7965388b01b58af33af2b0995f91","sha256":"sha256:14c85f76a3cf2ebb18aa3c97186840897bf2147c886818a5c73670d3a6db170a"}],"files":[{"path":"index.json","sha256":"sha256:76d942557692ee653136f10fcf98e5b3beef43d9ed9a9082eb6d17002b64ddd9"},{"path":"schema.json","sha256":"sha256:66b86b75d36568c1c353a2d5cf32d0e6562e21e7dfea0004a757d0f774761264"},{"path":"schema.yaml","sha256":"sha256:cf40d46e901e4a8e7bb4b7f7ad4365ffec687bef81832663dc136626b3963c3d"}],"generator_version":"ruby-preservation-oracle-v1","lml_checksum":"sha256:81eaac6230a81d4285fb4ea743f202234ef3f3c48482ca60ce9e9b642a5622e5","manifest":1,"schema_version":2,"target":"ruby"}
@@ -0,0 +1 @@
1
+ {"capabilities":["json","xml"],"lml_bundle":1,"models":{"LmlPreservation::Bounded@default":{"attributes":[{"collection":{"max":2,"min":1},"default":{"present":false},"initialize_empty":false,"name":"items","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"json":{"rules":[{"key":["items"],"to":"items"}]}},"model":"LmlPreservation::Bounded","register":"default"},"LmlPreservation::Cdata@default":{"attributes":[{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"text","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"xml":{"namespace":{"mode":"inherit"},"root":{"element":"cdata"},"rules":[{"cdata":true,"kind":"content","namespace":{"mode":"inherit"},"to":"text"}]}},"model":"LmlPreservation::Cdata","register":"default"},"LmlPreservation::Imported@oracle":{"attributes":[{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"name","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"json":{"rules":[{"key":["name"],"to":"name"}]}},"model":"LmlPreservation::Imported","register":"oracle"},"LmlPreservation::Mixed@default":{"attributes":[{"collection":{"max":null,"min":0},"default":{"present":false},"initialize_empty":false,"name":"text","required":false,"type":{"kind":"builtin","name":"string"}},{"collection":{"max":null,"min":0},"default":{"present":false},"initialize_empty":false,"name":"em","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"xml":{"namespace":{"mode":"inherit"},"root":{"element":"mixed"},"rules":[{"kind":"content","namespace":{"mode":"inherit"},"to":"text"},{"kind":"element","name":["em"],"namespace":{"mode":"inherit"},"to":"em"}]}},"model":"LmlPreservation::Mixed","ordered_content":{"member":"__lml_content","version":1},"register":"default"},"LmlPreservation::Namespaces@default":{"attributes":[{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"qualified","required":false,"type":{"kind":"builtin","name":"string"}},{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"plain","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"xml":{"namespace":{"mode":"uri","prefix":"p","uri":"urn:lml:preservation"},"root":{"element":"record"},"rules":[{"kind":"element","name":["qualified"],"namespace":{"mode":"inherit"},"to":"qualified"},{"kind":"element","name":["plain"],"namespace":{"mode":"unqualified"},"to":"plain"}]}},"model":"LmlPreservation::Namespaces","register":"default"},"LmlPreservation::Ordered@default":{"attributes":[{"collection":{"max":null,"min":0},"default":{"present":false},"initialize_empty":false,"name":"a","required":false,"type":{"kind":"builtin","name":"string"}},{"collection":{"max":null,"min":0},"default":{"present":false},"initialize_empty":false,"name":"b","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"xml":{"namespace":{"mode":"inherit"},"root":{"element":"ordered"},"rules":[{"kind":"element","name":["a"],"namespace":{"mode":"inherit"},"to":"a"},{"kind":"element","name":["b"],"namespace":{"mode":"inherit"},"to":"b"}]}},"model":"LmlPreservation::Ordered","ordered_content":{"member":"__lml_content","version":1},"register":"default"},"LmlPreservation::States@default":{"attributes":[{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"value","required":false,"type":{"kind":"builtin","name":"string"}},{"collection":false,"default":{"present":true,"value":"default"},"initialize_empty":false,"name":"fallback","required":false,"type":{"kind":"builtin","name":"string"}},{"collection":{"max":null,"min":0},"default":{"present":false},"initialize_empty":true,"name":"items","required":false,"type":{"kind":"builtin","name":"string"}}],"lml":2,"mappings":{"json":{"rules":[{"key":["value"],"render":{"default":false,"empty":true,"nil":true},"to":"value"},{"key":["fallback"],"render":{"default":true},"to":"fallback"},{"key":["items"],"render":{"empty":true},"to":"items"}]}},"model":"LmlPreservation::States","register":"default"},"LmlPreservation::TypedEnum@default":{"attributes":[{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"number","required":false,"type":{"kind":"builtin","name":"integer"},"values":[1,2]},{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"flag","required":false,"type":{"kind":"builtin","name":"boolean"},"values":[true,false]}],"lml":2,"mappings":{"json":{"rules":[{"key":["number"],"to":"number"},{"key":["flag"],"to":"flag"}]}},"model":"LmlPreservation::TypedEnum","register":"default"}},"provenance":{"source_revision":"8a8ef040963b7965388b01b58af33af2b0995f91"},"roots":["LmlPreservation::Bounded@default","LmlPreservation::Cdata@default","LmlPreservation::Imported@oracle","LmlPreservation::Mixed@default","LmlPreservation::Namespaces@default","LmlPreservation::Ordered@default","LmlPreservation::States@default","LmlPreservation::TypedEnum@default"],"value_types":{}}
@@ -0,0 +1,319 @@
1
+ ---
2
+ capabilities:
3
+ - json
4
+ - xml
5
+ lml_bundle: 1
6
+ models:
7
+ LmlPreservation::Bounded@default:
8
+ attributes:
9
+ - collection:
10
+ max: 2
11
+ min: 1
12
+ default:
13
+ present: false
14
+ initialize_empty: false
15
+ name: items
16
+ required: false
17
+ type:
18
+ kind: builtin
19
+ name: string
20
+ lml: 2
21
+ mappings:
22
+ json:
23
+ rules:
24
+ - key:
25
+ - items
26
+ to: items
27
+ model: LmlPreservation::Bounded
28
+ register: default
29
+ LmlPreservation::Cdata@default:
30
+ attributes:
31
+ - collection: false
32
+ default:
33
+ present: false
34
+ initialize_empty: false
35
+ name: text
36
+ required: false
37
+ type:
38
+ kind: builtin
39
+ name: string
40
+ lml: 2
41
+ mappings:
42
+ xml:
43
+ namespace:
44
+ mode: inherit
45
+ root:
46
+ element: cdata
47
+ rules:
48
+ - cdata: true
49
+ kind: content
50
+ namespace:
51
+ mode: inherit
52
+ to: text
53
+ model: LmlPreservation::Cdata
54
+ register: default
55
+ LmlPreservation::Imported@oracle:
56
+ attributes:
57
+ - collection: false
58
+ default:
59
+ present: false
60
+ initialize_empty: false
61
+ name: name
62
+ required: false
63
+ type:
64
+ kind: builtin
65
+ name: string
66
+ lml: 2
67
+ mappings:
68
+ json:
69
+ rules:
70
+ - key:
71
+ - name
72
+ to: name
73
+ model: LmlPreservation::Imported
74
+ register: oracle
75
+ LmlPreservation::Mixed@default:
76
+ attributes:
77
+ - collection:
78
+ max:
79
+ min: 0
80
+ default:
81
+ present: false
82
+ initialize_empty: false
83
+ name: text
84
+ required: false
85
+ type:
86
+ kind: builtin
87
+ name: string
88
+ - collection:
89
+ max:
90
+ min: 0
91
+ default:
92
+ present: false
93
+ initialize_empty: false
94
+ name: em
95
+ required: false
96
+ type:
97
+ kind: builtin
98
+ name: string
99
+ lml: 2
100
+ mappings:
101
+ xml:
102
+ namespace:
103
+ mode: inherit
104
+ root:
105
+ element: mixed
106
+ rules:
107
+ - kind: content
108
+ namespace:
109
+ mode: inherit
110
+ to: text
111
+ - kind: element
112
+ name:
113
+ - em
114
+ namespace:
115
+ mode: inherit
116
+ to: em
117
+ model: LmlPreservation::Mixed
118
+ ordered_content:
119
+ member: __lml_content
120
+ version: 1
121
+ register: default
122
+ LmlPreservation::Namespaces@default:
123
+ attributes:
124
+ - collection: false
125
+ default:
126
+ present: false
127
+ initialize_empty: false
128
+ name: qualified
129
+ required: false
130
+ type:
131
+ kind: builtin
132
+ name: string
133
+ - collection: false
134
+ default:
135
+ present: false
136
+ initialize_empty: false
137
+ name: plain
138
+ required: false
139
+ type:
140
+ kind: builtin
141
+ name: string
142
+ lml: 2
143
+ mappings:
144
+ xml:
145
+ namespace:
146
+ mode: uri
147
+ prefix: p
148
+ uri: urn:lml:preservation
149
+ root:
150
+ element: record
151
+ rules:
152
+ - kind: element
153
+ name:
154
+ - qualified
155
+ namespace:
156
+ mode: inherit
157
+ to: qualified
158
+ - kind: element
159
+ name:
160
+ - plain
161
+ namespace:
162
+ mode: unqualified
163
+ to: plain
164
+ model: LmlPreservation::Namespaces
165
+ register: default
166
+ LmlPreservation::Ordered@default:
167
+ attributes:
168
+ - collection:
169
+ max:
170
+ min: 0
171
+ default:
172
+ present: false
173
+ initialize_empty: false
174
+ name: a
175
+ required: false
176
+ type:
177
+ kind: builtin
178
+ name: string
179
+ - collection:
180
+ max:
181
+ min: 0
182
+ default:
183
+ present: false
184
+ initialize_empty: false
185
+ name: b
186
+ required: false
187
+ type:
188
+ kind: builtin
189
+ name: string
190
+ lml: 2
191
+ mappings:
192
+ xml:
193
+ namespace:
194
+ mode: inherit
195
+ root:
196
+ element: ordered
197
+ rules:
198
+ - kind: element
199
+ name:
200
+ - a
201
+ namespace:
202
+ mode: inherit
203
+ to: a
204
+ - kind: element
205
+ name:
206
+ - b
207
+ namespace:
208
+ mode: inherit
209
+ to: b
210
+ model: LmlPreservation::Ordered
211
+ ordered_content:
212
+ member: __lml_content
213
+ version: 1
214
+ register: default
215
+ LmlPreservation::States@default:
216
+ attributes:
217
+ - collection: false
218
+ default:
219
+ present: false
220
+ initialize_empty: false
221
+ name: value
222
+ required: false
223
+ type:
224
+ kind: builtin
225
+ name: string
226
+ - collection: false
227
+ default:
228
+ present: true
229
+ value: default
230
+ initialize_empty: false
231
+ name: fallback
232
+ required: false
233
+ type:
234
+ kind: builtin
235
+ name: string
236
+ - collection:
237
+ max:
238
+ min: 0
239
+ default:
240
+ present: false
241
+ initialize_empty: true
242
+ name: items
243
+ required: false
244
+ type:
245
+ kind: builtin
246
+ name: string
247
+ lml: 2
248
+ mappings:
249
+ json:
250
+ rules:
251
+ - key:
252
+ - value
253
+ render:
254
+ default: false
255
+ empty: true
256
+ nil: true
257
+ to: value
258
+ - key:
259
+ - fallback
260
+ render:
261
+ default: true
262
+ to: fallback
263
+ - key:
264
+ - items
265
+ render:
266
+ empty: true
267
+ to: items
268
+ model: LmlPreservation::States
269
+ register: default
270
+ LmlPreservation::TypedEnum@default:
271
+ attributes:
272
+ - collection: false
273
+ default:
274
+ present: false
275
+ initialize_empty: false
276
+ name: number
277
+ required: false
278
+ type:
279
+ kind: builtin
280
+ name: integer
281
+ values:
282
+ - 1
283
+ - 2
284
+ - collection: false
285
+ default:
286
+ present: false
287
+ initialize_empty: false
288
+ name: flag
289
+ required: false
290
+ type:
291
+ kind: builtin
292
+ name: boolean
293
+ values:
294
+ - true
295
+ - false
296
+ lml: 2
297
+ mappings:
298
+ json:
299
+ rules:
300
+ - key:
301
+ - number
302
+ to: number
303
+ - key:
304
+ - flag
305
+ to: flag
306
+ model: LmlPreservation::TypedEnum
307
+ register: default
308
+ provenance:
309
+ source_revision: 8a8ef040963b7965388b01b58af33af2b0995f91
310
+ roots:
311
+ - LmlPreservation::Bounded@default
312
+ - LmlPreservation::Cdata@default
313
+ - LmlPreservation::Imported@oracle
314
+ - LmlPreservation::Mixed@default
315
+ - LmlPreservation::Namespaces@default
316
+ - LmlPreservation::Ordered@default
317
+ - LmlPreservation::States@default
318
+ - LmlPreservation::TypedEnum@default
319
+ value_types: {}
@@ -0,0 +1,153 @@
1
+ # rubocop:disable all
2
+ require "json"
3
+ require "lutaml/model"
4
+ require "lutaml/model/lml"
5
+ V = Lutaml::Model::Lml
6
+ DV = V::DocumentValidator
7
+ STR = {"kind"=>"builtin","name"=>"string"}
8
+ def attr(name = "x") = {"name"=>name,"type"=>STR}
9
+ def doc(attrs: [attr], mappings: nil)
10
+ d = {"lml"=>2,"model"=>"A","register"=>"default","attributes"=>attrs}
11
+ d["mappings"] = mappings if mappings
12
+ d
13
+ end
14
+ def xml(m) = doc(mappings: {"xml"=>m})
15
+ def rule(r) = xml({"rules"=>[{"kind"=>"element","name"=>["a"],"to"=>"x"}.merge(r)]})
16
+ def nest(n, leaf = "x") = (1..n).inject(leaf) { |acc, _| [acc] }
17
+ def bundle(extra = {}) = {"lml_bundle"=>1,"roots"=>[],"models"=>{},"value_types"=>{},"capabilities"=>[]}.merge(extra)
18
+
19
+ cases = []
20
+ add = ->(name, kind, text) { cases << { "name"=>name, "kind"=>kind, "input"=>text } }
21
+ j = ->(h) { JSON.generate(h, max_nesting: false) }
22
+
23
+ add.("valid_control", "document", j.(doc))
24
+ ["foo?","foo!","foo=","1a","Abc","a-b","a b","aé"].each { |n| add.("name_#{n}", "document", j.(doc(attrs: [attr(n)]))) }
25
+ %w[_x aB9 display hash schema_location send freeze].each { |n| add.("name_ok_#{n}", "document", j.(doc(attrs: [attr("ok"), attr(n)]))) }
26
+ DV::RESERVED_ATTRIBUTE_NAMES.each { |n| add.("reserved_#{n}", "document", j.(doc(attrs: [attr("ok"), attr(n)]))) }
27
+ add.("name_empty", "document", j.(doc(attrs: [attr("")])))
28
+ add.("name_ordered_content", "document", j.(doc(attrs: [attr("__lml_content")])))
29
+
30
+ add.("root_string", "document", j.(xml({"root"=>"a"})))
31
+ add.("root_array", "document", j.(xml({"root"=>[]})))
32
+ add.("root_null", "document", j.(xml({"root"=>nil})))
33
+ add.("root_ok", "document", j.(xml({"root"=>{"element"=>"a","mixed"=>true}})))
34
+ add.("root_element_empty", "document", j.(xml({"root"=>{"element"=>""}})))
35
+ add.("root_element_number", "document", j.(xml({"root"=>{"element"=>5}})))
36
+ add.("root_mixed_string", "document", j.(xml({"root"=>{"element"=>"a","mixed"=>"yes"}})))
37
+ add.("root_mixed_number", "document", j.(xml({"root"=>{"element"=>"a","mixed"=>1}})))
38
+ add.("json_root_mixed_string", "document", j.(doc(mappings: {"json"=>{"root"=>{"mixed"=>"no"}}})))
39
+ %w[child_mappings root_mappings].each do |k|
40
+ add.("mapping_#{k}_array", "document", j.(xml({k=>[]})))
41
+ add.("mapping_#{k}_string", "document", j.(xml({k=>"x"})))
42
+ add.("mapping_#{k}_ok", "document", j.(xml({k=>{"a"=>"b"}})))
43
+ add.("rule_#{k}_array", "document", j.(rule({k=>[]})))
44
+ add.("rule_#{k}_null", "document", j.(rule({k=>nil})))
45
+ add.("rule_#{k}_ok", "document", j.(rule({k=>{"a"=>"b"}})))
46
+ end
47
+ add.("rule_cdata_string", "document", j.(rule({"cdata"=>"true"})))
48
+ add.("rule_cdata_null", "document", j.(rule({"cdata"=>nil})))
49
+ add.("rule_cdata_ok", "document", j.(rule({"cdata"=>true})))
50
+ [["1a"],[""],["a b"],[5],["a:b"],[nil]].each do |(p)|
51
+ ns = {"mode"=>"uri","uri"=>"urn:x","prefix"=>p}
52
+ add.("prefix_#{p.inspect}_mapping", "document", j.(xml({"namespace"=>ns})))
53
+ add.("prefix_#{p.inspect}_rule", "document", j.(rule({"namespace"=>ns})))
54
+ end
55
+ %w[a _a A1 a.b-c_d xml].each { |p| add.("prefix_ok_#{p}", "document", j.(xml({"namespace"=>{"mode"=>"uri","uri"=>"urn:x","prefix"=>p}}))) }
56
+
57
+ # typed defaults: a present default must match its builtin type.
58
+ INT = {"kind"=>"builtin","name"=>"integer"}
59
+ BOOL = {"kind"=>"builtin","name"=>"boolean"}
60
+ def dflt(type, value) = doc(attrs: [attr.merge("type"=>type, "default"=>{"present"=>true,"value"=>value})])
61
+ add.("default_int_on_string", "document", j.(dflt(STR, 5)))
62
+ add.("default_string_on_integer", "document", j.(dflt(INT, "5")))
63
+ add.("default_string_on_boolean", "document", j.(dflt(BOOL, "true")))
64
+ add.("default_array_on_string", "document", j.(dflt(STR, ["x"])))
65
+ add.("default_ok_integer", "document", j.(dflt(INT, 5)))
66
+ add.("default_ok_boolean", "document", j.(dflt(BOOL, false)))
67
+
68
+ # One accept and one refuse vector per builtin type. The accept values are
69
+ # what Lml.export_bundle writes (measured); the refuse values are the wrong
70
+ # JSON shape. qname is a plain string (never a {namespace, local} object) and
71
+ # every builtin but the integers (integer, positive_integer, non_negative_integer), boolean, float and hash is shape-checked only: the
72
+ # exporter passes a user's string through verbatim, so "abc" on a decimal is
73
+ # accepted (typed_default_ok_decimal_not_lexical).
74
+ TYPED_DEFAULTS = {
75
+ "string"=>["s", 5], "token"=>["t", 5], "uri"=>["http://x/", 5], "email"=>["a@b.c", 5],
76
+ "hostname"=>["h.example", 5], "ip"=>["1.2.3.4", 5], "boolean"=>[true, "true"], "integer"=>[5, "5"],
77
+ "decimal"=>["1.5", true], "float"=>["1.5", 1.5], "rational"=>["1/2", true], "date"=>["2020-01-02", 20200102],
78
+ "time"=>["2020-01-02T03:04:05Z", 3], "date_time"=>["2020-01-02T03:04:05+00:00", 3],
79
+ "time_without_date"=>["03:04:05", 3], "duration"=>["P1D", 1],
80
+ "qname"=>["a:b", {"namespace"=>"urn:x","local"=>"a"}], "base64_binary"=>["aGk=", 1],
81
+ "hex_binary"=>["6869", 1], "symbol"=>["sym", 1], "hash"=>[{"a"=>1}, "x"],
82
+ "email_address"=>["a@b.c", 5], "ip_v4_address"=>["1.2.3.4", 5], "ip_v6_address"=>["::1", 5],
83
+ "uuid"=>["123e4567-e89b-12d3-a456-426614174000", 5], "reference"=>["r1", 5], "uri_reference"=>["a/b#c", 5],
84
+ "date_with_timezone"=>["2020-01-02+05:00", 20200102], "date_time_with_timezone"=>["2020-01-02T03:04:05+05:00", 3],
85
+ "day_time_duration"=>["P1D", 1], "year_month_duration"=>["P1Y", 1],
86
+ "positive_integer"=>[5, "5"], "non_negative_integer"=>[0, "0"],
87
+ "g_year"=>["2020", 5], "g_year_month"=>["2020-01", 5], "g_month"=>["--01", 5],
88
+ "g_month_day"=>["--01-02", 5], "g_day"=>["---02", 5], "idrefs"=>["a b", 5], "nmtokens"=>["a b", 5]
89
+ }
90
+ raise "update TYPED_DEFAULTS" unless TYPED_DEFAULTS.keys.sort == DV::BUILTIN_TYPES.sort
91
+ TYPED_DEFAULTS.each do |type, (ok, bad)|
92
+ t = {"kind"=>"builtin","name"=>type}
93
+ add.("typed_default_ok_#{type}", "document", j.(dflt(t, ok)))
94
+ add.("typed_default_refused_#{type}", "document", j.(dflt(t, bad)))
95
+ end
96
+ add.("typed_default_ok_decimal_not_lexical", "document", j.(dflt({"kind"=>"builtin","name"=>"decimal"}, "abc")))
97
+
98
+ # What the exporter refuses (so no bundle carries these): an integer beyond
99
+ # +-(2**53 - 1), a float collection, a null float default, a JSON float
100
+ # inside a hash default. The validator refuses the same inputs.
101
+ add.("typed_default_ok_integer_max_safe", "document", j.(dflt(INT, 9007199254740991)))
102
+ add.("typed_default_ok_integer_min_safe", "document", j.(dflt(INT, -9007199254740991)))
103
+ add.("typed_default_refused_integer_2_53", "document", j.(dflt(INT, 9007199254740992)))
104
+ add.("typed_default_refused_integer_negative_2_53", "document", j.(dflt(INT, -9007199254740992)))
105
+ FLT = {"kind"=>"builtin","name"=>"float"}
106
+ coll = {"min"=>0,"max"=>nil}
107
+ add.("typed_default_refused_float_collection", "document",
108
+ j.(doc(attrs: [attr.merge("type"=>FLT, "collection"=>coll, "default"=>{"present"=>true,"value"=>["1.5","2.5"]})])))
109
+ add.("typed_default_refused_float_empty_collection", "document",
110
+ j.(doc(attrs: [attr.merge("type"=>FLT, "collection"=>coll, "default"=>{"present"=>true,"value"=>[]})])))
111
+ add.("typed_default_refused_float_null", "document", j.(dflt(FLT, nil)))
112
+ add.("typed_default_refused_hash_with_json_float", "document", j.(dflt({"kind"=>"builtin","name"=>"hash"}, {"a"=>1.5})))
113
+
114
+ # depth: root is level 1. Pad inside provenance (bundle) / default.value (document).
115
+ def deep_doc(levels)
116
+ # levels: total container levels. root(1)+attributes(2)+attr(3)+default(4)=4, value nest adds the rest
117
+ # The attribute is a hash so a nested default is well typed: {"v"=>...} is one level.
118
+ extra = levels - 4
119
+ hash_type = {"kind"=>"builtin","name"=>"hash"}
120
+ doc(attrs: [attr.merge("type"=>hash_type, "default"=>{"present"=>true,"value"=>{"v"=>nest(extra - 1)}})])
121
+ end
122
+ [99, 100, 101].each { |n| add.("doc_depth_#{n}", "document", j.(deep_doc(n))) }
123
+ def deep_bundle(levels)
124
+ bundle("provenance"=>{"p"=>nest(levels - 2)})
125
+ end
126
+ [99, 100, 101].each { |n| add.("bundle_depth_#{n}", "bundle", JSON.generate(deep_bundle(n), max_nesting: false)) }
127
+
128
+ # duplicate keys (text-level)
129
+ base = JSON.generate(bundle)
130
+ add.("dup_top", "bundle", base.sub(/\}\z/, ',"roots":[]}'))
131
+ add.("dup_escaped", "bundle", base.sub(/\}\z/, ',"roots":[]}'))
132
+ add.("dup_nested", "bundle", base.sub('"models":{}', '"models":{"A@d":{"lml":2},"A@d":{"lml":2}}'))
133
+ add.("dup_provenance", "bundle", base.sub(/\}\z/, ',"provenance":{"a":1,"a":2}}'))
134
+ add.("dup_in_array", "bundle", base.sub(/\}\z/, ',"provenance":{"l":[{"k":1,"k":2}]}}'))
135
+ add.("dup_none_same_key_different_objects", "bundle", base.sub(/\}\z/, ',"provenance":{"l":[{"k":1},{"k":2}],"m":{"k":3}}}'))
136
+ add.("dup_string_value_not_key", "bundle", base.sub(/\}\z/, ',"provenance":{"a":"b","c":"a"}}'))
137
+
138
+ out = cases.map do |c|
139
+ exp =
140
+ begin
141
+ case c["kind"]
142
+ when "document" then DV.validate!(JSON.parse(c["input"], max_nesting: false), kind: :document)
143
+ else V::Importer.bundle(c["input"])
144
+ end
145
+ nil
146
+ rescue V::RejectedError => e
147
+ { "reason"=>e.reason.to_s, "location"=>e.location, "detail"=>e.detail }
148
+ end
149
+ c.merge("expect"=>exp)
150
+ end
151
+ File.binwrite(ARGV[0], JSON.pretty_generate(out) + "\n")
152
+ puts out.count { |c| c["expect"] }, out.size
153
+ out.each { |c| puts "#{c['name']}: #{c['expect']&.values_at('reason','location').inspect}" } if ENV["V"]