tags:

views:

110

answers:

1

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.

Can any kind soul gimme code to get it ?

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.

+2  A: 

have you already looked at DocumentBuilder#setErrorHandler?

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

Lorenzo Boccaccia
ErrorHandler kicks in with already formed string. ( e.g. The element of type Foo should be (bar)* ). The proper message should be ' The element 'Foo' should contain subelements 'bar' only'.I can get the exhaustive list from XMLMessages.properties, and map them to the string that i want to print
Vardhan Varma