问题
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.
回答1:
have you already looked at DocumentBuilder#setErrorHandler?
if yes, could you explain why this approach doesn't work for you?
来源:https://stackoverflow.com/questions/130960/how-can-i-provide-custom-error-messages-using-jaxp-documentbuilder