protected boolean _read(Node n) { try {
Object ret = xml.next();
if (ret == null) return false;
- if (ret instanceof String) {
- n.cdata = (String)ret;
+ if (ret instanceof XML.Text) {
+ n.cdata = ((XML.Text)ret).t;
n.delta = xml.getDepth() - currentdelta;
currentdelta = xml.getDepth();
return true;
} catch (Exception e) { throw new RuntimeException(e); } }
}
- public void toXML(Writer writer) throws IOException { Node n = new Node(); if (read(n)) toXML(writer, n); }
+ public void toXML(Writer writer) throws IOException {
+ Node n = new Node();
+ do { if (!read(n)) n = null; } while (n!=null && n.cdata != null);
+ toXML(writer, n);
+ }
private Node toXML(Writer w, Node n) throws IOException {
final String name = n.name;
if (n.cdata != null) {
w.write("/>");
} else {
w.write(">");
- while(n != null && n.delta > 0) n = toXML(w, n);
+ while(n != null && n.delta > 0) { n = toXML(w, n); }
w.write("</");
w.write(name);
w.write(">");