Skip to content

Commit

Permalink
Refactor XML navigation
Browse files Browse the repository at this point in the history
Signed-off-by: Jarno Elovirta <jarno@elovirta.com>
  • Loading branch information
jelovirt committed Oct 6, 2023
1 parent efad05c commit 94bb36a
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/main/java/org/dita/dost/reader/SubjectSchemeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,15 @@ public void loadSubjectScheme(final File scheme) {
}

public void loadSubjectScheme(final Element schemeRoot) {
final List<Element> rootChildren = XMLUtils.getChildElements(schemeRoot);
for (Element child : rootChildren) {
final String attrValue = child.getAttribute(ATTRIBUTE_NAME_CLASS);
if (SUBJECTSCHEME_ENUMERATIONDEF.matches(attrValue)) {
processEnumerationDef(schemeRoot, child);
}
for (Element child : XMLUtils.getChildElements(schemeRoot, SUBJECTSCHEME_ENUMERATIONDEF)) {
processEnumerationDef(schemeRoot, child);
}
}

public void processEnumerationDef(final Element schemeRoot, final Element enumerationDef) {
final List<Element> enumChildren = XMLUtils.getChildElements(enumerationDef);
String elementName = "*";
QName attributeName = null;
for (Element child : enumChildren) {
for (Element child : XMLUtils.getChildElements(enumerationDef)) {
final String attrValue = child.getAttribute(ATTRIBUTE_NAME_CLASS);
if (SUBJECTSCHEME_ELEMENTDEF.matches(attrValue)) {
elementName = child.getAttribute(ATTRIBUTE_NAME_NAME);
Expand Down Expand Up @@ -303,11 +298,8 @@ private void putValuePairsIntoMap(

while (!queue.isEmpty()) {
final Element node = queue.poll();
final NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element) children.item(i));
}
for (Element childElement : XMLUtils.getChildElements(node)) {
queue.offer(childElement);
}
if (SUBJECTSCHEME_SUBJECTDEF.matches(node)) {
final String key = node.getAttribute(ATTRIBUTE_NAME_KEYS);
Expand Down

0 comments on commit 94bb36a

Please sign in to comment.