From 219df8b2c47cd61c3dbb8b59e8cc92324f00db57 Mon Sep 17 00:00:00 2001 From: Vincent Stange Date: Fri, 7 Jul 2017 13:37:26 +0900 Subject: [PATCH] Second list of changes from the code review --- .../BasicXQueryGenerator.java | 16 +++++++++------- .../mathmltools/mml/CMMLInfo.java | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/formulasearchengine/mathmlquerygenerator/BasicXQueryGenerator.java b/src/main/java/com/formulasearchengine/mathmlquerygenerator/BasicXQueryGenerator.java index f78e50b..84f4d7e 100644 --- a/src/main/java/com/formulasearchengine/mathmlquerygenerator/BasicXQueryGenerator.java +++ b/src/main/java/com/formulasearchengine/mathmlquerygenerator/BasicXQueryGenerator.java @@ -74,14 +74,16 @@ private String generateSimpleConstraints(Node node, boolean isRoot) { //If an element node and not an attribute or text node, add to xquery and increment index childElementIndex++; - // We only want to consider elements below the content mathml semantics, a deeper annotation-node will be ignored - boolean notAnnotationNode = child.getLocalName() == null || !XMLHelper.ANNOTATION_XML_PATTERN.matcher(child.getLocalName()).matches(); - if (notAnnotationNode) { - if (handleSpecialElements(child, childElementIndex)) { - // this was a special element and was handled otherwise (e.g. qvar) - continue; - } + boolean wasSpecialElement = handleSpecialElements(child, childElementIndex); + if (wasSpecialElement) { + continue; // this was a special element and was handled otherwise (e.g. qvar) + } + // We only want to consider elements below the content mathml semantics, + // a deeper lying annotation-node should be ignored + boolean annotationNode = child.getLocalName() != null + && XMLHelper.ANNOTATION_XML_PATTERN.matcher(child.getLocalName()).matches(); + if (!annotationNode) { if (queryHasText) { //Add another condition on top of existing condition in query out.append(" and "); diff --git a/src/main/java/com/formulasearchengine/mathmltools/mml/CMMLInfo.java b/src/main/java/com/formulasearchengine/mathmltools/mml/CMMLInfo.java index 2730f07..abdd37f 100644 --- a/src/main/java/com/formulasearchengine/mathmltools/mml/CMMLInfo.java +++ b/src/main/java/com/formulasearchengine/mathmltools/mml/CMMLInfo.java @@ -101,10 +101,12 @@ private void abstractNodeCD(Node node) { String cd; try { cd = node.getAttributes().getNamedItem("cd").getNodeValue(); - } catch (final DOMException | NullPointerException e) { - LOG.error("attribute not accessible or not found", e); + } catch (final DOMException e) { + LOG.warn("attribute not accessible or not found", e); //TODO: Implement CD fallback cd = ""; + } catch (final NullPointerException e) { + cd = ""; } if (cd != null && cd.isEmpty()) { return;