Skip to content

[Fix] read ReqIF documents whose elements use a namespace prefix (#87) - #93

Merged
samatstariongroup merged 1 commit into
developmentfrom
fix/gh87-prefixed-elements
Oct 18, 2026
Merged

samatstariongroup merged 1 commit into
developmentfrom
fix/gh87-prefixed-elements

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the ReqIFSharp code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

Fixes #87.

Elements were matched on their qualified name (XmlReader.Name, which includes the prefix). A document that binds the ReqIF namespace to a prefix (<reqif:REQ-IF xmlns:reqif="...">) was therefore read as zero documents, with no error, although it is valid against the schema. The same problem affected nested lookups.

Changes

  • Root element (ReqIFDeserializer, all four sync/async and .reqif/.reqifz paths): matched on local name and namespace.
    • A root in the ReqIF namespace is read, with or without a prefix.
    • A root in no namespace is still read, as before.
    • A REQ-IF root in any other namespace is skipped and a warning is logged. Before, such a root was read when it had no prefix. The schema (targetNamespace = http://www.omg.org/spec/ReqIF/20110401/reqif.xsd, elementFormDefault="qualified") does not allow it, and ReqIF 1.2 clause 3 names the schema as the authoritative description of the document structure. Listed under Changed in the CHANGELOG.
  • Nested elements:
    • RelationGroup now switches on LocalName (source/target specification, spec relations).
    • Every ReadToDescendant("X") now passes the current element's namespace. This covers the type references, SPEC-OBJECT-REF in hierarchies and relations, and the attribute-definition references of the Boolean, Date, Integer, Real and String values.

Tests

New PrefixedNamespaceTestFixture, 14 tests:

  • A reqif:-prefixed copy of four test documents reads into the same object graph as the original, sync and async, .reqif and .reqifz. The graphs are compared by re-serializing both and comparing the XML, ignoring namespace declarations.
  • A namespace-free copy of reqifsharpgenerated.reqif reads into the same graph as the original.
  • A root in another namespace (<other:REQ-IF> and <REQ-IF xmlns="…other">) gives zero documents and one warning, sync and async.

dotnet build -c Release: 0 warnings. dotnet test: 403 passed.

🤖 Generated with Claude Code

#87

Elements were matched on their qualified name, so a document that binds
the ReqIF namespace to a prefix (reqif:REQ-IF) was read as zero documents,
and nested lookups (type references, spec-object references, relation-group
source/target and spec relations) failed the same way.

- Match the REQ-IF root on local name and namespace in all four sync/async
  .reqif/.reqifz paths. A root in no namespace is still read; a REQ-IF root
  in any other namespace is skipped and a warning is logged.
- Switch RelationGroup to LocalName and pass the current element's
  namespace to every ReadToDescendant call.
- Add PrefixedNamespaceTestFixture: prefixed and namespace-free copies of
  test documents read to the same object graph as the originals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@samatstariongroup
samatstariongroup merged commit c5dc6b2 into development Oct 18, 2026
8 checks passed
@samatstariongroup
samatstariongroup deleted the fix/gh87-prefixed-elements branch October 18, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents

1 participant