DataAdapter adapter = AdapterFactory.getInstance().getAdapter(file);
// adapt each file...
String outDTD = adapter.getOutputType();
ByteArrayOutputStream bout = new ByteArrayOutputStream(2048);
ParserContext handler = new ParserContext();
// fill in some details - to be included in the output...
handler.setAttribute(ParserContext.FILE_INDEX, fileCount++);
handler.setAttribute(ParserContext.OBJECT, props
.getProperty("ID", null));
handler.setAttribute(ParserContext.PROCESS, props.getProperty("Type",
null));
// Set up the handler.
ParserListener listener = new DTDXmlParserListener(bout, outDTD == null ? null
: Config.getInstance().getXMLBaseURL() + "/" + outDTD);
handler.addListener(listener);
// Adapt the file.
LogManager.getInstance().logMessage(LogMessage.WORTHLESS_CHATTER, "Starting Adapter");
adapter.adapt(file, handler);
LogManager.getInstance().logMessage(LogMessage.WORTHLESS_CHATTER, "Finished adapting");