Skip to content

Commit 2b2d023

Browse files
committed
Read documents that put the ReqIF elements in a prefixed namespace
A document written as <rif:REQ-IF xmlns:rif="..."> failed with 'Document contains no CORE-CONTENT': elements were looked up by their qualified name via getElementsByTagName, and the spec type switch compared full node names. Only the embedded XHTML had been converted to local-name matching so far. - ReqIFDocument, ReqIFHeader, ReqIFCoreContent, SpecObject, Specification, SpecHierarchy and SpecType now locate elements by local name (XmlUtils) and iterate child elements instead of filtering #text - The datatype and spec type switches use the local name, so an unknown kind no longer records a prefixed source element name - Header fields are read through one helper; a missing REQ-IF-TOOL-ID no longer throws - Tests: PrefixedNamespaceTest, incl. a check that a prefixed and a default-namespace document produce identical core content Tool extensions keep the prefix of their source document, because they are copied verbatim rather than interpreted; a test pins that. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011mat2d7AJkouKhXWUYzHxs
1 parent 0e59043 commit 2b2d023

9 files changed

Lines changed: 272 additions & 122 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ This fork is based on https://github.com/bfriebel/requirements-interchange-forma
1010
# Supported Formats
1111
ReqIF file extensions .reqif and .reqifz (compressed).
1212

13+
Elements are matched by their local name, so it does not matter whether a
14+
document puts the ReqIF elements into the default namespace
15+
(`<REQ-IF xmlns="...">`) or into a prefixed one (`<rif:REQ-IF xmlns:rif="...">`).
16+
The same holds for the embedded XHTML (`xhtml:div`, `reqif-xhtml:div`, ...).
17+
1318
# Build & Test
1419
The project builds with Maven (Java 17+):
1520

src/main/java/de/uni_stuttgart/ils/reqif4j/reqif/ReqIFCoreContent.java

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ public ReqIFCoreContent(Element coreContent, TypeClassifier typeClassifier) {
139139
}
140140

141141

