use of eu.esdihumboldt.hale.ui.io.legacy.mappingexport.MappingExportException in project hale by halestudio.
the class RifMappingExportProvider method export.
/**
* @see MappingExportProvider#export(Alignment, String, Collection, Collection)
*/
@Override
public MappingExportReport export(Alignment al, String path, Collection<SchemaElement> sourceSchema, Collection<SchemaElement> targetSchema) throws MappingExportException {
MappingExportReport report = new MappingExportReport();
try {
HaleAlignment hal = new HaleAlignment(al, sourceSchema, targetSchema);
Document document = AlignmentToRifTranslator.getInstance(report).translate(hal);
DOMSource source = new DOMSource(document);
File newFile = new File(path);
OutputStream stream = new FileOutputStream(newFile);
StreamResult result = new StreamResult(stream);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
// $NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// $NON-NLS-1$ //$NON-NLS-2$
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(source, result);
} catch (TranslationException e) {
throw new MappingExportException(e.getMessage(), e);
} catch (FileNotFoundException e) {
throw new MappingExportException(e.getMessage(), e);
} catch (TransformerException e) {
throw new MappingExportException(e.getMessage(), e);
}
return report;
}
Aggregations