1 package dolda.jsvc.next;
6 public class IndentWriter extends XmlWriter {
7 public int collimit = 80;
9 public IndentWriter(Document doc) {
13 private static boolean onlytext(Element el) {
14 for(Node n = el.getFirstChild(); n != null; n = n.getNextSibling()) {
15 if(!(n instanceof Text))
21 protected boolean prebreak(ColumnWriter out, Element el) {
22 if(el.getFirstChild() == null)
29 protected int indent(ColumnWriter out, Element el) {
35 protected boolean postbreak(ColumnWriter out, Element el) {
36 if(out.col > collimit)
38 return(!onlytext(el));
41 protected void attribute(ColumnWriter out, String nm, String val, int indent) throws IOException {
42 if(out.col > indent) {
43 if(nm.length() + val.length() + 4 > collimit)
46 super.attribute(out, nm, val, indent);
49 public static void main(String[] args) throws Exception {
50 Html barda = Html.xhtml11("Barda");
51 barda.addcss("/slen.css", "Test");
52 barda.insert("body", barda.el("h1", barda.text("Mast")));
55 XmlWriter w = new IndentWriter(barda.doc);
56 w.setnsname(Html.ns, null);