@Override
    public void endDocument() throws SAXException {
        if (handler != null) {
            try {
                handler.endDocument();
            } catch (final Throwable e) {
                try {
                    final Throwable throwable = unwrapException(e);

                    errorReceiverProxy.log(Severity.FATAL_ERROR,
                            getLocation(throwable),
                            getElementId(),
                            throwable.toString(),
                            throwable);
                    // If we aren't stepping then throw an exception to terminate early.
                    if (!pipelineContext.isStepping()) {
                        throw LoggedException.wrap(throwable);
                    }

                } finally {
                    // We don't want the whole pipeline to terminate processing
                    // if there is a problem with the transform.
                    super.endDocument();
                }
            } finally {
                handler = null;
                elementCount = 0;
            }
        } else if (passThrough) {
            super.endDocument();
        }
    }
@throws org.xml.sax.SAXException any SAX exception, possibly wrapping another exception
@see #startDocument
@see stroom.pipeline.filter.AbstractXMLFilter#endDocument()
stroom-pipeline/src/main/java/stroom/pipeline/filter/XsltFilter.java