diff --git a/pom.xml b/pom.xml
index fa41515..7a0ad26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,12 @@
1.2.3
test
+
+ com.fasterxml.woodstox
+ woodstox-core
+ 6.5.1
+ test
+
diff --git a/resources/metadataWithDtd.ods b/resources/metadataWithDtd.ods
new file mode 100644
index 0000000..edfe5a3
Binary files /dev/null and b/resources/metadataWithDtd.ods differ
diff --git a/src/com/github/miachm/sods/XmlReaderEventImpl.java b/src/com/github/miachm/sods/XmlReaderEventImpl.java
index b40757b..16a8eb6 100644
--- a/src/com/github/miachm/sods/XmlReaderEventImpl.java
+++ b/src/com/github/miachm/sods/XmlReaderEventImpl.java
@@ -13,6 +13,10 @@ class XmlReaderEventImpl implements XmlReader {
@Override
public XmlReaderInstanceEventImpl load(InputStream in) throws IOException {
try {
+ // #77 Make the ODS files with DTD work on the JBoss-bundled Woodstox,
+ // or ensure they work on another StAX implementation set to validate by default.
+ inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+
reader = inputFactory.createXMLStreamReader(in);
// Skip start of document
try {
diff --git a/tests/com/github/miachm/sods/XMLInputFactoriesTest.java b/tests/com/github/miachm/sods/XMLInputFactoriesTest.java
new file mode 100644
index 0000000..4dc4a5a
--- /dev/null
+++ b/tests/com/github/miachm/sods/XMLInputFactoriesTest.java
@@ -0,0 +1,44 @@
+package com.github.miachm.sods;
+
+import org.testng.SkipException;
+import org.testng.annotations.Test;
+
+import javax.xml.stream.XMLInputFactory;
+import java.io.File;
+
+import static org.testng.AssertJUnit.*;
+
+public class XMLInputFactoriesTest {
+
+ // Disable this test by default, because XmlReaderEventImpl stores a static XMLInputFactory
+ // instance, which is not reset after the test.
+ @Test(enabled = false)
+ public void testLoadUsingBundledXMLInputFactory() throws Exception {
+ testUsingFactory("com.sun.xml.internal.stream.XMLInputFactoryImpl");
+ }
+
+ @Test
+ public void testLoadUsingWoodstoxXMLInputFactory() throws Exception {
+ testUsingFactory("com.ctc.wstx.stax.WstxInputFactory");
+ }
+
+ private void testUsingFactory(String factoryName) throws Exception {
+ // Skip test if factory is not available
+ try {
+ Class.forName(factoryName);
+ } catch (ClassNotFoundException e) {
+ throw new SkipException(factoryName + " not found, ignore this test.");
+ }
+
+ try {
+ System.setProperty(XMLInputFactory.class.getName(), factoryName);
+
+ SpreadSheet spread = new SpreadSheet(new File("resources/metadataWithDtd.ods"));
+ assertEquals(spread.getNumSheets(),1);
+
+ } finally {
+ System.clearProperty(XMLInputFactory.class.getName());
+ }
+ }
+
+}