Fix bug #16336 as suggested.
git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226194 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
04ad8d99bb
commit
1dafbf63c9
@ -298,15 +298,54 @@ public class CatalogResolver implements EntityResolver, URIResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!href.equals(result)) {
|
catalogManager.debug.message(2, "Resolved URI", href, result);
|
||||||
catalogManager.debug.message(2, "Resolved URI", href, result);
|
|
||||||
// }
|
|
||||||
|
|
||||||
SAXSource source = new SAXSource();
|
SAXSource source = new SAXSource();
|
||||||
source.setInputSource(new InputSource(result));
|
source.setInputSource(new InputSource(result));
|
||||||
|
setEntityResolver(source);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Establish an entityResolver for newly resolved URIs.</p>
|
||||||
|
*
|
||||||
|
* <p>This is called from the URIResolver to set an EntityResolver
|
||||||
|
* on the SAX parser to be used for new XML documents that are
|
||||||
|
* encountered as a result of the document() function, xsl:import,
|
||||||
|
* or xsl:include. This is done because the XSLT processor calls
|
||||||
|
* out to the SAXParserFactory itself to create a new SAXParser to
|
||||||
|
* parse the new document. The new parser does not automatically
|
||||||
|
* inherit the EntityResolver of the original (although arguably
|
||||||
|
* it should). See below:</p>
|
||||||
|
*
|
||||||
|
* <tt>"If an application wants to set the ErrorHandler or
|
||||||
|
* EntityResolver for an XMLReader used during a transformation,
|
||||||
|
* it should use a URIResolver to return the SAXSource which
|
||||||
|
* provides (with getXMLReader) a reference to the XMLReader"</tt>
|
||||||
|
*
|
||||||
|
* <p>...quoted from page 118 of the Java API for XML
|
||||||
|
* Processing 1.1 specification</p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void setEntityResolver(SAXSource source) throws TransformerException {
|
||||||
|
XMLReader reader = source.getXMLReader();
|
||||||
|
if (reader == null) {
|
||||||
|
SAXParserFactory spFactory = SAXParserFactory.newInstance();
|
||||||
|
spFactory.setNamespaceAware(true);
|
||||||
|
try {
|
||||||
|
reader = spFactory.newSAXParser().getXMLReader();
|
||||||
|
}
|
||||||
|
catch (ParserConfigurationException ex) {
|
||||||
|
throw new TransformerException(ex);
|
||||||
|
}
|
||||||
|
catch (SAXException ex) {
|
||||||
|
throw new TransformerException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reader.setEntityResolver(this);
|
||||||
|
source.setXMLReader(reader);
|
||||||
|
}
|
||||||
|
|
||||||
/** Attempt to construct an absolute URI */
|
/** Attempt to construct an absolute URI */
|
||||||
private String makeAbsolute(String uri) {
|
private String makeAbsolute(String uri) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user