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

pager.groovy (revision 479)
21 21
//
22 22
//
23 23
//
24
// $LastChangedDate: 2017-01-24 18:11:42 +0100 (Tue, 24 Jan 2017) $
25
// $LastChangedRevision: 3400 $
24
// $LastChangedDate: 2017-05-02 11:55:17 +0200 (mar. 02 mai 2017) $
25
// $LastChangedRevision: 3436 $
26 26
// $LastChangedBy: mdecorde $
27 27
//
28 28
package org.txm.importer.xml;
......
151 151
		if (pagedWriter != null) {
152 152
			def tags = pagedWriter.getTagStack().clone();
153 153

  
154
			if (firstWord) { // there was no words
154
			if (firstWord) { // there was no words found
155 155
				pagedWriter.writeCharacters("");
156
				//				if (this.idxstart.size() == 0) {
157
				//					this.idxstart.add("w_0")
158
				//					pagedWriter.write("<span id=\"w_0\"/>");
159
				//				} else {
160 156
				this.idxstart.add("w_0")
161 157
				pagedWriter.write("<span id=\"w_0\"/>");
162
				//				}
163 158
			}
164 159
			pagedWriter.writeEndElements();
165 160
			pagedWriter.close();
......
208 203
			pagedWriter.writeStartElements(tags);
209 204
			return true;
210 205
		} catch (Exception e) {
211
			System.out.println(e.getLocalizedMessage());
206
			System.out.println("Error: "+e.getLocalizedMessage());
212 207
			return false;
213 208
		}
214 209
	}
......
259 254
			switch (event) {
260 255
				case XMLStreamConstants.START_ELEMENT:
261 256
					localname = parser.getLocalName();
257
					
258
					if (localname == paginationElement) {
259
						createNextOutput();
260
						pagedWriter.write("\n");
261
						if (parser.getAttributeValue(null,"n") != null) {
262
							pagedWriter.writeElement("p", ["style":"color:red", "align":"center"], "- "+parser.getAttributeValue(null,"n")+" -")
263
						}
264
					}
265
					
262 266
					switch (localname) {
263 267
						case "text":
264 268
							pagedWriter.write("\n");
......
308 312
							pagedWriter.writeStartElement("p",["class":rend])
309 313
							break;
310 314
						//case "pb":
311
						case paginationElement:
312
							createNextOutput();
313
							wordcount=0;
314
							pagedWriter.write("\n");
315
							if (parser.getAttributeValue(null,"n") != null) {
316
								pagedWriter.writeElement("p", ["style":"color:red", "align":"center"], "- "+parser.getAttributeValue(null,"n")+" -")
317
							}
318
							break;
315
						
319 316
						case "lb":
320 317
						case "br":
321 318
							pagedWriter.writeEmptyElement("br")
322 319
							break;
323 320
						case "w":
321
						
324 322
							wordid = parser.getAttributeValue(null,"id");
323
							
324
							wordcount++;
325
							if (wordcount >= wordmax) {
326
								createNextOutput();
327
							}
328
							
325 329
							if (firstWord) {
326 330
								firstWord = false;
327 331
								this.idxstart.add(wordid);
328 332
							}
329
							wordcount++;
330
							if (wordcount >= wordmax) {
331
								createNextOutput();
332
							}
333
							
333 334
							break;
334 335
						case "ana":
335 336
							flaginterp=true;

Also available in: Unified diff