lutaml-model 0.8.181 → 0.8.183

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: 461625987c7637612b57671b30897876e703d33fc0baa9354bcc59b8026666f7
4
- data.tar.gz: 72ea3b59453e91f1272f86cf3c381684b736fa39fde338187dc5259239eeba80
3
+ metadata.gz: 7a5a76da65495bed983c333fb3eddb3c6e8785c78c7e726378c17d1832be0915
4
+ data.tar.gz: b7665014e43334ff712a88e1b959cef40583c2b7cd0f19c9b8c0d36150f01c63
5
5
  SHA512:
6
- metadata.gz: 4b719debdf1a00a74b1cd48ad26d69b3688de6873d8bdace9cd4d9a2b79a3041f6a39dcdec56672b259dfd5af11e324d764e678515a543cec2110343a1716b2d
7
- data.tar.gz: 9b05b26ab2260074cd58582f5709b07b56189fcb8dce0155927cfe2e824ee73819ca56500fa03b273137b774a5b230afe4f36842eba0506c7428d41853f0782e
6
+ metadata.gz: 5dc8da8474f375b8c70e7ba05a1c587beea69c1ea90b013d8113c199fbdc5330cc527e5305c33b6736fe685c138f7db8083724f24d9338636eb7aed142b77130
7
+ data.tar.gz: bb96ee5a1d4e3daff6ad42e94a7752084ff08e17383d0e4b42fd5ef11b8534a5678a3683403dfcbcc02e1533639defe23dc8c45d371c15d8e8a2a95cde4bf0a3
@@ -133,6 +133,7 @@ require "lutaml/xml/attribute_namespace_resolver"
133
133
  require "lutaml/xml/blank_namespace"
134
134
  require "lutaml/xml/blank_namespace_handler"
135
135
  require "lutaml/xml/builder"
136
+ require "lutaml/xml/collection_consolidation"
136
137
  require "lutaml/xml/configurable"
137
138
  require "lutaml/xml/data_model"
138
139
  require "lutaml/xml/decisions"
@@ -542,6 +543,7 @@ require "lutaml/xml/decisions/rules/inherit_parent_prefix_rule"
542
543
  require "lutaml/xml/decisions/rules/namespace_scope_rule"
543
544
  require "lutaml/xml/decisions/rules/reuse_parent_prefix_rule"
544
545
  require "lutaml/xml/decisions/rules/used_prefix_rule"
546
+ require "lutaml/xml/schema/builder/moxml"
545
547
  require "lutaml/model/schema/xml_compiler/spec_builder/complex_types"
546
548
  require "lutaml/model/schema/xml_compiler/spec_builder/members"
547
549
  require "lutaml/model/schema/xml_compiler/spec_builder/simple_types"
@@ -91,7 +91,7 @@ module Lutaml
91
91
  id = Utils.snake_case(entry.name).to_sym
92
92
  "#{indent}#{class_name} # Trigger autoload\n" \
93
93
  "#{indent}context.registry.register(:#{id}, #{class_name})\n" \
94
- "#{indent}#{class_name}.instance_variable_set(:@register, :#{@register_id})"
94
+ "#{indent}#{class_name}.set_register_context(:#{@register_id})"
95
95
  end.join("\n")
96
96
  end
97
97
 
@@ -76,6 +76,10 @@ module Lutaml
76
76
  raise "XML schema compilation requires lutaml-xml. Add it to your Gemfile."
77
77
  end
78
78
 
79
+ def self.target_namespace(_xml)
80
+ raise "XML schema compilation requires lutaml-xml. Add it to your Gemfile."
81
+ end
82
+
79
83
  def self.from_relaxng(_rng, _options = {})
80
84
  raise "RELAX NG schema compilation requires lutaml-xml. Add it to your Gemfile."
81
85
  end
@@ -130,7 +130,7 @@ module Lutaml
130
130
  raise Lutaml::Model::FormatAdapterNotSpecifiedError.new(format) if adapter.nil?
131
131
 
132
132
  # Resolve imports at the entry point of deserialization
133
- register = options[:register] || Lutaml::Model::Config.default_register
133
+ register = extract_register_id(options[:register])
134
134
 
135
135
  # Hook for format-specific pre-deserialization (e.g., XML mapping import resolution)
136
136
  pre_deserialize_hook(format, register)
@@ -177,7 +177,7 @@ module Lutaml
177
177
  adapter_name &&= adapter_name.name
178
178
  return nil unless adapter_name.to_s.end_with?("LeptrisAdapter")
179
179
 
180
- register = Lutaml::Model::Config.default_register
180
+ register = extract_register_id(nil)
181
181
  plan = Lutaml::Xml::Leptris::PlanCompiler.compile(self, register)
182
182
  return nil unless plan &&
183
183
  Lutaml::Xml::Leptris::PlanSerializer.serializable?(plan)
@@ -206,7 +206,7 @@ module Lutaml
206
206
  adapter_name = adapter_name&.name
207
207
  return nil unless adapter_name.to_s.end_with?("LeptrisAdapter")
208
208
 
209
- register = Lutaml::Model::Config.default_register
209
+ register = extract_register_id(nil)
210
210
  plan = Lutaml::Xml::Leptris::PlanCompiler.compile(self, register)
211
211
  return nil unless plan
212
212
 
