lutaml-model 0.8.183 → 0.8.184

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: 7a5a76da65495bed983c333fb3eddb3c6e8785c78c7e726378c17d1832be0915
4
- data.tar.gz: b7665014e43334ff712a88e1b959cef40583c2b7cd0f19c9b8c0d36150f01c63
3
+ metadata.gz: 7512cd09dea291c7f8ef58266e2fb60aa313701ed7bb0df1843e8c7a194dd092
4
+ data.tar.gz: 720c91d86520af12e609cef406ae88b9d865450ca04c3e0fd3741114abe1b4da
5
5
  SHA512:
6
- metadata.gz: 5dc8da8474f375b8c70e7ba05a1c587beea69c1ea90b013d8113c199fbdc5330cc527e5305c33b6736fe685c138f7db8083724f24d9338636eb7aed142b77130
7
- data.tar.gz: bb96ee5a1d4e3daff6ad42e94a7752084ff08e17383d0e4b42fd5ef11b8534a5678a3683403dfcbcc02e1533639defe23dc8c45d371c15d8e8a2a95cde4bf0a3
6
+ metadata.gz: b5bf83dd31ae2e125c9b886325074b4ae36a333ac637dae2ce364d2dc96850c370e457a0ecb073ece1b2ab247f8e584c000437dfe18c39ed43b4b90bf442a2c9
7
+ data.tar.gz: ebb1d2c13fe1a3725ed78b64dccdfe6993b918a9969121b3569b56a877f3d9bf07f389569ab838f3a3a0ca866928f6fe5cb06bc9ef948d3ef1ff93f34b030686
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.183"
5
+ VERSION = "0.8.184"
6
6
  end
7
7
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xml
5
+ module Schema
6
+ module Xsd
7
+ # XSD 1.1 conditional type assignment — a type alternative on an
8
+ # element declaration, selected by an XPath test (#1203).
9
+ class Alternative < Base
10
+ attribute :id, :string
11
+ attribute :test, :string
12
+ attribute :type, :string
13
+ attribute :xpath_default_namespace, :string
14
+ attribute :annotation, :annotation
15
+
16
+ xml do
17
+ element "alternative"
18
+ mixed_content
19
+ namespace Lutaml::Xml::Schema::XsdNamespace
20
+
21
+ map_attribute :id, to: :id
22
+ map_attribute :test, to: :test
23
+ map_attribute :type, to: :type
24
+ map_attribute :xpathDefaultNamespace, to: :xpath_default_namespace
25
+ map_element :annotation, to: :annotation
26
+ end
27
+
28
+ Lutaml::Xml::Schema::Xsd.register_model(self, :alternative)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xml
5
+ module Schema
6
+ module Xsd
7
+ # XSD 1.1 assertion — an XPath predicate evaluated against the
8
+ # owning complex type's instance (#1203).
9
+ class Assert < Base
10
+ attribute :id, :string
11
+ attribute :test, :string
12
+ attribute :xpath_default_namespace, :string
13
+ attribute :annotation, :annotation
14
+
15
+ xml do
16
+ element "assert"
17
+ mixed_content
18
+ namespace Lutaml::Xml::Schema::XsdNamespace
19
+
20
+ map_attribute :id, to: :id
21
+ map_attribute :test, to: :test
22
+ map_attribute :xpathDefaultNamespace, to: :xpath_default_namespace
23
+ map_element :annotation, to: :annotation
24
+ end
25
+
26
+ Lutaml::Xml::Schema::Xsd.register_model(self, :assert)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -10,6 +10,8 @@ module Lutaml
10
10
  AnyAttribute
11
11
  Annotation
12
12
  Attribute
13
+ Assert
14
+ OpenContent
13
15
  ].freeze
14
16
 
15
17
  attribute :id, :string
@@ -26,6 +28,9 @@ module Lutaml
26
28
  attribute :annotation, :annotation
27
29
  attribute :simple_content, :simple_content
