*/
public final Document transform(String type, String source, Parameters parameters, Document input) {
ComponentSelector selector = null;
Transformer transformer = null;
SourceResolver resolver = null;
SAXParser parser = null;
Source inputsource = null;
Document document = null;
try {
selector = (ComponentSelector) this.manager.lookup(Transformer.ROLE+
"Selector");
assertNotNull("Test lookup of transformer selector", selector);
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
assertNotNull("Test lookup of source resolver", resolver);
parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
assertNotNull("Test lookup of parser", parser);
assertNotNull("Test if transformer name is not null", type);
transformer = (Transformer) selector.select(type);
assertNotNull("Test lookup of transformer", transformer);
transformer.setup(new SourceResolverAdapter(resolver, this.manager),
objectmodel, source, parameters);
DOMBuilder builder = new DOMBuilder();
transformer.setConsumer(new WhitespaceFilter(builder));
assertNotNull("Test if input document is not null", input);
DOMStreamer streamer = new DOMStreamer(transformer);
streamer.stream(input);
document = builder.getDocument();
assertNotNull("Test for transformer document", document);
} catch (ComponentException ce) {
getLogger().error("Could not retrieve transformer", ce);
ce.printStackTrace();
fail("Could not retrieve transformer:"+ce.toString());
} catch (SAXException saxe) {
getLogger().error("Could not execute test", saxe);
fail("Could not execute test:"+saxe.toString());
} catch (IOException ioe) {
getLogger().error("Could not execute test", ioe);
fail("Could not execute test:"+ioe.toString());
} catch (ProcessingException pe) {
getLogger().error("Could not execute test", pe);
pe.printStackTrace();
fail("Could not execute test:"+pe.toString());
} finally {
if (transformer!=null)
selector.release(transformer);
if (selector!=null)
this.manager.release(selector);
if (inputsource!=null)
resolver.release(inputsource);
if (resolver!=null)
this.manager.release(resolver);
if (parser!=null)