class Lutaml::Model::XmlAdapter::NokogiriAdapter

def build_unordered_element(xml, element, options = {})

def build_unordered_element(xml, element, options = {})
  mapper_class = options[:mapper_class] || element.class
  xml_mapping = mapper_class.mappings_for(:xml)
  return xml unless xml_mapping
  attributes = options[:xml_attributes] ||= {}
  attributes = build_attributes(element,
                                xml_mapping).merge(attributes)&.compact
  prefixed_xml = if options.key?(:namespace_prefix)
                   options[:namespace_prefix] ? xml[options[:namespace_prefix]] : xml
                 elsif xml_mapping.namespace_prefix
                   xml[xml_mapping.namespace_prefix]
                 else
                   xml
                 end
  tag_name = options[:tag_name] || xml_mapping.root_element
  prefixed_xml.public_send(tag_name, attributes) do
    if options.key?(:namespace_prefix) && !options[:namespace_prefix]
      xml.parent.namespace = nil
    end
    xml_mapping.elements.each do |element_rule|
      attribute_def = attribute_definition_for(element, element_rule, mapper_class: mapper_class)
      value = attribute_value_for(element, element_rule)
      next if value.nil? && !element_rule.render_nil?
      nsp_xml = element_rule.prefix ? xml[element_rule.prefix] : xml
      if attribute_def.collection?
        value.each do |v|
          add_to_xml(nsp_xml, v, attribute_def, element_rule)
        end
      elsif !value.nil? || element_rule.render_nil?
        add_to_xml(nsp_xml, value, attribute_def, element_rule)
      end
    end
    if (content_rule = xml_mapping.content_mapping)
      text = element.send(content_rule.to)
      text = text.join if text.is_a?(Array)
      if content_rule.custom_methods[:to]
        text = @root.send(content_rule.custom_methods[:to], @root, text)
      end
      prefixed_xml.text text
    end
  end
end