lutaml-model 0.8.191 → 0.8.192
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/lib/compat/opal/generate_boot.rb +5 -4
- data/lib/compat/opal/lutaml_model_boot.rb +0 -7
- data/lib/lutaml/model/serialize/format_conversion.rb +4 -6
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/adapter/adapter_helpers.rb +3 -3
- data/lib/lutaml/xml/adapter/base_adapter.rb +13 -29
- data/lib/lutaml/xml/adapter/moxml_adapter.rb +113 -22
- data/lib/lutaml/xml/adapter/xml_parser.rb +6 -8
- data/lib/lutaml/xml/adapter/xml_serializer.rb +3 -1
- data/lib/lutaml/xml/adapter.rb +0 -4
- data/lib/lutaml/xml/adapter_element.rb +19 -9
- data/lib/lutaml/xml/adapter_loader.rb +26 -11
- data/lib/lutaml/xml/builder/base.rb +6 -7
- data/lib/lutaml/xml/document.rb +1 -1
- data/lib/lutaml/xml/format.rb +0 -10
- data/lib/lutaml/xml/leptris/plan_hydrator.rb +2 -2
- data/spec/lutaml/model/cdata_spec.rb +11 -27
- data/spec/lutaml/model/encoding_spec.rb +6 -6
- data/spec/lutaml/model/except_spec.rb +5 -7
- data/spec/lutaml/model/mixed_content_spec.rb +22 -25
- data/spec/lutaml/model/multiple_mapping_spec.rb +8 -10
- data/spec/lutaml/model/ordered_content_spec.rb +5 -8
- data/spec/lutaml/model/processing_instruction_spec.rb +6 -9
- data/spec/lutaml/model/serialize/attribute_definition_block_form_spec.rb +1 -1
- data/spec/lutaml/model/serialize/builder_spec.rb +1 -1
- data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +5 -8
- data/spec/lutaml/xml/adapter/empty_document_diagnostics_spec.rb +3 -4
- data/spec/lutaml/xml/adapter/nokogiri_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/oga_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/order_spec.rb +8 -22
- data/spec/lutaml/xml/adapter/over_cap_parse_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/ox_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/rexml_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/xml_namespace_spec.rb +5 -8
- data/spec/lutaml/xml/adapter_loader_spec.rb +15 -3
- data/spec/lutaml/xml/adapter_metadata_default_spec.rb +1 -1
- data/spec/lutaml/xml/adapter_moxml_engine_spec.rb +1 -2
- data/spec/lutaml/xml/builder/builder_spec.rb +28 -20
- data/spec/lutaml/xml/default_namespace_spec.rb +4 -5
- data/spec/lutaml/xml/entity_fragmentation_spec.rb +2 -2
- data/spec/lutaml/xml/mapping_rule_spec.rb +1 -2
- data/spec/lutaml/xml/mapping_spec.rb +12 -14
- data/spec/lutaml/xml/namespace_missing_prefix_spec.rb +1 -1
- data/spec/lutaml/xml/namespace_preservation_spec.rb +11 -11
- data/spec/lutaml/xml/namespace_scope_vcard_spec.rb +5 -8
- data/spec/lutaml/xml/prefix_control_spec.rb +5 -8
- data/spec/lutaml/xml/type_namespace_prefix_spec.rb +2 -2
- data/spec/lutaml/xml/xml_adapter_spec.rb +5 -8
- data/spec/lutaml/xml/xml_declaration_spec.rb +19 -19
- data/spec/spec_helper.rb +2 -2
- data/spec/support/test_adapter_config.rb +9 -25
- metadata +1 -21
- data/lib/lutaml/xml/adapter/leptris_adapter.rb +0 -16
- data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +0 -16
- data/lib/lutaml/xml/adapter/oga_adapter.rb +0 -20
- data/lib/lutaml/xml/adapter/ox_adapter.rb +0 -16
- data/lib/lutaml/xml/adapter/rexml_adapter.rb +0 -25
- data/lib/lutaml/xml/builder/leptris.rb +0 -13
- data/lib/lutaml/xml/builder/nokogiri.rb +0 -13
- data/lib/lutaml/xml/builder/oga.rb +0 -13
- data/lib/lutaml/xml/builder/ox.rb +0 -13
- data/lib/lutaml/xml/builder/rexml.rb +0 -13
- data/lib/lutaml/xml/leptris/element.rb +0 -34
- data/lib/lutaml/xml/nokogiri/element.rb +0 -34
- data/lib/lutaml/xml/nokogiri.rb +0 -10
- data/lib/lutaml/xml/oga/element.rb +0 -15
- data/lib/lutaml/xml/oga.rb +0 -10
- data/lib/lutaml/xml/ox/element.rb +0 -15
- data/lib/lutaml/xml/ox.rb +0 -10
- data/lib/lutaml/xml/rexml/element.rb +0 -15
- data/lib/lutaml/xml/rexml.rb +0 -10
- data/lib/tasks/xml_optimization_benchmark.rb +0 -178
|
@@ -4,7 +4,7 @@ require "spec_helper"
|
|
|
4
4
|
require "nokogiri"
|
|
5
5
|
require "lutaml/model"
|
|
6
6
|
require "lutaml/xml"
|
|
7
|
-
require "lutaml/xml/adapter/
|
|
7
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
8
8
|
|
|
9
9
|
# Regression coverage for lutaml-model#871: very large documents must
|
|
10
10
|
# deserialize completely, with no silent truncation and no data loss.
|
|
@@ -76,7 +76,7 @@ RSpec.describe "parsing documents past libxml2's 10 MB buffer cap" do
|
|
|
76
76
|
|
|
77
77
|
it "returns the complete tree from the adapter layer" do
|
|
78
78
|
Lutaml::Model::Config.with_adapter(xml: :nokogiri) do
|
|
79
|
-
document = Lutaml::Xml::Adapter::
|
|
79
|
+
document = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(over_cap_document)
|
|
80
80
|
|
|
81
81
|
expect(document.root.children.count).to eq(7)
|
|
82
82
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
-
|
|
2
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
3
3
|
|
|
4
|
-
RSpec.describe Lutaml::Xml::Adapter::
|
|
4
|
+
RSpec.describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox), :ox_adapter do
|
|
5
5
|
let(:xml_string) do
|
|
6
6
|
<<-XML
|
|
7
7
|
<root xmlns="http://example.com/default" xmlns:prefix="http://example.com/prefixed">
|
|
@@ -2,9 +2,9 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
4
4
|
require "rexml/document"
|
|
5
|
-
|
|
5
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
6
|
|
|
7
|
-
RSpec.describe Lutaml::Xml::Adapter::
|
|
7
|
+
RSpec.describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
8
8
|
let(:xml_string) do
|
|
9
9
|
<<~XML
|
|
10
10
|
<root xmlns="http://example.com/default" xmlns:prefix="http://example.com/prefixed">
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
-
require "lutaml/xml/adapter/
|
|
3
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
4
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
2
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
3
|
require_relative "../../../../lib/lutaml/model"
|
|
7
4
|
require_relative "../../../support/xml_mapping_namespaces"
|
|
8
5
|
|
|
@@ -496,11 +493,11 @@ RSpec.describe "XmlNamespace" do
|
|
|
496
493
|
end
|
|
497
494
|
end
|
|
498
495
|
|
|
499
|
-
describe Lutaml::Xml::Adapter::
|
|
496
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
500
497
|
it_behaves_like "an XML namespace parser", described_class
|
|
501
498
|
end
|
|
502
499
|
|
|
503
|
-
describe Lutaml::Xml::Adapter::
|
|
500
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
504
501
|
around do |example|
|
|
505
502
|
if /(with prefixed namespace|with default namespace|mixing different namespaces)/.match?(example.metadata[:description])
|
|
506
503
|
skip "Ox adapter has known broken namespace implementation"
|
|
@@ -515,14 +512,14 @@ RSpec.describe "XmlNamespace" do
|
|
|
515
512
|
end
|
|
516
513
|
end
|
|
517
514
|
|
|
518
|
-
describe Lutaml::Xml::Adapter::
|
|
515
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
519
516
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
520
517
|
it_behaves_like "an XML namespace parser",
|
|
521
518
|
described_class
|
|
522
519
|
end
|
|
523
520
|
end
|
|
524
521
|
|
|
525
|
-
describe Lutaml::Xml::Adapter::
|
|
522
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
526
523
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
527
524
|
it_behaves_like "an XML namespace parser",
|
|
528
525
|
described_class
|
|
@@ -3,12 +3,24 @@
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
5
|
RSpec.describe Lutaml::Xml::AdapterLoader do
|
|
6
|
-
|
|
6
|
+
# Every adapter type loads the one shared adapter file; the
|
|
7
|
+
# chained-cause contract lives at the ENGINE preload — a missing
|
|
8
|
+
# engine gem must name the real gap, not present as a bare
|
|
9
|
+
# unknown-type error.
|
|
10
|
+
it "chains the engine LoadError cause instead of masking it" do
|
|
11
|
+
allow(Moxml::Adapter).to receive(:load)
|
|
12
|
+
.and_raise(LoadError, "cannot load such file -- nokogiri")
|
|
7
13
|
expect do
|
|
8
|
-
described_class.
|
|
14
|
+
described_class.load_moxml_adapter(:nokogiri, :xml)
|
|
9
15
|
end.to raise_error(Lutaml::Model::UnknownAdapterTypeError) do |error|
|
|
10
16
|
expect(error.cause).to be_a(LoadError)
|
|
11
|
-
expect(error.cause.message).to include("
|
|
17
|
+
expect(error.cause.message).to include("nokogiri")
|
|
12
18
|
end
|
|
13
19
|
end
|
|
20
|
+
|
|
21
|
+
it "raises for an unknown engine at the adapter factory" do
|
|
22
|
+
expect do
|
|
23
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:bogus)
|
|
24
|
+
end.to raise_error(ArgumentError, /unknown XML engine/)
|
|
25
|
+
end
|
|
14
26
|
end
|
|
@@ -28,7 +28,7 @@ RSpec.describe "XML adapter metadata default (#908, #1224)" do
|
|
|
28
28
|
.and_return(:leptris)
|
|
29
29
|
|
|
30
30
|
adapter = Lutaml::Model::Config.adapter_for(:xml)
|
|
31
|
-
expect(adapter.
|
|
31
|
+
expect(adapter.engine_name).to eq(:leptris)
|
|
32
32
|
ensure
|
|
33
33
|
Lutaml::Model::AdapterResolver.reset!
|
|
34
34
|
end
|
|
@@ -17,8 +17,7 @@ RSpec.describe "the deferred lane's engine resolution seams" do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "answers the engine Moxml deploys through the adapter seam" do
|
|
20
|
-
expect(Lutaml::Model::Config.xml_adapter.
|
|
21
|
-
.to eq("Lutaml::Xml::Adapter::LeptrisAdapter")
|
|
20
|
+
expect(Lutaml::Model::Config.xml_adapter.engine_name).to eq(:leptris)
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
it "parses an XSD schema under the deferred lane" do
|
|
@@ -5,7 +5,7 @@ require "spec_helper"
|
|
|
5
5
|
RSpec.shared_examples "a consistent XML builder" do
|
|
6
6
|
describe "#create_and_add_element" do
|
|
7
7
|
it "creates an element with attributes" do
|
|
8
|
-
builder =
|
|
8
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
9
9
|
xml.create_and_add_element("root", attributes: { "id" => "1" })
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "nests elements via block" do
|
|
18
|
-
builder =
|
|
18
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
19
19
|
xml.create_and_add_element("root") do
|
|
20
20
|
xml.create_and_add_element("child")
|
|
21
21
|
end
|
|
@@ -29,7 +29,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
29
29
|
|
|
30
30
|
describe "#add_text" do
|
|
31
31
|
it "adds a text node to an element" do
|
|
32
|
-
builder =
|
|
32
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
33
33
|
xml.create_and_add_element("root") do
|
|
34
34
|
xml.text("hello")
|
|
35
35
|
end
|
|
@@ -41,7 +41,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
41
41
|
|
|
42
42
|
describe "#add_cdata" do
|
|
43
43
|
it "adds a CDATA section to an element" do
|
|
44
|
-
builder =
|
|
44
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
45
45
|
xml.create_and_add_element("root") do
|
|
46
46
|
xml.cdata("some data")
|
|
47
47
|
end
|
|
@@ -53,7 +53,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
53
53
|
|
|
54
54
|
describe "#add_comment" do
|
|
55
55
|
it "appends a comment node to an element" do
|
|
56
|
-
builder =
|
|
56
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
57
57
|
xml.create_and_add_element("root") do
|
|
58
58
|
xml.add_comment(xml.current_node, "a comment")
|
|
59
59
|
end
|
|
@@ -70,7 +70,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
70
70
|
|
|
71
71
|
describe "#add_xml_fragment" do
|
|
72
72
|
it "parses and inserts XML fragment" do
|
|
73
|
-
builder =
|
|
73
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
74
74
|
xml.create_and_add_element("root") do
|
|
75
75
|
xml.add_xml_fragment(xml.current_node, "<child>text</child>")
|
|
76
76
|
end
|
|
@@ -82,7 +82,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
82
82
|
|
|
83
83
|
describe "#to_xml" do
|
|
84
84
|
it "serializes the built document" do
|
|
85
|
-
builder =
|
|
85
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
86
86
|
xml.create_and_add_element("root", attributes: { "key" => "val" }) do
|
|
87
87
|
xml.text("content")
|
|
88
88
|
end
|
|
@@ -94,14 +94,14 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it "returns empty string when no root" do
|
|
97
|
-
builder =
|
|
97
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine)
|
|
98
98
|
expect(builder.to_xml).to eq("")
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
describe "method_missing DSL" do
|
|
103
103
|
it "creates elements dynamically" do
|
|
104
|
-
builder =
|
|
104
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
105
105
|
xml.create_and_add_element("root") do
|
|
106
106
|
xml.create_and_add_element("item", attributes: { "id" => "1" })
|
|
107
107
|
end
|
|
@@ -113,17 +113,17 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
113
113
|
|
|
114
114
|
describe "encoding" do
|
|
115
115
|
it "stores encoding from build options" do
|
|
116
|
-
builder =
|
|
116
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine, encoding: "ISO-8859-1")
|
|
117
117
|
expect(builder.encoding).to eq("ISO-8859-1")
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
it "defaults encoding to nil" do
|
|
121
|
-
builder =
|
|
121
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine)
|
|
122
122
|
expect(builder.encoding).to be_nil
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
it "encodes output XML with specified encoding" do
|
|
126
|
-
builder =
|
|
126
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine, encoding: "ISO-8859-1") do |xml|
|
|
127
127
|
xml.create_and_add_element("root") do
|
|
128
128
|
xml.text("café")
|
|
129
129
|
end
|
|
@@ -135,7 +135,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "keeps UTF-8 when no encoding specified" do
|
|
138
|
-
builder =
|
|
138
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
139
139
|
xml.create_and_add_element("root") do
|
|
140
140
|
xml.text("café")
|
|
141
141
|
end
|
|
@@ -149,7 +149,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
149
149
|
|
|
150
150
|
describe "namespace handling" do
|
|
151
151
|
it "declares xmlns attributes as namespaces" do
|
|
152
|
-
builder =
|
|
152
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
153
153
|
xml.create_and_add_element("root",
|
|
154
154
|
attributes: { "xmlns:ns" => "http://example.com" })
|
|
155
155
|
end
|
|
@@ -159,7 +159,7 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
it "keeps default namespace elements unprefixed" do
|
|
162
|
-
builder =
|
|
162
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
163
163
|
xml.create_and_add_element("root",
|
|
164
164
|
attributes: { "xmlns" => "urn:example" }) do
|
|
165
165
|
xml.create_and_add_element("child") do
|
|
@@ -180,22 +180,28 @@ RSpec.shared_examples "a consistent XML builder" do
|
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
RSpec.describe "XML Builder consistency" do
|
|
183
|
-
describe
|
|
183
|
+
describe "on :nokogiri" do
|
|
184
|
+
let(:engine) { :nokogiri }
|
|
185
|
+
|
|
184
186
|
it_behaves_like "a consistent XML builder"
|
|
185
187
|
end
|
|
186
188
|
|
|
187
|
-
describe
|
|
189
|
+
describe "on :ox" do
|
|
190
|
+
let(:engine) { :ox }
|
|
191
|
+
|
|
188
192
|
it_behaves_like "a consistent XML builder"
|
|
189
193
|
end
|
|
190
194
|
|
|
191
|
-
describe
|
|
195
|
+
describe "on :oga" do
|
|
196
|
+
let(:engine) { :oga }
|
|
197
|
+
|
|
192
198
|
it_behaves_like "a consistent XML builder"
|
|
193
199
|
|
|
194
200
|
it "defaults namespace validation to lenient under Opal" do
|
|
195
201
|
allow(Lutaml::Model::RuntimeCompatibility).to receive(:opal?)
|
|
196
202
|
.and_return(true)
|
|
197
203
|
|
|
198
|
-
builder =
|
|
204
|
+
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
199
205
|
xml.create_and_add_element(
|
|
200
206
|
"root",
|
|
201
207
|
attributes: {
|
|
@@ -210,7 +216,9 @@ RSpec.describe "XML Builder consistency" do
|
|
|
210
216
|
end
|
|
211
217
|
end
|
|
212
218
|
|
|
213
|
-
describe
|
|
219
|
+
describe "on :rexml" do
|
|
220
|
+
let(:engine) { :rexml }
|
|
221
|
+
|
|
214
222
|
it_behaves_like "a consistent XML builder"
|
|
215
223
|
end
|
|
216
224
|
end
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
|
-
require "lutaml/xml/adapter/
|
|
5
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
4
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
5
|
require_relative "../../support/xml_mapping_namespaces"
|
|
7
6
|
|
|
8
7
|
# Test for issue #504: Default namespace handling
|
|
@@ -170,18 +169,18 @@ RSpec.describe DefaultNamespaceSpec do
|
|
|
170
169
|
end
|
|
171
170
|
end
|
|
172
171
|
|
|
173
|
-
describe Lutaml::Xml::Adapter::
|
|
172
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
174
173
|
it_behaves_like "default namespace serialization", described_class
|
|
175
174
|
end
|
|
176
175
|
|
|
177
|
-
describe Lutaml::Xml::Adapter::
|
|
176
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
178
177
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
179
178
|
it_behaves_like "default namespace serialization",
|
|
180
179
|
described_class
|
|
181
180
|
end
|
|
182
181
|
end
|
|
183
182
|
|
|
184
|
-
describe Lutaml::Xml::Adapter::
|
|
183
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
185
184
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
186
185
|
it_behaves_like "default namespace serialization",
|
|
187
186
|
described_class
|
|
@@ -429,7 +429,7 @@ RSpec.describe "XML Entity Fragmentation Issue #5" do
|
|
|
429
429
|
# These tests exercise the adapter's to_xml path (build_xml → native
|
|
430
430
|
# Nokogiri serialization), which is distinct from NokogiriElement#to_xml.
|
|
431
431
|
context "adapter-level to_xml round-trip" do
|
|
432
|
-
let(:adapter_class) { Lutaml::Xml::Adapter::
|
|
432
|
+
let(:adapter_class) { Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) }
|
|
433
433
|
|
|
434
434
|
it "preserves non-standard entity references" do
|
|
435
435
|
doc = adapter_class.parse("<copyright>© 2005 Mulberry</copyright>")
|
|
@@ -463,7 +463,7 @@ RSpec.describe "XML Entity Fragmentation Issue #5" do
|
|
|
463
463
|
end
|
|
464
464
|
|
|
465
465
|
context "entity references in attribute values" do
|
|
466
|
-
let(:adapter_class) { Lutaml::Xml::Adapter::
|
|
466
|
+
let(:adapter_class) { Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) }
|
|
467
467
|
|
|
468
468
|
it "preserves non-standard entities in attributes via element to_xml" do
|
|
469
469
|
root = adapter_class.parse('<root attr="© 2024"/>').root
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
require "lutaml/xml/adapter/
|
|
4
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
3
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
4
|
require_relative "../../support/xml_mapping_namespaces"
|
|
7
5
|
|
|
8
6
|
# Define a sample class for testing map content
|
|
@@ -498,7 +496,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
498
496
|
expect(parsed.beta).to eq("bye")
|
|
499
497
|
|
|
500
498
|
# Ox adapter omits xmlns:ex1 declaration (namespace hoisting difference)
|
|
501
|
-
expected = if adapter_class == Lutaml::Xml::Adapter::
|
|
499
|
+
expected = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
502
500
|
<<~XML
|
|
503
501
|
<example xmlns="http://www.check.com" ex1:alpha="hello" beta="bye"/>
|
|
504
502
|
XML
|
|
@@ -628,7 +626,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
628
626
|
# Different adapters have different hoisting behaviors:
|
|
629
627
|
# - Nokogiri/Oga: Hoists namespace to parent
|
|
630
628
|
# - Ox: No namespace declaration (uses inline xmi prefix without xmlns)
|
|
631
|
-
expected = if adapter_class == Lutaml::Xml::Adapter::
|
|
629
|
+
expected = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
632
630
|
# Ox doesn't add xmlns declaration when model has no namespace
|
|
633
631
|
<<~XML.strip
|
|
634
632
|
<ownedComment>
|
|
@@ -657,7 +655,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
657
655
|
# Different adapters have different hoisting behaviors:
|
|
658
656
|
# - Nokogiri/Oga: Hoists namespace to parent
|
|
659
657
|
# - Ox: No namespace declaration (uses inline xmi prefix without xmlns)
|
|
660
|
-
expected = if adapter_class == Lutaml::Xml::Adapter::
|
|
658
|
+
expected = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
661
659
|
# Ox doesn't add xmlns declaration when model has no namespace
|
|
662
660
|
<<~XML.strip
|
|
663
661
|
<ownedComment annotatedElement="test2">
|
|
@@ -696,7 +694,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
696
694
|
# GML uses DEFAULT format (format info lost due to namespace_locations sibling collision)
|
|
697
695
|
# Note: Ox adapter always uses prefix format
|
|
698
696
|
let(:expected_xml) do
|
|
699
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
697
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
700
698
|
# Ox uses prefix format
|
|
701
699
|
<<~XML
|
|
702
700
|
<SameElementName App="hello" xmlns="http://www.omg.org/spec/XMI/20131001">
|
|
@@ -804,7 +802,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
804
802
|
# NOTE: mapping with namespace: nil, prefix: nil has differing adapter behavior:
|
|
805
803
|
# - Nokogiri: Cannot parse element with parent namespace prefix, returns nil
|
|
806
804
|
# - Ox/Oga: Can parse element with parent namespace prefix successfully
|
|
807
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
805
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
808
806
|
expect(parsed.without_namespace).to be_nil
|
|
809
807
|
else
|
|
810
808
|
expect(parsed.without_namespace.value).to eq("without namespace text")
|
|
@@ -815,7 +813,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
815
813
|
# Serialize the parsed model
|
|
816
814
|
serialized = parsed.to_xml
|
|
817
815
|
|
|
818
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
816
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
819
817
|
# Nokogiri cannot parse the pn:WithoutNamespace element, so it's nil
|
|
820
818
|
# and won't be in the serialized output. Verify other elements round-trip.
|
|
821
819
|
reparsed = XmlMappingSpec::WithChildExplicitNamespace.from_xml(serialized)
|
|
@@ -920,7 +918,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
920
918
|
# Both are W3C compliant.
|
|
921
919
|
let(:expected_xml) do
|
|
922
920
|
# Ox uses prefix format, Nokogiri/Oga use default format
|
|
923
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
921
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
924
922
|
<<~XML
|
|
925
923
|
<ChildNamespaceNil xmlns="http://www.omg.org/spec/XMI/20131001">
|
|
926
924
|
<ElementDefaultNamespace>Default namespace</ElementDefaultNamespace>
|
|
@@ -1125,25 +1123,25 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
1125
1123
|
end
|
|
1126
1124
|
end
|
|
1127
1125
|
|
|
1128
|
-
describe Lutaml::Xml::Adapter::
|
|
1126
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
1129
1127
|
it_behaves_like "having XML Mappings", described_class
|
|
1130
1128
|
end
|
|
1131
1129
|
|
|
1132
|
-
describe Lutaml::Xml::Adapter::
|
|
1130
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
1133
1131
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
1134
1132
|
it_behaves_like "having XML Mappings",
|
|
1135
1133
|
described_class
|
|
1136
1134
|
end
|
|
1137
1135
|
end
|
|
1138
1136
|
|
|
1139
|
-
describe Lutaml::Xml::Adapter::
|
|
1137
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
1140
1138
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
1141
1139
|
it_behaves_like "having XML Mappings",
|
|
1142
1140
|
described_class
|
|
1143
1141
|
end
|
|
1144
1142
|
end
|
|
1145
1143
|
|
|
1146
|
-
describe Lutaml::Xml::Adapter::
|
|
1144
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
1147
1145
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
1148
1146
|
it_behaves_like "having XML Mappings", described_class
|
|
1149
1147
|
end
|
|
@@ -13,7 +13,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
13
13
|
XML
|
|
14
14
|
|
|
15
15
|
# Parse the XML
|
|
16
|
-
doc = Lutaml::Xml::Adapter::
|
|
16
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
17
17
|
|
|
18
18
|
# Re-serialize
|
|
19
19
|
output = doc.to_xml
|
|
@@ -32,7 +32,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
32
32
|
</root>
|
|
33
33
|
XML
|
|
34
34
|
|
|
35
|
-
doc = Lutaml::Xml::Adapter::
|
|
35
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
36
36
|
output = doc.to_xml
|
|
37
37
|
|
|
38
38
|
# All three namespaces should be preserved
|
|
@@ -50,7 +50,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
50
50
|
</article>
|
|
51
51
|
XML
|
|
52
52
|
|
|
53
|
-
doc = Lutaml::Xml::Adapter::
|
|
53
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
54
54
|
output = doc.to_xml
|
|
55
55
|
|
|
56
56
|
# Should preserve mml namespace
|
|
@@ -72,7 +72,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
72
72
|
</article>
|
|
73
73
|
XML
|
|
74
74
|
|
|
75
|
-
doc = Lutaml::Xml::Adapter::
|
|
75
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
76
76
|
output = doc.to_xml
|
|
77
77
|
|
|
78
78
|
expect(output).to include('xmlns="http://jats.nlm.nih.gov/publishing/1.3"')
|
|
@@ -86,7 +86,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
86
86
|
</article>
|
|
87
87
|
XML
|
|
88
88
|
|
|
89
|
-
doc = Lutaml::Xml::Adapter::
|
|
89
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
90
90
|
output = doc.to_xml
|
|
91
91
|
|
|
92
92
|
expect(output).to include('xmlns="http://example.com/default"')
|
|
@@ -112,7 +112,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
112
112
|
</article>
|
|
113
113
|
XML
|
|
114
114
|
|
|
115
|
-
doc = Lutaml::Xml::Adapter::
|
|
115
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
116
116
|
output = doc.to_xml
|
|
117
117
|
|
|
118
118
|
# All four namespaces should be preserved
|
|
@@ -131,7 +131,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
131
131
|
</root>
|
|
132
132
|
XML
|
|
133
133
|
|
|
134
|
-
doc = Lutaml::Xml::Adapter::
|
|
134
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
135
135
|
output = doc.to_xml
|
|
136
136
|
|
|
137
137
|
# All namespaces should be present (order not strictly required by XML spec)
|
|
@@ -149,7 +149,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
149
149
|
</root>
|
|
150
150
|
XML
|
|
151
151
|
|
|
152
|
-
doc = Lutaml::Xml::Adapter::
|
|
152
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
153
153
|
output = doc.to_xml
|
|
154
154
|
|
|
155
155
|
# Empty namespace (explicit no namespace)
|
|
@@ -163,7 +163,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
163
163
|
</root>
|
|
164
164
|
XML
|
|
165
165
|
|
|
166
|
-
doc = Lutaml::Xml::Adapter::
|
|
166
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
167
167
|
|
|
168
168
|
output = doc.to_xml
|
|
169
169
|
# Should not have any xmlns declarations
|
|
@@ -184,7 +184,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
184
184
|
</article>
|
|
185
185
|
XML
|
|
186
186
|
|
|
187
|
-
doc = Lutaml::Xml::Adapter::
|
|
187
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
188
188
|
output = doc.to_xml
|
|
189
189
|
|
|
190
190
|
# All namespaces preserved, including unused
|
|
@@ -218,7 +218,7 @@ RSpec.describe "Namespace Preservation Issue #3" do
|
|
|
218
218
|
</article>
|
|
219
219
|
XML
|
|
220
220
|
|
|
221
|
-
doc = Lutaml::Xml::Adapter::
|
|
221
|
+
doc = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).parse(xml_input)
|
|
222
222
|
output = doc.to_xml
|
|
223
223
|
|
|
224
224
|
# Verify all JATS namespaces are preserved
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require_relative "../../../lib/lutaml/model"
|
|
3
|
-
require "lutaml/xml/adapter/
|
|
4
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
6
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
3
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
7
4
|
|
|
8
5
|
# WARNING: This is a fictitious XML namespace example for vCard, vCard does not
|
|
9
6
|
# actually use XML in this way. This is solely for testing namespace_scope
|
|
@@ -591,26 +588,26 @@ RSpec.describe "namespace_scope with vCard" do
|
|
|
591
588
|
end
|
|
592
589
|
|
|
593
590
|
context "with Nokogiri adapter" do
|
|
594
|
-
it_behaves_like "namespace_scope behavior", Lutaml::Xml::Adapter::
|
|
591
|
+
it_behaves_like "namespace_scope behavior", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
595
592
|
end
|
|
596
593
|
|
|
597
594
|
context "with Ox adapter" do
|
|
598
595
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
599
|
-
it_behaves_like "namespace_scope behavior", Lutaml::Xml::Adapter::
|
|
596
|
+
it_behaves_like "namespace_scope behavior", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
600
597
|
end
|
|
601
598
|
end
|
|
602
599
|
|
|
603
600
|
context "with Oga adapter" do
|
|
604
601
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
605
602
|
it_behaves_like "namespace_scope behavior",
|
|
606
|
-
Lutaml::Xml::Adapter::
|
|
603
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
607
604
|
end
|
|
608
605
|
end
|
|
609
606
|
|
|
610
607
|
context "with REXML adapter" do
|
|
611
608
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
612
609
|
it_behaves_like "namespace_scope behavior",
|
|
613
|
-
Lutaml::Xml::Adapter::
|
|
610
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml)
|
|
614
611
|
end
|
|
615
612
|
end
|
|
616
613
|
end
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require_relative "../../../lib/lutaml/model"
|
|
3
|
-
require "lutaml/xml/adapter/
|
|
4
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
6
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
3
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
7
4
|
|
|
8
5
|
# Tests for Solution 1: Prefix Control Feature
|
|
9
6
|
# These tests validate the prefix control functionality described in PROPOSAL-default-namespace.md
|
|
@@ -261,26 +258,26 @@ RSpec.describe "XML Prefix Control" do
|
|
|
261
258
|
end
|
|
262
259
|
|
|
263
260
|
context "with Nokogiri adapter" do
|
|
264
|
-
it_behaves_like "prefix control behavior", Lutaml::Xml::Adapter::
|
|
261
|
+
it_behaves_like "prefix control behavior", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
265
262
|
end
|
|
266
263
|
|
|
267
264
|
context "with Ox adapter" do
|
|
268
265
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
269
266
|
it_behaves_like "prefix control behavior",
|
|
270
|
-
Lutaml::Xml::Adapter::
|
|
267
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
271
268
|
end
|
|
272
269
|
end
|
|
273
270
|
|
|
274
271
|
context "with Oga adapter" do
|
|
275
272
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
276
|
-
it_behaves_like "prefix control behavior", Lutaml::Xml::Adapter::
|
|
273
|
+
it_behaves_like "prefix control behavior", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
277
274
|
end
|
|
278
275
|
end
|
|
279
276
|
|
|
280
277
|
context "with REXML adapter" do
|
|
281
278
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
282
279
|
it_behaves_like "prefix control behavior",
|
|
283
|
-
Lutaml::Xml::Adapter::
|
|
280
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml)
|
|
284
281
|
end
|
|
285
282
|
end
|
|
286
283
|
end
|