void (final MultiText mtext, int offset, int len) { while (len > 0) { final Content c = get(offset); if (c instanceof Text) { // either Text or CDATA if (!Verifier.isAllXMLWhitespace(c.getValue())) { break; } } else { break; } offset++; len--; } while (len > 0) { final Content c = get(offset + len - 1); if (c instanceof Text) { // either Text or CDATA if (!Verifier.isAllXMLWhitespace(c.getValue())) { break; } } else { break; } len--; } for (int i = 0; i < len; i++) { Trim trim = Trim.NONE; if (i + 1 == len) { trim = Trim.RIGHT; } if (i == 0) { trim = Trim.LEFT; } if (len == 1) { trim = Trim.BOTH; } final Content c = get(offset + i); switch (c.getCType()) { case Text: mtext.appendText(trim, c.getValue()); break; case CDATA: mtext.appendCDATA(trim, c.getValue()); break; case EntityRef: // treat like any other content. // raw. default: mtext.appendRaw(c); break; } } }