summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org/madore/damlengine/DamlEngine.java3
-rw-r--r--org/madore/damlengine/Unparser.java32
2 files changed, 21 insertions, 14 deletions
diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java
index 2cde6ec..c146587 100644
--- a/org/madore/damlengine/DamlEngine.java
+++ b/org/madore/damlengine/DamlEngine.java
@@ -56,7 +56,8 @@ public final class DamlEngine {
doc.normalizeDocument();
Unparser unparser
= new Unparser(doc, new OutputStreamWriter(System.out,
- "UTF-8"));
+ "UTF-8"),
+ "html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"");
unparser.unparse();
}
diff --git a/org/madore/damlengine/Unparser.java b/org/madore/damlengine/Unparser.java
index 82ff9e1..0eeec00 100644
--- a/org/madore/damlengine/Unparser.java
+++ b/org/madore/damlengine/Unparser.java
@@ -11,10 +11,12 @@ public final class Unparser {
private enum Dir { PUSHING, POPPING }
private Dir dir;
private final Writer out;
+ private final String forceDoctype;
- public Unparser(Document doc, Writer out) {
+ public Unparser(Document doc, Writer out, String forceDoctype) {
this.doc = doc;
this.out = out;
+ this.forceDoctype = forceDoctype;
}
protected void enter() {
@@ -126,18 +128,22 @@ public final class Unparser {
public void unparse()
throws IOException {
out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
- DocumentType doctype = doc.getDoctype();
- if ( doctype != null ) {
- String externalId = "";
- if ( doctype.getPublicId() != null ) {
- externalId = " PUBLIC \""+doctype.getPublicId()+"\" \""
- +doctype.getSystemId()+"\"";
- } else if ( doctype.getSystemId() != null ) {
- externalId = " SYSTEM \""+doctype.getSystemId()+"\"";
- }
- out.write("<!DOCTYPE "+doctype.getName()+externalId+">\n");
- } else
- out.write("\n");
+ if ( forceDoctype == null ) {
+ DocumentType doctype = doc.getDoctype();
+ if ( doctype != null ) {
+ String externalId = "";
+ if ( doctype.getPublicId() != null ) {
+ externalId = " PUBLIC \""+doctype.getPublicId()+"\" \""
+ +doctype.getSystemId()+"\"";
+ } else if ( doctype.getSystemId() != null ) {
+ externalId = " SYSTEM \""+doctype.getSystemId()+"\"";
+ }
+ out.write("<!DOCTYPE "+doctype.getName()+externalId+">\n");
+ } else
+ out.write("\n");
+ } else {
+ out.write("<!DOCTYPE "+forceDoctype+">\n");
+ }
cursor = doc.getDocumentElement();
dir = Dir.PUSHING;
while ( cursor != null ) {