for(Node node : toSerializeNodes) {
try {
serialize(node, serializeWriter);
} catch (IOException e) {
throw new SmooksException("Unexpected pre-text node serialization exception.", e);
}
}
// Get rid of leading and space characters (only spaces - not all whitespace).
// This helps eliminate ugly indentation issues in the serialized XML...
String xml;
try {
xml = normalizeLines(serializeWriter.toString());
} catch (IOException e) {
throw new SmooksException("Unexpected pre-text node serialization exception while attempting to remove excess whitespace.", e);
}
StringBuilder trimEnd = new StringBuilder(xml);
while(trimEnd.length() > 0 && trimEnd.charAt(0) == ' ') {
trimEnd.deleteCharAt(0);
}