/**
* Fix for bugzilla bug 24187
*/
StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset);
try {
if (source instanceof DOMSource ) {
final DOMSource domsrc = (DOMSource) source;
baseId = domsrc.getSystemId();
final org.w3c.dom.Node node = domsrc.getNode();
final DOM2SAX dom2sax = new DOM2SAX(node);
_stylesheetPIHandler.setBaseId(baseId);
dom2sax.setContentHandler( _stylesheetPIHandler);
dom2sax.parse();
} else {
isource = SAXSource.sourceToInputSource(source);
baseId = isource.getSystemId();
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
if (_isSecureProcessing) {
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
}
catch (org.xml.sax.SAXException e) {}
}
SAXParser jaxpParser = factory.newSAXParser();
reader = jaxpParser.getXMLReader();
if (reader == null) {
reader = XMLReaderFactory.createXMLReader();
}
_stylesheetPIHandler.setBaseId(baseId);
reader.setContentHandler(_stylesheetPIHandler);
reader.parse(isource);
}
if (_uriResolver != null ) {
_stylesheetPIHandler.setURIResolver(_uriResolver);
}
} catch (StopParseException e ) {
// startElement encountered so do not parse further
} catch (javax.xml.parsers.ParserConfigurationException e) {
throw new TransformerConfigurationException(
"getAssociatedStylesheets failed", e);
} catch (org.xml.sax.SAXException se) {
throw new TransformerConfigurationException(
"getAssociatedStylesheets failed", se);
} catch (IOException ioe ) {
throw new TransformerConfigurationException(
"getAssociatedStylesheets failed", ioe);
}
return _stylesheetPIHandler.getAssociatedStylesheet();
}