/** * Simple transformation method. * * @param contextFile * - Absolute path to source xml file. * @param StreamSource * - the xslt file. * @param resultDir * - Directory where you want to put resulting files. * @param parameters * - Map defining global XSLT parameters based via transformer to the XSLT file. * @throws TransformerException */ public static void simpleTransform(final String contextFile, final InputStream xsltSource, final File result, final Map<String, String> parameters) throws TransformerException { final TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); final Transformer transformer = tFactory.newTransformer(new StreamSource(xsltSource)); applyParameters(transformer, parameters); transformer.transform(new StreamSource(new File(contextFile)), new StreamResult(result)); }
/** * Generates source code by applying the <code>ddJavaAll.xsl</code> XSLT extracted from the resource stream. * * @throws TransformerException */ public void generateCode(final MetadataParserPath path, final boolean verbose) throws TransformerException { /** initialize the map which will overwrite global parameters as defined in metadata.xsl/ddJava.xsl */ final Map<String, String> xsltParameters = new HashMap<String, String>(); xsltParameters.put("gOutputFolder", getURIPath(path.getPathToImpl())); xsltParameters.put("gOutputFolderApi", getURIPath(path.getPathToApi())); xsltParameters.put("gOutputFolderTest", getURIPath(path.getPathToTest())); xsltParameters.put("gOutputFolderService", getURIPath(path.getPathToServices())); xsltParameters.put("gVerbose", Boolean.toString(verbose)); final InputStream is = MetadataParser.class.getResourceAsStream("/META-INF/ddJavaAll.xsl"); if (log.isLoggable(Level.FINE)) { log.fine("Stream resource: " + is); } XsltTransformer.simpleTransform(pathToMetadata, is, new File("./tempddJava.xml"), xsltParameters); }
/** * Generates source code by applying the <code>ddJavaAll.xsl</code> XSLT extracted from the resource stream. * * @throws TransformerException */ public void generateCode(final MetadataParserPath path, final boolean verbose) throws TransformerException { /** initialize the map which will overwrite global parameters as defined in metadata.xsl/ddJava.xsl */ final Map<String, String> xsltParameters = new HashMap<String, String>(); xsltParameters.put("gOutputFolder", getURIPath(path.getPathToImpl())); xsltParameters.put("gOutputFolderApi", getURIPath(path.getPathToApi())); xsltParameters.put("gOutputFolderTest", getURIPath(path.getPathToTest())); xsltParameters.put("gOutputFolderService", getURIPath(path.getPathToServices())); xsltParameters.put("gVerbose", Boolean.toString(verbose)); final InputStream is = MetadataParser.class.getResourceAsStream("/META-INF/ddJavaAll.xsl"); if (log.isLoggable(Level.FINE)) { log.fine("Stream resource: " + is); } XsltTransformer.simpleTransform(pathToMetadata, is, new File("./tempddJava.xml"), xsltParameters); }
/** * Simple transformation method. * * @param contextFile * - Absolute path to source xml file. * @param StreamSource * - the xslt file. * @param resultDir * - Directory where you want to put resulting files. * @param parameters * - Map defining global XSLT parameters based via transformer to the XSLT file. * @throws TransformerException */ public static void simpleTransform(final String contextFile, final InputStream xsltSource, final File result, final Map<String, String> parameters) throws TransformerException { final TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); final Transformer transformer = tFactory.newTransformer(new StreamSource(xsltSource)); applyParameters(transformer, parameters); transformer.transform(new StreamSource(new File(contextFile)), new StreamResult(result)); }
/** * Simple transformation method. * * @param sourcePath * - Absolute path to source xml file. * @param StreamSource * - the xslt file. * @param resultDir * - Directory where you want to put resulting files. * @param parameters * - Map defining global XSLT parameters based via tranformer to the XSLT file. * @throws TransformerException */ public static void simpleTransform(final String sourcePath, final StreamSource xsltSource, final String resultDir, final Map<String, String> parameters) throws TransformerException { final TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); final Transformer transformer = tFactory.newTransformer(xsltSource); applyParameters(transformer, parameters); transformer.transform(new StreamSource(new File(sourcePath)), new StreamResult(new File(resultDir + "/metadata.xml"))); }
/** * Simple transformation method. * * @param sourcePath * - Absolute path to source xml file. * @param StreamSource * - the xslt file. * @param resultDir * - Directory where you want to put resulting files. * @param parameters * - Map defining global XSLT parameters based via tranformer to the XSLT file. * @throws TransformerException */ public static void simpleTransform(final String sourcePath, final StreamSource xsltSource, final String resultDir, final Map<String, String> parameters) throws TransformerException { final TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); final Transformer transformer = tFactory.newTransformer(xsltSource); applyParameters(transformer, parameters); transformer.transform(new StreamSource(new File(sourcePath)), new StreamResult(new File(resultDir + "/metadata.xml"))); }
/** * Simple transformation method. * * @param sourcePath * - Absolute path to source xml file. * @param xsltPath * - Absolute path to xslt file. * @param resultDir * - Directory where you want to put resulting files. * @param parameters * - Map defining global XSLT parameters based via tranformer to the XSLT file. * @throws TransformerException */ public static void simpleTransform(final String sourcePath, final String xsltPath, final String resultDir, final Map<String, String> parameters) throws TransformerException { final TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); final Transformer transformer = tFactory.newTransformer(new StreamSource(new File(xsltPath))); applyParameters(transformer, parameters); transformer.transform(new StreamSource(new File(sourcePath)), new StreamResult(new File(resultDir))); }
/** * Simple transformation method. * * @param sourcePath * - Absolute path to source xml file. * @param xsltPath * - Absolute path to xslt file. * @param resultDir * - Directory where you want to put resulting files. * @param parameters * - Map defining global XSLT parameters based via tranformer to the XSLT file. * @throws TransformerException */ public static void simpleTransform(final String sourcePath, final String xsltPath, final String resultDir, final Map<String, String> parameters) throws TransformerException { final TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); final Transformer transformer = tFactory.newTransformer(new StreamSource(new File(xsltPath))); applyParameters(transformer, parameters); transformer.transform(new StreamSource(new File(sourcePath)), new StreamResult(new File(resultDir))); }