package at.gv.egovernment.moa.spss.server.tools; import java.io.FileNotFoundException; import java.io.FileOutputStream; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; /** * A tool for converting a MOA SPSS Version 1.0 configuration file into * a Version 1.3 configuration file. * * @author Gregor Karlinger * @version $Id$ */ public class ConfigTool { public static void main(String[] args) { if (args == null || args.length != 2) { System.out.println("Usage: ConfigTool "); System.out.println(" ... Old config file to be transformed"); System.out.println(" ... New config file resulting from the transform"); System.exit(-1); } try { TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource( ConfigTool.class.getResourceAsStream("/resources/tools/ConfigurationMapper.xsl"))); transformer.transform(new StreamSource(args[0]), new StreamResult(new FileOutputStream(args[1]))); System.out.println("Successfully mapped configuration file."); } catch (TransformerConfigurationException e) { System.err.println("An error occurred during mapping the configuration file:"); System.err.println(" Cannot initialize XSLT transform."); System.err.println(" " + e.getMessage()); } catch (FileNotFoundException e) { System.err.println("An error occurred during mapping the configuration file:"); System.err.println(" There is a problem with the filename for the new configuration file."); System.err.println(" " + e.getMessage()); } catch (TransformerException e) { System.err.println("An error occurred during mapping the configuration file:"); System.err.println(" " + e.getMessage()); } } }