lutaml-model 0.8.201 → 0.8.202
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/.github/scripts/test_installed_gem.rb +1 -13
- data/.github/workflows/downstream-performance.yml +1 -22
- data/.github/workflows/performance.yml +1 -33
- data/.github/workflows/rake.yml +2 -6
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -4
- data/Gemfile +0 -23
- data/README.adoc +25 -86
- data/Rakefile +2 -167
- data/docs/_guides/advanced-mapping.adoc +6 -6
- data/docs/_guides/character-encoding.adoc +0 -3
- data/docs/_guides/gem-integration.adoc +1 -1
- data/docs/_guides/index.adoc +0 -4
- data/docs/_guides/xml/type-namespaces.adoc +1 -1
- data/docs/_guides/xml-guide-0.8.0.adoc +2 -2
- data/docs/_guides/xml-namespaces.adoc +2 -3
- data/docs/_guides/xml_mappings/03_architecture.adoc +2 -2
- data/docs/_guides/xml_mappings/07_best_practices.adoc +2 -3
- data/docs/_guides/xml_mappings/08_troubleshooting.adoc +1 -9
- data/docs/_pages/comparison-with-shale.adoc +1 -1
- data/docs/_pages/configuration.adoc +6 -40
- data/docs/_pages/index.adoc +0 -1
- data/docs/_pages/serialization_adapters.adoc +4 -16
- data/docs/_references/architecture.adoc +1 -1
- data/docs/_references/lutaml-namespace-planning.md +1 -1
- data/docs/_references/three-phase-namespace-architecture.adoc +1 -2
- data/docs/_references/xsd-generation-with-namespace-support.adoc +3 -8
- data/docs/_tutorials/lutaml-xml-architecture.adoc +2 -8
- data/docs/architecture.md +7 -11
- data/docs/conversion_caching.adoc +1 -1
- data/docs/index.adoc +0 -1
- data/docs/key_value_data_model.adoc +1 -1
- data/docs/namespace-management.adoc +4 -10
- data/lib/lutaml/json/format.rb +0 -1
- data/lib/lutaml/json/generator_options.rb +0 -1
- data/lib/lutaml/key_value/transform.rb +9 -16
- data/lib/lutaml/lml/document_builder.rb +2 -2
- data/lib/lutaml/lml/entity_types.rb +2 -2
- data/lib/lutaml/model/adapter_resolver.rb +5 -15
- data/lib/lutaml/model/cached_type_resolver.rb +1 -7
- data/lib/lutaml/model/error/unknown_adapter_type_error.rb +1 -1
- data/lib/lutaml/model/global_context.rb +3 -5
- data/lib/lutaml/model/instrumentation.rb +0 -3
- data/lib/lutaml/model/mapping/mapping_rule.rb +6 -10
- data/lib/lutaml/model/register.rb +20 -31
- data/lib/lutaml/model/runtime_compatibility.rb +0 -92
- data/lib/lutaml/model/schema/class_loader.rb +2 -4
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/simple_types.rb +2 -3
- data/lib/lutaml/model/serialize/attribute_definition.rb +10 -184
- data/lib/lutaml/model/serialize/conversion_caching.rb +1 -5
- data/lib/lutaml/model/serialize/model_import.rb +0 -5
- data/lib/lutaml/model/serialize/value_mapping.rb +0 -3
- data/lib/lutaml/model/services/rule_value_extractor.rb +4 -7
- data/lib/lutaml/model/store.rb +10 -17
- data/lib/lutaml/model/toml.rb +0 -2
- data/lib/lutaml/model/transformation_registry.rb +3 -7
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model.rb +3 -19
- data/lib/lutaml/toml/format.rb +4 -8
- data/lib/lutaml/xml/adapter/moxml_adapter.rb +1 -7
- data/lib/lutaml/xml/adapter.rb +0 -4
- data/lib/lutaml/xml/adapter_loader.rb +1 -6
- data/lib/lutaml/xml/builder/base.rb +0 -3
- data/lib/lutaml/xml/builder.rb +0 -8
- data/lib/lutaml/xml/data_model.rb +1 -1
- data/lib/lutaml/xml/doctype_extractor.rb +3 -3
- data/lib/lutaml/xml/format.rb +22 -74
- data/lib/lutaml/xml/leptris/plan_compiler.rb +1 -2
- data/lib/lutaml/xml/model_transform.rb +14 -24
- data/lib/lutaml/xml/polymorphic_value_handler.rb +1 -1
- data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
- data/lib/lutaml/xml/schema/builder.rb +6 -9
- data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
- data/lib/lutaml/xml/xml_element.rb +3 -2
- data/lib/lutaml/xml/xsd_validator.rb +4 -11
- data/lib/lutaml/yaml/adapter/yeptris_adapter.rb +2 -2
- data/lib/lutaml/yamls/adapter_loader.rb +1 -5
- data/lib/tasks/performance_comparator.rb +1 -1
- data/lutaml-model.gemspec +3 -8
- data/spec/benchmarks/xml_parsing_benchmark_spec.rb +1 -1
- data/spec/lutaml/json/adapter/standard_adapter_spec.rb +6 -9
- data/spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb +0 -2
- data/spec/lutaml/model/cached_type_resolver_spec.rb +2 -54
- data/spec/lutaml/model/cdata_spec.rb +2 -15
- data/spec/lutaml/model/encoding_spec.rb +0 -9
- data/spec/lutaml/model/except_spec.rb +0 -7
- data/spec/lutaml/model/json_spec.rb +0 -14
- data/spec/lutaml/model/mixed_content_spec.rb +6 -46
- data/spec/lutaml/model/ordered_content_spec.rb +0 -7
- data/spec/lutaml/model/processing_instruction_spec.rb +0 -6
- data/spec/lutaml/model/runtime_compatibility_spec.rb +0 -37
- data/spec/lutaml/model/serializable_spec.rb +0 -2
- data/spec/lutaml/model/toml_spec.rb +0 -23
- data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +0 -4
- data/spec/lutaml/xml/adapter/order_spec.rb +1 -1
- data/spec/lutaml/xml/adapter/xml_namespace_spec.rb +0 -7
- data/spec/lutaml/xml/attribute_namespace_disjointness_spec.rb +6 -6
- data/spec/lutaml/xml/builder/builder_spec.rb +0 -24
- data/spec/lutaml/xml/default_namespace_spec.rb +1 -8
- data/spec/lutaml/xml/doctype_preservation_spec.rb +0 -4
- data/spec/lutaml/xml/entity_fragmentation_spec.rb +0 -6
- data/spec/lutaml/xml/fpi_namespace_spec.rb +0 -21
- data/spec/lutaml/xml/mapping_spec.rb +8 -15
- data/spec/lutaml/xml/namespace_scope_vcard_spec.rb +0 -7
- data/spec/lutaml/xml/namespace_spec.rb +0 -13
- data/spec/lutaml/xml/prefix_control_spec.rb +0 -6
- data/spec/lutaml/xml/schema/builder_moxml_spec.rb +1 -1
- data/spec/lutaml/xml/xml_adapter_spec.rb +0 -7
- data/spec/lutaml/xml/xml_spec.rb +2 -88
- data/spec/spec_helper.rb +5 -24
- data/spec/support/test_adapter_config.rb +6 -6
- metadata +1 -32
- data/.github/workflows/js-pr-check.yml +0 -106
- data/.github/workflows/js-sync.yml +0 -55
- data/.github/workflows/opal.yml +0 -65
- data/.gitmodules +0 -6
- data/.rspec-opal +0 -5
- data/docs/_guides/opal.adoc +0 -232
- data/lib/compat/opal/generate_boot.rb +0 -137
- data/lib/compat/opal/js_bundle_entry.rb +0 -42
- data/lib/compat/opal/lutaml_model_boot.rb +0 -638
- data/lib/compat/opal/monitor.rb +0 -31
- data/lib/compat/opal/moxml/adapter/customized_rexml/entity_reference.rb +0 -9
- data/lib/compat/opal/moxml/adapter/customized_rexml/formatter.rb +0 -225
- data/lib/compat/opal/moxml/adapter/customized_rexml.rb +0 -11
- data/lib/compat/opal/moxml_boot.rb +0 -68
- data/lib/compat/opal/objectspace_shim.rb +0 -23
- data/lib/compat/opal/rexml/namespace.rb +0 -59
- data/lib/compat/opal/rexml/parsers/baseparser.rb +0 -1016
- data/lib/compat/opal/rexml/source.rb +0 -214
- data/lib/compat/opal/rexml/text.rb +0 -426
- data/lib/compat/opal/rexml/xmltokens.rb +0 -45
- data/lib/compat/opal/rexml_compat.rb +0 -85
- data/lib/compat/opal/yaml_compat.rb +0 -32
- data/lib/lutaml/model/cached_type_resolver/mutex_hash_cache.rb +0 -53
- data/lib/lutaml/model/schema/schema_builder/oga.rb +0 -92
- data/lib/lutaml/xml/schema/builder/oga.rb +0 -92
- data/spec/lutaml/model/boot_manifest_spec.rb +0 -30
- data/spec/lutaml/model/opal_smoke_spec.rb +0 -199
- data/spec/lutaml/model/serialize/attribute_definition_block_form_spec.rb +0 -244
- data/spec/lutaml/xml/adapter/oga_adapter_spec.rb +0 -135
- data/spec/lutaml/xml/opal_xml_spec.rb +0 -204
- data/spec/support/opal.rb +0 -9
|
@@ -383,20 +383,20 @@ NOTE: For `NokogiriAdapter`, we can also call `to_xml` on `value.node.adapter_no
|
|
|
383
383
|
# @namespace_prefix=nil,
|
|
384
384
|
# @text=nil>
|
|
385
385
|
|
|
386
|
-
#
|
|
386
|
+
# Adapter Node
|
|
387
387
|
|
|
388
|
-
# <Lutaml::
|
|
388
|
+
# <Lutaml::Xml::AdapterElement:0x0000000107314158
|
|
389
389
|
# @attributes={},
|
|
390
390
|
# @children=
|
|
391
|
-
# [#<Lutaml::
|
|
392
|
-
# #<Lutaml::
|
|
391
|
+
# [#<Lutaml::Xml::AdapterElement:0x0000000107314090 @attributes={}, @children=[], @default_namespace=nil, @name="text", @namespace_prefix=nil, @text="\n ">,
|
|
392
|
+
# #<Lutaml::Xml::AdapterElement:0x000000010730fe78
|
|
393
393
|
# @attributes={},
|
|
394
|
-
# @children=[#<Lutaml::
|
|
394
|
+
# @children=[#<Lutaml::Xml::AdapterElement:0x000000010730fd88 @attributes={}, @children=[], @default_namespace=nil, @name="text", @namespace_prefix=nil, @text="Metadata">],
|
|
395
395
|
# @default_namespace=nil,
|
|
396
396
|
# @name="category",
|
|
397
397
|
# @namespace_prefix=nil,
|
|
398
398
|
# @text="Metadata">,
|
|
399
|
-
# #<Lutaml::
|
|
399
|
+
# #<Lutaml::Xml::AdapterElement:0x000000010730f8d8 @attributes={}, @children=[], @default_namespace=nil, @name="text", @namespace_prefix=nil, @text="\n ">],
|
|
400
400
|
# @default_namespace=nil,
|
|
401
401
|
# @name="metadata",
|
|
402
402
|
# @namespace_prefix=nil,
|
|
@@ -25,9 +25,6 @@ on the adapter used.
|
|
|
25
25
|
** Nokogiri: `UTF-8`. The encoding is set to the default encoding of the Nokogiri library,
|
|
26
26
|
which is `UTF-8`.
|
|
27
27
|
|
|
28
|
-
** Oga: `UTF-8`. The encoding is set to the default encoding of the Oga library, which
|
|
29
|
-
uses `UTF-8`.
|
|
30
|
-
|
|
31
28
|
** Ox: `ASCII-8bit`. The encoding is set to the default encoding of the Ox library, which uses
|
|
32
29
|
`ASCII-8bit`.
|
|
33
30
|
|
|
@@ -18,7 +18,7 @@ compatible engines) cover a working default everywhere.
|
|
|
18
18
|
spec.add_dependency "lutaml-model", "~> 0.8"
|
|
19
19
|
----
|
|
20
20
|
|
|
21
|
-
Do not add Nokogiri, Ox,
|
|
21
|
+
Do not add Nokogiri, Ox, leptris, yeptris, or teptris to your
|
|
22
22
|
gemspec. All engines are optional at runtime:
|
|
23
23
|
|
|
24
24
|
* when an engine gem is in the end user's bundle, the matching
|
data/docs/_guides/index.adoc
CHANGED
|
@@ -62,10 +62,6 @@ See link:../references/rdf-namespaces[RDF Namespaces] for namespace classes,
|
|
|
62
62
|
* link:../consolidation-mapping[Consolidation Mapping] - Group sibling elements into structured models
|
|
63
63
|
* link:../document-validation[Document Validation] - Document-level validation with rules, profiles, and remediation
|
|
64
64
|
|
|
65
|
-
== Runtime environments
|
|
66
|
-
|
|
67
|
-
* link:../opal[Opal Usage Guide] - Run Lutaml::Model in the browser via Opal (Ruby to JavaScript)
|
|
68
|
-
|
|
69
65
|
== By task
|
|
70
66
|
|
|
71
67
|
=== I want to serialize to XML
|
|
@@ -958,7 +958,7 @@ As of Session 197 (2026-01-01), Type namespace handling follows the "Dumb Adapte
|
|
|
958
958
|
|
|
959
959
|
This architecture ensures:
|
|
960
960
|
|
|
961
|
-
* **Consistency**: Same logic across all adapters (Nokogiri,
|
|
961
|
+
* **Consistency**: Same logic across all adapters (Nokogiri, Ox)
|
|
962
962
|
* **Testability**: Planning and rendering can be tested independently
|
|
963
963
|
* **Maintainability**: Type namespace features added in one place only
|
|
964
964
|
* **No Duplication**: xmlns filtering prevents redundant declarations
|
|
@@ -740,7 +740,7 @@ IMPORTANT: The `prefix:` option only affects qualified elements. Unqualified ele
|
|
|
740
740
|
|
|
741
741
|
=== Overview
|
|
742
742
|
|
|
743
|
-
Lutaml::Model 0.8.0 implements a sophisticated three-phase namespace architecture that ensures optimal xmlns declarations while maintaining W3C XML Namespace compliance across all XML adapters (Nokogiri, Ox
|
|
743
|
+
Lutaml::Model 0.8.0 implements a sophisticated three-phase namespace architecture that ensures optimal xmlns declarations while maintaining W3C XML Namespace compliance across all XML adapters (Nokogiri, Ox).
|
|
744
744
|
|
|
745
745
|
This architecture guarantees consistent namespace behavior regardless of which underlying XML library is used.
|
|
746
746
|
|
|
@@ -854,7 +854,7 @@ All XML adapters use the three-phase architecture via consistent interfaces:
|
|
|
854
854
|
**Consistency guarantees**:
|
|
855
855
|
|
|
856
856
|
* **Same model + same options = same XML**: Deterministic output
|
|
857
|
-
* **Adapter-independent**: Nokogiri
|
|
857
|
+
* **Adapter-independent**: Nokogiri and Ox produce identical xmlns patterns
|
|
858
858
|
* **W3C compliant**: All output follows XML Namespace specifications
|
|
859
859
|
|
|
860
860
|
=== Benefits
|
|
@@ -284,7 +284,6 @@ All three XML adapters support format preservation:
|
|
|
284
284
|
|
|
285
285
|
* **Nokogiri** - Full support ✅
|
|
286
286
|
* **Ox** - Full support ✅
|
|
287
|
-
* **Oga** - Full support ✅
|
|
288
287
|
|
|
289
288
|
|
|
290
289
|
==== Elements in blank namespace
|
|
@@ -349,7 +348,7 @@ Per W3C XML Namespace specification, unprefixed elements normally inherit their
|
|
|
349
348
|
parent's default namespace. The `xmlns=""` declaration explicitly removes that
|
|
350
349
|
inheritance.
|
|
351
350
|
|
|
352
|
-
**Parsing support**: All three adapters (Nokogiri, Ox
|
|
351
|
+
**Parsing support**: All three adapters (Nokogiri, Ox) correctly handle both patterns.
|
|
353
352
|
====
|
|
354
353
|
|
|
355
354
|
[[namespace-priority-system]]
|
|
@@ -2460,7 +2459,7 @@ declarations.
|
|
|
2460
2459
|
|
|
2461
2460
|
When you parse XML that has an FPI in a namespace position, the parsing will succeed
|
|
2462
2461
|
because the underlying XML parser can store the value. However, when serializing back to XML,
|
|
2463
|
-
the underlying parser (Nokogiri,
|
|
2462
|
+
the underlying parser (Nokogiri, Ox, REXML) will reject the FPI as an invalid
|
|
2464
2463
|
namespace URI:
|
|
2465
2464
|
|
|
2466
2465
|
[source]
|
|
@@ -96,7 +96,7 @@ parent: XML Mappings Guide
|
|
|
96
96
|
│ ▼ │
|
|
97
97
|
│ ┌───────────────────────────────────────────────────────────┐ │
|
|
98
98
|
│ │ Schema::SchemaBuilder │ │
|
|
99
|
-
│ │ Adapters: Nokogiri
|
|
99
|
+
│ │ Adapters: Nokogiri │ │
|
|
100
100
|
│ └───────────────────────────────────────────────────────────┘ │
|
|
101
101
|
│ │
|
|
102
102
|
└───────────────────────────────────────────────────────────────────┘
|
|
@@ -202,4 +202,4 @@ generation engine that infers element/type structure and applies namespace
|
|
|
202
202
|
metadata.
|
|
203
203
|
|
|
204
204
|
`Schema::SchemaBuilder`::
|
|
205
|
-
Adapter-based XSD serialization supporting Nokogiri
|
|
205
|
+
Adapter-based XSD serialization supporting Nokogiri.
|
|
@@ -723,15 +723,14 @@ end
|
|
|
723
723
|
|
|
724
724
|
* **Ox**: Fastest, use for performance-critical applications
|
|
725
725
|
* **Nokogiri**: Most compatible, good balance
|
|
726
|
-
* **
|
|
727
|
-
* **REXML**: Pure Ruby (bundled with Ruby), Opal-compatible
|
|
726
|
+
* **REXML**: Pure Ruby (bundled with Ruby)
|
|
728
727
|
|
|
729
728
|
**Configure once:**
|
|
730
729
|
|
|
731
730
|
[source,ruby]
|
|
732
731
|
----
|
|
733
732
|
Lutaml::Model::Config.configure do |config|
|
|
734
|
-
config.xml_adapter_type = :ox # or :nokogiri
|
|
733
|
+
config.xml_adapter_type = :ox # or :nokogiri
|
|
735
734
|
end
|
|
736
735
|
----
|
|
737
736
|
|
|
@@ -283,7 +283,7 @@ Configure XML adapter before use:
|
|
|
283
283
|
----
|
|
284
284
|
# Add this to your initialization code
|
|
285
285
|
Lutaml::Model::Config.configure do |config|
|
|
286
|
-
config.xml_adapter_type = :nokogiri # or :ox
|
|
286
|
+
config.xml_adapter_type = :nokogiri # or :ox
|
|
287
287
|
end
|
|
288
288
|
----
|
|
289
289
|
|
|
@@ -782,10 +782,6 @@ Lutaml::Model::Config.configure do |config|
|
|
|
782
782
|
config.xml_adapter_type = :nokogiri
|
|
783
783
|
end
|
|
784
784
|
|
|
785
|
-
# Oga is pure Ruby (slowest but no native deps)
|
|
786
|
-
Lutaml::Model::Config.configure do |config|
|
|
787
|
-
config.xml_adapter_type = :oga
|
|
788
|
-
end
|
|
789
785
|
----
|
|
790
786
|
|
|
791
787
|
=== Large memory usage
|
|
@@ -905,10 +901,6 @@ Install required gem:
|
|
|
905
901
|
gem install ox
|
|
906
902
|
# or add to Gemfile: gem 'ox'
|
|
907
903
|
|
|
908
|
-
# For Oga
|
|
909
|
-
gem install oga
|
|
910
|
-
# or add to Gemfile: gem 'oga'
|
|
911
|
-
|
|
912
904
|
# Nokogiri usually already installed
|
|
913
905
|
gem install nokogiri
|
|
914
906
|
----
|
|
@@ -53,7 +53,7 @@ A migration guide from Shale to Lutaml::Model is provided at link:../migrations/
|
|
|
53
53
|
|
|
|
54
54
|
|
|
55
55
|
| Adapter support
|
|
56
|
-
| XML (Nokogiri, Ox
|
|
56
|
+
| XML (Nokogiri, Ox), YAML, JSON (JSON, MultiJson), TOML (Toml-rb, Tomlib)
|
|
57
57
|
| XML (Nokogiri, Ox), YAML, JSON (JSON, MultiJson), TOML (Toml-rb, Tomlib), CSV
|
|
58
58
|
| Lutaml::Model does not support CSV.
|
|
59
59
|
|
|
@@ -22,7 +22,7 @@ The auto-detection order for each format:
|
|
|
22
22
|
[cols="1,2",options="header"]
|
|
23
23
|
|===
|
|
24
24
|
| Format | Detection order
|
|
25
|
-
| XML | `:nokogiri` → `:ox` → `:
|
|
25
|
+
| XML | `:nokogiri` → `:ox` → `:rexml`
|
|
26
26
|
| TOML | `:teptris` → `:tomlib` → `:toml_rb` (Windows: `:teptris` → `:toml_rb`)
|
|
27
27
|
| JSON | `:standard` (always available)
|
|
28
28
|
| YAML | `:standard` (always available)
|
|
@@ -70,11 +70,8 @@ When an adapter is needed for a format, `AdapterResolver` follows this chain:
|
|
|
70
70
|
| `:ox`
|
|
71
71
|
| Fastest performance. Native C extensions.
|
|
72
72
|
|
|
73
|
-
| `:oga`
|
|
74
|
-
| Pure Ruby. No compilation needed. Opal-compatible.
|
|
75
|
-
|
|
76
73
|
| `:rexml`
|
|
77
|
-
| Pure Ruby. Bundled with Ruby (default gem).
|
|
74
|
+
| Pure Ruby. Bundled with Ruby (default gem).
|
|
78
75
|
|===
|
|
79
76
|
|
|
80
77
|
=== JSON adapters
|
|
@@ -167,7 +164,7 @@ TIP: `with_adapter` is thread-safe — each thread has its own scope stack. Use
|
|
|
167
164
|
# Instead of this:
|
|
168
165
|
around do |example|
|
|
169
166
|
old = Config.xml_adapter
|
|
170
|
-
Config.xml_adapter_type = :
|
|
167
|
+
Config.xml_adapter_type = :ox
|
|
171
168
|
example.run
|
|
172
169
|
ensure
|
|
173
170
|
Config.xml_adapter = old
|
|
@@ -175,7 +172,7 @@ end
|
|
|
175
172
|
|
|
176
173
|
# Prefer this:
|
|
177
174
|
around do |example|
|
|
178
|
-
Config.with_adapter(xml: :
|
|
175
|
+
Config.with_adapter(xml: :ox) { example.run }
|
|
179
176
|
end
|
|
180
177
|
----
|
|
181
178
|
|
|
@@ -225,7 +222,7 @@ end
|
|
|
225
222
|
|
|
226
223
|
If not explicitly configured, Lutaml::Model auto-detects on first use:
|
|
227
224
|
|
|
228
|
-
* XML: `:nokogiri` if available, else `:ox` → `:
|
|
225
|
+
* XML: `:nokogiri` if available, else `:ox` → `:rexml`
|
|
229
226
|
* JSON: `:standard` (alias: `:standard_json`)
|
|
230
227
|
* YAML: `:standard` (alias: `:standard_yaml`)
|
|
231
228
|
* Hash: `:standard` (alias: `:standard_hash`)
|
|
@@ -264,8 +261,7 @@ end
|
|
|
264
261
|
|
|
265
262
|
* **Nokogiri**: Most projects (default, best compatibility)
|
|
266
263
|
* **Ox**: Performance-critical applications
|
|
267
|
-
* **
|
|
268
|
-
* **REXML**: No extra gems, pure Ruby (bundled with Ruby). Also used under Opal.
|
|
264
|
+
* **REXML**: No extra gems, pure Ruby (bundled with Ruby).
|
|
269
265
|
|
|
270
266
|
=== Choose JSON adapter based on
|
|
271
267
|
|
|
@@ -279,36 +275,6 @@ end
|
|
|
279
275
|
* **Tomlib**: Non-Windows projects without teptris (better performance)
|
|
280
276
|
* **TomlRb**: Windows platforms without teptris (required due to tomlib incompatibility)
|
|
281
277
|
|
|
282
|
-
== Opal runtime compatibility
|
|
283
|
-
|
|
284
|
-
Lutaml::Model supports running under https://opalrb.com[Opal] (Ruby compiled to JavaScript) with some limitations. The library detects the runtime automatically via `Lutaml::Model::RuntimeCompatibility` and adapts its behavior accordingly.
|
|
285
|
-
|
|
286
|
-
The XML parsing layer is provided by the https://github.com/lutaml/moxml[moxml] gem, which has been updated to support Opal. Under Opal, moxml uses the REXML adapter because Opal reimplements `strscan` and `stringio` in its stdlib, enabling REXML (pure Ruby) to compile cleanly to JavaScript.
|
|
287
|
-
|
|
288
|
-
=== Adapter defaults on Opal
|
|
289
|
-
|
|
290
|
-
[cols="1,2",options="header"]
|
|
291
|
-
|===
|
|
292
|
-
| Format | Behavior
|
|
293
|
-
| XML | Only `:rexml` is available (auto-selected). Opal reimplements strscan/stringio in its stdlib, enabling REXML to compile to JavaScript.
|
|
294
|
-
| JSON | Only `:standard` is available. Oj and MultiJson require native extensions.
|
|
295
|
-
| YAML | `:standard` (Psych ships with Opal's stdlib).
|
|
296
|
-
| TOML | **Not available.** Both tomlib and toml-rb depend on native extensions.
|
|
297
|
-
| Hash | `:standard` (pure Ruby).
|
|
298
|
-
|===
|
|
299
|
-
|
|
300
|
-
=== Features unavailable on Opal
|
|
301
|
-
|
|
302
|
-
The following features raise `NotImplementedError` when called under Opal:
|
|
303
|
-
|
|
304
|
-
* `Lutaml::Model::Schema.to_xsd` -- XSD schema generation requires Nokogiri
|
|
305
|
-
* `Lutaml::Model::Schema.to_relaxng` -- RELAX NG generation requires Nokogiri
|
|
306
|
-
* `Lutaml::Model::Schema.from_xml` -- XML schema compilation is not supported
|
|
307
|
-
* `Lutaml::Xml::Schema::Xsd::Base#to_formatted_xml` -- XSD formatted output requires the Canon gem
|
|
308
|
-
* XPath queries -- REXML XPath requires features not yet supported by Opal's stdlib
|
|
309
|
-
|
|
310
|
-
See the link:../guides/opal[Opal Usage Guide] for complete setup instructions and limitations.
|
|
311
|
-
|
|
312
278
|
== See also
|
|
313
279
|
|
|
314
280
|
* link:../serialization_adapters[Serialization Adapters Reference]
|
data/docs/_pages/index.adoc
CHANGED
|
@@ -22,7 +22,6 @@ Fundamental concepts, configuration, and essential features of Lutaml::Model.
|
|
|
22
22
|
* link:breaking-changes[Breaking Changes] - Version compatibility
|
|
23
23
|
* link:comparison-with-shale[Comparison with Shale] - Migration guide
|
|
24
24
|
* link:xml-conformance[XML Standards Conformance] - W3C spec compliance status
|
|
25
|
-
* link:../guides/opal[Opal Usage] - Run in the browser via Opal
|
|
26
25
|
* link:troubleshooting[Troubleshooting] - Common issues and solutions
|
|
27
26
|
|
|
28
27
|
== Getting started
|
|
@@ -47,7 +47,7 @@ more information.
|
|
|
47
47
|
|
|
48
48
|
Adapters are resolved lazily on first use. If no adapter is explicitly configured, `AdapterResolver` probes for available gems in a preferred order:
|
|
49
49
|
|
|
50
|
-
* **XML**: `:nokogiri` → `:ox` → `:
|
|
50
|
+
* **XML**: `:nokogiri` → `:ox` → `:rexml`
|
|
51
51
|
* **TOML**: `:teptris` → `:tomlib` → `:toml_rb` (Windows: `:teptris` → `:toml_rb`)
|
|
52
52
|
* **JSON/YAML/Hash**: `:standard` (always available)
|
|
53
53
|
|
|
@@ -103,7 +103,7 @@ Syntax:
|
|
|
103
103
|
require 'lutaml/model'
|
|
104
104
|
|
|
105
105
|
Lutaml::Model::Config.configure do |config|
|
|
106
|
-
config.xml_adapter = :nokogiri # can be one of [:nokogiri, :ox, :
|
|
106
|
+
config.xml_adapter = :nokogiri # can be one of [:nokogiri, :ox, :rexml]
|
|
107
107
|
config.hash_adapter = :standard
|
|
108
108
|
config.yaml_adapter = :standard
|
|
109
109
|
config.json_adapter = :standard # can be one of [:standard, :multi_json, :oj]
|
|
@@ -189,18 +189,10 @@ Popular `libxml` based XML parser for Ruby.
|
|
|
189
189
|
Requires native extensions (i.e. compiled C code).
|
|
190
190
|
Requires the `nokogiri` gem.
|
|
191
191
|
|
|
192
|
-
Oga::
|
|
193
|
-
(optional, *deprecated*)
|
|
194
|
-
Pure Ruby XML parser.
|
|
195
|
-
Does not require native extensions.
|
|
196
|
-
Requires the `oga` gem.
|
|
197
|
-
|
|
198
192
|
[NOTE]
|
|
199
193
|
====
|
|
200
|
-
The Oga engine
|
|
201
|
-
|
|
202
|
-
Selecting Oga emits a deprecation warning; removal is planned for a
|
|
203
|
-
future release.
|
|
194
|
+
The Oga engine has been removed: `:oga` is no longer a selectable XML
|
|
195
|
+
engine. REXML is the pure-Ruby engine (deprecated).
|
|
204
196
|
====
|
|
205
197
|
|
|
206
198
|
Ox::
|
|
@@ -213,8 +205,6 @@ REXML::
|
|
|
213
205
|
(optional, *deprecated*)
|
|
214
206
|
Pure Ruby XML parser, bundled as a default gem with Ruby.
|
|
215
207
|
Moved from standard library to a default gem in Ruby 3.0.
|
|
216
|
-
Opal-compatible: Opal reimplements `strscan` and `stringio` in its stdlib,
|
|
217
|
-
enabling REXML to compile cleanly to JavaScript.
|
|
218
208
|
Requires the `rexml` gem (bundled with Ruby by default).
|
|
219
209
|
|
|
220
210
|
[NOTE]
|
|
@@ -234,8 +224,6 @@ require 'lutaml/model'
|
|
|
234
224
|
Lutaml::Model::Config.configure do |config|
|
|
235
225
|
config.xml_adapter = :nokogiri
|
|
236
226
|
# or
|
|
237
|
-
config.xml_adapter = :oga
|
|
238
|
-
# or
|
|
239
227
|
config.xml_adapter = :ox
|
|
240
228
|
# or
|
|
241
229
|
config.xml_adapter = :rexml
|
|
@@ -68,7 +68,7 @@ lib/lutaml/model/
|
|
|
68
68
|
|
|
69
69
|
* Pluggable serialization libraries without changing model code
|
|
70
70
|
* `SerializationAdapter` base class
|
|
71
|
-
* Format-specific adapters: Nokogiri, Ox
|
|
71
|
+
* Format-specific adapters: Nokogiri, Ox for XML; JSON, MultiJson, Oj for JSON
|
|
72
72
|
|
|
73
73
|
=== Strategy pattern
|
|
74
74
|
|
|
@@ -105,7 +105,7 @@ If this still feels confusing, think of it like organizing a party: Discovery fi
|
|
|
105
105
|
|
|
106
106
|
This integration ensures the plan "annotates" the data tree without embedding logic in it, aligning with the "dumb adapters" goal—adapters just apply the plan to the data.
|
|
107
107
|
|
|
108
|
-
2. Adapters (e.g., Nokogiri,
|
|
108
|
+
2. Adapters (e.g., Nokogiri, Ox) should traverse the `XmlDataModel` and `DeclarationPlan` trees in parallel (recursively, top-down from root), matching nodes by structure/position rather than lookup. This avoids runtime searches and ensures efficiency:
|
|
109
109
|
|
|
110
110
|
- **For Elements**: Start with `XmlElement` (data) and corresponding `DeclarationPlan::ElementNode` (plan).
|
|
111
111
|
- Create the XML element using `XmlElement#qualified_name(plan.use_prefix)` (applies prefix if set).
|
|
@@ -332,7 +332,7 @@ The `DeclarationPlanner` creates optimal xmlns declaration strategies:
|
|
|
332
332
|
|
|
333
333
|
Applies the plan during XML generation.
|
|
334
334
|
|
|
335
|
-
All XML adapters (Nokogiri,
|
|
335
|
+
All XML adapters (Nokogiri, Ox) use the three-phase architecture:
|
|
336
336
|
|
|
337
337
|
* `build_element_with_plan` - Core element building with namespace plan
|
|
338
338
|
* `build_ordered_element_with_plan` - Ordered content support
|
|
@@ -439,7 +439,6 @@ an optimal declaration strategy:
|
|
|
439
439
|
All XML adapters have been updated to use the three-phase architecture:
|
|
440
440
|
|
|
441
441
|
**NokogiriAdapter** (`lib/lutaml/model/xml/nokogiri_adapter.rb`)
|
|
442
|
-
**OgaAdapter** (`lib/lutaml/model/xml/oga_adapter.rb`)
|
|
443
442
|
**OxAdapter** (`lib/lutaml/model/xml/ox_adapter.rb`)
|
|
444
443
|
|
|
445
444
|
Each adapter implements:
|
|
@@ -60,14 +60,9 @@ both element declaration and type definition
|
|
|
60
60
|
|
|
61
61
|
== Adapter support
|
|
62
62
|
|
|
63
|
-
XSD generation uses SchemaBuilder adapters:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
full XSD 1.0 support
|
|
67
|
-
* `Oga`: Pure Ruby, feature
|
|
68
|
-
complete
|
|
69
|
-
|
|
70
|
-
Both adapters produce identical, standards-compliant XSD output.
|
|
63
|
+
XSD generation uses the SchemaBuilder adapters: the Nokogiri wrapper for
|
|
64
|
+
byte-identical emission, and the moxml layer for every other configured
|
|
65
|
+
engine. Both produce identical, standards-compliant XSD output.
|
|
71
66
|
|
|
72
67
|
== Complete example
|
|
73
68
|
|
|
@@ -239,7 +239,7 @@ This document provides a comprehensive architectural overview of LutaML::Model's
|
|
|
239
239
|
▼
|
|
240
240
|
┌──────────────────────────┐
|
|
241
241
|
│ XML Parser │
|
|
242
|
-
│ (Nokogiri/
|
|
242
|
+
│ (Nokogiri/Ox) │
|
|
243
243
|
└──────┬───────────────────┘
|
|
244
244
|
│
|
|
245
245
|
▼
|
|
@@ -942,12 +942,6 @@ xml_string = adapter.build_xml(
|
|
|
942
942
|
# - apply_prefix(element_name, prefix)
|
|
943
943
|
```
|
|
944
944
|
|
|
945
|
-
**OgaAdapter** (`oga_adapter.rb`):
|
|
946
|
-
```ruby
|
|
947
|
-
# Same interface as NokogiriAdapter
|
|
948
|
-
# Uses Oga XML library
|
|
949
|
-
```
|
|
950
|
-
|
|
951
945
|
**OxAdapter** (`ox_adapter.rb`):
|
|
952
946
|
```ruby
|
|
953
947
|
# Same interface as NokogiriAdapter
|
|
@@ -1271,7 +1265,7 @@ ns = register.namespace_for_prefix("po") # => PoNamespace
|
|
|
1271
1265
|
```ruby
|
|
1272
1266
|
# Configure adapter
|
|
1273
1267
|
Lutaml::Model::Config.configure do |config|
|
|
1274
|
-
config.xml_adapter = :nokogiri # or :
|
|
1268
|
+
config.xml_adapter = :nokogiri # or :ox
|
|
1275
1269
|
end
|
|
1276
1270
|
|
|
1277
1271
|
# Used at runtime
|
data/docs/architecture.md
CHANGED
|
@@ -116,25 +116,21 @@ cached_resolver.resolve(:string, context) # Resolves and caches
|
|
|
116
116
|
cached_resolver.resolve(:string, context) # Returns cached value
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
**Cache backend**: Uses `ConcurrentMapCache`
|
|
119
|
+
**Cache backend**: Uses `ConcurrentMapCache` (lock-free via Concurrent::Map). The backend can be overridden per-instance.
|
|
120
120
|
|
|
121
121
|
### RuntimeCompatibility
|
|
122
122
|
|
|
123
|
-
**Responsibility**:
|
|
123
|
+
**Responsibility**: The platform helpers the load-time wiring uses.
|
|
124
124
|
|
|
125
125
|
```ruby
|
|
126
|
-
|
|
127
|
-
Lutaml::Model::RuntimeCompatibility.native? #=> true (native) / false (Opal)
|
|
128
|
-
|
|
129
|
-
# Conditional autoload — only registers on native Ruby
|
|
126
|
+
# Registers each constant's autoload on the namespace
|
|
130
127
|
RuntimeCompatibility.autoload_native(self, OjAdapter: "path/to/oj_adapter")
|
|
131
128
|
|
|
132
|
-
#
|
|
133
|
-
RuntimeCompatibility.require_native("
|
|
134
|
-
```
|
|
129
|
+
# Requires each path
|
|
130
|
+
RuntimeCompatibility.require_native("concurrent")
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
RuntimeCompatibility.windows? #=> true on Windows
|
|
133
|
+
```
|
|
138
134
|
|
|
139
135
|
### TypeSubstitution
|
|
140
136
|
|
|
@@ -131,7 +131,7 @@ lives elsewhere); non-`Hash` options (e.g. the generator state objects Ruby's
|
|
|
131
131
|
JSON/YAML protocols pass); instance graphs `Marshal` cannot digest — notably,
|
|
132
132
|
instances parsed from XML retain native parser nodes for round-trip fidelity
|
|
133
133
|
and therefore skip serialization caching (programmatically built instances
|
|
134
|
-
cache fully); and any environment without native `Marshal`/`Digest
|
|
134
|
+
cache fully); and any environment without native `Marshal`/`Digest`.
|
|
135
135
|
|
|
136
136
|
Invalidation:: Entirely the store's concern — TTL, eviction, persistence, and
|
|
137
137
|
clearing belong to the backend you configured. If you mutate a register's
|
data/docs/index.adoc
CHANGED
|
@@ -19,7 +19,6 @@ Lutaml::Model is a Ruby library for creating information models with attributes
|
|
|
19
19
|
* **Multi-format serialization** - XML, JSON, YAML, TOML, JSON-LD, Turtle, Hash, YAML Stream
|
|
20
20
|
* **XML namespace support** - Full W3C namespace implementation
|
|
21
21
|
* **Linked Data support** - RDF namespaces, JSON-LD, and Turtle serialization
|
|
22
|
-
* **Opal support** - Run in the browser via Opal (Ruby to JavaScript) with REXML adapter
|
|
23
22
|
* **Validation** - Built-in validation with custom rules
|
|
24
23
|
* **Schema generation** - Generate XSD, JSON Schema, YAML Schema
|
|
25
24
|
* **Polymorphism** - Handle multiple types elegantly
|
|
@@ -1021,44 +1021,38 @@ This follows W3C XML Namespaces 1.0 §6.2 which states that child elements inher
|
|
|
1021
1021
|
|
|
1022
1022
|
== Adapter Compatibility
|
|
1023
1023
|
|
|
1024
|
-
All
|
|
1024
|
+
All XML adapters (Nokogiri, Ox, REXML) support the same namespace features:
|
|
1025
1025
|
|
|
1026
|
-
[cols="1,1,1,1
|
|
1027
|
-
|
|
1028
|
-
| Feature | Nokogiri | Ox | Oga | REXML
|
|
1026
|
+
[cols="1,1,1,1"]|===
|
|
1027
|
+
| Feature | Nokogiri | Ox | REXML
|
|
1029
1028
|
|
|
1030
1029
|
| Default namespace format
|
|
1031
1030
|
| ✓
|
|
1032
1031
|
| ✓
|
|
1033
1032
|
| ✓
|
|
1034
|
-
| ✓
|
|
1035
1033
|
|
|
1036
1034
|
| Prefixed namespace format
|
|
1037
1035
|
| ✓
|
|
1038
1036
|
| ✓
|
|
1039
1037
|
| ✓
|
|
1040
|
-
| ✓
|
|
1041
1038
|
|
|
1042
1039
|
| Namespace inheritance
|
|
1043
1040
|
| ✓
|
|
1044
1041
|
| ✓
|
|
1045
1042
|
| ✓
|
|
1046
|
-
| ✓
|
|
1047
1043
|
|
|
1048
1044
|
| Custom prefix strings (`prefix: "custom"`)
|
|
1049
1045
|
| ✓
|
|
1050
1046
|
| ✓
|
|
1051
1047
|
| ✓
|
|
1052
|
-
| ✓
|
|
1053
1048
|
|
|
1054
1049
|
| Round-trip namespace preservation
|
|
1055
1050
|
| ✓
|
|
1056
1051
|
| ✓
|
|
1057
1052
|
| ✓
|
|
1058
|
-
| ✓
|
|
1059
1053
|
|===
|
|
1060
1054
|
|
|
1061
|
-
NOTE: All adapters now produce identical namespace output.
|
|
1055
|
+
NOTE: All adapters now produce identical namespace output.
|
|
1062
1056
|
|
|
1063
1057
|
== Related Documentation
|
|
1064
1058
|
|
data/lib/lutaml/json/format.rb
CHANGED
|
@@ -32,7 +32,6 @@ module Lutaml
|
|
|
32
32
|
].freeze
|
|
33
33
|
|
|
34
34
|
# Additive, so a json release that adds an option needs no change here.
|
|
35
|
-
# Opal's JSON shim has no State class, hence the guard.
|
|
36
35
|
DERIVED_PERMITTED =
|
|
37
36
|
if defined?(::JSON::State)
|
|
38
37
|
accessors = ::JSON::State.instance_methods(false).grep(/\A[a-z_][a-z0-9_]*=\z/)
|
|
@@ -156,17 +156,13 @@ module Lutaml
|
|
|
156
156
|
# :scalar, :model, :child_map or :unmapped; child_rows is the child
|
|
157
157
|
# model's own row set. A recursive model graph compiles as a
|
|
158
158
|
# self-referential plan: child_rows may be the plan itself.
|
|
159
|
-
# Concurrent::Map
|
|
160
|
-
# (Concurrent is unavailable there) — the RULE_RECORDS pattern.
|
|
159
|
+
# Concurrent::Map — the RULE_RECORDS pattern.
|
|
161
160
|
# Writes are idempotent (the same deterministic plan is computed),
|
|
162
161
|
# so a lost race costs a duplicate build, never a wrong value.
|
|
163
|
-
KV_GROUP_PLANS =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.require_native("concurrent")
|
|
168
|
-
Concurrent::Map.new
|
|
169
|
-
end
|
|
162
|
+
KV_GROUP_PLANS = begin
|
|
163
|
+
Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
|
|
164
|
+
Concurrent::Map.new
|
|
165
|
+
end
|
|
170
166
|
|
|
171
167
|
# [model class, register, format, generation] -> { rule => plan }.
|
|
172
168
|
# Class-level, generation-retired: the whole dispatch table for a
|
|
@@ -176,13 +172,10 @@ module Lutaml
|
|
|
176
172
|
# node (~12 predicate calls plus a key array per rule per node;
|
|
177
173
|
# 154k+154k allocations per heroku.json parse). Same
|
|
178
174
|
# idempotent-write pattern as KV_GROUP_PLANS.
|
|
179
|
-
KV_WALK_PLANS =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
.require_native("concurrent")
|
|
184
|
-
Concurrent::Map.new
|
|
185
|
-
end
|
|
175
|
+
KV_WALK_PLANS = begin
|
|
176
|
+
Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
|
|
177
|
+
Concurrent::Map.new
|
|
178
|
+
end
|
|
186
179
|
|
|
187
180
|
def self.kv_group_plan(model_class, format, register)
|
|
188
181
|
# Context generation: specs (and apps) reset registers between
|
|
@@ -7,8 +7,8 @@ module Lutaml
|
|
|
7
7
|
class DocumentBuilder
|
|
8
8
|
# Default registry: builder keys → LML model classes. Built lazily
|
|
9
9
|
# (method, not load-time constant): the model classes live in the
|
|
10
|
-
# boot's later sections, and eager evaluation
|
|
11
|
-
#
|
|
10
|
+
# boot's later sections, and eager evaluation would load them
|
|
11
|
+
# before they are defined.
|
|
12
12
|
def self.default_registry
|
|
13
13
|
@default_registry ||= {
|
|
14
14
|
document: ::Lutaml::Lml::Document,
|
|
@@ -8,8 +8,8 @@ module Lutaml
|
|
|
8
8
|
# type list in four places.
|
|
9
9
|
module EntityTypes
|
|
10
10
|
# Registry built lazily (method, not load-time constant): the entity
|
|
11
|
-
# model classes load later in the boot, and eager evaluation
|
|
12
|
-
#
|
|
11
|
+
# model classes load later in the boot, and eager evaluation would
|
|
12
|
+
# reference them before they are defined.
|
|
13
13
|
def self.all
|
|
14
14
|
@all ||= [UmlClass, Enum, DataType, PrimitiveType].freeze
|
|
15
15
|
end
|