142-
if (coreContent.getElementsByTagName("DATATYPES").item(0).hasChildNodes()) {
142+
// Every element is matched by local name, so documents that put the
143+
// ReqIF elements into a prefixed namespace are read as well.
144+
Element datatypesElement = XmlUtils.firstDescendantByLocalName(coreContent, ReqIFConst.DATATYPES);
145+
if (datatypesElement != null) {
143146

144-
NodeList dataTypes = coreContent.getElementsByTagName("DATATYPES").item(0).getChildNodes();
145-
for (int datatype = 0; datatype < dataTypes.getLength(); datatype++) {
147+
for (Element dataType : XmlUtils.childElements(datatypesElement)) {
146148

147-
Node dataType = dataTypes.item(datatype);
148-
String dataTypeNodeName = dataType.getNodeName();
149-
if (!dataTypeNodeName.equals(ReqIFConst._TEXT)) {
149+
String dataTypeNodeName = XmlUtils.localName(dataType);
150+
{
150151

151152
String dataTypeID = dataType.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
152153
String dataTypeName = dataType.getAttributes().getNamedItem(ReqIFConst.LONG_NAME).getTextContent();
@@ -202,14 +203,13 @@ public ReqIFCoreContent(Element coreContent, TypeClassifier typeClassifier) {
202203
}
203204

204205

205-
if (coreContent.getElementsByTagName(ReqIFConst.SPEC_TYPES).item(0).hasChildNodes()) {
206+
Element specTypesElement = XmlUtils.firstDescendantByLocalName(coreContent, ReqIFConst.SPEC_TYPES);
207+
if (specTypesElement != null) {
206208

207-
NodeList specTypes = coreContent.getElementsByTagName(ReqIFConst.SPEC_TYPES).item(0).getChildNodes();
208-
for (int spectype = 0; spectype < specTypes.getLength(); spectype++) {
209+
for (Element specType : XmlUtils.childElements(specTypesElement)) {
209210

210-
Node specType = specTypes.item(spectype);
211-
String specTypeNodeName = specType.getNodeName();
212-
if (!specTypeNodeName.equals(ReqIFConst._TEXT)) {
211+
String specTypeNodeName = XmlUtils.localName(specType);
212+
{
213213

214214
String specTypeID = specType.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
215215

@@ -240,31 +240,23 @@ public ReqIFCoreContent(Element coreContent, TypeClassifier typeClassifier) {
240240
}
241241

242242

243-
if (coreContent.getElementsByTagName(ReqIFConst.SPEC_OBJECT).getLength() > 0) {
243+
for (Element specObj : XmlUtils.descendantsByLocalName(coreContent, ReqIFConst.SPEC_OBJECT)) {
244244

245-
NodeList specObjects = coreContent.getElementsByTagName(ReqIFConst.SPEC_OBJECT);
246-
for (int specobj = 0; specobj < specObjects.getLength(); specobj++) {
245+
String specObjID = XmlUtils.attribute(specObj, ReqIFConst.IDENTIFIER);
246+
Element typeRef = XmlUtils.firstDescendantByLocalName(specObj, ReqIFConst.SPEC_OBJECT_TYPE_REF);
247+
String specObjTypeRef = typeRef == null ? null : typeRef.getTextContent().trim();
247248

248-
Node specObj = specObjects.item(specobj);
249-
String specObjID = specObj.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
250-
String specObjTypeRef = ((Element) specObj).getElementsByTagName(ReqIFConst.SPEC_OBJECT_TYPE_REF).item(0).getTextContent();
251-
252-
this.specObjects.put(specObjID, new SpecObject(specObj, this.specTypes.get(specObjTypeRef), typeClassifier));
253-
}
249+
this.specObjects.put(specObjID, new SpecObject(specObj, this.specTypes.get(specObjTypeRef), typeClassifier));
254250
}
255251

256252

257-
if (coreContent.getElementsByTagName(ReqIFConst.SPEC_RELATION).getLength() > 0) {
258-
NodeList specRelations = coreContent.getElementsByTagName(ReqIFConst.SPEC_RELATION);
259-
for (int specrelation = 0; specrelation < specRelations.getLength(); specrelation++) {
260-
261-
Node specRelation = specRelations.item(specrelation);
262-
String specRelID = specRelation.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
263-
String specRelTypeRef = ((Element) specRelation).getElementsByTagName(ReqIFConst.SPEC_RELATION_TYPE_REF).item(0).getTextContent();
253+
for (Element specRelation : XmlUtils.descendantsByLocalName(coreContent, ReqIFConst.SPEC_RELATION)) {
264254

255+
String specRelID = XmlUtils.attribute(specRelation, ReqIFConst.IDENTIFIER);
256+
Element typeRef = XmlUtils.firstDescendantByLocalName(specRelation, ReqIFConst.SPEC_RELATION_TYPE_REF);
257+
String specRelTypeRef = typeRef == null ? null : typeRef.getTextContent().trim();
265258

266-
this.specRelation.put(specRelID, new SpecRelation(specRelation, this.specTypes.get(specRelTypeRef)));
267-
}
259+
this.specRelation.put(specRelID, new SpecRelation(specRelation, this.specTypes.get(specRelTypeRef)));
268260
}
269261

270262

@@ -274,17 +266,13 @@ public ReqIFCoreContent(Element coreContent, TypeClassifier typeClassifier) {
274266
}
275267

276268

277-
if (coreContent.getElementsByTagName(ReqIFConst.SPECIFICATION).getLength() > 0) {
278-
279-
NodeList specifications = coreContent.getElementsByTagName(ReqIFConst.SPECIFICATION);
280-
for (int spec = 0; spec < specifications.getLength(); spec++) {
269+
for (Element specification : XmlUtils.descendantsByLocalName(coreContent, ReqIFConst.SPECIFICATION)) {
281270

282-
Node specification = specifications.item(spec);
283-
String specID = specification.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
284-
String specTypeRef = ((Element) specification).getElementsByTagName(ReqIFConst.SPEC_TYPE_REF).item(0).getTextContent();
271+
String specID = XmlUtils.attribute(specification, ReqIFConst.IDENTIFIER);
272+
Element typeRef = XmlUtils.firstDescendantByLocalName(specification, ReqIFConst.SPEC_TYPE_REF);
273+
String specTypeRef = typeRef == null ? null : typeRef.getTextContent().trim();
285274

286-
this.specifications.put(specID, new Specification(specification, this.specTypes.get(specTypeRef), this.specObjects));
287-
}
275+
this.specifications.put(specID, new Specification(specification, this.specTypes.get(specTypeRef), this.specObjects));
288276
}
289277

290278

src/main/java/de/uni_stuttgart/ils/reqif4j/reqif/ReqIFDocument.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import de.uni_stuttgart.ils.reqif4j.specification.TypeClassifier;
1313
import de.uni_stuttgart.ils.reqif4j.util.SecureXml;
14+
import de.uni_stuttgart.ils.reqif4j.util.XmlUtils;
1415

1516
public class ReqIFDocument {
1617

@@ -129,20 +130,21 @@ private void setTypeClassifier(TypeClassifier typeClassifier) {
129130

130131
private void readDocument() {
131132

132-
if (this.reqifDocument.getElementsByTagName(ReqIFConst.THE_HEADER).getLength() > 0
133-
&& this.reqifDocument.getElementsByTagName(ReqIFConst.THE_HEADER).item(0).hasChildNodes()) {
134-
this.header = new ReqIFHeader((Element) this.reqifDocument.getElementsByTagName(ReqIFConst.THE_HEADER).item(0));
133+
// Elements are matched by local name, so a document that puts the ReqIF
134+
// elements into a prefixed namespace is read just like one using the
135+
// default namespace.
136+
Element theHeader = XmlUtils.firstDescendantByLocalName(this.reqifDocument, ReqIFConst.THE_HEADER);
137+
if (theHeader != null && theHeader.hasChildNodes()) {
138+
this.header = new ReqIFHeader(theHeader);
135139
}
136-
if (this.reqifDocument.getElementsByTagName(ReqIFConst.CORE_CONTENT).getLength() == 0) {
140+
Element coreContent = XmlUtils.firstDescendantByLocalName(this.reqifDocument, ReqIFConst.CORE_CONTENT);
141+
if (coreContent == null) {
137142
throw new ReqIFParseException("Document contains no " + ReqIFConst.CORE_CONTENT + " element: " + this.fileName);
138143
}
139-
this.content = new ReqIFCoreContent((Element) this.reqifDocument.getElementsByTagName(ReqIFConst.CORE_CONTENT).item(0), this.typeClassifier);
144+
this.content = new ReqIFCoreContent(coreContent, this.typeClassifier);
140145

141146
// Tool extensions are kept verbatim; the parser does not interpret them.
142-
org.w3c.dom.NodeList extensions = this.reqifDocument.getElementsByTagName(ReqIFConst.TOOL_EXTENSIONS);
143-
for (int extension = 0; extension < extensions.getLength(); extension++) {
144-
this.toolExtensions.add(extensions.item(extension));
145-
}
147+
this.toolExtensions.addAll(XmlUtils.descendantsByLocalName(this.reqifDocument, ReqIFConst.TOOL_EXTENSIONS));
146148
}
147149

148150
private static String extractFileName(String path) {

src/main/java/de/uni_stuttgart/ils/reqif4j/reqif/ReqIFHeader.java

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import org.w3c.dom.Element;
44

5+
import de.uni_stuttgart.ils.reqif4j.util.XmlUtils;
6+
57
public class ReqIFHeader {
68

79

@@ -67,31 +69,48 @@ public String getCreationTime() {
6769

6870

6971
public ReqIFHeader(Element theHeader) {
70-
71-
this.id = theHeader.getElementsByTagName(ReqIFConst.REQ_IF_HEADER).item(0).getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
72-
this.toolID = theHeader.getElementsByTagName(ReqIFConst.REQ_IF_TOOL_ID).item(0).getTextContent();
73-
74-
if(theHeader.getElementsByTagName(ReqIFConst.SOURCE_TOOL_ID).getLength() > 0) {
75-
this.sourceToolID = theHeader.getElementsByTagName(ReqIFConst.SOURCE_TOOL_ID).item(0).getTextContent();
72+
73+
Element reqifHeader = XmlUtils.firstDescendantByLocalName(theHeader, ReqIFConst.REQ_IF_HEADER);
74+
this.id = reqifHeader == null ? null : XmlUtils.attribute(reqifHeader, ReqIFConst.IDENTIFIER);
75+
this.toolID = textOf(theHeader, ReqIFConst.REQ_IF_TOOL_ID);
76+
77+
String sourceToolID = textOf(theHeader, ReqIFConst.SOURCE_TOOL_ID);
78+
if(sourceToolID != null) {
79+
this.sourceToolID = sourceToolID;
7680
}
77-
if(theHeader.getElementsByTagName(ReqIFConst.REQ_IF_VERSION).getLength() > 0) {
78-
this.reqifVersion = theHeader.getElementsByTagName(ReqIFConst.REQ_IF_VERSION).item(0).getTextContent();
81+
String reqifVersion = textOf(theHeader, ReqIFConst.REQ_IF_VERSION);
82+
if(reqifVersion != null) {
83+
this.reqifVersion = reqifVersion;
7984
}
80-
if(theHeader.getElementsByTagName(ReqIFConst.COMMENT).getLength() > 0) {
81-
this.comment = theHeader.getElementsByTagName(ReqIFConst.COMMENT).item(0).getTextContent();
82-
this.author = authorOf(this.comment);
85+
String comment = textOf(theHeader, ReqIFConst.COMMENT);
86+
if(comment != null) {
87+
this.comment = comment;
88+
this.author = authorOf(comment);
8389
}
84-
if(theHeader.getElementsByTagName(ReqIFConst.CREATION_TIME).getLength() > 0) {
85-
this.creationTime = theHeader.getElementsByTagName(ReqIFConst.CREATION_TIME).item(0).getTextContent();
86-
this.creationDate = creationDateOf(this.creationTime);
90+
String creationTime = textOf(theHeader, ReqIFConst.CREATION_TIME);
91+
if(creationTime != null) {
92+
this.creationTime = creationTime;
93+
this.creationDate = creationDateOf(creationTime);
8794
}
88-
if(theHeader.getElementsByTagName(ReqIFConst.TITLE).getLength() > 0) {
95+
String title = textOf(theHeader, ReqIFConst.TITLE);
96+
if(title != null) {
8997
// The title is returned as written in the document; stripping a
9098
// "_Template" suffix was a tool-specific hack in a generic parser.
91-
this.title = theHeader.getElementsByTagName(ReqIFConst.TITLE).item(0).getTextContent();
99+
this.title = title;
92100
}
93101
}
94102

103+
/**
104+
* @return the text of the first descendant with that local name, or null.
105+
* Matching by local name keeps documents readable that put the ReqIF
106+
* elements into a prefixed namespace.
107+
*/
108+
private static String textOf(Element parent, String localName) {
109+
110+
Element element = XmlUtils.firstDescendantByLocalName(parent, localName);
111+
return element == null ? null : element.getTextContent();
112+
}
113+
95114
/**
96115
* Creates a header from plain values, for documents that are generated
97116
* instead of parsed. The author is derived from the comment and the

src/main/java/de/uni_stuttgart/ils/reqif4j/specification/SpecHierarchy.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import de.uni_stuttgart.ils.reqif4j.attributes.AttributeValueXHTML;
1414
import de.uni_stuttgart.ils.reqif4j.attributes.AttributeValueXHTMLElementList;
1515
import de.uni_stuttgart.ils.reqif4j.reqif.ReqIFConst;
16+
import de.uni_stuttgart.ils.reqif4j.util.XmlUtils;
1617
import de.uni_stuttgart.ils.reqif4j.xhtml.XHTMLNode;
1718
import de.uni_stuttgart.ils.reqif4j.xhtml.XHTMLElementDiv;
1819

@@ -184,29 +185,22 @@ public SpecHierarchy(int hierarchyLvl, int section, Node specHierarchy, Map<Stri
184185
this.hierarchyLvl = hierarchyLvl;
185186
this.section = section;
186187
this.specHierarchyID = specHierarchy.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
187-
this.alternativeID = de.uni_stuttgart.ils.reqif4j.util.XmlUtils.alternativeID(specHierarchy);
188+
this.alternativeID = XmlUtils.alternativeID(specHierarchy);
188189

189-
for(int childnode = 0; childnode < specHierarchy.getChildNodes().getLength(); childnode ++) {
190-
Node childNode = specHierarchy.getChildNodes().item(childnode);
191-
if(childNode.getNodeName().equals(ReqIFConst.OBJECT)) {
192-
String specObjectRef = ((Element)childNode).getElementsByTagName(ReqIFConst.SPEC_OBJECT_REF).item(0).getTextContent();
193-
this.specObject = specObjects.get(specObjectRef);
194-
}
190+
Element object = XmlUtils.firstChildElementByLocalName(specHierarchy, ReqIFConst.OBJECT);
191+
Element specObjectRef = XmlUtils.firstDescendantByLocalName(object, ReqIFConst.SPEC_OBJECT_REF);
192+
if(specObjectRef != null) {
193+
this.specObject = specObjects.get(specObjectRef.getTextContent().trim());
195194
}
196-
197-
if( ((Element)specHierarchy).getElementsByTagName(ReqIFConst.CHILDREN).getLength() > 0
198-
&& ((Element)specHierarchy).getElementsByTagName(ReqIFConst.CHILDREN).item(0).getChildNodes().getLength() > 0 ) {
199-
200-
NodeList children = ((Element)specHierarchy).getElementsByTagName(ReqIFConst.CHILDREN).item(0).getChildNodes();
201-
for(int child = 0; child < children.getLength(); child++) {
202-
203-
Node newSpecHierarchy = children.item(child);
204-
if(!newSpecHierarchy.getNodeName().equals(ReqIFConst._TEXT)) {
205-
206-
String specHierarchyID = newSpecHierarchy.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
207-
208-
this.children.put(specHierarchyID, new SpecHierarchy(this.hierarchyLvl+1, section, newSpecHierarchy, specObjects));
209-
}
195+
196+
Element childrenElement = XmlUtils.firstChildElementByLocalName(specHierarchy, ReqIFConst.CHILDREN);
197+
if(childrenElement != null) {
198+
199+
for(Element newSpecHierarchy: XmlUtils.childElements(childrenElement)) {
200+
201+
String specHierarchyID = XmlUtils.attribute(newSpecHierarchy, ReqIFConst.IDENTIFIER);
202+
203+
this.children.put(specHierarchyID, new SpecHierarchy(this.hierarchyLvl+1, section, newSpecHierarchy, specObjects));
210204
}
211205
}
212206
}

src/main/java/de/uni_stuttgart/ils/reqif4j/specification/SpecObject.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ public SpecObject(Node specObject, SpecType specType, TypeClassifier typeClassif
150150
*/
151151
protected void readAttributeValues(Node specObject, SpecType specType) {
152152

153-
if( ((Element)specObject).getElementsByTagName(ReqIFConst.VALUES).getLength() > 0
154-
&& ((Element)specObject).getElementsByTagName(ReqIFConst.VALUES).item(0).hasChildNodes() ) {
155-
156-
NodeList attributeValues = ((Element)specObject).getElementsByTagName(ReqIFConst.VALUES).item(0).getChildNodes();
157-
for(int attval = 0; attval < attributeValues.getLength(); attval++) {
158-
159-
Node attribute = attributeValues.item(attval);
160-
String attValNodeName = attribute.getNodeName();
161-
if(!attValNodeName.equals(ReqIFConst._TEXT)) {
153+
// VALUES is located by local name so prefixed ReqIF namespaces work too;
154+
// only this object's own VALUES is taken, not a nested one.
155+
Element valuesElement = XmlUtils.firstChildElementByLocalName(specObject, ReqIFConst.VALUES);
156+
if(valuesElement != null) {
157+
158+
for(Element attribute: XmlUtils.childElements(valuesElement)) {
159+
160+
String attValNodeName = XmlUtils.localName(attribute);
161+
{
162162

163163
String attributeDefinitionRef = XmlUtils.firstChildElement(
164164
XmlUtils.firstChildElementByLocalName(attribute, ReqIFConst.DEFINITION)).getTextContent().trim();

src/main/java/de/uni_stuttgart/ils/reqif4j/specification/SpecType.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,10 @@ public SpecType(Node specType, Map<String, Datatype> dataTypes) {
153153
Node specAttributes = XmlUtils.firstChildElementByLocalName(specType, ReqIFConst.SPEC_ATTRIBUTES);
154154
if(specAttributes != null) {
155155

156-
NodeList attributeDefinitions = specAttributes.getChildNodes();
156+
for(Node attributeDefinition: XmlUtils.childElements(specAttributes)) {
157157

158-
for(int specatt = 0; specatt < attributeDefinitions.getLength(); specatt++) {
159-
160-
Node attributeDefinition = attributeDefinitions.item(specatt);
161-
String attDefNodeName = attributeDefinition.getNodeName();
162-
if(!attDefNodeName.equals(ReqIFConst._TEXT)) {
158+
String attDefNodeName = XmlUtils.localName(attributeDefinition);
159+
{
163160

164161
String attDefID = attributeDefinition.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
165162

src/main/java/de/uni_stuttgart/ils/reqif4j/specification/Specification.java

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,13 @@ public Specification(Node specification, SpecType specType, Map<String, SpecObje
158158
this.alternativeID = XmlUtils.alternativeID(specification);
159159
this.type = specType;
160160

161-
if( ((Element)specification).getElementsByTagName(ReqIFConst.VALUES).getLength() > 0
162-
&& ((Element)specification).getElementsByTagName(ReqIFConst.VALUES).item(0).getChildNodes().getLength() > 0 ) {
163-
164-
NodeList attributeValues = ((Element)specification).getElementsByTagName(ReqIFConst.VALUES).item(0).getChildNodes();
165-
for(int attval = 0; attval < attributeValues.getLength(); attval++) {
166-
167-
Node attribute = attributeValues.item(attval);
168-
String attValNodeName = attribute.getNodeName();
169-
if(!attValNodeName.equals(ReqIFConst._TEXT)) {
161+
Element valuesElement = XmlUtils.firstChildElementByLocalName(specification, ReqIFConst.VALUES);
162+
if(valuesElement != null) {
163+
164+
for(Element attribute: XmlUtils.childElements(valuesElement)) {
165+
166+
String attValNodeName = XmlUtils.localName(attribute);
167+
{
170168

171169
String attributeDefinitionRef = XmlUtils.firstChildElement(
172170
XmlUtils.firstChildElementByLocalName(attribute, ReqIFConst.DEFINITION)).getTextContent().trim();
@@ -291,19 +289,14 @@ public Specification(Node specification, SpecType specType, Map<String, SpecObje
291289
}
292290
}
293291

294-
if( ((Element)specification).getElementsByTagName(ReqIFConst.CHILDREN).getLength() > 0
295-
&& ((Element)specification).getElementsByTagName(ReqIFConst.CHILDREN).item(0).getChildNodes().getLength() > 0 ) {
296-
297-
NodeList children = ((Element)specification).getElementsByTagName(ReqIFConst.CHILDREN).item(0).getChildNodes();
298-
for(int child = 0; child < children.getLength(); child++) {
299-
300-
Node specHierarchy = children.item(child);
301-
if(!specHierarchy.getNodeName().equals(ReqIFConst._TEXT)) {
302-
303-
String specHierarchyID = specHierarchy.getAttributes().getNamedItem(ReqIFConst.IDENTIFIER).getTextContent();
304-
305-
this.children.put(specHierarchyID, new SpecHierarchy(1, ++this.sectionCounter, specHierarchy, specObjects));
306-
}
292+
Element childrenElement = XmlUtils.firstChildElementByLocalName(specification, ReqIFConst.CHILDREN);
293+
if(childrenElement != null) {
294+
295+
for(Element specHierarchy: XmlUtils.childElements(childrenElement)) {
296+
297+
String specHierarchyID = XmlUtils.attribute(specHierarchy, ReqIFConst.IDENTIFIER);
298+
299+
this.children.put(specHierarchyID, new SpecHierarchy(1, ++this.sectionCounter, specHierarchy, specObjects));
307300
}
308301
}
309302

0 commit comments

Comments
 (0)