* @param parameters Generator parameters.
*/
public final Document generate(String type, String source, Parameters parameters) {
ComponentSelector selector = null;
Generator generator = null;
SourceResolver resolver = null;
SAXParser parser = null;
Source assertionsource = null;
Document document = null;
try {
selector = (ComponentSelector) this.manager.lookup(Generator.ROLE +
"Selector");
assertNotNull("Test lookup of generator 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 generator name is not null", type);
generator = (Generator) selector.select(type);
assertNotNull("Test lookup of generator", generator);
generator.setup(new SourceResolverAdapter(resolver, this.manager),
objectmodel, source, parameters);
DOMBuilder builder = new DOMBuilder();
generator.setConsumer(new WhitespaceFilter(builder));
generator.generate();
document = builder.getDocument();
assertNotNull("Test for generator document", document);