lutaml-model 0.8.179 → 0.8.180
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/Gemfile +5 -2
- data/lib/compat/opal/lutaml_model_boot.rb +2 -0
- data/lib/lutaml/model/type/id_refs.rb +33 -0
- data/lib/lutaml/model/type/nm_tokens.rb +33 -0
- data/lib/lutaml/model/type.rb +6 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/spec/lutaml/model/schema/xml_compiler_runtime_spec.rb +65 -0
- data/spec/lutaml/xml/validate_xml_with_constructs_spec.rb +0 -11
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e923a0e0792f0329e8bd5f4008d17baa30e80f4622f772d1b877c0ec13952c8b
|
|
4
|
+
data.tar.gz: a59f92e90c98a6d0f1e77016616486be237c61db69410f1e412d1f91864d6345
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86d5ec47de95898724f2517e9d206a7e027baa85178b0312de4f1f3aa4fc477d4ac4c77948c1a36c91187c3597b5d22a00c789c3adb23f0500f11ddc5cf2ae16
|
|
7
|
+
data.tar.gz: 28abd3d0802117bfe05b9c5f825f825fc962c2aaa091b9eccfc2003bdcf60f011a629227d8a580743f7efb3400fcddebbf6e65c0a8d90ce897173e06e4ed0b94
|
data/Gemfile
CHANGED
|
@@ -48,8 +48,11 @@ gem "rexml"
|
|
|
48
48
|
# (see Lutaml::Xml::Leptris::MIN_LEPTRIS_VERSION) — child snapshots,
|
|
49
49
|
# exact-URI attribute rows, nested-attribute capture, wildcard rows,
|
|
50
50
|
# walk-side ns retention and leniency, :unqualified rows, and the
|
|
51
|
-
# address-based text attach all ride it.
|
|
52
|
-
|
|
51
|
+
# address-based text attach all ride it. The dev floor additionally
|
|
52
|
+
# pins the XSD lane's targetNamespace qualification (leptris#2158,
|
|
53
|
+
# first shipped in 1.9.443.0) so CI validates against the enforcing
|
|
54
|
+
# engine; consumer runtime support stays at MIN_LEPTRIS_VERSION.
|
|
55
|
+
gem "leptris", ">= 1.9.443.0" # dev floor: RAW op (leptris#1941) capability line plus the XSD targetNamespace enforcement (leptris#2158); MIN_LEPTRIS_VERSION stays 1.9.406.0 for consumers, and the emission lane additionally version-gates namespaced trees to >= 1.9.407.0 (attr ns_prefix deep-copy, leptris#1967/#1968)
|
|
53
56
|
gem "teptris"
|
|
54
57
|
gem "yeptris" unless Gem.win_platform?
|
|
55
58
|
# TODO: revert rng branch to main when lutaml/rng#32 is merged
|
|
@@ -354,10 +354,12 @@ require "lutaml/model/type/g_year_month"
|
|
|
354
354
|
require "lutaml/model/type/hash"
|
|
355
355
|
require "lutaml/model/type/hex_binary"
|
|
356
356
|
require "lutaml/model/type/hostname"
|
|
357
|
+
require "lutaml/model/type/id_refs"
|
|
357
358
|
require "lutaml/model/type/integer"
|
|
358
359
|
require "lutaml/model/type/ip_v4_address"
|
|
359
360
|
require "lutaml/model/type/ip_v6_address"
|
|
360
361
|
require "lutaml/model/type/metaschema_pattern"
|
|
362
|
+
require "lutaml/model/type/nm_tokens"
|
|
361
363
|
require "lutaml/model/type/non_negative_integer"
|
|
362
364
|
require "lutaml/model/type/positive_integer"
|
|
363
365
|
require "lutaml/model/type/qname"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema IDREFS datatype: a whitespace-separated list of IDREF
|
|
7
|
+
# values — "a1 b2", "a1".
|
|
8
|
+
#
|
|
9
|
+
# @example Using IdRefs type
|
|
10
|
+
# attribute :see_also, :idrefs
|
|
11
|
+
class IdRefs < String
|
|
12
|
+
IDREF = /[a-zA-Z_][\w.-]*/
|
|
13
|
+
PATTERN = /\A#{IDREF}(?:\s+#{IDREF})*\z/
|
|
14
|
+
|
|
15
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
16
|
+
value&.to_s
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.valid?(value)
|
|
20
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.json_schema_format
|
|
24
|
+
"idrefs"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.default_xsd_type
|
|
28
|
+
"xs:IDREFS"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema NMTOKENS datatype: a whitespace-separated list of
|
|
7
|
+
# NMTOKEN values — "en-US de-DE", "en-US".
|
|
8
|
+
#
|
|
9
|
+
# @example Using NmTokens type
|
|
10
|
+
# attribute :locales, :nmtokens
|
|
11
|
+
class NmTokens < String
|
|
12
|
+
NMTOKEN = /[\w.:-]+/
|
|
13
|
+
PATTERN = /\A#{NMTOKEN}(?:\s+#{NMTOKEN})*\z/
|
|
14
|
+
|
|
15
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
16
|
+
value&.to_s
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.valid?(value)
|
|
20
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.json_schema_format
|
|
24
|
+
"nmtokens"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.default_xsd_type
|
|
28
|
+
"xs:NMTOKENS"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/lutaml/model/type.rb
CHANGED
|
@@ -43,6 +43,8 @@ module Lutaml
|
|
|
43
43
|
autoload :GMonth, "#{__dir__}/type/g_month"
|
|
44
44
|
autoload :GMonthDay, "#{__dir__}/type/g_month_day"
|
|
45
45
|
autoload :GDay, "#{__dir__}/type/g_day"
|
|
46
|
+
autoload :IdRefs, "#{__dir__}/type/id_refs"
|
|
47
|
+
autoload :NmTokens, "#{__dir__}/type/nm_tokens"
|
|
46
48
|
|
|
47
49
|
# Error classes (defined in error/type/ but under Type namespace)
|
|
48
50
|
autoload :InvalidValueError, "#{__dir__}/error/type/invalid_value_error"
|
|
@@ -60,6 +62,7 @@ module Lutaml
|
|
|
60
62
|
integer: "Lutaml::Model::Type::Integer",
|
|
61
63
|
float: "Lutaml::Model::Type::Float",
|
|
62
64
|
double: "Lutaml::Model::Type::Float",
|
|
65
|
+
int: "Lutaml::Model::Type::Integer",
|
|
63
66
|
decimal: "Lutaml::Model::Type::Decimal",
|
|
64
67
|
date: "Lutaml::Model::Type::Date",
|
|
65
68
|
time: "Lutaml::Model::Type::Time",
|
|
@@ -72,6 +75,9 @@ module Lutaml
|
|
|
72
75
|
duration: "Lutaml::Model::Type::Duration",
|
|
73
76
|
uri: "Lutaml::Model::Type::Uri",
|
|
74
77
|
qname: "Lutaml::Model::Type::QName",
|
|
78
|
+
q_name: "Lutaml::Model::Type::QName",
|
|
79
|
+
idrefs: "Lutaml::Model::Type::IdRefs",
|
|
80
|
+
nmtokens: "Lutaml::Model::Type::NmTokens",
|
|
75
81
|
base64_binary: "Lutaml::Model::Type::Base64Binary",
|
|
76
82
|
hex_binary: "Lutaml::Model::Type::HexBinary",
|
|
77
83
|
email_address: "Lutaml::Model::Type::EmailAddress",
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -214,4 +214,69 @@ RSpec.describe "runtime XSD class loading" do
|
|
|
214
214
|
expect(Lutaml::Model::Type::GMonth.valid?("--11")).to be(true)
|
|
215
215
|
end
|
|
216
216
|
end
|
|
217
|
+
|
|
218
|
+
# The union builder blanket-snakes member names, so every skippable
|
|
219
|
+
# builtin spelling that a union can carry must resolve to a registered
|
|
220
|
+
# type — #1190 covers the four the g-date work left out.
|
|
221
|
+
describe "union members over the remaining skippable builtins" do
|
|
222
|
+
{
|
|
223
|
+
"xs:int" => ["int", "<rint><v>42</v></rint>", 42],
|
|
224
|
+
"xs:QName" => ["qname", "<rqname><v>p:foo</v></rqname>", "p:foo"],
|
|
225
|
+
"xs:IDREFS" => ["idrefs", "<ridrefs><v>a1 b2</v></ridrefs>", "a1 b2"],
|
|
226
|
+
"xs:NMTOKENS" => ["nmtokens", "<rnmtokens><v>a1 b2</v></rnmtokens>",
|
|
227
|
+
"a1 b2"],
|
|
228
|
+
}.each do |member, (suffix, xml, expected)|
|
|
229
|
+
it "resolves a #{member} union member and parses an instance" do
|
|
230
|
+
xsd = <<~XSD
|
|
231
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
232
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
233
|
+
<xs:simpleType name="u#{suffix}">
|
|
234
|
+
<xs:union memberTypes="#{member}"/>
|
|
235
|
+
</xs:simpleType>
|
|
236
|
+
<xs:complexType name="T#{suffix}">
|
|
237
|
+
<xs:sequence>
|
|
238
|
+
<xs:element name="v" type="u#{suffix}"/>
|
|
239
|
+
</xs:sequence>
|
|
240
|
+
</xs:complexType>
|
|
241
|
+
<xs:element name="r#{suffix}" type="T#{suffix}"/>
|
|
242
|
+
</xs:schema>
|
|
243
|
+
XSD
|
|
244
|
+
dir = "union_#{suffix}_models"
|
|
245
|
+
Lutaml::Model::Schema.from_xml(
|
|
246
|
+
xsd, output_dir: dir, load_classes: true
|
|
247
|
+
)
|
|
248
|
+
namespace = dir.split("_").map(&:capitalize).join
|
|
249
|
+
|
|
250
|
+
parsed = Object.const_get("#{namespace}::T#{suffix}").from_xml(xml)
|
|
251
|
+
|
|
252
|
+
expect(parsed.v).to eq(expected)
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
describe "builtin list spellings and aliases" do
|
|
258
|
+
it "registers the union-facing symbols" do
|
|
259
|
+
codes = Lutaml::Model::Type::TYPE_CODES
|
|
260
|
+
|
|
261
|
+
expect(codes[:int]).to eq("Lutaml::Model::Type::Integer")
|
|
262
|
+
expect(codes[:q_name]).to eq("Lutaml::Model::Type::QName")
|
|
263
|
+
expect(codes[:idrefs]).to eq("Lutaml::Model::Type::IdRefs")
|
|
264
|
+
expect(codes[:nmtokens]).to eq("Lutaml::Model::Type::NmTokens")
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it "validates the IDREFS lexical form" do
|
|
268
|
+
expect(Lutaml::Model::Type::IdRefs.valid?("a1")).to be(true)
|
|
269
|
+
expect(Lutaml::Model::Type::IdRefs.valid?("a1 b2")).to be(true)
|
|
270
|
+
expect(Lutaml::Model::Type::IdRefs.valid?("1a b2")).to be(false)
|
|
271
|
+
expect(Lutaml::Model::Type::IdRefs.valid?("a1,b2")).to be(false)
|
|
272
|
+
expect(Lutaml::Model::Type::IdRefs.valid?("")).to be(false)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it "validates the NMTOKENS lexical form" do
|
|
276
|
+
expect(Lutaml::Model::Type::NmTokens.valid?("en-US")).to be(true)
|
|
277
|
+
expect(Lutaml::Model::Type::NmTokens.valid?("en-US de-DE")).to be(true)
|
|
278
|
+
expect(Lutaml::Model::Type::NmTokens.valid?("en US,fr")).to be(false)
|
|
279
|
+
expect(Lutaml::Model::Type::NmTokens.valid?("")).to be(false)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
217
282
|
end
|
|
@@ -188,17 +188,6 @@ RSpec.describe "validate_xml_with XSD constructs" do
|
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
it "rejects a document missing the target namespace" do
|
|
191
|
-
# The leptris engine's targetNamespace qualification fix
|
|
192
|
-
# (leptris#2158, tracked as leptris/leptris-ruby#679) merged after
|
|
193
|
-
# the v1.9.442 engine tag, so no released leptris gem carries it
|
|
194
|
-
# yet; the cell gates until a gem build ships the fix. The default
|
|
195
|
-
# nokogiri lane enforces it and runs the assertion.
|
|
196
|
-
engine = Lutaml::Model::Config.xml_adapter_type&.to_s
|
|
197
|
-
if engine == "leptris"
|
|
198
|
-
skip "leptris targetNamespace enforcement pending a leptris " \
|
|
199
|
-
"gem carrying leptris#2158"
|
|
200
|
-
end
|
|
201
|
-
|
|
202
191
|
xml = "<address><city>Berlin</city></address>"
|
|
203
192
|
|
|
204
193
|
expect(XsdNamespacedDoc.validate_xml(xml)).not_to be_empty
|
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.
|
|
4
|
+
version: 0.8.180
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -682,10 +682,12 @@ files:
|
|
|
682
682
|
- lib/lutaml/model/type/hash.rb
|
|
683
683
|
- lib/lutaml/model/type/hex_binary.rb
|
|
684
684
|
- lib/lutaml/model/type/hostname.rb
|
|
685
|
+
- lib/lutaml/model/type/id_refs.rb
|
|
685
686
|
- lib/lutaml/model/type/integer.rb
|
|
686
687
|
- lib/lutaml/model/type/ip_v4_address.rb
|
|
687
688
|
- lib/lutaml/model/type/ip_v6_address.rb
|
|
688
689
|
- lib/lutaml/model/type/metaschema_pattern.rb
|
|
690
|
+
- lib/lutaml/model/type/nm_tokens.rb
|
|
689
691
|
- lib/lutaml/model/type/non_negative_integer.rb
|
|
690
692
|
- lib/lutaml/model/type/positive_integer.rb
|
|
691
693
|
- lib/lutaml/model/type/qname.rb
|