X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fnext%2FXmlWriter.java;h=a5e698e1920ae47e3c8715061478a4835efbec80;hb=cb67d09c40c80d0389d7a0a796a4abf0007f61a6;hp=6e7c9687371e442001752fd3d54de6216d5eb307;hpb=6e40b32ee7b4e65f600f6aeb25838d6d40e76838;p=jsvc.git diff --git a/src/dolda/jsvc/next/XmlWriter.java b/src/dolda/jsvc/next/XmlWriter.java index 6e7c968..a5e698e 100644 --- a/src/dolda/jsvc/next/XmlWriter.java +++ b/src/dolda/jsvc/next/XmlWriter.java @@ -7,7 +7,7 @@ import dolda.jsvc.util.Misc; public class XmlWriter { private Map nsnames = new HashMap(); - private Document doc; + public final Document doc; private int nsser = 1; public XmlWriter(Document doc) { @@ -142,11 +142,11 @@ public class XmlWriter { } if(postbreak(out, el)) - out.indent(indent); + out.write('\n'); } protected void text(ColumnWriter out, String s, int indent) throws IOException { - out.write(s); + out.write(Misc.htmlq(s)); } protected void text(ColumnWriter out, Text txt, int indent) throws IOException { @@ -176,12 +176,16 @@ public class XmlWriter { } } + protected void doctype(ColumnWriter out, DocumentType dt) throws IOException { + out.write(String.format("\n", dt.getName(), dt.getPublicId(), dt.getSystemId())); + } + public void write(Writer out) throws IOException { findallnsnames(); ColumnWriter col = new ColumnWriter(out); DocumentType t = doc.getDoctype(); if(t != null) - out.write(String.format("\n", t.getName(), t.getPublicId(), t.getSystemId())); + doctype(col, t); node(col, doc.getDocumentElement(), 0); } @@ -201,15 +205,4 @@ public class XmlWriter { write(w); w.flush(); } - - public static void main(String[] args) throws Exception { - Html barda = Html.xhtml11("Barda"); - barda.addcss("/slen.css", "Test"); - barda.insert("body", barda.el("h1", barda.text("Mast"))); - barda.finalise(); - XmlWriter w = new XmlWriter(barda.doc); - w.setnsname(Html.ns, null); - w.write(System.out); - System.out.flush(); - } }