--- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java 2016-11-16 12:14:28.000000000 +0100 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java 2016-11-16 12:14:28.000000000 +0100 @@ -17,7 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.sun.org.apache.xml.internal.utils; import com.sun.org.apache.xalan.internal.XalanConstants; @@ -50,8 +49,9 @@ private static final String NAMESPACE_PREFIXES_FEATURE = "http://xml.org/sax/features/namespace-prefixes"; private static final XMLReaderManager m_singletonManager = - new XMLReaderManager(); + new XMLReaderManager(); private static final String property = "org.xml.sax.driver"; + /** * Parser factory to be used to construct XMLReader objects */ @@ -69,23 +69,27 @@ private boolean m_useServicesMechanism = true; + private boolean m_NamespaceAware = true; + private boolean _secureProcessing; - /** + + /** * protocols allowed for external DTD references in source file and/or stylesheet. */ private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT; private XMLSecurityManager _xmlSecurityManager; - //Catalog Feature + /** + * Catalog Feature + */ private boolean _useCatalog; private CatalogFeatures _catalogFeatures; /** * Hidden constructor */ - private XMLReaderManager() { - } + private XMLReaderManager() {} /** * Retrieves the singleton reader manager @@ -120,8 +124,9 @@ reader = m_readers.get(); boolean threadHasReader = (reader != null); String factory = SecuritySupport.getSystemProperty(property); - if (threadHasReader && m_inUse.get(reader) != Boolean.TRUE && - ( factory == null || reader.getClass().getName().equals(factory))) { + if (threadHasReader && + m_inUse.get(reader) != Boolean.TRUE && + (factory == null || reader.getClass().getName().equals(factory))) { m_inUse.put(reader, Boolean.TRUE); } else { try { @@ -151,13 +156,6 @@ throw pce; // pass along pce } } - try { - reader.setFeature(NAMESPACES_FEATURE, true); - reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false); - } catch (SAXException se) { - // Try to carry on if we've got a parser that - // doesn't know about namespace prefixes. - } } catch (ParserConfigurationException ex) { throw new SAXException(ex); } catch (FactoryConfigurationError ex1) { @@ -174,6 +172,20 @@ } try { + //reader is cached, but this feature might have been reset + if (m_NamespaceAware) { + reader.setFeature(NAMESPACES_FEATURE, true); + reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false); + } else { + reader.setFeature(NAMESPACES_FEATURE, false); + reader.setFeature(NAMESPACE_PREFIXES_FEATURE, true); + } + } catch (SAXException se) { + // Try to carry on if we've got a parser that + // doesn't know about namespace prefixes. + } + + try { //reader is cached, but this property might have been reset reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD); } catch (SAXException se) { @@ -249,10 +261,12 @@ * Set feature */ public void setFeature(String name, boolean value) { - if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { + if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) { _secureProcessing = value; } else if (XMLConstants.USE_CATALOG.equals(name)) { _useCatalog = value; + } else if (NAMESPACES_FEATURE.equals(name)) { + m_NamespaceAware = value; } }