@Override
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
        try {
            charactersAdded = false;
            --indentLevel;
            if ( lastOutputNodeType == Node.ELEMENT_NODE ) {
                writePrintln();
                indent();
            }

            // XXXX: need to determine this using a stack and checking for
            // content / children
            boolean hadContent = true;
            if ( hadContent ) {
                writeClose(qName);
            }
            else {
                writeEmptyElementClose(qName);
            }
            lastOutputNodeType = Node.ELEMENT_NODE;

            super.endElement( namespaceURI, localName, qName );
        }
        catch (IOException e) {
            handleException(e);
        }
    }
<p>Writes the closing tag of an {@link Element}</p>

@param element <code>Element</code> to output.
@throws IOException if the element could not be written
xmppserver/src/main/java/org/jivesoftware/util/XMLWriter.java