diff options
author | David A. Madore <david+git@madore.org> | 2011-08-28 15:55:47 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2011-08-28 15:55:47 +0200 |
commit | db0a709f2743d9502fb601bed4a1f115d3856c61 (patch) | |
tree | d93bc9df7227cedc91e08b46245a0031bba3a429 /org/madore/damlengine/DamlEngine.java | |
parent | 0003925549ea009bb0a99c225b5d1992ccd8e7af (diff) | |
download | damlengine-db0a709f2743d9502fb601bed4a1f115d3856c61.tar.gz damlengine-db0a709f2743d9502fb601bed4a1f115d3856c61.tar.bz2 damlengine-db0a709f2743d9502fb601bed4a1f115d3856c61.zip |
Prepare for weblog selection (and mess everything up).
Diffstat (limited to 'org/madore/damlengine/DamlEngine.java')
-rw-r--r-- | org/madore/damlengine/DamlEngine.java | 39 |
1 files changed, 29 insertions, 10 deletions
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); } } |