How can I provide custom error messages using JAXP DocumentBuilder?

好久不见. 提交于 2019-12-12 16:35:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!