Line | Hits | Source |
---|---|---|
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 | ||
19 | 0 | public 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 | ||
45 | 0 | File xmlFile = new File(xmlFileName); |
46 | 0 | File xsltFile = new File(xslFileName); |
47 | ||
48 | // JAXP reads data using the Source interface | |
49 | ||
50 | 0 | Source xmlSource = new StreamSource(xmlFile); |
51 | 0 | Source xsltSource = new StreamSource(xsltFile); |
52 | ||
53 | // the factory pattern supports different XSLT processors | |
54 | ||
55 | 0 | TransformerFactory transFact = TransformerFactory.newInstance(); |
56 | 0 | Transformer trans = transFact.newTransformer(xsltSource); |
57 | 0 | trans.transform(xmlSource, new StreamResult(outputFileName)); |
58 | ||
59 | 0 | } |
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 | ||
72 | 0 | if (args.length != 3) { |
73 | ||
74 | 0 | System.err.println( |
75 | "Usage: java umich.cac.xml.Xslt [xmlfile] [xsltfile] [outputfile]"); | |
76 | ||
77 | 0 | System.exit(-1); |
78 | ||
79 | } | |
80 | ||
81 | 0 | String xmlFile = args[0]; |
82 | 0 | String xslFile = args[1]; |
83 | 0 | String outputFile = args[2]; |
84 | ||
85 | 0 | Xslt.createOutputFile(xmlFile, xslFile, outputFile); |
86 | ||
87 | 0 | } |
88 | ||
89 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |