Repository navigation
Fix RELAX NG validation of documents with XML declarations - #380
Merged
Merged
Conversation
Contributor
Author
|
The Test workflow currently reports This follow-up was prepared with Codex. |
bardrop
reviewed
Nov 18, 2026
naitoh
reviewed
Nov 28, 2026
naitoh
left a comment
Contributor
There was a problem hiding this comment.
Thank you for fixing this issue!
The implementation in lib/rexml/validation/relaxng.rb looks good to me.
I left a few inline suggestions on test/test_validation_rng.rb to remove redundant test cases and simplify nested loops so the test suite stays concise and easy to maintain.
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents with XML declarations fail RELAX NG validation on
:xmldecl. The multiline example in #241 also emits whitespace before and after the root, which the validator incorrectly treats as element content.Handle the declaration and root-external XML whitespace in
RelaxNG#receive. Skip comments, processing instructions, and DTD declarations so markup before, inside, or after the root does not advance the schema. Use the existing attribute stack to identify element nesting, initialize it for validation without an initialreset, and retain its existing reset behavior. Whitespace inside elements still reaches schema validation, includingtextand exactvaluepatterns. The sharedValidatoris unchanged.Fixes #241.
The regression tests keep the original schema and multiline document from #241. They check whitespace around the root with and without an XML declaration, first use without an initial reset, and reuse after an unfinished document. They also exercise invalid structure, whitespace inside elements, exact text values, comments, processing instructions, and DTDs with an internal subset.
Validation on macOS arm64 with Ruby 4.0.7 at
b894913:0fee9c5. Two still fail on3ed87be, before the changes for comments, processing instructions, and DTDs.bundle exec rake testandbundle exec rake test RUBYOPT=--enable-frozen-string-literaleach passed all 850 tests (2,720 assertions, zero omissions).git diff --checkpassed.The preceding revision was also checked with Ruby 3.4.9, including testing the installed gem and building RDoc.
OpenAI Codex prepared the implementation, tests, description, and follow-up and ran the local checks.