if (r.isElement())
rootelems++;
else if (r.isText()) {
Text t = r.asText();
if (!StringTypes.isWhitespace(t.getString()))
throw new XMLWellformednessException("non-whitespace text at root", t.getOrigin());
}
if (rootelems != 1)
throw new XMLWellformednessException("wrong number of root elements", x.getOrigin());
}
final Stack<Entry> stack = new Stack<Entry>(); // using heap stack, avoids deep recursive calls
final boolean[] non_first_element = new boolean[1];
stack.push(new Entry(Entry.Kind.START_NODE, x, null, false, "", false));
final XML.XHTMLMode xhtmlDoctype = XML.getXHTMLDoctype();