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: c356719b1c0c3434ba1acb3f59be81cb9374403c8020710ee4d4a5ea78748765
4
- data.tar.gz: ac2aa51ef80ce8db3c50b8055df95b6a3732e3e40b72689c635e8ac22fe889f2
3
+ metadata.gz: cf72982044ef4dcc8a413bafe9432721faac7954f6cee3ff75446b3cf9af0016
4
+ data.tar.gz: 9c920d3cf43328d88cfd4be60cfd4b03dbf40b2c7f7d3e532d35518e3081014c
5
5
  SHA512:
6
- metadata.gz: b63ac862dc2eeef4a599ff5ada8c6f2434b3bf71187b5813a2637e69f25170692d373bffb2b9413b48323b1cd6161a8529a2ec6582a2fc313d46c95fa8b67088
7
- data.tar.gz: 24e23bdedad47cc0796cff0bad1b32809c649bad4a13a64b23d08b3bef2dad4c769cfc299cdb85abeffd9a53ea677c41f91c759114f320a5047787cafc6c253e
6
+ metadata.gz: d396accc65f1dff8a826baf62764e01f2217d20bff02ca3aee70d4dba7244df7c8577ff6f1d84fd3d97f93e7f8dcc87583d07a441398c691aaa90f5955799d73
7
+ data.tar.gz: 124d44d40a30dbe9ff896d7afc8eedfda5a66d6a06453d43901cbd6dffdcbab2f2f34234b9cebdd30326e0110678a3f346e35ed1d0e8553a896bf69af42b5a66
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.6"
5
+ VERSION = "0.8.7"
6
6
  end
7
7
  end
@@ -145,13 +145,10 @@ module Lutaml
145
145
  attribute_group.sort_by { |item| item.name.to_s }
146
146
  end
147
147
 
148
- # Capture both the target namespace URI and the matching prefix
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
- namespaces.find { |_, namespace| namespace.uri == value }&.first
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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "lutaml/model"
3
4
  require "lutaml/xml/schema/xsd"
4
5
 
5
6
  module XsdSpecHelper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.