Skip to content

fix(spec): move XML declaration before the leading comment in fixture - #8

Merged
ronaldtse merged 2 commits into
mainfrom
fix/fixture-xml-prolog-order
Sep 25, 2026
Merged

ronaldtse merged 2 commits into
mainfrom
fix/fixture-xml-prolog-order

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Problem

The dependent-gems CI run against lutaml-model main reported 1 failure out of 30 examples: spec/reqif_spec.rb[1:1:8:1], the round-trip comparison for the antcc_MAG8000-LTE-FeatureSpecReqBL4.reqif fixture (Canon reported > characters missing from XHTML-CONTENT text, e.g. device -> ...).

Root cause

The fixture is not well-formed: it starts with a provenance comment (<!-- FROM: ... -->) before the XML declaration. Per the XML spec, the declaration must be the very first thing in the document.

When the Nokogiri adapter parses this input, the misplacement causes &gt; character references in the document body to be silently dropped (a minimal prolog reproducer confirms: a comment preceding <?xml?> makes Nokogiri drop &gt; entities from text; the same document with the comment after the declaration parses fine). lutaml-model's reqif round trip therefore loses the > characters and the Canon comparison fails.

Not a lutaml-model regression: the failure reproduces identically against released lutaml-model 0.8.59 and main (d978d533); the fixture predates this.

Fix

One-line fixture repair: move <?xml version="1.0" encoding="UTF-8"?> to line 1 and let the provenance comment follow it (a legal prolog comment). No document content changes.

Full suite: 31 examples, 0 failures (the +1 example vs CI is not part of this change).

The antcc MAG8000 fixture began with a provenance comment followed by
the XML declaration. A comment before the XML declaration is not
well-formed: the declaration must be the very first thing in the
document.

Modern strict parsing rejects or degrades such input; with the
Nokogiri adapter this specific misplacement caused '&gt;' character
references in the document body to be dropped during parsing, so the
round-trip comparison failed on missing '>' characters in
XHTML-CONTENT text.

Reorder the prolog so the declaration is line 1 and the comment
follows it (a legal prolog comment). No document content changes.
@ronaldtse
ronaldtse merged commit 9eaefc3 into main Sep 25, 2026
14 checks passed
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