Changed to DTD to make all 3 top elements optional, and also to allow for empty templates.
ConfigParser now uses the internal j8583.dtd if available in the classpath. git-svn-id: https://j8583.svn.sourceforge.net/svnroot/j8583/j8583@95 db60a039-f72e-0410-b1d2-baa000846441
This commit is contained in:
@@ -32,6 +32,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.solab.iso8583.CustomField;
|
||||
@@ -97,6 +99,21 @@ public class ConfigParser {
|
||||
Document doc = null;
|
||||
try {
|
||||
docb = docfact.newDocumentBuilder();
|
||||
docb.setEntityResolver(new EntityResolver() {
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicId, String systemId)
|
||||
throws SAXException, IOException {
|
||||
if (systemId.indexOf("j8583.dtd") >= 0) {
|
||||
URL dtd = getClass().getResource("j8583.dtd");
|
||||
if (dtd == null) {
|
||||
log.warn("Cannot find j8583.dtd in classpath. j8583 config files will not be validated.");
|
||||
} else {
|
||||
return new InputSource(dtd.toString());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
doc = docb.parse(stream);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
log.error("ISO8583 Cannot parse XML configuration", ex);
|
||||
|
||||
Reference in New Issue
Block a user