Repository navigation
Description
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 typeATTRIBUTE-VALUE-XHTML:THE-ORIGINAL-VALUEis an optional child (minOccurs="0",maxOccurs="1") of typeREQIF:XHTML-CONTENT, next toTHE-VALUEandDEFINITIONin anxsd: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
theValuetotheOriginalValue, stores a simplified representation and exports it withisSimplifiedset 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 keepsTHE-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-VALUEinReadXmlandReadXmlAsyncthe same way asTHE-VALUE(inner XML, trimmed). - Take care with the reader position:
ReadInnerXmlmoves the reader past the end tag, so in awhile (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 documentTHE-ORIGINAL-VALUEdirectly afterTHE-VALUEwould then be lost.
Acceptance criteria
TheOriginalValueholds the content ofTHE-ORIGINAL-VALUEafter readingreqifsharpgenerated.reqif, sync and async.- Read, write and read again keeps
TheOriginalValueandIsSimplified. THE-ORIGINAL-VALUEis read before and afterTHE-VALUEandDEFINITION, in indented and minified documents.
Steps to Reproduce
- Deserialize
ReqIFSharp.Tests/TestData/reqifsharpgenerated.reqif. - Find an
AttributeValueXHTMLwhose element containsTHE-ORIGINAL-VALUE(for example the one at line 375 of the file). TheOriginalValueisnull;TheValueandIsSimplifiedare read.
System Configuration
- reqifsharp version: 10.1.2 (
developmentat c5dc6b2) - Environment (Operating system, version and so on): any
- .NET Framework version: netstandard2.0 library
- Additional information: found during the review of the fix for [Bug]: Elements are skipped when a ReqIF document has no whitespace between elements #94
Activity
[Update] remove references to GitHub issues from code comments
[Add] AttributeValueXHTML.ExtractNormalizedTextFromValue for plain te…