Reviewed-by: lancea, dfuchs
This commit is contained in:
Joe Wang 2013-06-10 14:42:57 -07:00
parent e89bdfbdc3
commit b914f8d6be
4 changed files with 31 additions and 9 deletions

View File

@ -52,6 +52,7 @@ import org.xml.sax.ContentHandler;
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 @@ public class Parser implements Constants, ContentHandler {
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));
}

View File

@ -105,8 +105,6 @@ public final class Util {
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 @@ public final class Util {
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

View File

@ -675,8 +675,6 @@ final class ValidatorHandlerImpl extends ValidatorHandler implements
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 @@ final class ValidatorHandlerImpl extends ValidatorHandler implements
// 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

View File

@ -136,11 +136,16 @@ public class XMLReaderManager {
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) {