28
30
  attribute :complex_content, :complex_content
31
+ attribute :assert, :assert, collection: true,
32
+ initialize_empty: true
33
+ attribute :open_content, :open_content
29
34
  attribute :attribute, :attribute, collection: true,
30
35
  initialize_empty: true
31
36
  attribute :attribute_group, :attribute_group, collection: true,
@@ -54,6 +59,8 @@ module Lutaml
54
59
  map_element :anyAttribute, to: :any_attribute
55
60
  map_element :simpleContent, to: :simple_content
56
61
  map_element :complexContent, to: :complex_content
62
+ map_element :assert, to: :assert
63
+ map_element :openContent, to: :open_content
57
64
  end
58
65
 
59
66
  liquid do
@@ -25,6 +25,8 @@ module Lutaml
25
25
  attribute :key, :key, collection: true, initialize_empty: true
26
26
  attribute :keyref, :keyref, collection: true, initialize_empty: true
27
27
  attribute :unique, :unique, collection: true, initialize_empty: true
28
+ attribute :alternative, :alternative, collection: true,
29
+ initialize_empty: true
28
30
 
29
31
  xml do
30
32
  element "element"
@@ -51,6 +53,7 @@ module Lutaml
51
53
  map_element :keyref, to: :keyref
52
54
  map_element :unique, to: :unique
53
55
  map_element :key, to: :key
56
+ map_element :alternative, to: :alternative
54
57
  end
55
58
 
56
59
  liquid do
@@ -12,6 +12,8 @@ module Lutaml
12
12
  attribute :choice, :choice
13
13
  attribute :sequence, :sequence
14
14
  attribute :annotation, :annotation
15
+ attribute :assert, :assert, collection: true,
16
+ initialize_empty: true
15
17
  attribute :any_attribute, :any_attribute
16
18
  attribute :attribute, :attribute, collection: true,
17
19
  initialize_empty: true
@@ -31,6 +33,7 @@ module Lutaml
31
33
  map_element :sequence, to: :sequence
32
34
  map_element :attribute, to: :attribute
33
35
  map_element :annotation, to: :annotation
36
+ map_element :assert, to: :assert
34
37
  map_element :anyAttribute, to: :any_attribute
35
38
  map_element :attributeGroup, to: :attribute_group
36
39
  end
@@ -8,6 +8,8 @@ module Lutaml
8
8
  attribute :id, :string
9
9
  attribute :base, :string
10
10
  attribute :annotation, :annotation
11
+ attribute :assert, :assert, collection: true,
12
+ initialize_empty: true
11
13
  attribute :any_attribute, :any_attribute
12
14
  attribute :attribute, :attribute, collection: true,
13
15
  initialize_empty: true
@@ -23,6 +25,7 @@ module Lutaml
23
25
  map_attribute :base, to: :base
24
26
  map_element :attribute, to: :attribute
25
27
  map_element :annotation, to: :annotation
28
+ map_element :assert, to: :assert
26
29
  map_element :anyAttribute, to: :any_attribute
27
30
  map_element :attributeGroup, to: :attribute_group
28
31
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xml
5
+ module Schema
6
+ module Xsd
7
+ # XSD 1.1 open content — relaxes the owning complex type's content
8
+ # model to admit foreign-namespace elements (mode: interleave or
9
+ # suffix) (#1203).
10
+ class OpenContent < Base
11
+ attribute :id, :string
12
+ attribute :mode, :string
13
+ attribute :annotation, :annotation
14
+
15
+ xml do
16
+ element "openContent"
17
+ mixed_content
18
+ namespace Lutaml::Xml::Schema::XsdNamespace
19
+
20
+ map_attribute :id, to: :id
21
+ map_attribute :mode, to: :mode
22
+ map_element :annotation, to: :annotation
23
+ end
24
+
25
+ Lutaml::Xml::Schema::Xsd.register_model(self, :open_content)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -12,6 +12,8 @@ module Lutaml
12
12
  attribute :choice, :choice
