Use SAXParserFactory to support XInclude.
diff --git a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/DispatchDriver.java b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/DispatchDriver.java
index 1ce5a10..feb340a 100644
--- a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/DispatchDriver.java
+++ b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/DispatchDriver.java
@@ -18,6 +18,8 @@
import java.io.UnsupportedEncodingException;
import java.util.Locale;
+import javax.xml.parsers.SAXParser;
+
import org.eclipse.actf.ai.xmlstore.nvdl.dispatcher.NVDLSAXDispatcher;
import org.eclipse.actf.ai.xmlstore.nvdl.model.Location;
import org.eclipse.actf.ai.xmlstore.nvdl.model.NVDLAction;
@@ -32,14 +34,13 @@
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
/**
* The <code>DispatchDriver</code> is a driver for validation.
*/
public class DispatchDriver implements NVDLSAXDispatcher.DebugHandlerFactory {
- private XMLReader reader;
+ private SAXParser parser;
private NVDLSAXReader nvdlReader;
private ErrorHandler eh;
private String targetDirectory;
@@ -105,9 +106,9 @@
}
private void setupReader() throws Exception {
- reader = NVDLSAXReader.newXMLReader();
- reader.setErrorHandler(eh);
- nvdlReader = new NVDLSAXReader(reader, eh);
+ parser = NVDLSAXReader.newSAXParser();
+ parser.getXMLReader().setErrorHandler(eh);
+ nvdlReader = new NVDLSAXReader(parser, eh);
}
void dispatch(String nvdlFile, String instanceFilename, String targetDirectory)
diff --git a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ReconstructionDriver.java b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ReconstructionDriver.java
index 1a0f54f..372dd22 100644
--- a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ReconstructionDriver.java
+++ b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ReconstructionDriver.java
@@ -17,6 +17,8 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
+import javax.xml.parsers.SAXParser;
+
import org.eclipse.actf.ai.xmlstore.nvdl.model.NVDLRules;
import org.eclipse.actf.ai.xmlstore.nvdl.reader.NVDLSAXReader;
import org.eclipse.actf.ai.xmlstore.nvdl.rec.SAXReconstructor;
@@ -34,7 +36,7 @@
* The <code>ReconstructionDriver</code> is a driver for reconstruction.
*/
public class ReconstructionDriver {
- private XMLReader reader;
+ private SAXParser parser;
private NVDLSAXReader nvdlReader;
private ErrorHandler eh;
// private boolean debug;
@@ -103,9 +105,9 @@
}
private void setupReader() throws Exception {
- reader = NVDLSAXReader.newXMLReader();
- reader.setErrorHandler(eh);
- nvdlReader = new NVDLSAXReader(reader, eh);
+ parser = NVDLSAXReader.newSAXParser();
+ parser.getXMLReader().setErrorHandler(eh);
+ nvdlReader = new NVDLSAXReader(parser, eh);
}
ReconstructionDriver(ErrorHandler eh,
diff --git a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/TestDriver.java b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/TestDriver.java
index 3ae02d0..e2d3bd4 100644
--- a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/TestDriver.java
+++ b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/TestDriver.java
@@ -14,13 +14,9 @@
import java.io.File;
import java.io.FilenameFilter;
+import javax.xml.parsers.SAXParser;
import javax.xml.validation.ValidatorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
import org.eclipse.actf.ai.xmlstore.nvdl.NVDLException;
import org.eclipse.actf.ai.xmlstore.nvdl.dispatcher.NVDLSAXDispatcher;
import org.eclipse.actf.ai.xmlstore.nvdl.model.NVDLRules;
@@ -28,15 +24,19 @@
import org.eclipse.actf.ai.xmlstore.nvdl.util.DefaultErrorHandler;
import org.eclipse.actf.ai.xmlstore.nvdl.util.IRIUtil;
import org.eclipse.actf.ai.xmlstore.nvdl.util.Log;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
public class TestDriver {
- XMLReader xmlReader;
+ SAXParser parser;
NVDLSAXReader r;
TestDriver() throws SAXException {
- this.xmlReader = NVDLSAXReader.newXMLReader();
- xmlReader.setErrorHandler(DefaultErrorHandler.getErrorHandler());
- this.r = new NVDLSAXReader(xmlReader);
+ this.parser = NVDLSAXReader.newSAXParser();
+ parser.getXMLReader().setErrorHandler(DefaultErrorHandler.getErrorHandler());
+ this.r = new NVDLSAXReader(parser);
}
static public class TestSet {
diff --git a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ValidationDriver.java b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ValidationDriver.java
index ea0c694..778ea21 100644
--- a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ValidationDriver.java
+++ b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/driver/ValidationDriver.java
@@ -13,6 +13,8 @@
import java.util.Locale;
+import javax.xml.parsers.SAXParser;
+
import org.eclipse.actf.ai.xmlstore.nvdl.dispatcher.NVDLSAXDispatcher;
import org.eclipse.actf.ai.xmlstore.nvdl.model.Location;
import org.eclipse.actf.ai.xmlstore.nvdl.model.NVDLAction;
@@ -26,14 +28,13 @@
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
-import org.xml.sax.XMLReader;
/**
* The <code>ValidationDriver</code> is a driver for validation.
*/
public class ValidationDriver implements NVDLSAXDispatcher.DebugHandlerFactory {
- private XMLReader reader;
+ private SAXParser parser;
private NVDLSAXReader nvdlReader;
private ErrorHandler eh;
private boolean debug;
@@ -62,9 +63,9 @@
}
private void setupReader() throws Exception {
- reader = NVDLSAXReader.newXMLReader();
- reader.setErrorHandler(eh);
- nvdlReader = new NVDLSAXReader(reader, eh);
+ parser = NVDLSAXReader.newSAXParser();
+ parser.getXMLReader().setErrorHandler(eh);
+ nvdlReader = new NVDLSAXReader(parser, eh);
}
void validate(String nvdlFile, String instanceFile)
diff --git a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/reader/NVDLSAXReader.java b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/reader/NVDLSAXReader.java
index 32d5a84..bf2addd 100644
--- a/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/reader/NVDLSAXReader.java
+++ b/plugins/org.eclipse.actf.ai.xmlstore/src/org/eclipse/actf/ai/xmlstore/nvdl/reader/NVDLSAXReader.java
@@ -13,6 +13,9 @@
import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
import javax.xml.validation.SchemaFactory;
import org.eclipse.actf.ai.xmlstore.nvdl.NVDLException;
@@ -37,10 +40,11 @@
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.helpers.XMLReaderFactory;
/**
@@ -1138,19 +1142,29 @@
return rules;
}
- public static XMLReader newXMLReader() throws SAXException {
- XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setFeature("http://xml.org/sax/features/namespaces", true);
- reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
- return reader;
+ public static SAXParser newSAXParser() throws SAXException {
+ SAXParserFactory pf = SAXParserFactory.newInstance();
+ try {
+ pf.setFeature("http://xml.org/sax/features/namespaces", true);
+ pf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+ pf.setXIncludeAware(true);
+ return pf.newSAXParser();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ return null;
+ }
}
- public NVDLSAXReader(XMLReader reader) {
- this(reader, null);
+ public NVDLSAXReader(SAXParser parser) throws SAXException {
+ this(parser, null);
+ }
+
+ public NVDLSAXReader(ErrorHandler eh) throws SAXException {
+ this(newSAXParser(), eh);
}
- public NVDLSAXReader(XMLReader reader, ErrorHandler eh) {
- this.reader = reader;
+ public NVDLSAXReader(SAXParser parser, ErrorHandler eh) throws SAXException {
+ this.reader = parser.getXMLReader();
if (eh != null) {
this.eh = eh;
} else {