@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (currentContainer != null) { currentContainer.processEndChildElement(uri, localName, qName, buffer != null ? buffer.toString() : null); // The current container was interested in this element if (currentContainer.getNestedElements().contains(localName)) { buffer = null; } Container container = getContainer(uri, localName); if (container != null) { // We are exiting the container, record it so we know it's already been declared (for error reporting) seenContainers.add(container); // And stop work until we find another container of interest currentContainer = null; } } }