13
13
  attribute :sequence, :sequence
14
14
  attribute :annotation, :annotation
15
+ attribute :assert, :assert, collection: true,
16
+ initialize_empty: true
15
17
  attribute :any_attribute, :any_attribute
16
18
  attribute :attribute, :attribute, collection: true,
17
19
  initialize_empty: true
@@ -31,6 +33,7 @@ module Lutaml
31
33
  map_element :sequence, to: :sequence
32
34
  map_element :attribute, to: :attribute
33
35
  map_element :annotation, to: :annotation
36
+ map_element :assert, to: :assert
34
37
  map_element :anyAttribute, to: :any_attribute
35
38
  map_element :attributeGroup, to: :attribute_group
36
39
  end
@@ -8,6 +8,8 @@ module Lutaml
8
8
  attribute :id, :string
9
9
  attribute :base, :string
10
10
  attribute :annotation, :annotation
11
+ attribute :assert, :assert, collection: true,
12
+ initialize_empty: true
11
13
  attribute :simple_type, :simple_type
12
14
  attribute :any_attribute, :any_attribute
13
15
  attribute :length, :length, collection: true, initialize_empty: true
@@ -56,6 +58,7 @@ module Lutaml
56
58
  map_element :simpleType, to: :simple_type
57
59
  map_element :whiteSpace, to: :white_space
58
60
  map_element :annotation, to: :annotation
61
+ map_element :assert, to: :assert
59
62
  map_element :maxLength, to: :max_length
60
63
  map_element :minLength, to: :min_length
61
64
  map_element :attribute, to: :attribute
@@ -28,15 +28,16 @@ module Lutaml
28
28
  # List of all XSD model classes that need to be autoloaded and registered.
29
29
  # This is used in parse() to ensure all types are registered before parsing.
30
30
  XSD_AUTOLOAD_CLASSES = %i[
31
- All Annotation Any AnyAttribute Appinfo Attribute AttributeGroup
32
- Choice ComplexContent ComplexType Documentation Element Enumeration
33
- ExtensionComplexContent ExtensionSimpleContent Field FractionDigits
34
- Glob Group Import Include Key Keyref Length List MaxExclusive
35
- MaxInclusive MaxLength MinExclusive MinInclusive MinLength
36
- Notation Pattern Redefine RestrictionComplexContent
37
- RestrictionSimpleContent RestrictionSimpleType Schema SchemaPath
38
- Selector Sequence SimpleContent SimpleType TotalDigits Union Unique
39
- WhiteSpace SchemaFileValidationResults
31
+ All Alternative Annotation Any AnyAttribute Appinfo Assert Attribute
32
+ AttributeGroup Choice ComplexContent ComplexType Documentation
33
+ Element Enumeration ExtensionComplexContent ExtensionSimpleContent
34
+ Field FractionDigits Glob Group Import Include Key Keyref Length List
35
+ MaxExclusive MaxInclusive MaxLength MinExclusive MinInclusive
36
+ MinLength Notation OpenContent Pattern Redefine
37
+ RestrictionComplexContent RestrictionSimpleContent
38
+ RestrictionSimpleType Schema SchemaPath Selector Sequence SimpleContent
39
+ SimpleType TotalDigits Union Unique WhiteSpace
40
+ SchemaFileValidationResults
40
41
  ].freeze
41
42
 
42
43
  # Autoload all XSD model files (lazy loading)
@@ -57,10 +58,12 @@ module Lutaml
57
58
  autoload :SerializedSchema, "#{__dir__}/xsd/serialized_schema"
58
59
  autoload :SchemaNameResolver, "#{__dir__}/xsd/schema_name_resolver"
59
60
  autoload :All, "#{__dir__}/xsd/all"
61
+ autoload :Alternative, "#{__dir__}/xsd/alternative"
60
62
  autoload :Annotation, "#{__dir__}/xsd/annotation"
61
63
  autoload :Any, "#{__dir__}/xsd/any"