@@ -223,6 +223,7 @@ module Lutaml
223
223
  Lutaml::Xml::Leptris::PlanHydrator.call(self, plan,
224
224
  plan[:descriptor].walk(root),
225
225
  node: root,
226
+ register: register,
226
227
  declaration_plan_mode:
227
228
  options.fetch(
228
229
  :import_declaration_plan, :eager
@@ -453,7 +454,7 @@ module Lutaml
453
454
  end
454
455
 
455
456
  # Resolve imports at the start of serialization
456
- register = options[:register] || Lutaml::Model::Config.default_register
457
+ register = extract_register_id(options[:register])
457
458
 
458
459
  # Hook for format-specific pre-serialization (e.g., XML mapping import resolution)
459
460
  pre_serialize_hook(format, register)
@@ -461,6 +462,8 @@ module Lutaml
461
462
  # Recursively resolve child model imports
462
463
  ensure_child_imports_resolved!(register)
463
464
 
465
+ options[:register] = register
466
+
464
467
  transformer = Lutaml::Model::Config.transformer_for(format)
465
468
  transformer.model_to_data(self, instance, format, options)
466
469
  end
@@ -48,6 +48,21 @@ module Lutaml
48
48
  @format_type_serializers = {}
49
49
 
50
50
  class << self
51
+ # Set the register context for this type class.
52
+ #
53
+ # Called by derivation registries (RegistryGenerator) so derived
54
+ # types resolve their members (e.g. union memberTypes) in the
55
+ # register they were registered into. Mirrors Serializable's
56
+ # set_register_context contract.
57
+ #
58
+ # @param register_id [Symbol] The register ID
59
+ # @return [void]
60
+ def set_register_context(register_id)
61
+ return if instance_variable_defined?(:@register)
62
+
63
+ @register = register_id
64
+ end
65
+
51
66
  # Register a custom type serializer for a specific format and type class.
52
67
  # Format plugins call this at load time to register their custom serialization logic.
53
68
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.181"
5
+ VERSION = "0.8.183"
6
6
  end
7
7
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xml
5
+ # Shared XML post-processing for interpreted mappings and native plans.
6
+ # Organization belongs to the collection's XML mapping; both parse paths
7
+ # must run it after all attributes, deferred mappings and delegates settle.
8
+ module CollectionConsolidation
9
+ def self.call(instance, register, instance_is_serialize = nil)
10
+ return unless instance_is_serialize || instance.is_a?(::Lutaml::Model::Serialize)
11
+
12
+ instance.class.attributes.each_value do |attr|
13
+ next unless attr.collection?
14
+ next unless attr.custom_collection?
15
+
16
+ collection = instance.public_send(attr.name)
17
+ next unless collection.is_a?(::Lutaml::Model::Collection)
18
+ next unless collection.class.organization
19
+
20
+ mappings = collection.class.mappings_for(:xml, register)
21
+ next unless mappings.is_a?(::Lutaml::Xml::Mapping)
22
+ next if mappings.consolidation_maps.empty?
23
+
24
+ mappings.consolidation_maps.each do |map|
25
+ org = collection.class.organization
26
+ resolved_map = if map.group_class
27
+ map
28
+ else
29
+ ::Lutaml::Model::ConsolidationMap.new(
30
+ by: map.by,
31
+ to: map.to,
32
+ group_class: org.group_class,
33
+ rules: map.rules,
34
+ )
35
+ end
36
+ ::Lutaml::Model::Consolidation::Engine.run(
37
+ collection, resolved_map, collection.collection
38
+ )
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -129,6 +129,7 @@ module Lutaml
129
129
  autoload :Element, "#{__dir__}/element"
130
130
  autoload :NestedCollectionAttribute,
131
131
  "#{__dir__}/nested_collection_attribute"
132
+ autoload :CollectionConsolidation, "#{__dir__}/collection_consolidation"
132
133
  autoload :ModelTransform, "#{__dir__}/model_transform"
133
134
  autoload :ParseSession, "#{__dir__}/parse_session"
134
135
  autoload :TypeNamespaceResolver, "#{__dir__}/type_namespace_resolver"
@@ -323,6 +324,22 @@ Lutaml::Model::Schema.register_method(:from_xml) do |xml, options = {}|
323
324
  Lutaml::Model::Schema::XmlCompiler.to_models(xml, options)
324
325
  end
325
326
 
327
+ # The target namespace URI of an XSD document — the value callers pass
328
+ # back as the compile's `namespace:` option so generated models bind
329
+ # their schema namespace (parse-side matching and emission both ride
330
+ # it; see #1204). Rides Xsd.parse so the metaschema registration
331
+ # preamble runs before the parse resolves attribute types.
332
+ Lutaml::Model::Schema.register_method(:target_namespace) do |xml|
333
+ if Lutaml::Model.opal?
334
+ raise NotImplementedError,
335
+ "XML schema compilation is not available under Opal."
336
+ end
337
+
338
+ parsed = Lutaml::Xml::Schema::Xsd.parse(xml, validate_schema: false)
339
+ schema = parsed.is_a?(Array) ? parsed.first : parsed
340
+ schema&.target_namespace
341
+ end
342
+
326
343
  Lutaml::Model::Schema.register_method(:from_relaxng) do |rng, options = {}|
327
344
  if Lutaml::Model::RuntimeCompatibility.opal?
328
345
  raise NotImplementedError,
@@ -98,6 +98,7 @@ module Lutaml
98
98
  interpret_deferred(model_class, plan, value, instance, node,
99
99
  buckets, run_children)
100
100
  route_delegates(delegates, instance)
101
+ CollectionConsolidation.call(instance, register)
101
102
  instance
102
103
  end
103
104
 
@@ -1724,37 +1724,7 @@ effective_register = lutaml_register)
1724
1724
  # @param instance [Serializable] the deserialized model instance
1725
1725
  # @param register [Symbol] the register id
1726
1726
  def run_consolidation(instance, register, instance_is_serialize = nil)
1727
- return unless instance_is_serialize || instance.is_a?(::Lutaml::Model::Serialize)
1728
-
1729
- instance.class.attributes.each_value do |attr|
1730
- next unless attr.collection?
1731
- next unless attr.custom_collection?
1732
-
1733
- collection = instance.public_send(attr.name)
1734
- next unless collection.is_a?(::Lutaml::Model::Collection)
1735
- next unless collection.class.organization
1736
-
1737
- mappings = collection.class.mappings_for(:xml, register)
1738
- next unless mappings.is_a?(::Lutaml::Xml::Mapping)
1739
- next if mappings.consolidation_maps.empty?
1740
-
1741
- mappings.consolidation_maps.each do |map|
1742
- org = collection.class.organization
1743
- resolved_map = if map.group_class
1744
- map
1745
- else
1746
- ::Lutaml::Model::ConsolidationMap.new(
1747
- by: map.by,
1748
- to: map.to,
1749
- group_class: org.group_class,
1750
- rules: map.rules,
1751
- )
1752
- end
1753
- ::Lutaml::Model::Consolidation::Engine.run(
1754
- collection, resolved_map, collection.collection
1755
- )
1756
- end
1757
- end
1727
+ CollectionConsolidation.call(instance, register, instance_is_serialize)
1758
1728
  end
1759
1729
 
1760
1730
  # Check if any child element in the pre-built Set matches the rule.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xml
5
+ module Schema
6
+ class Builder
7
+ # The moxml-backed schema builder (issue #1184): schema
8
+ # generation rides the CONFIGURED engine through the moxml
9
+ # layer, so every engine with a builder face generates
10
+ # schemas — not only the engines with a dedicated wrapper.
11
+ # The backend resolves from Config's plain symbol; the
12
+ # AdapterResolver's FIXED_ADAPTER_TYPE sentinel never reaches
13
+ # Moxml (the closed #1183 leak).
14
+ #
15
+ # The block receives the Moxml::Builder and drives it with
16
+ # the same method_missing tag DSL the Nokogiri/Oga wrappers
17
+ # expose: tag(attrs) { ... } closures, symbol or string
18
+ # attribute keys, xmlns handled as a namespace declaration.
19
+ class Moxml
20
+ attr_reader :builder
21
+
22
+ def initialize(options = {}, &block)
23
+ encoding = options[:encoding] || "UTF-8"
24
+ backend = Lutaml::Model::Config.xml_adapter_type || :nokogiri
25
+ @context = ::Moxml.new(backend)
26
+ @builder = ::Moxml::Builder.new(@context)
27
+ # Nokogiri's Builder emits the declaration when an
28
+ # encoding is given; parity here.
29
+ @builder.declaration(version: "1.0", encoding: encoding)
30
+ yield(@builder) if block
31
+ end
32
+
33
+ # Generate the schema XML string
34
+ # @param options [Hash] formatting options
35
+ # @option options [Boolean] :pretty Pretty print with indentation
36
+ # @option options [Integer] :indent Number of spaces (default: 2)
37
+ # @return [String] schema XML string
38
+ def to_xml(options = {})
39
+ doc = @builder.document
40
+ if options[:pretty]
41
+ indent = options[:indent] || 2
42
+ doc.to_xml(indent: indent)
43
+ else
44
+ doc.to_xml
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -14,6 +14,7 @@ module Lutaml
14
14
  class Builder
15
15
  autoload :Nokogiri, "#{__dir__}/builder/nokogiri"
16
16
  autoload :Oga, "#{__dir__}/builder/oga"
17
+ autoload :Moxml, "#{__dir__}/builder/moxml"
17
18
 
18
19
  attr_reader :builder, :adapter_type
19
20
 
@@ -24,13 +25,11 @@ module Lutaml
24
25
  # Use specified adapter, or configured XML adapter, or default to Nokogiri
25
26
  requested_adapter = adapter_type || Lutaml::Model::Config.xml_adapter_type || :nokogiri
26
27
 
27
- # Schema generation requires a builder API which only Nokogiri and Oga provide
28
- # Ox and REXML are valid XML parsing adapters but don't have schema builder implementations
29
- @adapter_type = if SUPPORTED_BUILDERS.include?(requested_adapter)
30
- requested_adapter
31
- else
32
- :nokogiri
33
- end
28
+ # Engines with a dedicated wrapper keep it (byte-identical
29
+ # emission); every other configured engine generates through
30
+ # the moxml layer (#1184) — the wrapper follows the engine
31
+ # instead of silently substituting Nokogiri.
32
+ @adapter_type = requested_adapter
34
33
  @options = options
35
34
  @builder = create_builder(&block)
36
35
  end
@@ -51,6 +50,8 @@ module Lutaml
51
50
  Nokogiri.new(@options, &block)
52
51
  when :oga
53
52
  Oga.new(@options, &block)
53
+ else
54
+ Moxml.new(@options, &block)
54
55
  end
55
56
  end
56
57
  end
@@ -1,19 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
4
-
5
3
  module Lutaml
6
4
  module Xml
7
5
  module Schema
8
6
  # RelaxNG schema generation for XML models
9
7
  #
10
- # Generates RELAX NG schemas from LutaML model classes.
8
+ # Generates RELAX NG schemas from LutaML model classes. The
9
+ # emission rides the configured engine through the moxml layer
10
+ # (#1184); an explicit adapter option keeps the dedicated
11
+ # Nokogiri/Oga wrappers available.
11
12
  class RelaxngSchema
12
13
  extend Lutaml::Model::Schema::SharedMethods
13
14
 
14
15
  def self.generate(klass, options = {})
15
16
  register = extract_register_from(klass)
16
- builder = ::Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
17
+ adapter = options[:adapter] ||
18
+ Lutaml::Model::Config.xml_adapter_type || :nokogiri
19
+ builder = Builder.new(
20
+ adapter_type: adapter,
21
+ options: { encoding: "UTF-8" },
22
+ ) do |xml|
17
23
  xml.grammar(xmlns: "http://relaxng.org/ns/structure/1.0") do
18
24
  generate_start(xml, klass)
19
25
  generate_define(xml, klass, register)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
4
-
5
3
  module Lutaml
6
4
  module Xml
7
5
  module Schema
@@ -89,7 +87,7 @@ module Lutaml
89
87
  # @param content [String] XML content to analyze
90
88
  # @return [String] Detected version ("1.0" or "1.1")
91
89
  def self.detect_version(content)
92
- doc = ::Nokogiri::XML(content)
90
+ doc = parse_context.parse(content)
93
91
  root = doc.root
94
92
  return "1.0" unless root
95
93
 
@@ -105,13 +103,23 @@ module Lutaml
105
103
  "1.0"
106
104
  end
107
105
  end
108
- rescue ::Nokogiri::XML::SyntaxError
106
+ rescue Moxml::ParseError
109
107
  "1.0" # Default to 1.0 if cannot parse
110
108
  end
111
109
 
110
+ # The configured engine as a moxml backend symbol. Config's
111
+ # plain symbol — NOT the AdapterResolver's configured type,
112
+ # whose FIXED_ADAPTER_TYPE sentinel is internal and must
113
+ # never reach Moxml (the closed #1183 leak). Not memoized:
114
+ # the backend follows the CURRENT config (hosts and suites
115
+ # switch adapters mid-process); construction is cheap.
116
+ def self.parse_context
117
+ Moxml.new(Lutaml::Model::Config.xml_adapter_type || :nokogiri)
118
+ end
119
+
112
120
  # Check if document has XSD 1.1 specific features
113
121
  #
114
- # @param doc [Nokogiri::XML::Document] Parsed XML document
122
+ # @param doc [Moxml::Document] Parsed XML document
115
123
  # @return [Boolean] true if XSD 1.1 features are present
116
124
  def self.has_xsd_1_1_features?(doc)
117
125
  # Check for XSD 1.1 specific elements
@@ -152,25 +160,25 @@ module Lutaml
152
160
  # @param content [String] XML content to validate
153
161
  # @raise [SchemaValidationError] if XML syntax is invalid
154
162
  def validate_xml_syntax(content)
155
- ::Nokogiri::XML(content, &:strict)
156
- rescue ::Nokogiri::XML::SyntaxError => e
163
+ self.class.parse_context.parse(content, strict: true)
164
+ rescue Moxml::ParseError => e
157
165
  raise SchemaValidationError, "Invalid XML syntax: #{e.message}"
158
166
  end
159
167
 
160
168
  # Parse XML with error handling
161
169
  #
162
170
  # @param content [String] XML content to parse
163
- # @return [::Nokogiri::XML::Document] Parsed document
171
+ # @return [Moxml::Document] Parsed document
164
172
  # @raise [SchemaValidationError] if parsing fails
165
173
  def parse_xml(content)
166
- ::Nokogiri::XML(content)
167
- rescue ::Nokogiri::XML::SyntaxError => e
174
+ self.class.parse_context.parse(content)
175
+ rescue Moxml::ParseError => e
168
176
  raise SchemaValidationError, "Failed to parse XML: #{e.message}"
169
177
  end
170
178
 
171
179
  # Validate that root element is xs:schema
172
180
  #
173
- # @param doc [Nokogiri::XML::Document] Parsed XML document
181
+ # @param doc [Moxml::Document] Parsed XML document
174
182
  # @raise [SchemaValidationError] if root element is not a valid schema element
175
183
  def validate_schema_root(doc)
176
184
  root = doc.root
@@ -188,7 +196,7 @@ module Lutaml
188
196
  end
189
197
 
190
198
  # Check if root element has the correct namespace
191
- namespace_uri = root.namespace&.href
199
+ namespace_uri = root.namespace&.uri
192
200
  return if namespace_uri == XSD_NAMESPACE
193
201
 
194
202
  if namespace_uri.nil?
@@ -204,7 +212,7 @@ module Lutaml
204
212
 
205
213
  # Validate schema version compatibility
206
214
  #
207
- # @param doc [Nokogiri::XML::Document] Parsed XML document
215
+ # @param doc [Moxml::Document] Parsed XML document
208
216
  # @raise [SchemaValidationError] if schema uses features incompatible with target version
209
217
  def validate_schema_version(doc)
210
218
  return if @version == "1.1" # 1.1 accepts all features
@@ -221,7 +229,7 @@ module Lutaml
221
229
 
222
230
  # Detect which XSD 1.1 features are present
223
231
  #
224
- # @param doc [Nokogiri::XML::Document] Parsed XML document
232
+ # @param doc [Moxml::Document] Parsed XML document
225
233
  # @return [Array<String>] List of detected XSD 1.1 features
226
234
  def detect_1_1_features(doc)
227
235
  features = []
@@ -786,23 +786,81 @@ skip_unmapped: false)
786
786
  end
