protected void harvestFile(Configuration config, File file,
PropertySource props) throws IOException {
// get the adapter...
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");
// Get the transformer that is configured to map from the native format
// to the "nlnz_presmet.xsd" format. Note that because the
// nlnz_presmet.xsd files have a preamble, and may contain metadata for
// multiple files within a single output file (for the
// ComplexObjectHarvester) the transformation does not
// create a complete XML file, just a <File>...</File> section.
// Different Harvester implementations may use the transformer mapping
// to create complete XML documents; it's up to the Harvester what it
// expects the transformation to achieve.
LogManager.getInstance().logMessage(LogMessage.WORTHLESS_CHATTER, "Starting Transformation");
TransformProcessor transformer = TransformProcessor.getInstance(adapter
.getOutputType(), getOutputType());
// Transform the document into the target format.
LogManager.getInstance().logMessage(LogMessage.WORTHLESS_CHATTER, "Finished Transformation");
transformer.transform(new ByteArrayInputStream(bout.toByteArray()),