Shale is a Ruby object mapper and serializer for JSON, YAML, TOML, CSV and XML. It allows you to parse JSON, YAML, TOML, CSV and XML data and convert it into Ruby data structures, as well as serialize data structures into JSON, YAML, TOML, CSV or XML.
Update README for allowing default XML namespaces.
Roundtrip test as contributed by @opoudjis:
require 'shale'
class Person < ::Shale::Mapper
require 'shale/adapter/nokogiri'
::Shale.xml_adapter = ::Shale::Adapter::Nokogiri
attribute :output1, ::Shale::Type::String
attribute :output2, ::Shale::Type::String
xml do
root 'collection'
namespace 'http://metanorma.org', nil
map_attribute 'output1', to: :output1
map_element 'output2', to: :output2
end
end
person = Person.from_xml(<<~DATA)
<collection xmlns="http://metanorma.org" output1='A'>
<output2>John</output2>
</collection>
DATA
pp person.to_xml
Update README for allowing default XML namespaces.
Roundtrip test as contributed by @opoudjis:
Originally posted by @HassanAkbar in https://github.com/lutaml/shale/issues/6#issuecomment-2134612796