Skip to content

[Fix] read THE-ORIGINAL-VALUE of XHTML attribute values; fixes #95 - #99

Merged
samatstariongroup merged 1 commit into
developmentfrom
GH95
Oct 19, 2026
Merged

samatstariongroup merged 1 commit into
developmentfrom
GH95

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the ReqIFSharp code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

Fixes #95.

AttributeValueXHTML.ReadXml and ReadXmlAsync never read THE-ORIGINAL-VALUE, although WriteXml writes it. TheOriginalValue was always null after reading, so a document that was read and written again lost the original values of its simplified XHTML attribute values. ReqIF 1.2 (10.8.20 and Clause 8) needs that value so that a later tool in the exchange chain can restore the original.

Changes (AttributeValueXHTML.cs)

  • The read loop now handles only the direct children of ATTRIBUTE-VALUE-XHTML: DEFINITION, THE-VALUE and THE-ORIGINAL-VALUE, in any order, as the schema's xsd:all allows. THE-ORIGINAL-VALUE is read like THE-VALUE (inner XML, trimmed).
  • ReadInnerXml and Skip already move the reader to the next node, so the loop does not call Read() after them. Adding THE-ORIGINAL-VALUE to the old loop would have lost it in minified documents when it follows THE-VALUE (the problem fixed in [Bug]: Elements are skipped when a ReqIF document has no whitespace between elements #94).
  • ATTRIBUTE-DEFINITION-XHTML-REF is read through a subtree of DEFINITION, where the schema puts it. An unknown reference still throws InvalidOperationException.
  • Any other child is skipped, with its content.

Tests

  • New AttributeValueXHTMLReadTestFixture:
    • the six original values in reqifsharpgenerated.reqif are read, and each is marked as simplified;
    • read, write and read again keeps TheOriginalValue and IsSimplified;
    • four orders of the three children, and two orders with an unknown child (which contains a THE-VALUE and a DEFINITION that must not be read), each read correctly, indented and minified, .reqif and .reqifz, sync and async. THE-VALUE and THE-ORIGINAL-VALUE get distinct content, so a mix-up is caught;
    • an unknown definition reference throws.
  • AttributeValueXHTMLTestFixture: ReadXmlAsync throws OperationCanceledException for a cancelled token.
  • The minify helper moved from MinifiedDocumentTestFixture into TestDocuments, and keeps whitespace inside THE-ORIGINAL-VALUE. The existing graph comparisons now include the original values.
  • Each new test fails when the code it covers is broken: the old reader fails all of them, and the old loop with THE-ORIGINAL-VALUE added fails the minified orders.
  • dotnet build -c Release: 0 warnings; dotnet test: 448 passed.

Found during this work and tracked separately:

🤖 Generated with Claude Code

AttributeValueXHTML.ReadXml and ReadXmlAsync never read THE-ORIGINAL-VALUE,
so TheOriginalValue was always null after reading, and a document that was
read and written again lost the original values of its simplified XHTML
attribute values.

- Read only the direct children (DEFINITION, THE-VALUE, THE-ORIGINAL-VALUE)
  in any order. ReadInnerXml and Skip already move to the next node, so the
  loop does not call Read after them and no sibling is skipped in minified
  documents (see #94). Other children are skipped.
- Read the definition reference through a subtree of DEFINITION; an
  unknown reference still throws.
- Add AttributeValueXHTMLReadTestFixture: original values read from the
  test data, kept on read-write-read, and four child orders (also with an
  unknown child) read correctly, indented and minified, reqif and reqifz,
  sync and async. Add a cancellation test for ReadXmlAsync.
- Move the minify helper into TestDocuments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

@samatstariongroup
samatstariongroup merged commit ebffa6f into development Oct 19, 2026
8 checks passed
@samatstariongroup
samatstariongroup deleted the GH95 branch October 19, 2026 06:44
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.

[Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read

1 participant