throws SAXException {
PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
XSLTProcessor processor = null;
Source stylesheet = null;
SourceResolver resolver = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
stylesheet = resolver.resolveURI(this.getStylesheetURI(config, layout));
processor = (XSLTProcessor) this.manager.lookup(config.xsltRole);
TransformerHandler transformer = processor.getTransformerHandler(stylesheet);
Map parameter = layout.getParameters();
if (parameter.size() > 0) {
Map.Entry entry;
Transformer theTransformer = transformer.getTransformer();
for (Iterator iter = parameter.entrySet().iterator(); iter.hasNext();) {
entry = (Map.Entry) iter.next();
theTransformer.setParameter((String)entry.getKey(), entry.getValue());
}
}
SAXResult result = new SAXResult(new IncludeXMLConsumer((handler)));
if (handler instanceof LexicalHandler) {
result.setLexicalHandler((LexicalHandler) handler);
}
transformer.setResult(result);
transformer.startDocument();
context.invokeNext(layout, service, transformer);
transformer.endDocument();
} catch (XSLTProcessorException xpe) {
throw new SAXException("XSLT Exception.", xpe);
} catch (IOException io) {
throw new SAXException("Error in resolving.", io);
} catch (ServiceException ce) {
throw new SAXException("Unable to lookup component.", ce);
} finally {
if (null != resolver) {
resolver.release(stylesheet);
this.manager.release(resolver);
}
this.manager.release(processor);
}
}