Skip to content

fix: order <note> children to match the MusicXML content model - #63

Merged
thaihuynhxyz merged 2 commits into
mainfrom
fix/note-child-order
Aug 7, 2026
Merged

fix: order <note> children to match the MusicXML content model#63
thaihuynhxyz merged 2 commits into
mainfrom
fix/note-child-order

Conversation

@thaihuynhxyz

Copy link
Copy Markdown
Collaborator

Stacked on #62 — review that one first. Base will switch to main once #62 merges.

Problem

Pre-existing on main, unrelated to #60. The <note> child list writes <beam> before <stem>, and <accidental> after <staff>. The spec sequence is <accidental>, <stem>, <staff>, <beam>.

Nothing is lost, but the output fails schema validation, so other tools may reject the file or drop elements.

Fix

Move the two entries into their spec slots, and add a round-trip test per asset that compares every <note> child list against the source file.

The children the library still drops are listed explicitly in unwrittenChildren rather than being silently ignored, so the remaining gap stays visible. Today that is <time-modification> and <lyric> (parsed but never written), plus the ones that are never parsed.

Known, not fixed here

<measure> has a worse version of the same problem: it groups children by type, so <backup> moves after all the notes. On voice-element.xml that turns two parallel voices into eight notes in a row. That needs the source order preserved, not a fixed order, so it belongs in its own change.

Test plan

  • dart test — 117 pass (4 new)
  • dart analyze — clean
  • dart format — no changes
  • All 4 new tests fail without the fix

thaihuynhxyz and others added 2 commits August 7, 2026 21:02
The <note> constructor built its child list without the parsed ties, so
every <tie> was dropped on serialization and a parse-then-write round trip
lost the tie information.

Add the ties to the child list in the slot the MusicXML content model
gives them, between <duration> and <voice>.

Co-authored-by: SheepYang1993 <15150244+SheepYang1993@users.noreply.github.com>
<beam> was written before <stem> and <accidental> after <staff>, but the
spec sequence is <accidental>, <stem>, <staff>, <beam>. The data survived
but the output failed schema validation.

Add a round-trip test per asset that compares every <note> child list
against the source file. The set of children the library still drops
(<time-modification>, <lyric>, and the ones it never parses) is listed
explicitly so the gap stays visible.
@thaihuynhxyz thaihuynhxyz mentioned this pull request Aug 7, 2026
Base automatically changed from fix/note-tie-children to main August 7, 2026 14:07
@thaihuynhxyz
thaihuynhxyz merged commit 49c9cdb into main Aug 7, 2026
@thaihuynhxyz
thaihuynhxyz deleted the fix/note-child-order branch August 7, 2026 14:08
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.

1 participant