changeset 857:c0727f8c3ea8

8016500: Unlocalized warnings. Reviewed-by: lancea
author joehw
date Sat, 19 Oct 2013 16:15:44 -0700
parents e200ce7cc24b
children 036cf3985427
files src/com/sun/org/apache/xerces/internal/jaxp/DefaultValidationErrorHandler.java src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
diffstat 3 files changed, 23 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/jaxp/DefaultValidationErrorHandler.java	Thu Oct 17 16:59:05 2013 -0700
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/DefaultValidationErrorHandler.java	Sat Oct 19 16:15:44 2013 -0700
@@ -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 @@
 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 @@
             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();
--- a/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java	Thu Oct 17 16:59:05 2013 -0700
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java	Sat Oct 19 16:15:44 2013 -0700
@@ -141,7 +141,7 @@
         // 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 {
--- a/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java	Thu Oct 17 16:59:05 2013 -0700
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java	Sat Oct 19 16:15:44 2013 -0700
@@ -20,15 +20,6 @@
 
 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;
@@ -46,6 +37,14 @@
 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;
@@ -185,7 +184,7 @@
         // 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 {
@@ -664,6 +663,10 @@
             return super.getProperty(name);
         }
 
+        Locale getLocale() {
+            return fConfiguration.getLocale();
+        }
+
         private void setSchemaValidatorFeature(String name, boolean value)
             throws SAXNotRecognizedException, SAXNotSupportedException {
             try {