From 3b1023c45a919f25ef38c080f2ac2c0dc5d5e7ca Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sun, 28 Aug 2011 19:52:02 +0200 Subject: (Preliminary) handling of weblog entry selection and summary. --- org/madore/damlengine/DamlEngine.java | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'org/madore/damlengine/DamlEngine.java') diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index bf2049d..da49aeb 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -6,6 +6,7 @@ import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; // import org.xml.sax.EntityResolver; import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; @@ -40,6 +41,22 @@ public final class DamlEngine { } } + public static final class GetDocumentBuilder { + static final DocumentBuilder db; + static { + final Resolver resolver = new Resolver(); + final DocumentBuilderFactory dbf = new DocumentBuilderFactoryImpl(); + dbf.setNamespaceAware(true); + dbf.setValidating(false); + try { + db = dbf.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + db.setEntityResolver(resolver); + } + } + private DamlEngine() { // Forbid instantiation throw new AssertionError("DamlEngine cannot be instantiated"); } @@ -73,12 +90,7 @@ public final class DamlEngine { Context.WeblogSelectionContext wsc) throws Exception { - final Resolver resolver = new Resolver(); - final DocumentBuilderFactory dbf = new DocumentBuilderFactoryImpl(); - dbf.setNamespaceAware(true); - dbf.setValidating(false); - final DocumentBuilder db = dbf.newDocumentBuilder(); - db.setEntityResolver(resolver); + final DocumentBuilder db = GetDocumentBuilder.db; Document doc = db.parse(fname); processDocument(doc, wsc); -- cgit v1.2.3