private void writeErrors() {
        if (errors.size() > 0) {
            for (final StoredError error : errors) {
                try {
                    final AttributesImpl atts = new AttributesImpl();
                    if (error.getSeverity() != null) {
                        atts.addAttribute(BLANK, TYPE, TYPE, STRING, error.getSeverity().getDisplayValue());
                    }
                    if (error.getLocation() != null) {
                        atts.addAttribute(BLANK, LOCATION, LOCATION, STRING, error.getLocation().toString());
                    }
                    if (error.getElementId() != null) {
                        atts.addAttribute(BLANK, ELEMENT_ID, ELEMENT_ID, STRING, error.getElementId());
                    }

                    String message = error.getMessage();
                    if (message == null) {
                        message = "";
                    }
                    if (error.getElementId() != null) {
                        message = error.getElementId() + COLON + SPACE + message;
                    }
                    message = getMessage(message);
                    atts.addAttribute(BLANK, MESSAGE, MESSAGE, STRING, message);

                    super.startElement(URI, ERROR, ERROR, atts);
                    super.endElement(URI, ERROR, ERROR);
                } catch (final SAXException e) {
                    LOGGER.error("Unable to write errors!", e);
                }
            }
            errors.clear();
        }
    }
@param ch     the characters from the XML document
@param start  the start position in the array
@param length the number of characters to read from the array
stroom-headless/src/main/java/stroom/headless/HeadlessFilter.java