qiuwei / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
1 stars 1 forks source link

No formatting of messages coming from Xerces #161

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When using Xerces to validate using a XML Schema, the issues reported are very 
cryptic because there has been no MessageFormatter set.

There is probably a very good reason to not set this MessageFormatter when the 
XMLErrorReporter is initialised, possibly to allow the user to set it's own 
message formatters; however ... just in case ... adding the following to the 
ValidatorImpl constructor will fix this issue.

if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
  XMLMessageFormatter xmft = new XMLMessageFormatter();
  errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
  errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
}

if (errorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == 
null) {
  XSMessageFormatter xmft = new XSMessageFormatter();
  errorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);
}

Kind regards,
Edwin

Original issue reported on code.google.com by edankert@gmail.com on 3 Oct 2012 at 10:00