lutaml-model 0.8.6 → 0.8.7
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf72982044ef4dcc8a413bafe9432721faac7954f6cee3ff75446b3cf9af0016
|
|
4
|
+
data.tar.gz: 9c920d3cf43328d88cfd4be60cfd4b03dbf40b2c7f7d3e532d35518e3081014c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d396accc65f1dff8a826baf62764e01f2217d20bff02ca3aee70d4dba7244df7c8577ff6f1d84fd3d97f93e7f8dcc87583d07a441398c691aaa90f5955799d73
|
|
7
|
+
data.tar.gz: 124d44d40a30dbe9ff896d7afc8eedfda5a66d6a06453d43901cbd6dffdcbab2f2f34234b9cebdd30326e0110678a3f346e35ed1d0e8553a896bf69af42b5a66
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -145,13 +145,10 @@ module Lutaml
|
|
|
145
145
|
attribute_group.sort_by { |item| item.name.to_s }
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
# discovered during XML deserialization.
|
|
150
|
-
def target_namespace_from(model, value, custom_args = {})
|
|
148
|
+
def target_namespace_from(model, value)
|
|
151
149
|
model.target_namespace = value
|
|
152
|
-
namespaces = custom_args[:namespaces] || {}
|
|
153
150
|
model.target_namespace_prefix =
|
|
154
|
-
|
|
151
|
+
namespace_prefix_for(model.pending_plan_root_element, value)
|
|
155
152
|
end
|
|
156
153
|
|
|
157
154
|
# Find a type definition by local name
|
|
@@ -246,6 +243,12 @@ module Lutaml
|
|
|
246
243
|
|
|
247
244
|
private
|
|
248
245
|
|
|
246
|
+
def namespace_prefix_for(element, namespace_uri)
|
|
247
|
+
element&.own_namespaces&.find do |_, namespace|
|
|
248
|
+
namespace.uri == namespace_uri
|
|
249
|
+
end&.first
|
|
250
|
+
end
|
|
251
|
+
|
|
249
252
|
def all_namespaces
|
|
250
253
|
# Aggregate the schema target namespace with imported namespaces.
|
|
251
254
|
namespaces = [target_namespace].compact
|
|
@@ -14,6 +14,26 @@ RSpec.describe "Schema mapping integration" do
|
|
|
14
14
|
Lutaml::Xml::Schema::Xsd::Glob.schema_mappings = nil
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
describe "target namespace prefix parsing" do
|
|
18
|
+
let(:xsd_content) do
|
|
19
|
+
<<~XSD
|
|
20
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
21
|
+
xmlns:t="http://example.com/test"
|
|
22
|
+
targetNamespace="http://example.com/test">
|
|
23
|
+
<xs:element name="Root" type="xs:string"/>
|
|
24
|
+
</xs:schema>
|
|
25
|
+
XSD
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "captures the root prefix declared for the target namespace" do
|
|
29
|
+
parsed = Lutaml::Xml::Schema::Xsd.parse(xsd_content)
|
|
30
|
+
|
|
31
|
+
expect(parsed.target_namespace).to eq("http://example.com/test")
|
|
32
|
+
expect(parsed.target_namespace_prefix).to eq("t")
|
|
33
|
+
expect(parsed.element.first.target_prefix).to eq("t")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
17
37
|
describe "parsing with exact string mappings" do
|
|
18
38
|
let(:xsd_content) do
|
|
19
39
|
<<~XSD
|