787
787
 
788
788
  def self.reject_invalid_xsd_pattern!(regexp, source)
789
- return unless defined?(::Nokogiri::XML::Schema)
790
-
791
- probe = <<~XSD
792
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
793
- <xs:simpleType name="p">
794
- <xs:restriction base="xs:string">
795
- <xs:pattern value="#{xsd_escape(source)}"/>
796
- </xs:restriction>
797
- </xs:simpleType>
798
- </xs:schema>
799
- XSD
800
- schema = ::Nokogiri::XML::Schema(probe)
801
- return if schema.errors.empty?
802
-
803
- raise_inexpressible_pattern!(regexp, schema.errors.first.message)
804
- rescue ::Nokogiri::XML::SyntaxError => e
805
- raise_inexpressible_pattern!(regexp, e.message)
789
+ detail = structural_xsd_incompatibility(source)
790
+ return unless detail
791
+
792
+ raise_inexpressible_pattern!(regexp, detail)
793
+ end
794
+
795
+ # The structural probe for XSD's regexp subset (issue #1184).
796
+ # The constructs Ruby's engine adds beyond XSD 1.0's —
797
+ # lookaround, atomic groups, conditionals, backreferences,
798
+ # possessive/lazy quantifiers, \G — are detected
799
+ # syntactically: a compile probe cannot vouch for
800
+ # expressibility on every engine, because moxml lanes compile
801
+ # inexpressible patterns silently (and lanes without a
802
+ # validator never probed at all). Escapes are honored
803
+ # pair-wise and character classes are skipped wholesale
804
+ # (their interiors are literal XSD text).
805
+ def self.structural_xsd_incompatibility(source)
806
+ i = 0
807
+ len = source.length
808
+ while i < len
809
+ ch = source[i]
810
+ if ch == "\\"
811
+ nxt = source[i + 1]
812
+ return "the backreference \\#{nxt}" if nxt && ("1".."9").cover?(nxt)
813
+ return "the \\G anchor" if nxt == "G"
814
+ return "a \\k backreference" if nxt == "k"
815
+
816
+ i += 2
817
+ next
818
+ end
819
+ if ch == "["
820
+ # char class: `]` right after `[` / `[^` is literal
821
+ j = i + 1
822
+ j += 1 if source[j] == "^"
823
+ j += 1 if source[j] == "]"
824
+ while j < len && source[j] != "]"
825
+ j += 2 if source[j] == "\\"
826
+ j += 1
827
+ end
828
+ i = j + 1
829
+ next
830
+ end
831
+ if ch == "("
832
+ rest = source[i, 4]
833
+ return "a lookaround" if rest.start_with?("(?=", "(?!",
834
+ "(?<=", "(?<!")
835
+ return "an atomic group" if rest.start_with?("(?>")
836
+ return "a conditional" if rest.start_with?("(?(")
837
+
838
+ i += 1
839
+ next
840
+ end
841
+ if ch == "{"
842
+ j = i + 1
843
+ j += 1 while j < len && source[j] =~ /[0-9,]/
844
+ if source[j] == "}"
845
+ nxt = source[j + 1]
846
+ return "a possessive quantifier" if nxt == "+"
847
+ return "a lazy quantifier" if nxt == "?"
848
+
849
+ i = j + 1
850
+ next
851
+ end
852
+ i += 1
853
+ next
854
+ end
855
+ case ch
856
+ when "*", "+", "?"
857
+ nxt = source[i + 1]
858
+ return "a possessive quantifier" if nxt == "+"
859
+ return "a lazy quantifier" if nxt == "?"
860
+ end
861
+ i += 1
862
+ end
863
+ nil
806
864
  end
