lutaml-model 0.8.195 → 0.8.197
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/docs/_references/plan-schema-spec.adoc +308 -0
- data/lib/compat/opal/lutaml_model_boot.rb +2 -0
- data/lib/lutaml/lml/format/adapter/standard_adapter.rb +10 -3
- data/lib/lutaml/lml/models/top_element_attribute.rb +7 -2
- data/lib/lutaml/model/serialize/annotations.rb +74 -0
- data/lib/lutaml/model/serialize/builder.rb +2 -0
- data/lib/lutaml/model/serialize/initialization.rb +20 -1
- data/lib/lutaml/model/serialize/tracking_default_hash.rb +64 -0
- data/lib/lutaml/model/serialize.rb +57 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/adapter_element.rb +5 -1
- data/lib/lutaml/xml/mapping.rb +15 -0
- data/lib/lutaml/xml/schema/xsd/attribute.rb +3 -0
- data/lib/lutaml/xml/schema/xsd/element.rb +3 -0
- data/lib/lutaml/xml/schema/xsd/max_scale.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/min_scale.rb +25 -0
- data/lib/lutaml/xml/schema/xsd/restriction_simple_type.rb +9 -0
- data/lib/lutaml/xml/schema/xsd/vc_conditional_attributes.rb +62 -0
- data/lib/lutaml/xml/schema/xsd.rb +6 -2
- data/lib/lutaml/xml/schema/xsd_schema.rb +2 -0
- data/spec/lml/lutaml/lml/format_adapter_spec.rb +24 -0
- data/spec/lml/lutaml/lml/json_transfer_spec.rb +188 -0
- data/spec/lml/lutaml/lml/property_laws_spec.rb +3 -38
- data/spec/lml/support/lml_property_support.rb +168 -0
- data/spec/lutaml/model/annotations_spec.rb +97 -0
- data/spec/lutaml/model/mutable_default_spec.rb +110 -0
- data/spec/lutaml/xml/adapter_element_verbatim_spec.rb +44 -0
- data/spec/lutaml/xml/plan_mixed_content_nested_namespace_spec.rb +2 -2
- data/spec/lutaml/xml/schema/xsd_scale_vc_spec.rb +59 -0
- metadata +14 -2
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
ENV["RANTLY_VERBOSE"] ||= "0"
|
|
4
|
+
require "rantly"
|
|
5
|
+
require "rantly/rspec_extensions"
|
|
6
|
+
require "rantly/shrinks"
|
|
7
|
+
require "lutaml/lml/format"
|
|
8
|
+
|
|
9
|
+
# Constants shared by the generative laws (TODO.next/sota/properties.md).
|
|
10
|
+
# Seeded and reproducible: the seed is printed before every property run,
|
|
11
|
+
# and Rantly shrinks the generated tuple on failure. PR runs use a
|
|
12
|
+
# reduced count and depth; the nightly workflow raises both through
|
|
13
|
+
# LML_PROPERTY_COUNT / LML_PROPERTY_DEPTH and supplies a fresh seed.
|
|
14
|
+
module PropertyLawsSupport
|
|
15
|
+
SEED = Integer(ENV.fetch("LML_PROPERTY_SEED", "20261020"))
|
|
16
|
+
COUNT = Integer(ENV.fetch("LML_PROPERTY_COUNT", "40"))
|
|
17
|
+
DEPTH = Integer(ENV.fetch("LML_PROPERTY_DEPTH", "2"))
|
|
18
|
+
|
|
19
|
+
TYPES = {
|
|
20
|
+
string: :string, integer: :integer, float: :float, boolean: :boolean
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
23
|
+
# Values that a bare-word emission would read back as something other
|
|
24
|
+
# than a string (or not read at all).
|
|
25
|
+
EDGE_STRINGS = [
|
|
26
|
+
"", "null", "true", "false", "01", "1.50", "2dCi9o", "0x10",
|
|
27
|
+
"with space", "a-b", 'quote"x', "back\\slash", " padded ",
|
|
28
|
+
"line\nbreak", "tab\there", "üñï", "🎨", "12", "-3"
|
|
29
|
+
].freeze
|
|
30
|
+
|
|
31
|
+
STRING_GEN = proc do
|
|
32
|
+
case choose(:print, :ascii, :edge)
|
|
33
|
+
when :print then string(:print)
|
|
34
|
+
when :ascii then string(:ascii)
|
|
35
|
+
else choose(*EDGE_STRINGS)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# The document-model comparison defined with TODO.canon/5.
|
|
40
|
+
DEFAULT_VALUES = {
|
|
41
|
+
"visibility" => "public", "literal" => false, "is_derived" => false,
|
|
42
|
+
"is_static" => false, "is_read_only" => false, "is_abstract" => false,
|
|
43
|
+
"direction" => "in"
|
|
44
|
+
}.freeze
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Grammar-directed LML document generator shared by the generative laws.
|
|
48
|
+
module LmlDocumentGenerator
|
|
49
|
+
# ---- grammar-directed document generation ----
|
|
50
|
+
|
|
51
|
+
def generated_document(params)
|
|
52
|
+
numbers = params.array
|
|
53
|
+
counts = Array.new(7) { |i| numbers[i] % (PropertyLawsSupport::DEPTH + 1) }
|
|
54
|
+
seed = numbers[7]
|
|
55
|
+
|
|
56
|
+
model = []
|
|
57
|
+
model.concat(generated_classes(seed, counts[0]))
|
|
58
|
+
model.concat(generated_enums(seed, counts[1], counts[2]))
|
|
59
|
+
model.concat(generated_packages(seed, counts[3]))
|
|
60
|
+
model.concat(generated_mappings(counts[4]))
|
|
61
|
+
|
|
62
|
+
source = +""
|
|
63
|
+
source << "lml \"1.0\"\n\n" if numbers[9].even?
|
|
64
|
+
source << "require \"gen.lml\"\n\n" if numbers[8].even?
|
|
65
|
+
source << wrap_models(seed, model) unless model.empty?
|
|
66
|
+
source << generated_instances(counts[5], counts[6])
|
|
67
|
+
source
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def wrap_models(seed, members)
|
|
71
|
+
"models Gen#{seed % 10} {\n#{indent(members.join("\n\n"))}\n}\n\n"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def generated_classes(seed, count)
|
|
75
|
+
Array.new(count) do |i|
|
|
76
|
+
attrs = Array.new((seed + i) % (PropertyLawsSupport::DEPTH + 2)) do |j|
|
|
77
|
+
generated_attribute(seed + i + j, j)
|
|
78
|
+
end
|
|
79
|
+
body = attrs.map { |line| indent(line) }
|
|
80
|
+
body << indent("definition \"generated class #{i}\"") if seed.even?
|
|
81
|
+
body << indent("op#{i}(in x: String) : Boolean") if (seed + i) % 4 == 1
|
|
82
|
+
body << indent("** class comment #{i}") if (seed + i) % 4 == 2
|
|
83
|
+
|
|
84
|
+
header = "class C#{i}"
|
|
85
|
+
header += " < Base" if (seed + i) % 5 == 3
|
|
86
|
+
"#{header} {\n#{body.join("\n\n")}\n}"
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def generated_attribute(seed, index)
|
|
91
|
+
name = "a#{index}"
|
|
92
|
+
type = PropertyLawsSupport::TYPES.keys.map { |key| key.to_s.capitalize }[seed % 4]
|
|
93
|
+
case seed % 6
|
|
94
|
+
when 0 then "attribute #{name}, #{type}"
|
|
95
|
+
when 1 then "attribute #{name}, #{type} { cardinality 0..n }"
|
|
96
|
+
when 2 then "attribute #{name}, #{type} { values { \"x\", \"y\" } }"
|
|
97
|
+
when 3 then "attribute #{name}, #{type} { pattern /a[0-9]+/ }"
|
|
98
|
+
when 4 then "-a#{index}: #{type} [1..2]"
|
|
99
|
+
else "attribute #{name}, #{type} { default: \"d#{index}\" }"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def generated_enums(seed, count, members)
|
|
104
|
+
Array.new(count) do |i|
|
|
105
|
+
body = ["definition \"generated enum #{i}\""]
|
|
106
|
+
Array.new(members) do |m|
|
|
107
|
+
body << generated_enum_member(seed + m, m)
|
|
108
|
+
end
|
|
109
|
+
"enum E#{i} {\n#{indent(body.join("\n\n"))}\n}"
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def generated_enum_member(seed, index)
|
|
114
|
+
case seed % 4
|
|
115
|
+
when 0 then "value \"v#{index}\" {\n definition \"member #{index}\"\n}"
|
|
116
|
+
when 1 then "value v#{index}"
|
|
117
|
+
when 2 then "m#{index}: String"
|
|
118
|
+
else "value \"p#{index}\" {\n payload = \"x\"\n instance Payload {\n a = \"b\"\n }\n}"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def generated_packages(seed, count)
|
|
123
|
+
Array.new(count) do
|
|
124
|
+
"package P#{seed % 10} {\n" \
|
|
125
|
+
"#{indent('class PClass { attribute x, String }')}\n\n" \
|
|
126
|
+
"#{indent('enum PEnum { value "p" }')}\n}"
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def generated_mappings(count)
|
|
131
|
+
return [] if count.zero?
|
|
132
|
+
|
|
133
|
+
["mapping xml Thing {\n" \
|
|
134
|
+
"#{indent('element "thing"')}\n\n" \
|
|
135
|
+
"#{indent('map_element "wire" a0')}\n}"]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def generated_instances(collections, instances)
|
|
139
|
+
lines = []
|
|
140
|
+
instances.times do |i|
|
|
141
|
+
lines << "instance \"t#{i}\" Thing {"
|
|
142
|
+
lines << indent("a0 = \"value #{i}\"")
|
|
143
|
+
lines << indent("a1 = 1")
|
|
144
|
+
lines << indent("a2 = true")
|
|
145
|
+
lines << indent("a3 = null")
|
|
146
|
+
lines << indent("a4 = [\"x\", \"null\", \"é\"]")
|
|
147
|
+
lines << "}"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
if collections.positive?
|
|
151
|
+
lines << "instances GenInstances {"
|
|
152
|
+
Array.new(collections) do |i|
|
|
153
|
+
lines << indent("collection \"col#{i}\" {")
|
|
154
|
+
lines << indent(indent("includes [\"t#{i}\"]"))
|
|
155
|
+
lines << indent(indent('validation { condition "count >= 0" }'))
|
|
156
|
+
lines << indent("}")
|
|
157
|
+
end
|
|
158
|
+
lines << "}"
|
|
159
|
+
end
|
|
160
|
+
return "" if lines.empty?
|
|
161
|
+
|
|
162
|
+
"#{lines.join("\n\n")}\n"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def indent(text)
|
|
166
|
+
text.lines.map { |line| " #{line}" }.join
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#288 step 1: the class-level annotation DSL —
|
|
6
|
+
# description/example/annotation — stored in a frozen per-class table.
|
|
7
|
+
# Purely additive: the table is invisible to serialization and to the
|
|
8
|
+
# #1033 exporter's declaration walk.
|
|
9
|
+
RSpec.describe "class-level annotations DSL" do
|
|
10
|
+
let(:annotated_class) do
|
|
11
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
12
|
+
attribute :name, :string
|
|
13
|
+
xml do
|
|
14
|
+
element "annotated"
|
|
15
|
+
map_element "name", to: :name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
description "A model carrying annotations."
|
|
19
|
+
description "Second prose line."
|
|
20
|
+
example %(name: "x"), description: "minimal shape"
|
|
21
|
+
example %(name: "y")
|
|
22
|
+
annotation :schema, "follows the base pattern"
|
|
23
|
+
annotation :schema, "extended per the profile"
|
|
24
|
+
annotation :source, "the base register"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before do
|
|
29
|
+
stub_const("AnnotatedSpecModel", annotated_class)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "stores repeatable descriptions in declaration order" do
|
|
33
|
+
expect(AnnotatedSpecModel.annotations[:descriptions]).to eq(
|
|
34
|
+
["A model carrying annotations.", "Second prose line."],
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "stores examples with optional descriptions" do
|
|
39
|
+
expect(AnnotatedSpecModel.annotations[:examples]).to eq(
|
|
40
|
+
[
|
|
41
|
+
{ snippet: %(name: "x"), description: "minimal shape" },
|
|
42
|
+
{ snippet: %(name: "y") },
|
|
43
|
+
],
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "groups keyed annotations per term, keeping declaration order" do
|
|
48
|
+
expect(AnnotatedSpecModel.annotations[:annotations][:schema]).to eq(
|
|
49
|
+
["follows the base pattern", "extended per the profile"],
|
|
50
|
+
)
|
|
51
|
+
expect(AnnotatedSpecModel.annotations[:annotations][:source]).to eq(
|
|
52
|
+
["the base register"],
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "returns a frozen table" do
|
|
57
|
+
table = AnnotatedSpecModel.annotations
|
|
58
|
+
expect(table).to be_frozen
|
|
59
|
+
expect(table[:descriptions]).to be_frozen
|
|
60
|
+
expect(table[:examples]).to be_frozen
|
|
61
|
+
expect(table[:annotations]).to be_frozen
|
|
62
|
+
expect(table[:annotations][:schema]).to be_frozen
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "isolates classes: an unannotated class reads an empty table" do
|
|
66
|
+
plain = Class.new(Lutaml::Model::Serializable)
|
|
67
|
+
stub_const("PlainSpecModel", plain)
|
|
68
|
+
|
|
69
|
+
expect(PlainSpecModel.annotations).to eq(
|
|
70
|
+
descriptions: [], examples: [], annotations: {},
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "does not leak annotations across sibling classes" do
|
|
75
|
+
sibling = Class.new(Lutaml::Model::Serializable)
|
|
76
|
+
stub_const("SiblingSpecModel", sibling)
|
|
77
|
+
SiblingSpecModel.description "sibling only"
|
|
78
|
+
|
|
79
|
+
expect(SiblingSpecModel.annotations[:descriptions]).to eq(["sibling only"])
|
|
80
|
+
expect(AnnotatedSpecModel.annotations[:descriptions]).not_to include("sibling only")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "leaves serialization byte-identical" do
|
|
84
|
+
annotated = AnnotatedSpecModel.new(name: "x")
|
|
85
|
+
plain = Class.new(Lutaml::Model::Serializable) do
|
|
86
|
+
attribute :name, :string
|
|
87
|
+
xml do
|
|
88
|
+
element "annotated"
|
|
89
|
+
map_element "name", to: :name
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
stub_const("PlainShapeSpecModel", plain)
|
|
93
|
+
|
|
94
|
+
expect(annotated.to_xml.strip).to eq(PlainShapeSpecModel.new(name: "x").to_xml.strip)
|
|
95
|
+
expect(annotated.to_json.strip).to eq(PlainShapeSpecModel.new(name: "x").to_json.strip)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lib/lutaml/model"
|
|
5
|
+
|
|
6
|
+
module MutableDefaultSpec
|
|
7
|
+
class Definition < Lutaml::Model::Serializable
|
|
8
|
+
attribute :terms, :string, collection: true
|
|
9
|
+
|
|
10
|
+
yaml do
|
|
11
|
+
map "terms", to: :terms
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Concept < Lutaml::Model::Serializable
|
|
16
|
+
attribute :id, :string
|
|
17
|
+
attribute :data, Definition, default: -> { Definition.new }
|
|
18
|
+
attribute :meta, :hash, default: -> { {} }
|
|
19
|
+
|
|
20
|
+
yaml do
|
|
21
|
+
map "id", to: :id
|
|
22
|
+
map "data", to: :data
|
|
23
|
+
map "meta", to: :meta
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class LocalizedConcept < Lutaml::Model::Serializable
|
|
28
|
+
attribute :id, :string
|
|
29
|
+
attribute :data, Definition, default: -> { Definition.new }
|
|
30
|
+
|
|
31
|
+
yaml do
|
|
32
|
+
map "id", to: :id
|
|
33
|
+
map "data", to: :data
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The delegating-setter shape from the issue: a custom writer that
|
|
37
|
+
# writes through the default nested object.
|
|
38
|
+
def language_code=(value)
|
|
39
|
+
data.terms = [value]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def language_code
|
|
43
|
+
data.terms&.first
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
RSpec.describe "mutable constructor defaults" do
|
|
49
|
+
describe "nested model default mutated in place" do
|
|
50
|
+
it "serializes the mutation (issue #1272)" do
|
|
51
|
+
concept = MutableDefaultSpec::Concept.new
|
|
52
|
+
concept.data.terms = ["thermal-neutron"]
|
|
53
|
+
|
|
54
|
+
yaml = concept.to_yaml
|
|
55
|
+
|
|
56
|
+
expect(yaml).to include("thermal-neutron")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "still omits an untouched default" do
|
|
60
|
+
concept = MutableDefaultSpec::Concept.new
|
|
61
|
+
|
|
62
|
+
expect(concept.to_yaml).not_to include("data")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "reads the mutation back through the nested reader" do
|
|
66
|
+
concept = MutableDefaultSpec::Concept.new
|
|
67
|
+
concept.data.terms = ["thermal-neutron"]
|
|
68
|
+
|
|
69
|
+
round_tripped = MutableDefaultSpec::Concept.from_yaml(concept.to_yaml)
|
|
70
|
+
|
|
71
|
+
expect(round_tripped.data.terms).to eq(["thermal-neutron"])
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe "delegating writer through the default" do
|
|
76
|
+
it "serializes the delegated mutation" do
|
|
77
|
+
concept = MutableDefaultSpec::LocalizedConcept.new
|
|
78
|
+
concept.language_code = "eng"
|
|
79
|
+
|
|
80
|
+
yaml = concept.to_yaml
|
|
81
|
+
|
|
82
|
+
expect(yaml).to include("eng")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "hash default mutated in place" do
|
|
87
|
+
it "serializes the mutation" do
|
|
88
|
+
concept = MutableDefaultSpec::Concept.new
|
|
89
|
+
concept.meta[:register] = "main"
|
|
90
|
+
|
|
91
|
+
yaml = concept.to_yaml
|
|
92
|
+
|
|
93
|
+
expect(yaml).to include("register")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "parsed instances keep the absent-omission semantics (#922)" do
|
|
98
|
+
it "keeps a read-but-unmutated absent attribute omitted" do
|
|
99
|
+
concept = MutableDefaultSpec::Concept.from_yaml("id: c1\n")
|
|
100
|
+
|
|
101
|
+
_ = concept.data # the read materializes the default object
|
|
102
|
+
_ = concept.meta
|
|
103
|
+
|
|
104
|
+
yaml = concept.to_yaml
|
|
105
|
+
|
|
106
|
+
expect(yaml).not_to include("data")
|
|
107
|
+
expect(yaml).not_to include("meta")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# Raw markup capture through a custom `with:` handler (the lane isodoc's
|
|
6
|
+
# BibdataConfig#bibdata_from_xml rides) must return the source subtree
|
|
7
|
+
# byte-for-byte. moxml's document serializer pretty-prints when the
|
|
8
|
+
# context's default indent applies, which compounds onto the source's own
|
|
9
|
+
# whitespace-only text nodes ("<v>\n <x/>" round-tripping as
|
|
10
|
+
# "<v>\n <x/>"); AdapterElement#to_xml opts out of formatting so the
|
|
11
|
+
# verbatim contract holds.
|
|
12
|
+
RSpec.describe "AdapterElement#to_xml verbatim raw markup" do
|
|
13
|
+
let(:handler_class) do
|
|
14
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
15
|
+
attribute :frag, :string
|
|
16
|
+
|
|
17
|
+
xml do
|
|
18
|
+
element "d"
|
|
19
|
+
map_element "frag", to: :frag,
|
|
20
|
+
with: {
|
|
21
|
+
from: :frag_from_xml, to: :frag_to_xml
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def frag_from_xml(model, node)
|
|
26
|
+
model.frag = node.to_xml
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def frag_to_xml(_model, _parent, _doc); end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "returns the subtree byte-for-byte when the source is single-spaced" do
|
|
34
|
+
source = "<d><frag>\n <x a=\"1\">inner</x>\n</frag></d>"
|
|
35
|
+
expect(handler_class.from_xml(source).frag)
|
|
36
|
+
.to eq("<frag>\n <x a=\"1\">inner</x>\n</frag>")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "does not compound onto pre-existing indentation on nested sources" do
|
|
40
|
+
source = "<d><frag><v>\n <x>inner</x>\n</v></frag></d>"
|
|
41
|
+
expect(handler_class.from_xml(source).frag)
|
|
42
|
+
.to eq("<frag><v>\n <x>inner</x>\n</v></frag>")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -64,9 +64,9 @@ RSpec.describe "nested model namespace declarations on the plan serialization pa
|
|
|
64
64
|
|
|
65
65
|
let(:xml) do
|
|
66
66
|
'<root xmlns="http://example.com/outer">' \
|
|
67
|
-
|
|
67
|
+
"<symbol>mm</symbol>" \
|
|
68
68
|
'<symbol><math xmlns="http://example.com/inner">' \
|
|
69
|
-
|
|
69
|
+
"<mi>mm</mi></math></symbol>" \
|
|
70
70
|
"</root>"
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe "XSD 1.1 scale facets and component-level vc: attributes" do
|
|
6
|
+
let(:source) do
|
|
7
|
+
<<~XML
|
|
8
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning">
|
|
9
|
+
<xs:attribute name="x" use="required" vc:typeUnavailable="xs:integer"/>
|
|
10
|
+
<xs:element name="e" vc:minVersion="1.1"/>
|
|
11
|
+
<xs:simpleType name="decMinMaxScale">
|
|
12
|
+
<xs:restriction base="xs:precisionDecimal">
|
|
13
|
+
<xs:minScale value="2"/>
|
|
14
|
+
<xs:maxScale value="3"/>
|
|
15
|
+
</xs:restriction>
|
|
16
|
+
</xs:simpleType>
|
|
17
|
+
</xs:schema>
|
|
18
|
+
XML
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
let(:root) { Lutaml::Xml::Schema::Xsd.parse(source, register: :xsd) }
|
|
22
|
+
|
|
23
|
+
describe "minScale/maxScale facets (XSD 1.1 §3.4.2)" do
|
|
24
|
+
it "parses the scale facets" do
|
|
25
|
+
restriction = root.simple_type.first.restriction
|
|
26
|
+
|
|
27
|
+
expect(restriction.min_scale.first.value).to eq(2)
|
|
28
|
+
expect(restriction.max_scale.first.value).to eq(3)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "round-trips the scale facets" do
|
|
32
|
+
xml = root.to_xml
|
|
33
|
+
|
|
34
|
+
expect(xml).to include("minScale")
|
|
35
|
+
expect(xml).to include("maxScale")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "component-level vc: conditional attributes (XSD 1.1 §4.2)" do
|
|
40
|
+
it "parses the declaration-level spellings" do
|
|
41
|
+
expect(root.attribute.first.vc_type_unavailable).to eq("xs:integer")
|
|
42
|
+
expect(root.element.first.vc_min_version).to eq("1.1")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "round-trips with the vc: namespace" do
|
|
46
|
+
xml = root.to_xml
|
|
47
|
+
|
|
48
|
+
expect(xml).to include("vc:typeUnavailable")
|
|
49
|
+
expect(xml).to include("vc:minVersion")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "absent vc: attributes stay absent" do
|
|
53
|
+
xml = root.to_xml
|
|
54
|
+
|
|
55
|
+
expect(xml).not_to include("vc:typeAvailable")
|
|
56
|
+
expect(xml).not_to include("vc:facetUnavailable")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.197
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -295,6 +295,7 @@ files:
|
|
|
295
295
|
- docs/_references/instance-serialization.adoc
|
|
296
296
|
- docs/_references/lutaml-namespace-planning.md
|
|
297
297
|
- docs/_references/parent-root-context.adoc
|
|
298
|
+
- docs/_references/plan-schema-spec.adoc
|
|
298
299
|
- docs/_references/rdf-namespaces.adoc
|
|
299
300
|
- docs/_references/reference_type.adoc
|
|
300
301
|
- docs/_references/serialization-model-mappings.adoc
|
|
@@ -752,6 +753,7 @@ files:
|
|
|
752
753
|
- lib/lutaml/model/serializable.rb
|
|
753
754
|
- lib/lutaml/model/serialization_adapter.rb
|
|
754
755
|
- lib/lutaml/model/serialize.rb
|
|
756
|
+
- lib/lutaml/model/serialize/annotations.rb
|
|
755
757
|
- lib/lutaml/model/serialize/attribute_definition.rb
|
|
756
758
|
- lib/lutaml/model/serialize/builder.rb
|
|
757
759
|
- lib/lutaml/model/serialize/conversion_caching.rb
|
|
@@ -760,6 +762,7 @@ files:
|
|
|
760
762
|
- lib/lutaml/model/serialize/format_conversion.rb
|
|
761
763
|
- lib/lutaml/model/serialize/initialization.rb
|
|
762
764
|
- lib/lutaml/model/serialize/model_import.rb
|
|
765
|
+
- lib/lutaml/model/serialize/tracking_default_hash.rb
|
|
763
766
|
- lib/lutaml/model/serialize/transformation_builder.rb
|
|
764
767
|
- lib/lutaml/model/serialize/value_mapping.rb
|
|
765
768
|
- lib/lutaml/model/services.rb
|
|
@@ -1022,9 +1025,11 @@ files:
|
|
|
1022
1025
|
- lib/lutaml/xml/schema/xsd/max_exclusive.rb
|
|
1023
1026
|
- lib/lutaml/xml/schema/xsd/max_inclusive.rb
|
|
1024
1027
|
- lib/lutaml/xml/schema/xsd/max_length.rb
|
|
1028
|
+
- lib/lutaml/xml/schema/xsd/max_scale.rb
|
|
1025
1029
|
- lib/lutaml/xml/schema/xsd/min_exclusive.rb
|
|
1026
1030
|
- lib/lutaml/xml/schema/xsd/min_inclusive.rb
|
|
1027
1031
|
- lib/lutaml/xml/schema/xsd/min_length.rb
|
|
1032
|
+
- lib/lutaml/xml/schema/xsd/min_scale.rb
|
|
1028
1033
|
- lib/lutaml/xml/schema/xsd/namespace_mapping.rb
|
|
1029
1034
|
- lib/lutaml/xml/schema/xsd/namespace_uri_remapping.rb
|
|
1030
1035
|
- lib/lutaml/xml/schema/xsd/notation.rb
|
|
@@ -1052,6 +1057,7 @@ files:
|
|
|
1052
1057
|
- lib/lutaml/xml/schema/xsd/unique.rb
|
|
1053
1058
|
- lib/lutaml/xml/schema/xsd/validation_error.rb
|
|
1054
1059
|
- lib/lutaml/xml/schema/xsd/validation_result.rb
|
|
1060
|
+
- lib/lutaml/xml/schema/xsd/vc_conditional_attributes.rb
|
|
1055
1061
|
- lib/lutaml/xml/schema/xsd/version.rb
|
|
1056
1062
|
- lib/lutaml/xml/schema/xsd/white_space.rb
|
|
1057
1063
|
- lib/lutaml/xml/schema/xsd_namespace.rb
|
|
@@ -1970,6 +1976,7 @@ files:
|
|
|
1970
1976
|
- spec/lml/lutaml/lml/has_attributes_spec.rb
|
|
1971
1977
|
- spec/lml/lutaml/lml/import_resolver_spec.rb
|
|
1972
1978
|
- spec/lml/lutaml/lml/instance_hydration_spec.rb
|
|
1979
|
+
- spec/lml/lutaml/lml/json_transfer_spec.rb
|
|
1973
1980
|
- spec/lml/lutaml/lml/lsp/server_spec.rb
|
|
1974
1981
|
- spec/lml/lutaml/lml/model_compiler_spec.rb
|
|
1975
1982
|
- spec/lml/lutaml/lml/models/association_spec.rb
|
|
@@ -2008,6 +2015,7 @@ files:
|
|
|
2008
2015
|
- spec/lml/lutaml/parsers/dsl_spec.rb
|
|
2009
2016
|
- spec/lml/lutaml/parsers/yaml_spec.rb
|
|
2010
2017
|
- spec/lml/lutaml/qualified_type_spec.rb
|
|
2018
|
+
- spec/lml/support/lml_property_support.rb
|
|
2011
2019
|
- spec/lutaml/integration/edge_cases_spec.rb
|
|
2012
2020
|
- spec/lutaml/integration/multi_format_spec.rb
|
|
2013
2021
|
- spec/lutaml/integration/round_trip_spec.rb
|
|
@@ -2027,6 +2035,7 @@ files:
|
|
|
2027
2035
|
- spec/lutaml/model/adapter_resolver_configured_spec.rb
|
|
2028
2036
|
- spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb
|
|
2029
2037
|
- spec/lutaml/model/adapter_type_unset_restore_spec.rb
|
|
2038
|
+
- spec/lutaml/model/annotations_spec.rb
|
|
2030
2039
|
- spec/lutaml/model/any_element_mapping_spec.rb
|
|
2031
2040
|
- spec/lutaml/model/attribute_apply_value_map_spec.rb
|
|
2032
2041
|
- spec/lutaml/model/attribute_collection_spec.rb
|
|
@@ -2124,6 +2133,7 @@ files:
|
|
|
2124
2133
|
- spec/lutaml/model/model_import_reentry_spec.rb
|
|
2125
2134
|
- spec/lutaml/model/model_transformer_spec.rb
|
|
2126
2135
|
- spec/lutaml/model/multiple_mapping_spec.rb
|
|
2136
|
+
- spec/lutaml/model/mutable_default_spec.rb
|
|
2127
2137
|
- spec/lutaml/model/namespace_autoload_spec.rb
|
|
2128
2138
|
- spec/lutaml/model/namespace_versioning_spec.rb
|
|
2129
2139
|
- spec/lutaml/model/one_entry_cache_spec.rb
|
|
@@ -2278,6 +2288,7 @@ files:
|
|
|
2278
2288
|
- spec/lutaml/xml/adapter/ox_adapter_spec.rb
|
|
2279
2289
|
- spec/lutaml/xml/adapter/rexml_adapter_spec.rb
|
|
2280
2290
|
- spec/lutaml/xml/adapter/xml_namespace_spec.rb
|
|
2291
|
+
- spec/lutaml/xml/adapter_element_verbatim_spec.rb
|
|
2281
2292
|
- spec/lutaml/xml/adapter_loader_spec.rb
|
|
2282
2293
|
- spec/lutaml/xml/adapter_metadata_default_spec.rb
|
|
2283
2294
|
- spec/lutaml/xml/adapter_moxml_engine_spec.rb
|
|
@@ -2412,6 +2423,7 @@ files:
|
|
|
2412
2423
|
- spec/lutaml/xml/schema/xsd/vc_versioning_spec.rb
|
|
2413
2424
|
- spec/lutaml/xml/schema/xsd/xsd_11_constructs_spec.rb
|
|
2414
2425
|
- spec/lutaml/xml/schema/xsd/xsd_spec.rb
|
|
2426
|
+
- spec/lutaml/xml/schema/xsd_scale_vc_spec.rb
|
|
2415
2427
|
- spec/lutaml/xml/schema_primer_spec.rb
|
|
2416
2428
|
- spec/lutaml/xml/serializable_namespace_spec.rb
|
|
2417
2429
|
- spec/lutaml/xml/shared_element_rules_spec.rb
|