user414441
user414441

Reputation:

How can I provide custom error messages using JAXP DocumentBuilder?

I want to provide my own message from the validation done in DocumentBuilder, rather than the one from XMLMessages.properties.

Now I see that a property error-reporter needs to be set to a class which extends XMLErrorReporter.

However, I've not been able to get ComponentManager from Document/Builder/Factory.

Doing parsing of string in SAXParseException is the last option, but I'm just thinking there may be a 'best practice' way of doing it.

Upvotes: 2

Views: 388

Answers (1)

Lorenzo Boccaccia
Lorenzo Boccaccia

Reputation: 6131

have you already looked at DocumentBuilder#setErrorHandler?

if yes, could you explain why this approach doesn't work for you?

Upvotes: 2

Related Questions