Coverage details for umich.cac.xml.Xslt

LineHitsSource
1 package umich.cac.xml;
2  
3 import java.io.File;
4  
5 import javax.xml.transform.Source;
6 import javax.xml.transform.Transformer;
7 import javax.xml.transform.TransformerFactory;
8 import javax.xml.transform.stream.StreamResult;
9 import javax.xml.transform.stream.StreamSource;
10  
11 /**
12  * This class transforms XML to output file using XSLT transform given the XML
13  * file, the XSL file, and the OUTPUT file. Used for debugging only.
14  *
15  * @author rmach@umich.edu
16  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/xml/Xslt.java,v 1.5 2003/10/21 19:07:46 rodmach Exp $
17  */
18  
190public class Xslt {
20  
21     /**
22      *
23      * Create a output file from a XSL transform given XML file and XSL file
24      *
25      * @param xmlFileName
26      * name of XML File to use
27      *
28      * @param xslFileName
29      * name of XSL file to use
30      *
31      * @param outputFileName
32      * name of output file
33      *
34      * @exception Exception
35      * Description of the Exception
36      *
37      */
38  
39     public static void createOutputFile(
40         String xmlFileName,
41         String xslFileName,
42         String outputFileName)
43         throws Exception {
44  
450        File xmlFile = new File(xmlFileName);
460        File xsltFile = new File(xslFileName);
47  
48         // JAXP reads data using the Source interface
49  
500        Source xmlSource = new StreamSource(xmlFile);
510        Source xsltSource = new StreamSource(xsltFile);
52  
53         // the factory pattern supports different XSLT processors
54  
550        TransformerFactory transFact = TransformerFactory.newInstance();
560        Transformer trans = transFact.newTransformer(xsltSource);
570        trans.transform(xmlSource, new StreamResult(outputFileName));
58  
590    }
60  
61     /**
62      * Main transform
63      *
64      * @param args
65      * arguments
66      * @exception Exception
67      * if anything goes wrong.
68      */
69  
70     public static void main(String args[]) throws Exception {
71  
720        if (args.length != 3) {
73  
740            System.err.println(
75                 "Usage: java umich.cac.xml.Xslt [xmlfile] [xsltfile] [outputfile]");
76  
770            System.exit(-1);
78  
79         }
80  
810        String xmlFile = args[0];
820        String xslFile = args[1];
830        String outputFile = args[2];
84  
850        Xslt.createOutputFile(xmlFile, xslFile, outputFile);
86  
870    }
88  
89 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.