From a9d7361ee110a79e29d849a4c7876a2738c509fe Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sun, 10 Oct 2010 23:20:14 +0200 Subject: Allow doctype overriding in unparser. --- org/madore/damlengine/Unparser.java | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'org/madore/damlengine/Unparser.java') 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(""); - 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("\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("\n"); + } else + out.write("\n"); + } else { + out.write("\n"); + } cursor = doc.getDocumentElement(); dir = Dir.PUSHING; while ( cursor != null ) { -- cgit v1.2.3