Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / doc / TeiToHtml.groovy @ 479

History | View | Annotate | Download (2.1 kB)

1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun. 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.doc
29

    
30
import java.io.File;
31
import org.txm.importer.ApplyXsl;
32

    
33
// TODO: Auto-generated Javadoc
34
/**
35
 * The Class TeiToHtml.
36
 */
37
class TeiToHtml {
38
        
39
        /** The imgdirname. */
40
        static String imgdirname = "ImagesTXM"
41
                
42
        /**
43
         * Run.
44
         *
45
         * @param teifile the teifile
46
         * @param xslfile the xslfile
47
         * @param htmloutdir the htmloutdir
48
         * @return true, if successful
49
         */
50
        public boolean run(File teifile, File xslfile, File htmloutdir)
51
        {
52
                println "** TEI TO HTML $teifile $htmloutdir"
53
                
54
                println "Check Pictures directory"
55
                if(!new File(htmloutdir.getParentFile(), imgdirname).exists())
56
                {
57
                        println "$imgdirname directory does not exists: "+new File(htmloutdir.getParentFile(), imgdirname).getAbsolutePath()
58
                        return false;
59
                }
60
                
61
                println "create html outdirectory with folders HTML and ImgTXM"
62
                if(!htmloutdir.mkdir())
63
                {
64
                        if(!htmloutdir.exists())
65
                        {println "Failed to create "+htmloutdir.getAbsolutePath();
66
                        return false;
67
                        }
68
                }
69
                
70
                println "apply xsl tei to HTML"
71
                ApplyXsl a = new ApplyXsl(xslfile.getAbsolutePath());
72
                String[] args = ["outputDir",htmloutdir];
73
                a.process(teifile.getAbsolutePath(), "./HTML",args);
74

    
75
                return true;
76
        }
77
}