Statistics
| Revision:

root / tmp / org.txm.core / src / groovy / filters / BuildXmlLiturgie / BuildXmlLiturgie.groovy @ 187

History | View | Annotate | Download (3.4 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:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package filters.BuildXmlLiturgie
29

    
30
import java.io.BufferedReader;
31
import java.io.BufferedWriter;
32
import java.io.FileInputStream;
33
import java.io.FileOutputStream;
34
import java.io.InputStreamReader;
35
import java.io.OutputStreamWriter;
36
import java.io.PrintStream;
37

    
38
import org.txm.importer.filters.*;
39
// TODO: Auto-generated Javadoc
40

    
41
/**
42
 * The Class BuildXmlLiturgie.
43
 *
44
 * @author ayepdieu
45
 */
46

    
47
public class BuildXmlLiturgie extends Filter
48
{
49
        /*
50
         * ville : msDescription>msIdentifier>settlement
51
         * cote : msDescription>msIdentifier>idno
52
         * institution : msDescription>msIdentifier>institution
53
         * usage : msDescription>msItem>respStmt>name
54
         * post : msDescription>history>origin>origDate , notBefore
55
         * ante : msDescription>history>origin>origDate , notAfter
56
         */
57
        
58
        /** The dir path name. */
59
        String dirPathName;;
60
        
61
        /** The file name. */
62
        String fileName;
63
        
64
        /* (non-Javadoc)
65
         * @see org.txm.importer.filters.Filter#SetUsedParam(java.lang.Object)
66
         */
67
        public void SetUsedParam(Object args)
68
        {
69
                
70
        }
71
        
72
        /* (non-Javadoc)
73
         * @see org.txm.importer.filters.Filter#filter()
74
         */
75
        public void filter()
76
        {
77
                
78
        }
79
        
80
        /* (non-Javadoc)
81
         * @see org.txm.importer.filters.Filter#before()
82
         */
83
        public boolean before()
84
        {
85
                this.readInput = false;
86
                return true;
87
        }
88
        
89
        /* (non-Javadoc)
90
         * @see org.txm.importer.filters.Filter#after()
91
         */
92
        public void after() {
93
                println("start transformPage");
94

    
95
                def body = new XmlSlurper().parse(this.input);
96
                def nodes = body.text.body.listBibl.msDescription;
97
                def idNotice=1;
98
                def idp=1;
99

    
100
                def xmlBuilder = new groovy.xml.StreamingMarkupBuilder();
101
                xmlBuilder.encoding = this.encodage;
102

    
103
                def xml = xmlBuilder.bind{
104
                        mkp.declareNamespace("":"http://www.tei-c.org/ns/1.0") 
105

    
106
                                nodes.each {
107
                                        //msDescription
108
                                        def ville = it.msIdentifier.settlement.text();
109
                                        def institution = it.msIdentifier.institution.text();
110
                                        def cote = it.msIdentifier.idno.text();
111
                                        def usage = it.msContents.msItem.respStmt.name.text();
112
                                        def post = it.history.origin.origDate.'@notBefore';
113
                                        def ante = it.history.origin.origDate.'@notAfter';
114
                                        
115
                                        def msitems = it.msContents.msItem.msItem;
116
                                        //println msitems.size();
117
                                        notice(n:idNotice, ville:ville, institution:institution, cote:cote, usage:usage,post:post,ante:ante )
118
                                                        {
119
                                                                idp=1;
120
                                                                msitems.each {
121
                                                                        def pp = (it.p);
122
                                                                        
123
                                                                        pp.each {
124
                                                                                it.attributes().put("n",idp) 
125
                                                                                mkp.yield(it)
126
                                                                                
127
                                                                                idp++
128
                                                                        }
129
                                                                }
130
                                                        }
131
                                        idNotice++;
132
                                }
133
                }
134
                this.output.write(xml);
135
        }
136
}