@Override
    public void endDocument() throws SAXException {
        try {
            super.endDocument();
        } finally {
            clearBuffer();
            depth = 0;

            if (hasOutputRoot) {
                hasOutputRoot = false;

                // Fire end events to match the root start events.
                final List<Event> events = rootEvents.getEvents();
                for (int i = events.size() - 1; i >= 0; i--) {
                    final Event event = events.get(i);
                    if (event.isStartElement()) {
                        final StartElement startElement = (StartElement) event;
                        super.endElement(startElement.getUri(), startElement.getLocalName(), startElement.getQName());
                    } else if (event.isStartPrefixMapping()) {
                        final StartPrefixMapping startPrefixMapping = (StartPrefixMapping) event;
                        super.endPrefixMapping(startPrefixMapping.getPrefix());
                    } else if (event.isStartDocument()) {
                        super.endDocument();
                    }
                }
            }
        }
    }
Filters out records that have raised an error or warning during processing.
stroom-pipeline/src/main/java/stroom/pipeline/filter/RecordOutputFilter.java