private void trimEndWhitespace(final StringBuilder sb) {
        int index = sb.length() - 1;
        while (index >= 0 && isWhitespace(sb.charAt(index))) {
            index--;
        }
        sb.setLength(index + 1);
    }
Reduces the current length of a <code>StringBuilder</code> to trim any
whitespace off the end of the buffer.

@param sb The <code>StringBuilder</code> to trim.
stroom-core-client-widget/src/main/java/stroom/editor/client/model/XmlFormatter.java