@Test
public void testDeepNesting() {
// need to get beyond 16 levels of XML.
DocType dt = new DocType("root");
Element root = new Element("root");
Document doc = new Document();
doc.addContent(dt);
doc.addContent(root);
String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
String dtdec = "<!DOCTYPE root>";
String lf = "\n";
StringBuilder raw = new StringBuilder();
raw.append(xmldec).append(lf).append(dtdec);
StringBuilder pretty = new StringBuilder();
pretty.append(xmldec).append(lf).append(dtdec);
if (!usesrawxmlout) {
// most test systems use the XMLOutputter in raw mode to output
// the results of the conversion. In Raw mode the XMLOutputter will
// not make pretty content outside of the root element (but it will
// put the XMLDeclaration on it's own line).
// so, in the cases where the actual pretty format is used, we add
// this newline after the DocType...
pretty.append(lf);
}
raw.append("<root>");
pretty.append("<root>");
pretty.append(lf);
final int depth = 40;
int cnt = depth;
Parent parent = root;
StringBuilder indent = new StringBuilder();
while (--cnt > 0) {
Element emt = new Element("emt");
parent.getContent().add(emt);
parent = emt;
raw.append("<emt>");
indent.append(" ");
pretty.append(indent.toString());
pretty.append("<emt>");
pretty.append(lf);
}
parent.getContent().add(new Element("bottom"));
raw.append("<bottom />");
pretty.append(indent.toString());
pretty.append(" <bottom />");
pretty.append(lf);