Document testDoc = builder.parse(testFile);
XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning");
String s = xo.str();
boolean base14kerning = ("true".equalsIgnoreCase(s));
FopFactory effFactory = (base14kerning ? fopFactoryWithBase14Kerning : fopFactory);
//Setup Transformer to convert the testcase XML to XSL-FO
Transformer transformer = getTestcase2FOStylesheet().newTransformer();
Source src = new DOMSource(testDoc);
//Setup Transformer to convert the area tree to a DOM
TransformerHandler athandler = tfactory.newTransformerHandler();
athandler.setResult(domres);
//Setup FOP for area tree rendering
FOUserAgent ua = effFactory.newFOUserAgent();
ua.setBaseURL(testFile.getParentFile().toURL().toString());
XMLRenderer atrenderer = new XMLRenderer();
atrenderer.setUserAgent(ua);
atrenderer.setContentHandler(athandler);
ua.setRendererOverride(atrenderer);
fop = effFactory.newFop(ua);
SAXResult fores = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, fores);
} finally {
ElementListObserver.removeObserver(elCollector);