< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java

Print this page

        

@@ -24,10 +24,12 @@
  */
 
 package com.sun.org.apache.xalan.internal.utils;
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.xml.sax.SAXException;
 
 
 /**
  * This class is not the same as that in Xerces. It is used to manage the
  * state of corresponding Xerces properties and pass the values over to

@@ -413,10 +415,27 @@
             }
         }
 
     }
 
+    // Array list to store printed warnings for each SAX parser used
+    private static final CopyOnWriteArrayList<String> printedWarnings = new CopyOnWriteArrayList<>();
+
+    /**
+     * Prints out warnings if a parser does not support the specified feature/property.
+     *
+     * @param parserClassName the name of the parser class
+     * @param propertyName the property name
+     * @param exception the exception thrown by the parser
+     */
+    public static void printWarning(String parserClassName, String propertyName, SAXException exception) {
+        String key = parserClassName+":"+propertyName;
+        if (printedWarnings.addIfAbsent(key)) {
+            System.err.println( "Warning: "+parserClassName+": "+exception.getMessage());
+        }
+    }
+
     /**
      * Read from system properties, or those in jaxp.properties
      *
      * @param property the type of the property
      * @param sysPropertyName the name of system property
< prev index next >