Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value missing in the output #95

Open
suleman-uzair opened this issue Oct 2, 2024 · 0 comments
Open

Default value missing in the output #95

suleman-uzair opened this issue Oct 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@suleman-uzair
Copy link

suleman-uzair commented Oct 2, 2024

To reproduce the issue, please review the provided code sample.

require "lutaml/model"
require 'lutaml/model/xml_adapter/ox_adapter'

Lutaml::Model::Config.configure do |config|
  config.xml_adapter = Lutaml::Model::XmlAdapter::OxAdapter
end

class Mstyle < Lutaml::Model::Serializable
  attribute :displaystyle, :string, default: -> { "true" }

  xml do
    root "mstyle"

    map_attribute :displaystyle, to: :displaystyle
  end
end

class Maths < Lutaml::Model::Serializable
  attribute :display, :string, default: -> { "block" }
  attribute :style, Mstyle, default: -> { Mstyle.new }

  xml do
    root "math"
    map_attribute :display, to: :display
    map_element :mstyle, to: :style
  end
end

xml = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display='true'></math>"
Maths.from_xml(xml).to_xml

> "<math display=\"true\"/>\n" 
@HassanAkbar HassanAkbar self-assigned this Oct 2, 2024
@ronaldtse ronaldtse added the bug Something isn't working label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants