1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.xmlcv;
28
29 import java.io.File;
30 import java.io.IOException;
31
32 import javax.xml.transform.TransformerException;
33 import javax.xml.transform.stream.StreamResult;
34 import javax.xml.transform.stream.StreamSource;
35
36 import org.xmlcv.util.Config;
37 import org.xmlcv.util.I18n;
38
39 /***
40 * Thread for HTML convertion
41 *
42 * @see org.xmlcv.Convert
43 * @version $Revision: 114 $
44 * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan </a>
45 */
46 public class ConvertHTML extends Convert {
47
48 /***
49 * Convert a <code>p_cv</code> CvModel to a HTML <code>p_file</code>
50 * file.
51 *
52 * @param p_cv
53 * CVModel object
54 * @param p_file
55 * file, will be written/overwritten
56 * @throws XmlCVException
57 */
58 public ConvertHTML(CVModel p_cv, File p_file) throws XmlCVException {
59 super(new StreamSource(p_cv.getInputStream()), p_file);
60 this.go();
61 }
62
63 public void go() {
64
65 try {
66 setXslt(Config.STYLES_XSL);
67 setupTransformer();
68
69 StreamResult res = new StreamResult(this._doneStream);
70
71
72 this._transformer.transform(this._srcXml, res);
73
74 } catch (TransformerException e) {
75 e.printStackTrace();
76 } finally {
77 try {
78 this._doneStream.close();
79 } catch (IOException e1) {
80 e1.printStackTrace();
81 }
82 }
83 }
84
85 public static void main(String[] args) throws XmlCVException {
86 if (args.length != 2) {
87 System.out.println(I18n.getString("Convert.WrongParameters"));
88 System.out.println(I18n.getString("ConvertHTML.Usage"));
89 } else {
90 CVModel cv = new CVModel(args[0]);
91 new ConvertHTML(cv, new File(args[1]));
92 }
93 }
94
95 }