diff --git a/CHANGELOG.md b/CHANGELOG.md index e3f849a..2637740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ The repository ships two NuGet packages that version independently: **ReqIFSharp ## [Unreleased] +### Changed + +- A `REQ-IF` root element in a namespace other than the ReqIF namespace (`http://www.omg.org/spec/ReqIF/20110401/reqif.xsd`) is no longer read as a ReqIF document; it is skipped and a warning is logged. Before, such an element was read when it had no prefix. A root in no namespace is still read ([#87](https://github.com/STARIONGROUP/ReqIFSharp/issues/87)). + +### Fixed + +- A document that binds the ReqIF namespace to a prefix (``) was read as zero documents, and type, source/target and relation-group references in it were not read. Elements are now matched on their local name and namespace ([#87](https://github.com/STARIONGROUP/ReqIFSharp/issues/87)). + ## [10.1.2] - 2026-10-18 ReqIFSharp.Extensions 5.2.2 diff --git a/ReqIFSharp.Tests/PrefixedNamespaceTestFixture.cs b/ReqIFSharp.Tests/PrefixedNamespaceTestFixture.cs new file mode 100644 index 0000000..cf2c594 --- /dev/null +++ b/ReqIFSharp.Tests/PrefixedNamespaceTestFixture.cs @@ -0,0 +1,304 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2017-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace ReqIFSharp.Tests +{ + using System.Collections.Generic; + using System.IO; + using System.IO.Compression; + using System.Linq; + using System.Text; + using System.Threading; + using System.Threading.Tasks; + using System.Xml.Linq; + + using Microsoft.Extensions.Logging; + + using NUnit.Framework; + + using ReqIFSharp; + + using Serilog; + using Serilog.Events; + + /// + /// Verifies that the REQ-IF root and the elements below it are matched on their local name and namespace, + /// so that a document in which the ReqIF namespace is bound to a prefix (reqif:REQ-IF) is read + /// the same as the unprefixed original, see GH-87. + /// + [TestFixture] + public class PrefixedNamespaceTestFixture + { + private static readonly XNamespace ReqIFNamespace = DefaultXmlAttributeFactory.ReqIFSchemaUri; + + // output.reqif and testreqif.reqif are left out: they contain unresolved type references, + // so their object graphs cannot be serialized for the comparison + private static readonly string[] TestFiles = + { + "Datatype-Demo.reqif", + "DefaultValueDemo.reqif", + "ProR_Traceability-Template-v1.0.reqif", + "reqifsharpgenerated.reqif" + }; + + private static readonly string[] ForeignNamespaceDocuments = + { + "", + "" + }; + + private static readonly SupportedFileExtensionKind[] Kinds = { SupportedFileExtensionKind.Reqif, SupportedFileExtensionKind.Reqifz }; + + private TestLogEventSink testLogEventSink; + + private ILoggerFactory loggerFactory; + + [SetUp] + public void SetUp() + { + this.testLogEventSink = new TestLogEventSink(); + + var logger = new LoggerConfiguration() + .MinimumLevel.Verbose() + .WriteTo.Sink(this.testLogEventSink) + .CreateLogger(); + + this.loggerFactory = LoggerFactory.Create(builder => builder.AddSerilog(logger, dispose: true)); + } + + [TearDown] + public void TearDown() + { + this.loggerFactory.Dispose(); + } + + [TestCaseSource(nameof(TestFiles))] + public void Verify_that_a_prefixed_document_is_read_the_same_as_the_original(string fileName) + { + var original = ReadTestFile(fileName); + var prefixed = CreatePrefixedCopy(original); + + foreach (var kind in Kinds) + { + var deserializer = new ReqIFDeserializer(); + + var expected = deserializer.Deserialize(ToStream(original, kind), kind).ToList(); + var actual = deserializer.Deserialize(ToStream(prefixed, kind), kind).ToList(); + + AssertSameGraph(expected, actual); + } + } + + [TestCaseSource(nameof(TestFiles))] + public async Task Verify_that_a_prefixed_document_is_read_the_same_as_the_original_async(string fileName) + { + var original = ReadTestFile(fileName); + var prefixed = CreatePrefixedCopy(original); + + foreach (var kind in Kinds) + { + var deserializer = new ReqIFDeserializer(); + + var expected = (await deserializer.DeserializeAsync(ToStream(original, kind), kind, CancellationToken.None)).ToList(); + var actual = (await deserializer.DeserializeAsync(ToStream(prefixed, kind), kind, CancellationToken.None)).ToList(); + + AssertSameGraph(expected, actual); + } + } + + [Test] + public void Verify_that_a_document_without_namespace_is_read_the_same_as_the_original() + { + var original = ReadTestFile("reqifsharpgenerated.reqif"); + var withoutNamespace = CreateCopyWithoutNamespace(original); + + foreach (var kind in Kinds) + { + var deserializer = new ReqIFDeserializer(); + + var expected = deserializer.Deserialize(ToStream(original, kind), kind).ToList(); + var actual = deserializer.Deserialize(ToStream(withoutNamespace, kind), kind).ToList(); + + AssertSameGraph(expected, actual); + } + } + + [Test] + public async Task Verify_that_a_document_without_namespace_is_read_the_same_as_the_original_async() + { + var original = ReadTestFile("reqifsharpgenerated.reqif"); + var withoutNamespace = CreateCopyWithoutNamespace(original); + + foreach (var kind in Kinds) + { + var deserializer = new ReqIFDeserializer(); + + var expected = (await deserializer.DeserializeAsync(ToStream(original, kind), kind, CancellationToken.None)).ToList(); + var actual = (await deserializer.DeserializeAsync(ToStream(withoutNamespace, kind), kind, CancellationToken.None)).ToList(); + + AssertSameGraph(expected, actual); + } + } + + [TestCaseSource(nameof(ForeignNamespaceDocuments))] + public void Verify_that_a_root_element_in_another_namespace_is_skipped_with_a_warning(string xml) + { + var deserializer = new ReqIFDeserializer(this.loggerFactory); + + var reqifs = deserializer.Deserialize(ToStream(xml, SupportedFileExtensionKind.Reqif), SupportedFileExtensionKind.Reqif); + + Assert.That(reqifs, Is.Empty); + this.AssertSkippedWarningLogged(); + } + + [TestCaseSource(nameof(ForeignNamespaceDocuments))] + public async Task Verify_that_a_root_element_in_another_namespace_is_skipped_with_a_warning_async(string xml) + { + var deserializer = new ReqIFDeserializer(this.loggerFactory); + + var reqifs = await deserializer.DeserializeAsync(ToStream(xml, SupportedFileExtensionKind.Reqif), SupportedFileExtensionKind.Reqif, CancellationToken.None); + + Assert.That(reqifs, Is.Empty); + this.AssertSkippedWarningLogged(); + } + + private void AssertSkippedWarningLogged() + { + var warnings = this.testLogEventSink.Events + .Where(e => e.Level == LogEventLevel.Warning && e.MessageTemplate.Text.Contains("has been skipped")) + .ToList(); + + Assert.That(warnings, Has.Count.EqualTo(1)); + Assert.That(warnings[0].RenderMessage(), Does.Contain("http://example.com/not-reqif")); + } + + private static string ReadTestFile(string fileName) + { + return File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", fileName)); + } + + /// + /// Returns a copy of the document in which every ReqIF element is written as reqif:... + /// + private static string CreatePrefixedCopy(string original) + { + // keep the original whitespace, so that the copy differs from the original only in its prefixes + var document = XDocument.Parse(original, LoadOptions.PreserveWhitespace); + + RemoveReqIFNamespaceDeclarations(document); + + document.Root!.SetAttributeValue(XNamespace.Xmlns + "reqif", ReqIFNamespace.NamespaceName); + + var prefixed = document.ToString(SaveOptions.DisableFormatting); + + Assert.That(prefixed, Does.Contain(" + /// Returns a copy of the document in which the ReqIF elements are in no namespace + /// + private static string CreateCopyWithoutNamespace(string original) + { + var document = XDocument.Parse(original, LoadOptions.PreserveWhitespace); + + RemoveReqIFNamespaceDeclarations(document); + + foreach (var element in document.Descendants().Where(e => e.Name.Namespace == ReqIFNamespace)) + { + element.Name = XNamespace.None + element.Name.LocalName; + } + + var withoutNamespace = document.ToString(SaveOptions.DisableFormatting); + + Assert.That(withoutNamespace, Does.Contain(" a.IsNamespaceDeclaration && a.Value == ReqIFNamespace.NamespaceName) + .Remove(); + } + } + + private static MemoryStream ToStream(string xml, SupportedFileExtensionKind kind) + { + var bytes = Encoding.UTF8.GetBytes(xml); + + if (kind == SupportedFileExtensionKind.Reqif) + { + return new MemoryStream(bytes); + } + + var zipStream = new MemoryStream(); + + using (var archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true)) + { + using var entryStream = archive.CreateEntry("document.reqif").Open(); + entryStream.Write(bytes, 0, bytes.Length); + } + + zipStream.Position = 0; + return zipStream; + } + + /// + /// Compares two object graphs by serializing both and comparing the XML, ignoring namespace declarations + /// (which differ by design between the original and its copy). + /// + private static void AssertSameGraph(IReadOnlyList expected, IReadOnlyList actual) + { + Assert.That(expected, Has.Count.EqualTo(1)); + Assert.That(actual, Has.Count.EqualTo(expected.Count), "the copy must be read as the same number of documents"); + Assert.That(actual[0].CoreContent.SpecObjects, Has.Count.EqualTo(expected[0].CoreContent.SpecObjects.Count)); + + var expectedXml = Normalize(expected); + var actualXml = Normalize(actual); + + Assert.That(actualXml.ToString(), Is.EqualTo(expectedXml.ToString())); + } + + private static XDocument Normalize(IEnumerable reqifs) + { + using var stream = new MemoryStream(); + + new ReqIFSerializer().Serialize(reqifs, stream, SupportedFileExtensionKind.Reqif); + + stream.Position = 0; + + var document = XDocument.Load(stream); + + foreach (var element in document.Descendants()) + { + element.Attributes().Where(a => a.IsNamespaceDeclaration).Remove(); + } + + return document; + } + } +} diff --git a/ReqIFSharp/AttributeValue/AttributeValueBoolean.cs b/ReqIFSharp/AttributeValue/AttributeValueBoolean.cs index f0a051d..b24c900 100644 --- a/ReqIFSharp/AttributeValue/AttributeValueBoolean.cs +++ b/ReqIFSharp/AttributeValue/AttributeValueBoolean.cs @@ -174,7 +174,7 @@ internal override void ReadXml(XmlReader reader) while (reader.Read()) { - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-BOOLEAN-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-BOOLEAN-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); @@ -204,7 +204,7 @@ internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken to { token.ThrowIfCancellationRequested(); - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-BOOLEAN-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-BOOLEAN-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); diff --git a/ReqIFSharp/AttributeValue/AttributeValueDate.cs b/ReqIFSharp/AttributeValue/AttributeValueDate.cs index ea559ea..16d0b5b 100644 --- a/ReqIFSharp/AttributeValue/AttributeValueDate.cs +++ b/ReqIFSharp/AttributeValue/AttributeValueDate.cs @@ -164,7 +164,7 @@ internal override void ReadXml(XmlReader reader) while (reader.Read()) { - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-DATE-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-DATE-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); @@ -194,7 +194,7 @@ internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken to { token.ThrowIfCancellationRequested(); - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-DATE-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-DATE-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); diff --git a/ReqIFSharp/AttributeValue/AttributeValueInteger.cs b/ReqIFSharp/AttributeValue/AttributeValueInteger.cs index 344fe03..edfb2ef 100644 --- a/ReqIFSharp/AttributeValue/AttributeValueInteger.cs +++ b/ReqIFSharp/AttributeValue/AttributeValueInteger.cs @@ -178,7 +178,7 @@ internal override void ReadXml(XmlReader reader) while (reader.Read()) { - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-INTEGER-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-INTEGER-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); @@ -208,7 +208,7 @@ internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken to { token.ThrowIfCancellationRequested(); - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-INTEGER-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-INTEGER-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); diff --git a/ReqIFSharp/AttributeValue/AttributeValueReal.cs b/ReqIFSharp/AttributeValue/AttributeValueReal.cs index 4715b0c..7d6e075 100644 --- a/ReqIFSharp/AttributeValue/AttributeValueReal.cs +++ b/ReqIFSharp/AttributeValue/AttributeValueReal.cs @@ -175,7 +175,7 @@ internal override void ReadXml(XmlReader reader) while (reader.Read()) { - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-REAL-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-REAL-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); @@ -205,7 +205,7 @@ internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken to { token.ThrowIfCancellationRequested(); - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-REAL-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-REAL-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); diff --git a/ReqIFSharp/AttributeValue/AttributeValueString.cs b/ReqIFSharp/AttributeValue/AttributeValueString.cs index eb29206..aecc635 100644 --- a/ReqIFSharp/AttributeValue/AttributeValueString.cs +++ b/ReqIFSharp/AttributeValue/AttributeValueString.cs @@ -156,7 +156,7 @@ internal override void ReadXml(XmlReader reader) while (reader.Read()) { - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-STRING-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-STRING-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); @@ -186,7 +186,7 @@ internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken to { token.ThrowIfCancellationRequested(); - if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-STRING-REF")) + if (reader.ReadToDescendant("ATTRIBUTE-DEFINITION-STRING-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); diff --git a/ReqIFSharp/ReqIFDeserializer.cs b/ReqIFSharp/ReqIFDeserializer.cs index 77026b3..f0b7b3a 100644 --- a/ReqIFSharp/ReqIFDeserializer.cs +++ b/ReqIFSharp/ReqIFDeserializer.cs @@ -293,7 +293,7 @@ private IEnumerable DeserializeReqIF(Stream stream, SupportedFileExtensio while (xmlReader.Read()) { - if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "REQ-IF")) + if (IsReqIFRootElement(xmlReader)) { var reqif = new ReqIF(this.loggerFactory); reqif.ReadXml(xmlReader); @@ -335,7 +335,7 @@ private IEnumerable DeserializeReqIF(Stream stream, SupportedFileExtensio while (xmlReader.Read()) { - if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "REQ-IF")) + if (IsReqIFRootElement(xmlReader)) { var reqif = new ReqIF(this.loggerFactory); reqif.ReadXml(xmlReader); @@ -401,7 +401,7 @@ private async Task> DeserializeReqIFAsync(Stream stream, Supp while (await xmlReader.ReadAsync()) { - if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "REQ-IF")) + if (IsReqIFRootElement(xmlReader)) { var reqif = new ReqIF(loggerFactory); await reqif.ReadXmlAsync(xmlReader, token); @@ -445,7 +445,7 @@ private async Task> DeserializeReqIFAsync(Stream stream, Supp { while (await xmlReader.ReadAsync()) { - if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "REQ-IF")) + if (IsReqIFRootElement(xmlReader)) { var reqif = new ReqIF(loggerFactory); await reqif.ReadXmlAsync(xmlReader, token); @@ -467,6 +467,38 @@ private async Task> DeserializeReqIFAsync(Stream stream, Supp throw new SerializationException($"The {nameof(stream)} could not be deserialized"); } + /// + /// Checks whether the is positioned on a REQ-IF root element. + /// The element is matched on its local name and namespace, so a prefixed root (reqif:REQ-IF) is found too. + /// A root without a namespace is still accepted, as it was before. A REQ-IF element in any other + /// namespace is not a ReqIF document; it is skipped and a warning is logged. + /// + /// + /// The to check + /// + /// + /// true when the current node is a REQ-IF element in the ReqIF namespace or in no namespace + /// + private bool IsReqIFRootElement(XmlReader xmlReader) + { + if (xmlReader.NodeType != XmlNodeType.Element || xmlReader.LocalName != "REQ-IF") + { + return false; + } + + if (xmlReader.NamespaceURI == DefaultXmlAttributeFactory.ReqIFSchemaUri || xmlReader.NamespaceURI.Length == 0) + { + return true; + } + + var xmlLineInfo = xmlReader as IXmlLineInfo; + + this.logger.LogWarning("The REQ-IF element at line:position {LineNumber}:{LinePosition} is in the namespace {NamespaceUri} instead of {ReqIFNamespaceUri} and has been skipped", + xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition, xmlReader.NamespaceURI, DefaultXmlAttributeFactory.ReqIFSchemaUri); + + return false; + } + /// /// Creates an instance of with or without validation settings /// diff --git a/ReqIFSharp/SpecElementWithAttributes/RelationGroup.cs b/ReqIFSharp/SpecElementWithAttributes/RelationGroup.cs index 6194d46..7105df9 100644 --- a/ReqIFSharp/SpecElementWithAttributes/RelationGroup.cs +++ b/ReqIFSharp/SpecElementWithAttributes/RelationGroup.cs @@ -170,10 +170,10 @@ protected override void ReadObjectSpecificElements(XmlReader reader) { var xmlLineInfo = reader as IXmlLineInfo; - switch (reader.Name) + switch (reader.LocalName) { case "SOURCE-SPECIFICATION": - if (reader.ReadToDescendant("SPECIFICATION-REF")) + if (reader.ReadToDescendant("SPECIFICATION-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specification = this.CoreContent.Specifications.SingleOrDefault(x => x.Identifier == reference); @@ -191,7 +191,7 @@ protected override void ReadObjectSpecificElements(XmlReader reader) } break; case "TARGET-SPECIFICATION": - if (reader.ReadToDescendant("SPECIFICATION-REF")) + if (reader.ReadToDescendant("SPECIFICATION-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specification = this.CoreContent.Specifications.SingleOrDefault(x => x.Identifier == reference); @@ -260,10 +260,10 @@ private async Task ReadObjectSpecificElementsInternalAsync(XmlReader reader, Can { var xmlLineInfo = reader as IXmlLineInfo; - switch (reader.Name) + switch (reader.LocalName) { case "SOURCE-SPECIFICATION": - if (reader.ReadToDescendant("SPECIFICATION-REF")) + if (reader.ReadToDescendant("SPECIFICATION-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specification = this.CoreContent.Specifications.SingleOrDefault(x => x.Identifier == reference); @@ -280,7 +280,7 @@ private async Task ReadObjectSpecificElementsInternalAsync(XmlReader reader, Can } break; case "TARGET-SPECIFICATION": - if (reader.ReadToDescendant("SPECIFICATION-REF")) + if (reader.ReadToDescendant("SPECIFICATION-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specification = this.CoreContent.Specifications.SingleOrDefault(x => x.Identifier == reference); @@ -323,7 +323,7 @@ protected override void ReadSpecType(XmlReader reader) throw new ArgumentNullException(nameof(reader)); } - if (reader.ReadToDescendant("RELATION-GROUP-TYPE-REF")) + if (reader.ReadToDescendant("RELATION-GROUP-TYPE-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); @@ -365,7 +365,7 @@ protected override Task ReadSpecTypeAsync(XmlReader reader, CancellationToken to /// private async Task ReadSpecTypeInternalAsync(XmlReader reader) { - if (reader.ReadToDescendant("RELATION-GROUP-TYPE-REF")) + if (reader.ReadToDescendant("RELATION-GROUP-TYPE-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); diff --git a/ReqIFSharp/SpecElementWithAttributes/SpecHierarchy.cs b/ReqIFSharp/SpecElementWithAttributes/SpecHierarchy.cs index bcdcad8..38727c5 100644 --- a/ReqIFSharp/SpecElementWithAttributes/SpecHierarchy.cs +++ b/ReqIFSharp/SpecElementWithAttributes/SpecHierarchy.cs @@ -381,7 +381,7 @@ private void Initialize(SpecHierarchy container, Specification root, ReqIFConten /// private void DeserializeObject(XmlReader reader) { - if (reader.ReadToDescendant("SPEC-OBJECT-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specObject = this.ReqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == reference); @@ -407,7 +407,7 @@ private async Task DeserializeObjectAsync(XmlReader reader, CancellationToken to { token.ThrowIfCancellationRequested(); - if (reader.ReadToDescendant("SPEC-OBJECT-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specObject = this.ReqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == reference); diff --git a/ReqIFSharp/SpecElementWithAttributes/SpecObject.cs b/ReqIFSharp/SpecElementWithAttributes/SpecObject.cs index 287fc38..2f62f13 100644 --- a/ReqIFSharp/SpecElementWithAttributes/SpecObject.cs +++ b/ReqIFSharp/SpecElementWithAttributes/SpecObject.cs @@ -134,7 +134,7 @@ protected override void ReadSpecType(XmlReader reader) throw new ArgumentNullException(nameof(reader)); } - if (reader.ReadToDescendant("SPEC-OBJECT-TYPE-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-TYPE-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); @@ -176,7 +176,7 @@ protected override Task ReadSpecTypeAsync(XmlReader reader, CancellationToken to /// private async Task ReadSpecTypeInternalAsync(XmlReader reader) { - if (reader.ReadToDescendant("SPEC-OBJECT-TYPE-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-TYPE-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); diff --git a/ReqIFSharp/SpecElementWithAttributes/SpecRelation.cs b/ReqIFSharp/SpecElementWithAttributes/SpecRelation.cs index dd99d62..067c73a 100644 --- a/ReqIFSharp/SpecElementWithAttributes/SpecRelation.cs +++ b/ReqIFSharp/SpecElementWithAttributes/SpecRelation.cs @@ -117,7 +117,7 @@ protected override void ReadObjectSpecificElements(XmlReader reader) switch (reader.LocalName) { case "SOURCE": - if (reader.ReadToDescendant("SPEC-OBJECT-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specObject = this.ReqIFContent.SpecObjects.SingleOrDefault(x => x.Identifier == reference); @@ -135,7 +135,7 @@ protected override void ReadObjectSpecificElements(XmlReader reader) } break; case "TARGET": - if (reader.ReadToDescendant("SPEC-OBJECT-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specObject = this.ReqIFContent.SpecObjects.SingleOrDefault(x => x.Identifier == reference); @@ -197,7 +197,7 @@ private async Task ReadObjectSpecificElementsInternalAsync(XmlReader reader) switch (reader.LocalName) { case "SOURCE": - if (reader.ReadToDescendant("SPEC-OBJECT-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specObject = this.ReqIFContent.SpecObjects.SingleOrDefault(x => x.Identifier == reference); @@ -215,7 +215,7 @@ private async Task ReadObjectSpecificElementsInternalAsync(XmlReader reader) } break; case "TARGET": - if (reader.ReadToDescendant("SPEC-OBJECT-REF")) + if (reader.ReadToDescendant("SPEC-OBJECT-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specObject = this.ReqIFContent.SpecObjects.SingleOrDefault(x => x.Identifier == reference); @@ -284,7 +284,7 @@ protected override void ReadSpecType(XmlReader reader) throw new ArgumentNullException(nameof(reader)); } - if (reader.ReadToDescendant("SPEC-RELATION-TYPE-REF")) + if (reader.ReadToDescendant("SPEC-RELATION-TYPE-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); @@ -326,7 +326,7 @@ protected override Task ReadSpecTypeAsync(XmlReader reader, CancellationToken t /// private async Task ReadSpecTypeInternalAsync(XmlReader reader) { - if (reader.ReadToDescendant("SPEC-RELATION-TYPE-REF")) + if (reader.ReadToDescendant("SPEC-RELATION-TYPE-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); diff --git a/ReqIFSharp/SpecElementWithAttributes/Specification.cs b/ReqIFSharp/SpecElementWithAttributes/Specification.cs index d6c7a05..4ae7379 100644 --- a/ReqIFSharp/SpecElementWithAttributes/Specification.cs +++ b/ReqIFSharp/SpecElementWithAttributes/Specification.cs @@ -176,7 +176,7 @@ protected override void ReadSpecType(XmlReader reader) throw new ArgumentNullException(nameof(reader)); } - if (reader.ReadToDescendant("SPECIFICATION-TYPE-REF")) + if (reader.ReadToDescendant("SPECIFICATION-TYPE-REF", reader.NamespaceURI)) { var reference = reader.ReadElementContentAsString(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference); @@ -213,7 +213,7 @@ protected override Task ReadSpecTypeAsync(XmlReader reader, CancellationToken to /// private async Task ReadSpecTypeInternalAsync(XmlReader reader) { - if (reader.ReadToDescendant("SPECIFICATION-TYPE-REF")) + if (reader.ReadToDescendant("SPECIFICATION-TYPE-REF", reader.NamespaceURI)) { var reference = await reader.ReadElementContentAsStringAsync(); var specType = this.ReqIFContent.SpecTypes.SingleOrDefault(x => x.Identifier == reference);