summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-04-11 08:53:49 +0200
committerDavid A. Madore <david+git@madore.org>2010-04-11 08:53:49 +0200
commit06164d04b12fcb561f1f893c837ebfa9c5825d98 (patch)
treed83311a6901a1e6c6de6b89a1a0b2f3ba47a215e
parent130ceae3c6b30283a63f157ea5010a78e63142ab (diff)
downloaddamlengine-06164d04b12fcb561f1f893c837ebfa9c5825d98.tar.gz
damlengine-06164d04b12fcb561f1f893c837ebfa9c5825d98.tar.bz2
damlengine-06164d04b12fcb561f1f893c837ebfa9c5825d98.zip
Another attempt at output formatting, this time with serializers. Still sucks.
-rw-r--r--org/madore/damlengine/DamlEngine.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java
index 696f509..80b1f2d 100644
--- a/org/madore/damlengine/DamlEngine.java
+++ b/org/madore/damlengine/DamlEngine.java
@@ -2,17 +2,15 @@ package org.madore.damlengine;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
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;
@@ -29,6 +27,7 @@ public final class DamlEngine {
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();
@@ -36,13 +35,6 @@ public final class DamlEngine {
dbf.setValidating(false);
final DocumentBuilder db = dbf.newDocumentBuilder();
db.setEntityResolver((EntityResolver)resolver);
- final TransformerFactory tf = TransformerFactory.newInstance();
- final Transformer t = tf.newTransformer();
- t.setOutputProperty(OutputKeys.METHOD, "xml");
- t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC,
- "-//W3C//DTD XHTML 1.0 Strict//EN");
- t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
if ( args.length == 0 ) {
System.err.println("expecting filename as argument");
@@ -51,7 +43,10 @@ public final class DamlEngine {
for (String fname : args) {
doc = db.parse(fname);
processDocument();
- t.transform(new DOMSource(doc), new StreamResult(System.out));
+ OutputFormat format = new OutputFormat(doc);
+ XHTMLSerializer serializer = new XHTMLSerializer(format);
+ serializer.setOutputByteStream(System.out);
+ serializer.serialize(doc);
}
}