package org.madore.damlengine; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.apache.xerces.dom.DOMImplementationSourceImpl; import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; import org.apache.xml.serialize.XHTMLSerializer; import org.apache.xml.serialize.OutputFormat; @SuppressWarnings("deprecation") public final class DamlEngine { private static Document doc; private DamlEngine() { } // Forbid instantiation public static void processDocument() { // ... } public static void main(String[] args) throws Exception { final Resolver resolver = new Resolver(); final DOMImplementationSourceImpl source = new DOMImplementationSourceImpl(); @SuppressWarnings("unused") final DOMImplementation impl = source.getDOMImplementation("XML 3.0 Core 3.0 LS 3.0"); 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(); OutputFormat format = new OutputFormat(doc); XHTMLSerializer serializer = new XHTMLSerializer(format); serializer.setOutputByteStream(System.out); serializer.serialize(doc); } } }