Skip to content

[Bug]: Elements are matched on local name only, so elements in another namespace are read as ReqIF elements #97

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

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 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's REQ-IF root (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.StartsWith element match, and decide whether ReadToDescendant(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 PrefixedNamespaceTestFixture and MinifiedDocumentTestFixture tests 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 ReqIFSharp uses the local name alone.

Steps to Reproduce

  1. Take ReqIFSharp.Tests/TestData/reqifsharpgenerated.reqif.
  2. Inside the first ATTRIBUTE-VALUE-XHTML, after THE-VALUE, add <other:THE-VALUE xmlns:other="http://example.com/other"><xhtml:p>foreign</xhtml:p></other:THE-VALUE>.
  3. Deserialize the document: the TheValue of that attribute value is <xhtml:p xmlns:xhtml="http://www.w3.org/1999/xhtml">foreign</xhtml:p>. The ReqIF THE-VALUE is lost. (Seen on the branch for [Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read #95; on development before [Bug]: THE-ORIGINAL-VALUE of an XHTML attribute value is not read #95 the result may differ, since that reader matched THE-VALUE anywhere in the element.)

System Configuration

Activity

  1. samatstariongroup commented on Oct 19, 2026

    @samatstariongroup
    MemberAuthor

    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-IF root instead.

    • Both rules give the same result for valid documents and for documents without namespace ([Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents  #87), and every element in another namespace is skipped with a warning either way.
    • They differ only for a document in the ReqIF namespace that also contains elements in no namespace (xmlns=""), which the schema does not allow. Those elements are still read, as they were before.
    • Comparing against the root's namespace would mean passing that namespace through every reader class, for no gain on valid input.

    The behaviour is pinned by ForeignNamespaceTestFixture.Verify_that_an_element_in_no_namespace_in_a_document_in_the_ReqIF_namespace_is_read.

  2. added 3 commits that reference this issue on Oct 19, 2026
    b21f8fc
    6d3eedc
    0b78164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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