diff options
Diffstat (limited to 'org/madore/damlengine/DamlEngine.java')
-rw-r--r-- | org/madore/damlengine/DamlEngine.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java new file mode 100644 index 0000000..8571319 --- /dev/null +++ b/org/madore/damlengine/DamlEngine.java @@ -0,0 +1,53 @@ +package org.madore.damlengine; + +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSParser; +import org.w3c.dom.ls.LSSerializer; +import org.w3c.dom.ls.LSInput; +import org.w3c.dom.ls.LSOutput; +import org.w3c.dom.Document; +import org.apache.xerces.dom.DOMImplementationSourceImpl; + +public final class DamlEngine { + + private static Document doc; + + private DamlEngine() { } // Forbid instantiation + + public static void processDocument() { + // ... + } + + public static void main(String[] args) { + + final Resolver resolver = new Resolver(); + final DOMImplementationSourceImpl source + = new DOMImplementationSourceImpl(); + final DOMImplementation impl + = source.getDOMImplementation("XML 3.0 Core 3.0 LS 3.0"); + final DOMImplementationLS implLS = (DOMImplementationLS)impl; + final LSParser parser + = implLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, + null); + parser.getDomConfig().setParameter("resource-resolver", resolver); + final LSSerializer writer = implLS.createLSSerializer(); + + if ( args.length == 0 ) { + System.err.println("expecting filename as argument"); + } + + for (String fname : args) { + final LSInput in = implLS.createLSInput(); + in.setSystemId(fname); + doc = parser.parse(in); + processDocument(); + final LSOutput out = implLS.createLSOutput(); + out.setByteStream(System.out); + writer.write(doc, out); + System.out.println(""); + } + + } + +} |