@Override
    public void startElement(final String uri, final String localName, final String qName, final Attributes atts)
            throws SAXException {
        depth++;

        if (root == null) {
            root = new StartElement(uri, localName, qName, atts);
            prefixes = prefixList.toArray(new StartPrefixMapping[0]);
        }

        if (depth > 2) {
            handler.startElement(uri, localName, qName, atts);

        } else if (depth == 2) {
            handler = createHandler();
            handler.startDocument();
            for (int i = 0; i < prefixes.length; i++) {
                final StartPrefixMapping prefixMapping = prefixes[i];
                handler.startPrefixMapping(prefixMapping.getPrefix(), prefixMapping.getUri());
            }
            handler.startElement(root.getUri(), root.getLocalName(), root.getQName(), root.getAttributes());

            // Get the header
            header = getHeader();

            handler.startElement(uri, localName, qName, atts);
        }
    }
Don't end prefix mappings if we are at the root element. Leave the end
processing method to do this.
stroom-pipeline/src/main/java/stroom/pipeline/record/XMLRecordEmitter.java