Repository navigation
[Fix] skip elements in a foreign namespace instead of reading them as ReqIF elements; fixes #97 - #100
Merged
Merged
Conversation
… ReqIF elements; fixes #97 Elements were matched on their local name only, so an element in another namespace with the name of a ReqIF element (for example <other:THE-VALUE>) was read as that ReqIF element. - Add XmlReaderExtensions.SkipForeignElement(Async): an element in a namespace other than the ReqIF namespace or no namespace is skipped with its content and a warning is logged; the reader is left on its end tag. - Call it at the top of every element loop of the reader, sync and async. - Read references with ReadToReqIFDescendant(Async), which skips foreign elements, and read the rest of TYPE, OBJECT and DEFINITION subtrees with SkipForeignElementsToEnd(Async), so a foreign element before or after a reference is reported. - Read single references with ReadElementContentAsStringToEndElement in the attribute definitions and enumeration values, so a sibling after a reference is not passed over in minified documents (see #94). - Elements in no namespace are still read in any document (decision noted on #97). - Keep the logger factory in the AttributeValue constructors: attribute values did not log anything. Enumeration values no longer report their own element and DEFINITION and VALUES as not supported. - Give EnumValue, Specification and AttributeValueString a logger, pass the owner's logger to AlternativeId, and pass the cancellation token to the private async readers. - Add ForeignNamespaceTestFixture and tests for the new helpers; move the prefix and no-namespace helpers into TestDocuments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…children and reference search positions; refs #97 - A foreign DEFINITION after the ReqIF one in Boolean, Date, Integer, Real and String attribute values is skipped with a warning. - An unknown ReqIF element in an enumeration value is still reported as not supported. - AttributeValueString created with a logger factory logs a skipped element. - ReadToReqIFDescendant started on an end tag or on whitespace. - A namespace that differs from the ReqIF namespace only in case is foreign. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.


Prerequisites
Description
Fixes #97.
The deserializer matched ReqIF elements on their local name only. An element in another namespace with the name of a ReqIF element, for example
<other:THE-VALUE xmlns:other="...">inside anATTRIBUTE-VALUE-XHTML, was read as that ReqIF element.Rule
An element is read as a ReqIF element when it is in the ReqIF namespace or in no namespace, in any document. Any other element is skipped, with its content, and a warning is logged. This differs from the proposal in the issue (the namespace of the
REQ-IFroot); the reason is in this comment. XHTML content and tool extensions are read as raw XML, as before.How
XmlReaderExtensions, each with an async variant that takes a cancellation token:SkipForeignElement: skips a foreign element, logs the warning, and leaves the reader on its end tag, so the nextRead()does not pass over a sibling in minified XML (see [Bug]: Elements are skipped when a ReqIF document has no whitespace between elements #94).ReadToReqIFDescendant: likeReadToDescendant, but skips foreign elements on the way; used for the 30 reference reads.SkipForeignElementsToEnd: reads the rest of aTYPE,OBJECTorDEFINITIONsubtree, so a foreign element after a reference is reported too.IsReqIFElementhelper,SkipForeignElementruns at the top of every element loop, sync and async (58 places), before the existingswitch (reader.LocalName). Theswitchstatements inSpecRelationandRelationGroup.ReadObjectSpecificElementsare reached only through the checked loop inSpecElementWithAttributes. TheLocalName == "object"match inAttributeValueXHTMLreads XHTML content and is left out on purpose.ReadElementContentAsStringToEndElement(from [Bug]: Elements are skipped when a ReqIF document has no whitespace between elements #94), so an element after a reference is not passed over in minified documents.Also fixed
AttributeValueconstructors did not keep theILoggerFactory, so attribute values never logged anything. With that fixed, enumeration values no longer report their own element and theirDEFINITIONandVALUESelements as not supported.EnumValue,SpecificationandAttributeValueStringgot a logger;AlternativeIduses the logger of its owner; the private async readers now receive the cancellation token of their caller.Tests
ForeignNamespaceTestFixture:.reqifand.reqifz, sync and async, and gives the same object graph as the original and exactly one warning;XmlReaderExtensionsTestFixture: the reader position, return values, warning text and cancellation of the three helpers.AttributeValueEnumerationTestFixture: reading enumeration values logs no warnings.Skip()moving past, search without skip, no subtree walk, depth check off by one, XHTML loop not moving on, the logger factory dropped, the enumeration cases removed, the oldReadElementContentAsString); every one makes tests fail.dotnet build -c Release: 0 warnings;dotnet test: 550 passed.Related, tracked separately: #98 (the public constructors of
AttributeValueXHTMLleaveExternalObjectsor the logger null).🤖 Generated with Claude Code