From db0a709f2743d9502fb601bed4a1f115d3856c61 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sun, 28 Aug 2011 15:55:47 +0200 Subject: Prepare for weblog selection (and mess everything up). --- org/madore/damlengine/DamlEngine.java | 39 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'org/madore/damlengine/DamlEngine.java') diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index 0837bd3..f055de1 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -1,5 +1,6 @@ package org.madore.damlengine; +import java.io.OutputStream; import java.io.OutputStreamWriter; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; @@ -55,14 +56,21 @@ public final class DamlEngine { } } - public static void processDocument(Document doc) { + public static void processDocument(Document doc, + Context.WeblogSelectionContext wsc) { TodoDeque todoDeque = new TodoDeque(); Context ctx = new Context(doc); + ctx.wsc = wsc; todoDeque.registerAtEnd(new RootTodo(ctx)); todoDeque.dispatchLoop(); } - public static void main(String[] args) + public static void processDocument(Document doc) { + processDocument(doc, null); + } + + public static void fullProcess(String fname, OutputStream out, + Context.WeblogSelectionContext wsc) throws Exception { final Resolver resolver = new Resolver(); @@ -72,19 +80,30 @@ public final class DamlEngine { final DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(resolver); + Document doc = db.parse(fname); + processDocument(doc, wsc); + doc.normalizeDocument(); + Unparser unparser + = new Unparser(doc, new OutputStreamWriter(out, "UTF-8"), + "html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\""); + unparser.unparse(); + + } + + public static void fullProcess(String fname, OutputStream out) + throws Exception { + fullProcess(fname, out, null); + } + + public static void main(String[] args) + throws Exception { + if ( args.length == 0 ) { System.err.println("expecting filename as argument"); } for (String fname : args) { - Document doc = db.parse(fname); - processDocument(doc); - doc.normalizeDocument(); - Unparser unparser - = new Unparser(doc, new OutputStreamWriter(System.out, - "UTF-8"), - "html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\""); - unparser.unparse(); + fullProcess (fname, System.out); } } -- cgit v1.2.3