807
865
 
808
866
  UNSUPPORTED_XSD_REGEX_FLAGS =
@@ -150,6 +150,12 @@ module Lutaml
150
150
  { "s" => "line1\nline2", "n" => nil },
151
151
  { "q" => "has: colon", "n" => nil },
152
152
  { "u" => "héllo wörld", "num" => "007", "f" => 1.5, "e" => "" },
153
+ # Under 80 characters but over 80 bytes: Psych folds by
154
+ # character column, so this stays on one line there. An
155
+ # engine that folds by byte column breaks it (glossarist's
156
+ # Russian localized concept).
157
+ { "cyr" => "процесс поглощения атмосферными газами " \
158
+ "электромагнитного излучения" },
153
159
  { "deep" => { "deeper" => [{ "x" => "y" }, [4, 5]] } },
154
160
  { "multi" => "para one\n\npara two", "dash" => "a - b - c",
155
161
  "omitted" => nil },
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <metanorma xmlns="https://www.metanorma.org/ns/standoc" type="presentation" version="2.8.7" schema-version="v2.1.6" flavor="iec">
3
+ <bibdata type="standard">
4
+ <title language="en" type="main">Cereals and pulses — Specifications and test methods — Rice</title>
5
+
6
+ <title language="en" type="title-intro">Cereals and pulses</title>
7
+
8
+ <title language="en" type="title-main">Specifications and test methods</title>
9
+
10
+ <title language="en" type="title-part">Rice</title>
11
+
12
+ <title language="en" type="title-part-prefix">Part 1</title>
13
+
14
+ <title language="fr" type="main">Céréales et légumineuses — Spécification et méthodes d’essai — Riz</title>
15
+
16
+ <title language="fr" type="title-intro">Céréales et légumineuses</title>
17
+
18
+ <title language="fr" type="title-main">Spécification et méthodes d’essai</title>
19
+
20
+ <title language="fr" type="title-part">Riz</title>
21
+
22
+ <title language="fr" type="title-part-prefix">Partie 1</title>
23
+ <docidentifier type="ISO" primary="true">IEC CD 17301-1:2016 ED2</docidentifier><docidentifier type="iso-reference">IEC CD 17301-1:2016 ED2(fr)</docidentifier><docidentifier type="iso-revdate">IEC CD 17301-1:2016-05 ED2(fr)</docidentifier><docidentifier type="URN">urn:iec:std:iec:17301-1:2016:stage-30.92:ed-2:fr</docidentifier><docidentifier type="iso-undated">IEC CD 17301-1 ED2</docidentifier><docidentifier type="iso-with-lang">IEC CD 17301-1:2016 ED2(fr)</docidentifier><docidentifier type="iso-tc">17301</docidentifier><language current="true">fr</language><script current="true">Latn</script></bibdata>
24
+
25
+ </metanorma>
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ # Reduced from the real IEC rice presentation fixture. The public model DSL
6
+ # reproduces its title organization without depending on Metanorma gems.
7
+ module LeptrisConsolidationSpec
8
+ class Namespace < Lutaml::Xml::Namespace
9
+ uri "https://www.metanorma.org/ns/standoc"
10
+ prefix_default "standoc"
11
+ element_form_default :qualified
12
+ end
13
+
14
+ class Title < Lutaml::Model::Serializable
15
+ attribute :language, :string
16
+ attribute :kind, :string
17
+ attribute :value, :string
18
+
19
+ xml do
20
+ element "title"
21
+ namespace Namespace
22
+ map_attribute "language", to: :language
23
+ map_attribute "type", to: :kind
24
+ map_content to: :value
25
+ end
26
+ end
27
+
28
+ class LocalizedTitle < Lutaml::Model::Serializable
29
+ attribute :language, :string
30
+ attribute :full, Title
31
+ attribute :intro, Title
32
+ attribute :main, Title
33
+ attribute :part, Title
34
+ attribute :part_prefix, Title
35
+ end
36
+
37
+ class Titles < Lutaml::Model::Collection
38
+ instances :items, Title
39
+ organizes :per_language, LocalizedTitle
40
+
41
+ xml do
42
+ element "titles"
43
+ namespace Namespace
44
+ map_instances to: :items
45
+ consolidate_map by: :language, to: :per_language do
46
+ gather :language, to: :language
47
+ dispatch_by :kind do
48
+ route "main" => :full
49
+ route "title-intro" => :intro
50
+ route "title-main" => :main
51
+ route "title-part" => :part
52
+ route "title-part-prefix" => :part_prefix
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ class Bibdata < Lutaml::Model::Serializable
59
+ attribute :titles, Title, collection: Titles
60
+
61
+ xml do
62
+ element "bibdata"
63
+ namespace Namespace
64
+ map_element "title", to: :titles
65
+ end
66
+ end
67
+
68
+ class Document < Lutaml::Model::Serializable
69
+ attribute :bibdata, Bibdata
70
+
71
+ xml do
72
+ element "metanorma"
73
+ namespace Namespace
74
+ map_element "bibdata", to: :bibdata
75
+ end
76
+ end
77
+ end
78
+
79
+ RSpec.describe "Leptris custom Collection consolidation" do
80
+ around do |example|
81
+ original_adapter = Lutaml::Model::Config.xml_adapter
82
+ original_fast = Lutaml::Model::Config.instance.xml_plan_fast_path
83
+ Lutaml::Model::Config.xml_adapter_type = :leptris
84
+ example.run
85
+ ensure
86
+ Lutaml::Model::Config.instance.xml_plan_fast_path = original_fast
87
+ Lutaml::Model::Config.xml_adapter = original_adapter
88
+ end
89
+
90
+ let(:xml) do
91
+ File.read(File.expand_path("../../fixtures/metanorma_iec_title_consolidation.xml", __dir__))
92
+ end
93
+
94
+ [true, false].each do |fast|
95
+ it "organizes real nested title data with xml_plan_fast_path=#{fast}" do
96
+ expect(Lutaml::Xml::Leptris.plan_path_compatible?).to be(true)
97
+
98
+ Lutaml::Model::Config.instance.xml_plan_fast_path = fast
99
+ if fast
100
+ plan = Lutaml::Xml::Leptris::PlanCompiler.compile(
101
+ LeptrisConsolidationSpec::Document,
102
+ Lutaml::Model::Config.default_register,
103
+ )
104
+ expect(plan).not_to be_nil # Do not silently test an interpretive fallback.
105
+ allow(Lutaml::Xml::Leptris::PlanHydrator).to receive(:call).and_call_original
106
+ end
107
+ document = LeptrisConsolidationSpec::Document.from_xml(xml)
108
+ if fast
109
+ expect(Lutaml::Xml::Leptris::PlanHydrator).to have_received(:call)
110
+ .with(LeptrisConsolidationSpec::Bibdata, anything, anything, any_args)
111
+ end
112
+ titles = document.bibdata.titles
113
+
114
+ expect(titles.items.length).to eq(10)
115
+ expect(titles.per_language.size).to eq(2)
116
+ expect(titles.per_language.map(&:language)).to contain_exactly("en", "fr")
117
+ en = titles.per_language.find { |group| group.language == "en" }
118
+ fr = titles.per_language.find { |group| group.language == "fr" }
119
+ expect(en.full.value).to include("Cereals and pulses")
120
+ expect(en.part.value).to eq("Rice")
121
+ expect(fr.full.value).to include("Céréales et légumineuses")
122
+ expect(fr.part.value).to eq("Riz")
123
+ expect(fr.part_prefix.value).to eq("Partie\u00a01")
124
+
125
+ # Re-running post-processing replaces the organized view without
126
+ # duplicating groups or replacing the raw item collection.
127
+ original_items = titles.items.dup
128
+ Lutaml::Xml::CollectionConsolidation.call(document.bibdata, :default)
129
+ expect(titles.items).to eq(original_items)
130
+ expect(titles.per_language.size).to eq(2)
131
+ expect(titles.per_language.find { |group| group.language == "fr" }.part).to equal(fr.part)
132
+
133
+ reparsed = LeptrisConsolidationSpec::Document.from_xml(document.to_xml)
134
+ expect(reparsed.bibdata.titles.items.size).to eq(10)
135
+ expect(reparsed.bibdata.titles.per_language.size).to eq(2)
136
+ expect(reparsed.bibdata.titles.per_language.map { |group| group.part.value })
137
+ .to contain_exactly("Rice", "Riz")
138
+ end
139
+ end
140
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "spec_helper"
4
4
  require "lutaml/model/schema"
