Skip to content

ics: persist Isoics description so XML round-trip preserves <text>#113

Merged
andrew2net merged 1 commit into
lutaml-integrationfrom
fix/ics-text-getter-bypass
May 7, 2026
Merged

ics: persist Isoics description so XML round-trip preserves <text>#113
andrew2net merged 1 commit into
lutaml-integrationfrom
fix/ics-text-getter-bypass

Conversation

@opoudjis

@opoudjis opoudjis commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #112<bibdata/ext/ics/text> is dropped on XML round-trip when the source omits <text>, under lutaml-model 0.8.

The previous design relied on a getter-only Isoics fallback in Relaton::Bib::ICS#text. lutaml-model 0.8 reads attribute values from the backing instance variable for nested-collection serialization (and consults @using_default[:text]), so a getter-only fallback is not picked up in that path — <text> is omitted from the output even though ics.text returns the Isoics description.

This change pushes the Isoics fallback through the public text= writer at the point code is assigned, and refuses the post-parse using_default_for(:text) mark so the value survives the deserialization consolidation step.

Changes

  • lib/relaton/bib/model/ics.rb

    • code= override pushes Isoics description through self.text= whenever @text is unset, so lutaml-model records the value via value_set_for(:text).
    • using_default_for override refuses to mark :text as default when @text already holds a string value, so the deserialization consolidation step doesn't suppress emission.
    • #text accessor kept as a convenience for direct readers.
  • spec/relaton/bib/model/ics_spec.rb

    • New XML serialization with Isoics fallback group adds round-trip coverage that the existing #get_text group did not exercise: ICS.new(code:), ICS.from_xml standalone, Ext.from_xml nesting an ICS with no <text> (the canonical metanorma collection round-trip path), the explicit-text-wins case, and the invalid-code case.

Test plan

  • bundle exec rspec spec/relaton/bib/model/ics_spec.rb — 11/11 pass (5 existing + 6 new).
  • bundle exec rspec — full suite green (190/190).

…serves <text>

Under lutaml-model 0.8, child elements parsed from XML and re-serialized
via a parent collection skip attributes whose backing ivar holds no
explicit value (the user-defined `#text` accessor is not consulted in
that path). Push the Isoics fallback through the public `text=` writer
when `code` is assigned, and refuse the post-parse `using_default_for`
mark, so the description is emitted on subsequent `to_xml`.

Adds spec coverage for the XML round-trip behaviour: `ICS.new(code:)`,
`ICS.from_xml`, `Ext.from_xml` nesting an ICS with no `<text>`, and the
explicit-text-wins case.

Closes #112.
@andrew2net andrew2net merged commit 0392d7d into lutaml-integration May 7, 2026
11 of 12 checks passed
@andrew2net andrew2net deleted the fix/ics-text-getter-bypass branch May 7, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants