8016500: Unlocalized warnigs

Reviewed-by: lancea
This commit is contained in:
Joe Wang 2013-10-17 16:35:28 -07:00
parent a45aa286f3
commit a630fe0c72
3 changed files with 24 additions and 17 deletions

View File

@ -20,6 +20,8 @@
package com.sun.org.apache.xerces.internal.jaxp;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import java.util.Locale;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
@ -30,6 +32,11 @@ import org.xml.sax.helpers.DefaultHandler;
class DefaultValidationErrorHandler extends DefaultHandler {
static private int ERROR_COUNT_LIMIT = 10;
private int errorCount = 0;
private Locale locale = Locale.getDefault();
public DefaultValidationErrorHandler(Locale locale) {
this.locale = locale;
}
// XXX Fix message i18n
public void error(SAXParseException e) throws SAXException {
@ -38,11 +45,8 @@ class DefaultValidationErrorHandler extends DefaultHandler {
return;
} else if (errorCount == 0) {
// Print a warning before the first error
System.err.println("Warning: validation was turned on but an org.xml.sax.ErrorHandler was not");
System.err.println("set, which is probably not what is desired. Parser will use a default");
System.err.println("ErrorHandler to print the first " +
ERROR_COUNT_LIMIT + " errors. Please call");
System.err.println("the 'setErrorHandler' method to fix this.");
System.err.println(SAXMessageFormatter.formatMessage(locale,
"errorHandlerNotSet", new Object [] {errorCount}));
}
String systemId = e.getSystemId();

View File

@ -141,7 +141,7 @@ public class DocumentBuilderImpl extends DocumentBuilder
// validation errors with a warning telling the user to set an
// ErrorHandler
if (dbf.isValidating()) {
fInitErrorHandler = new DefaultValidationErrorHandler();
fInitErrorHandler = new DefaultValidationErrorHandler(domParser.getXMLParserConfiguration().getLocale());
setErrorHandler(fInitErrorHandler);
}
else {

View File

@ -20,23 +20,14 @@
package com.sun.org.apache.xerces.internal.jaxp;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.validation.Schema;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;
import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import com.sun.org.apache.xerces.internal.util.Status;
import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
@ -46,6 +37,14 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.validation.Schema;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.HandlerBase;
@ -187,7 +186,7 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
// validation errors with a warning telling the user to set an
// ErrorHandler.
if (spf.isValidating()) {
fInitErrorHandler = new DefaultValidationErrorHandler();
fInitErrorHandler = new DefaultValidationErrorHandler(xmlReader.getLocale());
xmlReader.setErrorHandler(fInitErrorHandler);
}
else {
@ -686,6 +685,10 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
return super.getProperty(name);
}
Locale getLocale() {
return fConfiguration.getLocale();
}
private void setSchemaValidatorFeature(String name, boolean value)
throws SAXNotRecognizedException, SAXNotSupportedException {
try {