m_factory.setErrorListener(errorListener);
// Create a Templates ContentHandler to handle parsing of the
// stylesheet.
TemplatesHandler templatesHandler = m_factory.newTemplatesHandler();
// Set the system ID for the template handler since some
// TrAX implementations (XSLTC) rely on this in order to obtain
// a meaningful identifier for the Templates instances.
templatesHandler.setSystemId(id);
if (filter != null) {
filter.setContentHandler(templatesHandler);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Source = " + stylesheet + ", templatesHandler = " + templatesHandler);
}
// Initialize List for included validities
SourceValidity validity = stylesheet.getValidity();
if (validity != null && m_checkIncludes) {
m_includesMap.put(id, new ArrayList());
}
try {
// Process the stylesheet.
sourceToSAX(stylesheet, filter != null ? (ContentHandler) filter : (ContentHandler) templatesHandler);
// Get the Templates object (generated during the parsing of
// the stylesheet) from the TemplatesHandler.
final Templates template = templatesHandler.getTemplates();
if (null == template) {
throw new XSLTProcessorException("Unable to create templates for stylesheet: " + stylesheet.getURI());
}