lib/lutaml/model/xml_mapping.rb in lutaml-model-0.3.11 vs lib/lutaml/model/xml_mapping.rb in lutaml-model-0.3.12

- old
+ new

@@ -4,24 +4,27 @@ module Model class XmlMapping attr_reader :root_element, :namespace_uri, :namespace_prefix, - :mixed_content + :mixed_content, + :ordered def initialize @elements = {} @attributes = {} @content_mapping = nil @mixed_content = false end alias mixed_content? mixed_content + alias ordered? ordered - def root(name, mixed: false) + def root(name, mixed: false, ordered: false) @root_element = name @mixed_content = mixed + @ordered = ordered || mixed # mixed contenet will always be ordered end def prefixed_root if namespace_uri && namespace_prefix "#{namespace_prefix}:#{root_element}" @@ -47,21 +50,23 @@ prefix: (prefix_set = false nil) ) validate!(name, to, with) - @elements[name] = XmlMappingRule.new( + rule = XmlMappingRule.new( name, to: to, render_nil: render_nil, with: with, delegate: delegate, namespace: namespace, + default_namespace: namespace_uri, prefix: prefix, namespace_set: namespace_set != false, prefix_set: prefix_set != false, ) + @elements[rule.namespaced_name] = rule end def map_attribute( name, to: nil, @@ -73,20 +78,22 @@ prefix: (prefix_set = false nil) ) validate!(name, to, with) - @attributes[name] = XmlMappingRule.new( + rule = XmlMappingRule.new( name, to: to, render_nil: render_nil, with: with, delegate: delegate, namespace: namespace, prefix: prefix, + default_namespace: namespace_uri, namespace_set: namespace_set != false, prefix_set: prefix_set != false, ) + @attributes[rule.namespaced_name] = rule end # rubocop:enable Metrics/ParameterLists def map_content(