public String toString() {
        if (!isFinalized()) {
            throw new IllegalStateException("There are still" + " tag(s) that are not closed.");
        }
        StringWriter sw = writer; // Ensure we have string writer
        return sw.toString();
    }
Check if all tags have been properly closed.

@return true if all tags are closed
document/src/main/java/com/yahoo/document/serialization/XmlStream.java