5
+ require "open3"
6
+ require "rbconfig"
5
7
  require "tmpdir"
6
8
 
7
9
  # Runtime XSD-to-classes compilation (#251): Schema.from_xml compiles a
@@ -279,4 +281,197 @@ RSpec.describe "runtime XSD class loading" do
279
281
  expect(Lutaml::Model::Type::NmTokens.valid?("")).to be(false)
280
282
  end
281
283
  end
284
+
285
+ describe "register-isolated derivations (#1195)" do
286
+ let(:base_xsd) do
287
+ <<~XSD
288
+ <?xml version="1.0" encoding="UTF-8"?>
289
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
290
+ <xs:complexType name="ImportedThing">
291
+ <xs:sequence>
292
+ <xs:element name="label" type="xs:string"/>
293
+ </xs:sequence>
294
+ </xs:complexType>
295
+ </xs:schema>
296
+ XSD
297
+ end
298
+
299
+ let(:main_xsd) do
300
+ <<~XSD
301
+ <?xml version="1.0" encoding="UTF-8"?>
302
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
303
+ <xs:import schemaLocation="base.xsd"/>
304
+ <xs:complexType name="MainDoc">
305
+ <xs:sequence>
306
+ <xs:element name="thing" type="ImportedThing"/>
307
+ </xs:sequence>
308
+ </xs:complexType>
309
+ <xs:element name="main" type="MainDoc"/>
310
+ </xs:schema>
311
+ XSD
312
+ end
313
+
314
+ let(:register_id) { :runtime_iso_reg }
315
+
316
+ after do
317
+ Lutaml::Model::GlobalRegister.unregister(register_id) if
318
+ Lutaml::Model::GlobalRegister.lookup(register_id)
319
+ end
320
+
321
+ it "parses instances through imported-schema types from the " \
322
+ "derivation's register, with the default register untouched" do
323
+ Dir.mktmpdir do |dir|
324
+ File.write(File.join(dir, "base.xsd"), base_xsd)
325
+ File.write(File.join(dir, "main.xsd"), main_xsd)
326
+
327
+ Lutaml::Model::Schema.from_xml(
328
+ main_xsd,
329
+ output_dir: File.join(dir, "reg_iso_models"),
330
+ load_classes: true,
331
+ module_namespace: "RegIsoRuntimeModels",
332
+ register_id: register_id.to_s,
333
+ location: File.join(dir, "main.xsd"),
334
+ )
335
+
336
+ parsed = RegIsoRuntimeModels::MainDoc.from_xml(
337
+ "<main><thing><label>hello</label></thing></main>",
338
+ )
339
+
340
+ expect(parsed.thing.label).to eq("hello")
341
+ expect(Lutaml::Model::Config.default_register).not_to eq(register_id)
342
+ end
343
+ end
344
+
345
+ it "stamps the register through set_register_context, not " \
346
+ "instance_variable_set" do
347
+ entry = Lutaml::Model::Schema::CompiledOutput::Entry.new(
348
+ "ImportedThing", nil, :model
349
+ )
350
+ source = Lutaml::Model::Schema::RegistryGenerator.generate(
351
+ [entry], module_namespace: "ProbeRegNamespace",
352
+ register_id: register_id
353
+ )
354
+
355
+ expect(source).to include("set_register_context(:#{register_id})")
356
+ expect(source).not_to include("instance_variable_set")
357
+ end
358
+ end
359
+
360
+ describe "XSD-compile then namespaced-instance hydration (#1204)" do
361
+ let(:base_xsd) do
362
+ <<~XSD
363
+ <?xml version="1.0" encoding="UTF-8"?>
364
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
365
+ targetNamespace="http://example.com/s102-base"
366
+ elementFormDefault="qualified">
367
+ <xs:complexType name="ImportedMetric">
368
+ <xs:sequence>
369
+ <xs:element name="name" type="xs:string" minOccurs="0"/>
370
+ <xs:element name="valueType" type="xs:string" minOccurs="0"/>
371
+ </xs:sequence>
372
+ </xs:complexType>
373
+ </xs:schema>
374
+ XSD
375
+ end
376
+
377
+ let(:main_xsd) do
378
+ <<~XSD
379
+ <?xml version="1.0" encoding="UTF-8"?>
380
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
381
+ xmlns:b="http://example.com/s102-base"
382
+ targetNamespace="http://example.com/s102-main"
383
+ elementFormDefault="qualified">
384
+ <xs:import namespace="http://example.com/s102-base"
385
+ schemaLocation="base.xsd"/>
386
+ <xs:complexType name="MetricSet">
387
+ <xs:sequence>
388
+ <xs:element name="metric" type="b:ImportedMetric"
389
+ maxOccurs="unbounded"/>
390
+ </xs:sequence>
391
+ </xs:complexType>
392
+ <xs:element name="root">
393
+ <xs:complexType>
394
+ <xs:sequence>
395
+ <xs:element name="name" type="xs:string"/>
396
+ <xs:element name="metrics" type="MetricSet" minOccurs="0"/>
397
+ </xs:sequence>
398
+ </xs:complexType>
399
+ </xs:element>
400
+ </xs:schema>
401
+ XSD
402
+ end
403
+
404
+ let(:instance_xml) do
405
+ <<~XML
406
+ <m:root xmlns:m="http://example.com/s102-main"
407
+ xmlns:b="http://example.com/s102-base">
408
+ <m:name>S-102</m:name>
409
+ <m:metrics>
410
+ <m:metric>
411
+ <b:name>depth</b:name>
412
+ <b:valueType>real</b:valueType>
413
+ </m:metric>
414
+ <m:metric>
415
+ <b:name>uncertainty</b:name>
416
+ <b:valueType>TVU</b:valueType>
417
+ </m:metric>
418
+ </m:metrics>
419
+ </m:root>
420
+ XML
421
+ end
422
+
423
+ let(:register_id) { :s102_hydration_reg }
424
+
425
+ it "reports the schema's target namespace for the namespace: option" do
426
+ expect(Lutaml::Model::Schema.target_namespace(main_xsd))
427
+ .to eq("http://example.com/s102-main")
428
+ end
429
+
430
+ # The compile→hydrate contract runs in a subprocess: the suite's
431
+ # per-example GlobalRegister reset wipes the metaschema registrations
432
+ # that self-register at class-file load, and no in-process re-sync
433
+ # restores the full parse-time state. A fresh process is the honest
434
+ # environment for the consumer-facing contract (#406 drives it).
435
+ it "hydrates a prefixed instance into the compiled root model" do
436
+ Dir.mktmpdir do |dir|
437
+ File.write(File.join(dir, "base.xsd"), base_xsd)
438
+ File.write(File.join(dir, "main.xsd"), main_xsd)
439
+ File.write(File.join(dir, "instance.xml"), instance_xml)
440
+
441
+ probe = <<~RUBY
442
+ require "lutaml/model"
443
+
444
+ Lutaml::Model::Schema.from_xml(
445
+ File.read("#{dir}/main.xsd"),
446
+ output_dir: "#{dir}/s102_models",
447
+ load_classes: true,
448
+ namespace: Lutaml::Model::Schema.target_namespace(
449
+ File.read("#{dir}/main.xsd"),
450
+ ),
451
+ module_namespace: "S102HydrationModels",
452
+ register_id: "#{register_id}",
453
+ location: "#{dir}/main.xsd",
454
+ )
455
+
456
+ parsed = S102HydrationModels::CTRoot
457
+ .from_xml(File.read("#{dir}/instance.xml"))
458
+
459
+ puts "name=\#{parsed.name.inspect}"
460
+ puts "value_types=\#{parsed.metrics.metric.map(&:value_type).inspect}"
461
+ puts "default_register=\#{Lutaml::Model::Config.default_register.inspect}"
462
+ RUBY
463
+
464
+ _stdout, stderr, status = Open3.capture3(RbConfig.ruby, "-I", "lib",
465
+ "-e", probe)
466
+ expect(status).to be_success, stderr
467
+
468
+ expect(_stdout).to include('name="S-102"')
469
+ # maxOccurs="unbounded" members hydrate as collections and the
470
+ # imported-schema scalar resolves through the derivation's
471
+ # register at parse time
472
+ expect(_stdout).to include('value_types=["real", "TVU"]')
473
+ expect(_stdout).to include("default_register=:default")
474
+ end
475
+ end
476
+ end
282
477
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Lutaml::Xml::Schema::XsdSchema do
6
+ # issue #1184: the xs:pattern expressibility probe is structural —
7
+ # the constructs Ruby's engine adds beyond XSD 1.0's regexp are
8
+ # detected syntactically, on every lane (a compile probe cannot
9
+ # vouch where engines compile inexpressible patterns silently, and
10
+ # lanes without a validator never probed at all).
11
+ def probe(source)
12
+ described_class.reject_invalid_xsd_pattern!(/#{Regexp.escape(source)}/x, source)
13
+ end
14
+
15
+ shared_examples "inexpressible" do |source, detail|
16
+ it "rejects #{source.inspect}" do
17
+ expect { probe(source) }
18
+ .to raise_error(Lutaml::Model::Error, /not expressible.*#{detail}/)
19
+ end
20
+ end
21
+
22
+ it_behaves_like "inexpressible", "(?=.*[0-9])[a-z]+", "lookaround"
23
+ it_behaves_like "inexpressible", "a(?!b)", "lookaround"
24
+ it_behaves_like "inexpressible", "(?<=a)b", "lookaround"
25
+ it_behaves_like "inexpressible", "a(?>b|c)", "atomic"
26
+ it_behaves_like "inexpressible", "a(?(1)b|c)", "conditional"
27
+ it_behaves_like "inexpressible", "(a)\\1", "backreference"
28
+ it_behaves_like "inexpressible", "(?<word>a)\\k<word>", "backreference"
29
+ it_behaves_like "inexpressible", "a*+", "possessive quantifier"
30
+ it_behaves_like "inexpressible", "a{2,3}+", "possessive quantifier"
31
+ it_behaves_like "inexpressible", "a+?", "lazy quantifier"
32
+ it_behaves_like "inexpressible", "a*??", "lazy quantifier"
33
+ it_behaves_like "inexpressible", "\\Ga+", "anchor"
34
+
35
+ it "admits plain groups and quantifiers" do
36
+ expect { probe("[a-z]+(foo|bar)*baz?") }.not_to raise_error
37
+ end
38
+
39
+ it "does not false-positive on escapes or character classes" do
40
+ expect { probe("\\[\\d\\]") }.not_to raise_error
41
+ expect { probe("[a\\-z\\*+?]{2}") }.not_to raise_error
42
+ end
43
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Lutaml::Xml::Schema::Builder do
6
+ # issue #1184: schema generation rides the CONFIGURED engine through
7
+ # the moxml layer. The dedicated Nokogiri/Oga wrappers keep their
8
+ # lanes; every other engine (ox, leptris, rexml) generates through
9
+ # the Moxml wrapper instead of silently substituting Nokogiri.
10
+
11
+ describe "engine-following selection" do
12
+ it "keeps the dedicated Nokogiri wrapper when Nokogiri is requested" do
13
+ builder = described_class.new(adapter_type: :nokogiri)
14
+
15
+ expect(builder.adapter_type).to eq(:nokogiri)
16
+ expect(builder.builder).to be_a(described_class::Nokogiri)
17
+ end
18
+
19
+ it "routes other configured engines through the Moxml wrapper" do
20
+ builder = described_class.new(adapter_type: :ox)
21
+
22
+ expect(builder.adapter_type).to eq(:ox)
23
+ expect(builder.builder).to be_a(described_class::Moxml)
24
+ end
25
+ end
26
+
27
+ describe "Moxml wrapper emission" do
28
+ let(:builder) do
29
+ described_class.new(adapter_type: :ox) do |xml|
30
+ xml.schema(targetNamespace: "http://example.com") do
31
+ xml.element(name: "name", type: "xs:string")
32
+ end
33
+ end
34
+ end
35
+
36
+ it "emits the XML declaration with the encoding" do
37
+ expect(builder.to_xml).to start_with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
38
+ end
39
+
40
+ it "emits the nested schema DSL shape" do
41
+ xml = builder.to_xml
42
+
43
+ expect(xml).to include("<schema")
44
+ expect(xml).to include("targetNamespace=\"http://example.com\"")
45
+ # the empty-element form is lane-serialized; both forms are
46
+ # model-legal XML — the DSL shape is what parity binds here
47
+ expect(xml).to match(/<element name="name" type="xs:string"\s*\/?>(<\/element>)?/)
48
+ end
49
+
50
+ it "honors the pretty option" do
51
+ expect(builder.to_xml(pretty: true)).to include("\n")
52
+ end
53
+ end
54
+ end
@@ -83,6 +83,9 @@ RSpec.describe Lutaml::Yaml::Adapter::YeptrisAdapter do
83
83
  { "s" => "line1\nline2", "n" => nil },
84
84
  { "q" => "has: colon", "n" => nil },
85
85
  { "u" => "héllo wörld", "num" => "007", "f" => 1.5, "e" => "" },
86
+ # Under 80 characters, over 80 bytes: must not fold.
87
+ { "cyr" => "процесс поглощения атмосферными газами " \
88
+ "электромагнитного излучения" },
86
89
  { "deep" => { "deeper" => [{ "x" => "y" }, [4, 5]] } },
87
90
  { "multi" => "para one\n\npara two", "dash" => "a - b - c",
88
91
  "omitted" => nil },
data/spec/spec_helper.rb CHANGED
@@ -33,6 +33,21 @@ RSpec.configure do |config|
33
33
  Lutaml::Model::GlobalRegister.instance.reset if defined?(Lutaml::Model::GlobalRegister)
34
34
  end
35
35
 
36
+ # Restore the configured XML adapter after each example:
37
+ # adapter-switching specs set Config.xml_adapter_type directly and
38
+ # the drift used to leak into later specs. The moxml-routed XSD
39
+ # machinery follows the CURRENT config by design (#1184), which
40
+ # turned that leak into order-dependent schema-suite failures —
41
+ # the restore pins every example back to the spec_helper default.
42
+ config.around do |example|
43
+ previous = Lutaml::Model::Config.xml_adapter_type
44
+ begin
45
+ example.run
46
+ ensure
47
+ Lutaml::Model::Config.xml_adapter_type = previous if previous
48
+ end
49
+ end
50
+
36
51
  # Reset adapter state between adapter-switching tests
37
52
  config.after(:each, :adapter_test) do
38
53
  Lutaml::Model::AdapterScope.reset! if defined?(Lutaml::Model::AdapterScope)
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.181
4
+ version: 0.8.183
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-25 00:00:00.000000000 Z
11
+ date: 2026-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -789,6 +789,7 @@ files:
789
789
  - lib/lutaml/xml/builder/oga.rb
790
790
  - lib/lutaml/xml/builder/ox.rb
791
791
  - lib/lutaml/xml/builder/rexml.rb
792
+ - lib/lutaml/xml/collection_consolidation.rb
792
793
  - lib/lutaml/xml/configurable.rb
793
794
  - lib/lutaml/xml/data_model.rb
794
795
  - lib/lutaml/xml/decisions.rb
@@ -875,6 +876,7 @@ files:
875
876
  - lib/lutaml/xml/rexml/element.rb
876
877
  - lib/lutaml/xml/schema.rb
877
878
  - lib/lutaml/xml/schema/builder.rb
879
+ - lib/lutaml/xml/schema/builder/moxml.rb
878
880
  - lib/lutaml/xml/schema/builder/nokogiri.rb
879
881
  - lib/lutaml/xml/schema/builder/oga.rb
880
882
  - lib/lutaml/xml/schema/builtin_types.rb
@@ -1042,6 +1044,7 @@ files:
1042
1044
  - spec/fixtures/geolexica_v2_sample2.yaml
1043
1045
  - spec/fixtures/liquid_templates/_ceramic.liquid
1044
1046
  - spec/fixtures/liquid_templates/_ceramics_in_one.liquid
1047
+ - spec/fixtures/metanorma_iec_title_consolidation.xml
1045
1048
  - spec/fixtures/person.rb
1046
1049
  - spec/fixtures/sample_model.rb
1047
1050
  - spec/fixtures/vase.rb
@@ -1831,6 +1834,7 @@ files:
1831
1834
  - spec/lutaml/model/kv_flatten_memo_spec.rb
1832
1835
  - spec/lutaml/model/late_attribute_declaration_spec.rb
1833
1836
  - spec/lutaml/model/lazy_collection_spec.rb
1837
+ - spec/lutaml/model/leptris_consolidation_spec.rb
1834
1838
  - spec/lutaml/model/liquefiable_lazy_spec.rb
1835
1839
  - spec/lutaml/model/liquefiable_spec.rb
1836
1840
  - spec/lutaml/model/liquid/indexed_access_spec.rb
@@ -1880,6 +1884,7 @@ files:
1880
1884
  - spec/lutaml/model/schema/renderers/restricted_type_spec.rb
1881
1885
  - spec/lutaml/model/schema/renderers/union_spec.rb
1882
1886
  - spec/lutaml/model/schema/xml_compiler_runtime_spec.rb
1887
+ - spec/lutaml/model/schema/xsd_pattern_probe_spec.rb
1883
1888
  - spec/lutaml/model/schema/xsd_schema_spec.rb
1884
1889
  - spec/lutaml/model/schema/yaml_schema_spec.rb
1885
1890
  - spec/lutaml/model/sequence_choice_compositor_spec.rb
@@ -2093,6 +2098,7 @@ files:
2093
2098
  - spec/lutaml/xml/reusable_mapping_spec.rb
2094
2099
  - spec/lutaml/xml/reused_elements_namespace_spec.rb
2095
2100
  - spec/lutaml/xml/root_mappings/nested_child_mappings_spec.rb
2101
+ - spec/lutaml/xml/schema/builder_moxml_spec.rb
2096
2102
  - spec/lutaml/xml/schema/compiler_spec.rb
2097
2103
  - spec/lutaml/xml/schema/facet_round_trip_spec.rb
2098
2104
  - spec/lutaml/xml/schema/rnc_compiler_spec.rb