Skip to content

Commit 53d93b5

Browse files
committed
Transition to central XMLHelper in MMLQueryGenerator
* Moved XMLHelper and NonwhitespaceNodeList to inside the mathmlquerygenerator package to clarify dependency on mathmlquerygenerator. * Resolves physikerwelt#15
1 parent 6547032 commit 53d93b5

11 files changed

Lines changed: 616 additions & 133 deletions

File tree

mathmlquerygenerator.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</content>
1212
<orderEntry type="inheritedJdk" />
1313
<orderEntry type="sourceFolder" forTests="false" />
14+
<orderEntry type="library" name="Maven: net.sf.saxon:Saxon-HE:9.5.1-6" level="project" />
1415
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
1516
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
1617
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
</distributionManagement>
4747

4848
<dependencies>
49+
<dependency>
50+
<groupId>net.sf.saxon</groupId>
51+
<artifactId>Saxon-HE</artifactId>
52+
<version>9.5.1-6</version>
53+
</dependency>
4954
<dependency>
5055
<groupId>junit</groupId>
5156
<artifactId>junit</artifactId>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.formulasearchengine.mathmlquerygenerator;
22

3-
import com.formulasearchengine.xmlhelper.DomDocumentHelper;
4-
import com.formulasearchengine.xmlhelper.NonWhitespaceNodeList;
3+
import com.formulasearchengine.mathmlquerygenerator.xmlhelper.XMLHelper;
4+
import com.formulasearchengine.mathmlquerygenerator.xmlhelper.NonWhitespaceNodeList;
55
import org.w3c.dom.Document;
66
import org.w3c.dom.Node;
77
import org.w3c.dom.NodeList;
@@ -15,7 +15,7 @@
1515
import java.util.ArrayList;
1616
import java.util.List;
1717

18-
import static com.formulasearchengine.xmlhelper.NonWhitespaceNodeList.getFirstChild;
18+
import static com.formulasearchengine.mathmlquerygenerator.xmlhelper.NonWhitespaceNodeList.getFirstChild;
1919

2020
/**
2121
* Created by Moritz on 08.11.2014.
@@ -35,7 +35,7 @@ public NtcirTopicReader( Document topics ) {
3535
}
3636

3737
public NtcirTopicReader( File topicFile ) throws ParserConfigurationException, IOException, SAXException {
38-
DocumentBuilder documentBuilder = DomDocumentHelper.getDocumentBuilderFactory().newDocumentBuilder();
38+
DocumentBuilder documentBuilder = XMLHelper.getDocumentBuilder( true );
3939
topics = documentBuilder.parse( topicFile );
4040

4141
//TODO: Find out how this code duplication can be avoided in Java.
@@ -75,7 +75,7 @@ public final NtcirTopicReader setAddQvarMap( boolean addQvarMap ) {
7575
* @throws XPathExpressionException Thrown if xpaths fail to compile or fail to evaluate
7676
+ */
7777
public final List<NtcirPattern> extractPatterns() throws XPathExpressionException {
78-
final XPath xpath = DomDocumentHelper.namespaceAwareXpath( "t", NS_NII );
78+
final XPath xpath = XMLHelper.namespaceAwareXpath( "t", NS_NII );
7979
final XPathExpression xNum = xpath.compile( "./t:num" );
8080
final XPathExpression xFormula = xpath.compile( "./t:query/t:formula" );
8181
final NonWhitespaceNodeList topicList = new NonWhitespaceNodeList(

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.formulasearchengine.mathmlquerygenerator;
22

33

4-
import com.formulasearchengine.xmlhelper.DomDocumentHelper;
5-
import com.formulasearchengine.xmlhelper.NonWhitespaceNodeList;
4+
import com.formulasearchengine.mathmlquerygenerator.xmlhelper.XMLHelper;
5+
import com.formulasearchengine.mathmlquerygenerator.xmlhelper.NonWhitespaceNodeList;
66
import com.google.common.collect.Lists;
77
import org.w3c.dom.Document;
88
import org.w3c.dom.Node;
@@ -14,7 +14,7 @@
1414
import java.util.*;
1515
import java.util.regex.Pattern;
1616

17-
import static com.formulasearchengine.xmlhelper.NonWhitespaceNodeList.getFirstChild;
17+
import static com.formulasearchengine.mathmlquerygenerator.xmlhelper.NonWhitespaceNodeList.getFirstChild;
1818

1919
/**
2020
* Converts MathML queries into XQueries.
@@ -48,7 +48,7 @@ public class XQueryGenerator {
4848
*/
4949
public XQueryGenerator( String input )
5050
throws IOException, SAXException, ParserConfigurationException {
51-
final Document xml = DomDocumentHelper.String2Doc( input );
51+
final Document xml = XMLHelper.String2Doc( input, true );
5252
this.mainElement = getMainElement( xml );
5353
}
5454

src/main/java/com/formulasearchengine/xmlhelper/NonWhitespaceNodeList.java renamed to src/main/java/com/formulasearchengine/mathmlquerygenerator/xmlhelper/NonWhitespaceNodeList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.formulasearchengine.xmlhelper;
1+
package com.formulasearchengine.mathmlquerygenerator.xmlhelper;
22

33
import org.w3c.dom.Node;
44
import org.w3c.dom.NodeList;

0 commit comments

Comments
 (0)