62
64
  autoload :AnyAttribute, "#{__dir__}/xsd/any_attribute"
63
65
  autoload :Appinfo, "#{__dir__}/xsd/appinfo"
66
+ autoload :Assert, "#{__dir__}/xsd/assert"
64
67
  autoload :Attribute, "#{__dir__}/xsd/attribute"
65
68
  autoload :AttributeGroup, "#{__dir__}/xsd/attribute_group"
66
69
  autoload :Choice, "#{__dir__}/xsd/choice"
@@ -73,6 +76,7 @@ module Lutaml
73
76
  "#{__dir__}/xsd/extension_complex_content"
74
77
  autoload :ExtensionSimpleContent,
75
78
  "#{__dir__}/xsd/extension_simple_content"
79
+ autoload :OpenContent, "#{__dir__}/xsd/open_content"
76
80
  autoload :Field, "#{__dir__}/xsd/field"
77
81
  autoload :FractionDigits, "#{__dir__}/xsd/fraction_digits"
78
82
  autoload :Glob, "#{__dir__}/xsd/glob"
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "spec_helper"
4
+
5
+ RSpec.describe "XSD 1.1 constructs (#1203)" do
6
+ it "maps xs:assert on a complexType from the parsed XSD" do
7
+ xsd = <<~XSD
8
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
9
+ <xs:complexType name="t">
10
+ <xs:sequence>
11
+ <xs:element name="a" maxOccurs="unbounded"/>
12
+ </xs:sequence>
13
+ <xs:assert test="count(xs:a) &gt; 1"
14
+ xpathDefaultNamespace="##targetNamespace"/>
15
+ </xs:complexType>
16
+ </xs:schema>
17
+ XSD
18
+
19
+ schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
20
+ assert = schema.complex_type.first.assert.first
21
+
22
+ expect(assert).not_to be_nil
23
+ expect(assert.test).to eq("count(xs:a) > 1")
24
+ expect(assert.xpath_default_namespace).to eq("##targetNamespace")
25
+ end
26
+
27
+ it "maps xs:assert inside simpleContent and complexContent " \
28
+ "derivations" do
29
+ xsd = <<~XSD
30
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
31
+ <xs:complexType name="simple">
32
+ <xs:simpleContent>
33
+ <xs:extension base="xs:string">
34
+ <xs:assert test="string-length(.) &gt; 0"/>
35
+ </xs:extension>
36
+ </xs:simpleContent>
37
+ </xs:complexType>
38
+ <xs:complexType name="complex">
39
+ <xs:complexContent>
40
+ <xs:restriction base="xs:anyType">
41
+ <xs:assert test="true()"/>
42
+ </xs:restriction>
43
+ </xs:complexContent>
44
+ </xs:complexType>
45
+ </xs:schema>
46
+ XSD
47
+
48
+ schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
49
+ simple = schema.complex_type.find { |t| t.name == "simple" }
50
+ complex = schema.complex_type.find { |t| t.name == "complex" }
51
+
52
+ expect(simple.simple_content.extension.assert.first.test)
53
+ .to eq("string-length(.) > 0")
54
+ expect(complex.complex_content.restriction.assert.first.test)
55
+ .to eq("true()")
56
+ end
57
+
58
+ it "maps xs:openContent on a complexType" do
59
+ xsd = <<~XSD
60
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
61
+ <xs:complexType name="t">
62
+ <xs:sequence>
63
+ <xs:element name="a"/>
64
+ </xs:sequence>
65
+ <xs:openContent mode="suffix"/>
66
+ </xs:complexType>
67
+ </xs:schema>
68
+ XSD
69
+
70
+ schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
71
+ open_content = schema.complex_type.first.open_content
72
+
73
+ expect(open_content).not_to be_nil
74
+ expect(open_content.mode).to eq("suffix")
75
+ end
76
+
77
+ it "maps xs:alternative on an element declaration" do
78
+ xsd = <<~XSD
79
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
80
+ <xs:element name="shape">
81
+ <xs:alternative test="@kind='circle'" type="CircleType"
82
+ xpathDefaultNamespace="##targetNamespace"/>
83
+ <xs:alternative type="DefaultType"/>
84
+ </xs:element>
85
+ </xs:schema>
86
+ XSD
87
+
88
+ schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
89
+ alternatives = schema.element.first.alternative
90
+
91
+ expect(alternatives.map(&:type)).to eq(%w[CircleType DefaultType])
92
+ expect(alternatives.first.test).to eq("@kind='circle'")
93
+ expect(alternatives.first.xpath_default_namespace)
94
+ .to eq("##targetNamespace")
95
+ end
96
+
97
+ it "round-trips the constructs through to_xml" do
98
+ xsd = <<~XSD
99
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
100
+ <xs:complexType name="t">
101
+ <xs:openContent mode="interleave"/>
102
+ <xs:assert test="true()"/>
103
+ </xs:complexType>
104
+ <xs:element name="e">
105
+ <xs:alternative test="@k='v'" type="T"/>
106
+ </xs:element>
107
+ </xs:schema>
108
+ XSD
109
+
110
+ schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
111
+ emitted = schema.to_xml
112
+
113
+ expect(emitted).to include("<xs:assert")
114
+ expect(emitted).to include('test="true()"')
115
+ expect(emitted).to include("<xs:openContent")
116
+ expect(emitted).to include('mode="interleave"')
117
+ expect(emitted).to include("<xs:alternative")
118
+ expect(emitted).to include('type="T"')
119
+ end
120
+ end
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.183
4
+ version: 0.8.184
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -883,10 +883,12 @@ files:
883
883
  - lib/lutaml/xml/schema/relaxng_schema.rb
