Can I have custom ErrorHandler on XML Validator to print the XML?

16 Views Asked by At

I have a method to use javax.xml.validation.Validator to validate the xml from user and then log an error if the format is wrong. with code like following:

        try {
            try (final StringReader reader = new StringReader(xml)) {
                xmlValidator.validate(new StreamSource(reader));
            }
        } catch (Exception e) {
                log.error("Error: {}, xml: {}", e.getMessage(), xml);
        }

However, we found that somehow if the input will be paused if more than 25 to 30 messages per minutes, not sure why. If we change to set a custom ErrorHandler that log the error, there is no such issue. However, the interface of ErrorHandler only have the SAXParseException, not sure if there is any trick that I can still print out the xml message with problem?

0

There are 0 best solutions below