1 package dolda.jsvc.next;
6 public class HtmlWriter extends XHtmlWriter {
7 public HtmlWriter(Document doc) {
11 protected boolean asempty(ColumnWriter out, Element el) {
12 if(!super.asempty(out, el))
14 String n = el.getTagName();
15 if(n.equals("br") || n.equals("hr") || n.equals("img") ||
21 protected void attribute(ColumnWriter out, Attr attr, int indent) throws IOException {
22 if(attr.getNamespaceURI() != null)
23 throw(new RuntimeException("HTML does not support non-null-NS attributes (" + attr.getNamespaceURI() + " encountered)"));
24 super.attribute(out, attr, indent);
27 protected void element(ColumnWriter out, Element el, int indent) throws IOException {
28 if(!el.getNamespaceURI().equals(Html.ns))
29 throw(new RuntimeException("HTML does not support non-HTML elements (namespace " + el.getNamespaceURI() + " encountered)"));
30 super.element(out, el, indent);
33 public void write(Writer out) throws IOException {
34 DocumentType dt = doc.getDoctype();
36 throw(new RuntimeException("Writing HTML requires an HTML document"));
37 if(!dt.getName().equals("html"))
38 throw(new RuntimeException("Writing HTML requires an HTML document, not `" + dt.getName() + "'"));
39 String pubid = dt.getPublicId();
40 if(pubid.equals("-//W3C//DTD XHTML 1.1//EN")) {
42 throw(new RuntimeException("Unimplemented HTML doctype `" + pubid));