884
884
  - lib/lutaml/xml/schema/xsd.rb
885
885
  - lib/lutaml/xml/schema/xsd/all.rb
886
+ - lib/lutaml/xml/schema/xsd/alternative.rb
886
887
  - lib/lutaml/xml/schema/xsd/annotation.rb
887
888
  - lib/lutaml/xml/schema/xsd/any.rb
888
889
  - lib/lutaml/xml/schema/xsd/any_attribute.rb
889
890
  - lib/lutaml/xml/schema/xsd/appinfo.rb
891
+ - lib/lutaml/xml/schema/xsd/assert.rb
890
892
  - lib/lutaml/xml/schema/xsd/attribute.rb
891
893
  - lib/lutaml/xml/schema/xsd/attribute_group.rb
892
894
  - lib/lutaml/xml/schema/xsd/base.rb
@@ -925,6 +927,7 @@ files:
925
927
  - lib/lutaml/xml/schema/xsd/namespace_mapping.rb
926
928
  - lib/lutaml/xml/schema/xsd/namespace_uri_remapping.rb
927
929
  - lib/lutaml/xml/schema/xsd/notation.rb
930
+ - lib/lutaml/xml/schema/xsd/open_content.rb
928
931
  - lib/lutaml/xml/schema/xsd/pattern.rb
929
932
  - lib/lutaml/xml/schema/xsd/redefine.rb
930
933
  - lib/lutaml/xml/schema/xsd/restriction_complex_content.rb
@@ -2129,6 +2132,7 @@ files:
2129
2132
  - spec/lutaml/xml/schema/xsd/unresolvable_schema_location_spec.rb
2130
2133
  - spec/lutaml/xml/schema/xsd/validation_error_spec.rb
2131
2134
  - spec/lutaml/xml/schema/xsd/validation_result_spec.rb
2135
+ - spec/lutaml/xml/schema/xsd/xsd_11_constructs_spec.rb
2132
2136
  - spec/lutaml/xml/schema/xsd/xsd_spec.rb
2133
2137
  - spec/lutaml/xml/schema_primer_spec.rb
2134
2138
  - spec/lutaml/xml/serializable_namespace_spec.rb