[WIP] Keep text content in XML round-trip - #530
suleman-uzair wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements XML entity reference preservation in the Nokogiri adapter to enable round-trip XML processing. The changes introduce special handling for XML entity references (like —, ®, &spacer;) so they maintain their original form during parse-serialize cycles, rather than being converted to their Unicode equivalents.
Key Changes
- Introduced entity node tracking using a special marker (
__entity) to distinguish entity references from regular text nodes - Added entity-specific methods in the Element class and Nokogiri adapter for detection and serialization
- Implemented comprehensive test coverage across all three XML adapters (Nokogiri, Oga, Ox) to verify entity handling behavior
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/lutaml/model/entity_spec.rb | Adds comprehensive test coverage for entity handling across Nokogiri, Oga, and Ox adapters with mixed, ordered, and default content modes |
| lib/lutaml/model/xml/element.rb | Introduces constants and entity? method to identify entity reference nodes in the element tree |
| lib/lutaml/model/xml/nokogiri_adapter.rb | Implements entity node detection, serialization helpers, and special handling in ordered element building |
| lib/lutaml/model/xml/document.rb | Adds entity-aware text content processing in update_xml_with_entity_and_text method |
| lib/lutaml/model/xml/builder/nokogiri.rb | Adds add_entity method to create Nokogiri EntityReference nodes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
5539306 to
f901d8d
Compare
c11a81d to
2516b5f
Compare
ac0c619 to
249fd5e
Compare
|
Not sure why merging #526 closed this? Reopening. @suleman-uzair is this ready? Thanks. |
|
Trying to reopen. |
829deb3 to
8371976
Compare
@ronaldtse No, I'm currently working on the following PR to fix the failing CI checks: I'll let you know as soon as it's ready. |
Port PR #530 - Sanitize named HTML entities (like ©, —) to numeric character references before parsing, since XML parsers only support the 5 standard XML entities by default. - Add htmlentities gem dependency - Add sanitize_xml_for_entities to Document base class - Use sanitize in NokogiriAdapter and OgaAdapter parse methods - Add entity handling tests ( entity_spec.rb, nokogiri_adapter_spec.rb) - Update entity_fragmentation_spec expected Unicode chars - Update latin_encoding fixture with ⊚ entity
05a6674 to
1694368
Compare
Port PR #530 - Sanitize named HTML entities (like ©, —) to numeric character references before parsing, since XML parsers only support the 5 standard XML entities by default. - Add htmlentities gem dependency - Add sanitize_xml_for_entities to Document base class - Use sanitize in NokogiriAdapter and OgaAdapter parse methods - Add entity handling tests ( entity_spec.rb, nokogiri_adapter_spec.rb) - Update entity_fragmentation_spec expected Unicode chars - Update latin_encoding fixture with ⊚ entity
|
This is ported to #593 |
2edba74 to
8371976
Compare
Port PR #530 - Sanitize named HTML entities (like ©, —) to numeric character references before parsing, since XML parsers only support the 5 standard XML entities by default. - Add htmlentities gem dependency - Add sanitize_xml_for_entities to Document base class - Use sanitize in NokogiriAdapter and OgaAdapter parse methods - Add entity handling tests ( entity_spec.rb, nokogiri_adapter_spec.rb) - Update entity_fragmentation_spec expected Unicode chars - Update latin_encoding fixture with ⊚ entity
|
This PR updates the Nokogiri adapter to handle XML entities correctly in ordered and unordered processing.
closes #527