Revision 625 tmp/org.txm.groovy.core/src/groovy/org/txm/importer/xml/pager.groovy

pager.groovy (revision 625)
38 38
import java.net.URL;
39 39
import org.xml.sax.InputSource;
40 40
import org.xml.sax.helpers.DefaultHandler;
41
import org.txm.utils.io.FileCopy
41 42

  
42 43
/** Build a simple edition from a xml-tei. 
43 44
 * @author mdecorde */
......
144 145
		parser = factory.createXMLStreamReader(inputData);
145 146

  
146 147
		process();
148
		
149
		// copy txm.css file near editions
150
		try {
151
			File txmDir = infile.getParentFile().getParentFile();
152
			if (txmDir.exists() && txmDir.getName().equals("txm")) {
153
				File binDir = txmDir.getParentFile();
154
				File corporaDir = binDir.getParentFile();
155
				if (binDir.exists() && corporaDir.getName().equals("corpora")) {
156
					File htmlDir = new File(binDir, "HTML/"+basename.toUpperCase()+"/default")
157
					File txmhomeDir = corporaDir.getParentFile()
158
					File txmcss = new File(txmhomeDir, "css/txm.css")
159
					if (htmlDir.exists() && txmcss.exists()) {
160
						FileCopy.copy(txmcss, new File(htmlDir, "txm.css"))
161
					}
162
				}
163
			}
164
		} catch(Exception e) {
165
			println "Failed to copy TXM default CSS: "+e.getLocalizedMessage();
166
		}
147 167
	}
148 168

  
149 169
	private def closeMultiWriter()
......
175 195
			def tags = closeMultiWriter();
176 196
			for (int i = 0 ; i < tags.size() ; i++) {
177 197
				String tag = tags[i]
178
				if ("body" != tag) {
198
				if ("div" != tag) {
179 199
					tags.remove(i--)
180 200
				} else {
181
					tags.remove(i--) // remove "body"
182
					break; // remove elements until "body tag
201
					tags.remove(i--) // remove first "div"
202
					break; // remove elements until first "div" tag
183 203
				}
184 204
			}
185 205
			File outfile = new File(outdir, txtname+"_"+(++pagecount)+".html")
......
199 219
			pagedWriter.writeEndElement(); // </title>
200 220
			pagedWriter.writeEndElement() // </head>
201 221
			pagedWriter.writeStartElement("body") //<body>
202

  
222
			pagedWriter.writeStartElement("div") //<div class="txmeditionpage">
223
			pagedWriter.writeAttribute("class", "txmeditionpage")
224
			
203 225
			pagedWriter.writeStartElements(tags);
204 226
			return true;
205 227
		} catch (Exception e) {

Also available in: Unified diff