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
The deserializer matches most ReqIF elements on their local name only (reader.LocalName), and ignores their namespace. An element from another namespace whose local name is the same as a ReqIF element is therefore read as that ReqIF element. Matching is also inconsistent across the code base:
- The
REQ-IFroot is matched on local name and namespace: the ReqIF namespace or no namespace (ReqIFDeserializer.IsReqIFRootElement, [Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents #87). A root in another namespace is skipped with a warning. ReadToDescendant(name, reader.NamespaceURI)(30 calls) matches the name in the namespace of the current element ([Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents #87).- Everything else uses the local name only: 38
switch (reader.LocalName)statements and 24LocalName ==/LocalName.StartsWithchecks, in 22 files:AlternativeID, allAttributeDefinition*,AttributeValueEnumeration,AttributeValueXHTML,DatatypeDefinitionEnumeration,EnumValue,ReqIF,ReqIFContent,ReqIFDeserializer,ReqIFHeader,RelationGroup,SpecElementWithAttributes,SpecHierarchy,Specification,SpecRelationandSpecType.
The ReqIF schema (reqif.xsd, targetNamespace="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", elementFormDefault="qualified") puts every ReqIF element in the ReqIF namespace. Content from other namespaces is only allowed in XHTML values and in REQ-IF-TOOL-EXTENSION, and is read there as raw XML. A ReqIF element name in a foreign namespace is therefore never a ReqIF element. For example, <other:THE-VALUE xmlns:other="..."> inside an ATTRIBUTE-VALUE-XHTML is currently read as its THE-VALUE.
This was noticed during the review of #95, which matches the children of ATTRIBUTE-VALUE-XHTML on local name only, in line with the rest of the code.
Proposal
- Add one helper, for example
IsReqIFElement(this XmlReader reader, string localName), that is true when the local name matches and the namespace is the namespace of the document'sREQ-IFroot (the ReqIF namespace, or no namespace for a document without one, which [Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents #87 keeps supporting). - Use it in place of every
switch (reader.LocalName)/LocalName ==/LocalName.StartsWithelement match, and decide whetherReadToDescendant(name, reader.NamespaceURI)should use the same namespace. Keep the sync and async paths the same. - Skip an element in a foreign namespace, and log a warning as the reader already does for unsupported elements.
- Do not change how XHTML content and tool extensions are read.
Acceptance criteria
- A document in the ReqIF namespace, with or without a prefix, and a document in no namespace read as today: the existing
PrefixedNamespaceTestFixtureandMinifiedDocumentTestFixturetests pass. - An element with a ReqIF local name in a foreign namespace is not read as a ReqIF element and is skipped with a warning. This is tested for at least the header, a spec object (values, type), a relation group and an XHTML attribute value, sync and async.
- No element match in
ReqIFSharpuses the local name alone.
Steps to Reproduce
- Take
ReqIFSharp.Tests/TestData/reqifsharpgenerated.reqif. - Inside the first
ATTRIBUTE-VALUE-XHTML, afterTHE-VALUE, add<other:THE-VALUE xmlns:other="http://example.com/other"><xhtml:p>foreign</xhtml:p></other:THE-VALUE>. - Deserialize the document: the
TheValueof that attribute value is<xhtml:p xmlns:xhtml="http://www.w3.org/1999/xhtml">foreign</xhtml:p>. The ReqIFTHE-VALUEis lost. (Seen on the branch for [Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read #95; ondevelopmentbefore [Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read #95 the result may differ, since that reader matchedTHE-VALUEanywhere in the element.)
System Configuration
- reqifsharp version:
development(after [Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read #95) - Environment (Operating system, version and so on): any
- .NET Framework version: netstandard2.0 library
- Additional information: related to [Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents #87 and [Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read #95
Activity
samatstariongroup commentedon Oct 19, 2026
Decision taken while implementing this issue (branch
GH97):An element is read as a ReqIF element when it is in the ReqIF namespace or in no namespace, in any document. The proposal above compared against the namespace of the document's
REQ-IFroot instead.xmlns=""), which the schema does not allow. Those elements are still read, as they were before.The behaviour is pinned by
ForeignNamespaceTestFixture.Verify_that_an_element_in_no_namespace_in_a_document_in_the_ReqIF_namespace_is_read.[Add] tests for foreign DEFINITION wrappers, unsupported enumeration …
[Fix] skip elements in a foreign namespace instead of reading them as…
[Update] remove references to GitHub issues from code comments
[Add] AttributeValueXHTML.ExtractNormalizedTextFromValue for plain te…