package org.madore.damlengine; import java.util.LinkedList; import java.util.HashMap; import java.io.OutputStreamWriter; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; public final class DamlEngine { public static final String DAML_NS = "http://www.madore.org/~david/NS/daml/"; static Document doc; private DamlEngine() { } // Forbid instantiation public static void processDocument() { TodoDeque todoDeque = new TodoDeque(); HashMap options = new HashMap(); options.put("isRoot", true); todoDeque.registerAtEnd(TodoElement.getTodoElement(doc.getDocumentElement(), new HashMap(), options)); todoDeque.dispatchLoop(); } public static void main(String[] args) 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((EntityResolver)resolver); if ( args.length == 0 ) { System.err.println("expecting filename as argument"); } for (String fname : args) { doc = db.parse(fname); processDocument(); doc.normalizeDocument(); Unparser unparser = new Unparser(doc, new OutputStreamWriter(System.out)); unparser.unparse(); } } }