Not that I knew. You may have to create your own custom code to adapt error messages. One way could be to identify a set of regular expressions that can pull the appropriate snippets of validation error messages, and then include them again in your own error messages. Something like this comes to mind (not optimized, does not handle the general case, etc., but I think you will understand this idea):
String uglyMessage = "cvc-complex-type.2.4.b: The content of element 'node' is not complete. One of '{\"\":offer,\"\":links}' is expected."; String findRegex = "cvc-complex-type\\.2\\.4\\.b: The content of element '(\\w+)' is not complete\\. One of '\\{\"\":(\\w+),\"\":(\\w+)}' is expected\\."; String replaceRegex = "The element '$1' is not complete. The child elements '$2' and '$3' are expected."; String userFriendlyMessage = Pattern.compile(findRegex).matcher(uglyMessage).replaceAll(replaceRegex); System.out.println(userFriendlyMessage); // OUTPUT: // The element 'node' is not complete. The child elements 'offer' and 'links' are expected.
I suspect that these validator error messages are vendor-specific, so if you do not have control over the XML validation mechanism in the deployed application, this may not work for you.
source share