Skip to content

Commit 219df8b

Browse files
vstangephysikerwelt
authored andcommitted
Second list of changes from the code review
1 parent be4b0f9 commit 219df8b

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/main/java/com/formulasearchengine/mathmlquerygenerator/BasicXQueryGenerator.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ private String generateSimpleConstraints(Node node, boolean isRoot) {
7474
//If an element node and not an attribute or text node, add to xquery and increment index
7575
childElementIndex++;
7676

77-
// We only want to consider elements below the content mathml semantics, a deeper annotation-node will be ignored
78-
boolean notAnnotationNode = child.getLocalName() == null || !XMLHelper.ANNOTATION_XML_PATTERN.matcher(child.getLocalName()).matches();
79-
if (notAnnotationNode) {
80-
if (handleSpecialElements(child, childElementIndex)) {
81-
// this was a special element and was handled otherwise (e.g. qvar)
82-
continue;
83-
}
77+
boolean wasSpecialElement = handleSpecialElements(child, childElementIndex);
78+
if (wasSpecialElement) {
79+
continue; // this was a special element and was handled otherwise (e.g. qvar)
80+
}
8481

82+
// We only want to consider elements below the content mathml semantics,
83+
// a deeper lying annotation-node should be ignored
84+
boolean annotationNode = child.getLocalName() != null
85+
&& XMLHelper.ANNOTATION_XML_PATTERN.matcher(child.getLocalName()).matches();
86+
if (!annotationNode) {
8587
if (queryHasText) {
8688
//Add another condition on top of existing condition in query
8789
out.append(" and ");

src/main/java/com/formulasearchengine/mathmltools/mml/CMMLInfo.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ private void abstractNodeCD(Node node) {
101101
String cd;
102102
try {
103103
cd = node.getAttributes().getNamedItem("cd").getNodeValue();
104-
} catch (final DOMException | NullPointerException e) {
105-
LOG.error("attribute not accessible or not found", e);
104+
} catch (final DOMException e) {
105+
LOG.warn("attribute not accessible or not found", e);
106106
//TODO: Implement CD fallback
107107
cd = "";
108+
} catch (final NullPointerException e) {
109+
cd = "";
108110
}
109111
if (cd != null && cd.isEmpty()) {
110112
return;

0 commit comments

Comments
 (0)