Skip to content

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

Closed

Description

@samatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the reqifsharp
  • I have searched open and closed issues to ensure it has not already been reported

Description

AttributeValueXHTML.TheOriginalValue is always null after a document is read, even when the document contains a THE-ORIGINAL-VALUE element. WriteXml and WriteXmlAsync write the element, but ReadXml and ReadXmlAsync (AttributeValueXHTML.cs, around lines 235-307) only handle ATTRIBUTE-DEFINITION-XHTML-REF and THE-VALUE. A document that is read and written again by ReqIFSharp loses its original values without any message.

What the schema and the specification say

  • reqif.xsd, complex type ATTRIBUTE-VALUE-XHTML: THE-ORIGINAL-VALUE is an optional child (minOccurs="0", maxOccurs="1") of type REQIF:XHTML-CONTENT, next to THE-VALUE and DEFINITION in an xsd:all, so it can appear in any order.
  • ReqIF 1.2 (formal/2016-07-01), 10.8.20 AttributeValueXHTML: theOriginalValue : XhtmlContent [0..1] {composite}, "Linkage to the original attribute value that has been saved if isSimplified is true."
  • Clause 8, the exchange process: a tool that cannot handle a formatted value saves it by copying theValue to theOriginalValue, stores a simplified representation and exports it with isSimplified set to true. A later tool in the exchange chain may restore it "by copying theOriginalValue to theValue". This only works when every tool in the chain keeps THE-ORIGINAL-VALUE.

Why the tests do not show it

ReqIFSharp.Tests/TestData/reqifsharpgenerated.reqif contains THE-ORIGINAL-VALUE six times, but no test asserts TheOriginalValue after reading. Tests that compare two read graphs lose the value on both sides, and ReqIFSerializerTestFixture only writes it.

Proposal

  • Read THE-ORIGINAL-VALUE in ReadXml and ReadXmlAsync the same way as THE-VALUE (inner XML, trimmed).
  • Take care with the reader position: ReadInnerXml moves the reader past the end tag, so in a while (reader.Read()) loop the next sibling is skipped when there is no whitespace between elements (see [Bug]: Elements are skipped when a ReqIF document has no whitespace between elements #94). In a minified document THE-ORIGINAL-VALUE directly after THE-VALUE would then be lost.

Acceptance criteria

  • TheOriginalValue holds the content of THE-ORIGINAL-VALUE after reading reqifsharpgenerated.reqif, sync and async.
  • Read, write and read again keeps TheOriginalValue and IsSimplified.
  • THE-ORIGINAL-VALUE is read before and after THE-VALUE and DEFINITION, in indented and minified documents.

Steps to Reproduce

  1. Deserialize ReqIFSharp.Tests/TestData/reqifsharpgenerated.reqif.
  2. Find an AttributeValueXHTML whose element contains THE-ORIGINAL-VALUE (for example the one at line 375 of the file).
  3. TheOriginalValue is null; TheValue and IsSimplified are read.

System Configuration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions