8016153: Property http://javax.xml.XMLConstants/property/accessExternalDTD is not recognized.
authorjoehw
Mon, 10 Jun 2013 14:42:57 -0700
changeset 18354 ce3ebc4a1aec
parent 18353 15eab2d13b0e
child 18355 381a149016f9
8016153: Property http://javax.xml.XMLConstants/property/accessExternalDTD is not recognized. Reviewed-by: lancea, dfuchs
jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Thu Jun 06 15:03:55 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Mon Jun 10 14:42:57 2013 -0700
@@ -52,6 +52,7 @@
 import org.xml.sax.InputSource;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.AttributesImpl;
@@ -476,8 +477,15 @@
                 factory.setNamespaceAware(true);
             }
             final SAXParser parser = factory.newSAXParser();
-            parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
-                    _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
+            try {
+                parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
+                        _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
+            } catch (SAXNotRecognizedException e) {
+                ErrorMsg err = new ErrorMsg(ErrorMsg.WARNING_MSG,
+                        parser.getClass().getName() + ": " + e.getMessage());
+                reportError(WARNING, err);
+            }
+
             final XMLReader reader = parser.getXMLReader();
             return(parse(reader, input));
         }
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java	Thu Jun 06 15:03:55 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java	Mon Jun 10 14:42:57 2013 -0700
@@ -105,8 +105,6 @@
                     if (reader == null) {
                        try {
                            reader= XMLReaderFactory.createXMLReader();
-                           reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
-                                   xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
                        } catch (Exception e ) {
                            try {
 
@@ -138,6 +136,14 @@
                     reader.setFeature
                         ("http://xml.org/sax/features/namespace-prefixes",false);
 
+                    try {
+                        reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
+                                   xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
+                    } catch (SAXNotRecognizedException e) {
+                        System.err.println("Warning:  " + reader.getClass().getName() + ": "
+                                + e.getMessage());
+                    }
+
                     xsltc.setXMLReader(reader);
                 }catch (SAXNotRecognizedException snre ) {
                   throw new TransformerConfigurationException
--- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java	Thu Jun 06 15:03:55 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java	Mon Jun 10 14:42:57 2013 -0700
@@ -675,8 +675,6 @@
                     spf.setNamespaceAware(true);
                     try {
                         reader = spf.newSAXParser().getXMLReader();
-                           reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
-                                   fComponentManager.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
                         // If this is a Xerces SAX parser, set the security manager if there is one
                         if (reader instanceof com.sun.org.apache.xerces.internal.parsers.SAXParser) {
                            SecurityManager securityManager = (SecurityManager) fComponentManager.getProperty(SECURITY_MANAGER);
@@ -687,8 +685,13 @@
                                // Ignore the exception if the security manager cannot be set.
                                catch (SAXException exc) {}
                            }
-                           reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
-                                   fComponentManager.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
+                           try {
+                               reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
+                                      fComponentManager.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
+                           } catch (SAXException exc) {
+                               System.err.println("Warning: " + reader.getClass().getName() + ": " +
+                                      exc.getMessage());
+                           }
                         }
                     } catch( Exception e ) {
                         // this is impossible, but better safe than sorry
--- a/jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java	Thu Jun 06 15:03:55 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java	Mon Jun 10 14:42:57 2013 -0700
@@ -136,11 +136,16 @@
                 try {
                     reader.setFeature(NAMESPACES_FEATURE, true);
                     reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false);
-                    reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
                 } catch (SAXException se) {
                     // Try to carry on if we've got a parser that
                     // doesn't know about namespace prefixes.
                 }
+                try {
+                    reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
+                } catch (SAXException se) {
+                    System.err.println("Warning:  " + reader.getClass().getName() + ": "
+                                + se.getMessage());
+                }
             } catch (ParserConfigurationException ex) {
                 throw new SAXException(ex);
             } catch (FactoryConfigurationError ex1) {