Révision 2799

tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 2799)
51 51

  
52 52
		if (orderedTextIDs == null) { module.getProject().getTextsID() }
53 53

  
54
		if (!doDefaultEditionStep()) return;
55
		if (!doFacsEditionStep()) return;
56

  
57
		// remove extra XSL editions -> they will be recreated by the doPostEditionXSLStep call
54
		def xslEditionsToBuild = getXSLEditionsToBuild()
55
		if (!xslEditionsToBuild.contains("default")) { // avoid building the default edition if an XSL edition will build it
56
			if (!doDefaultEditionStep()) return;
57
		}
58
		
59
		if (!xslEditionsToBuild.contains("facs")) { // avoid building the facs edition if an XSL edition will build it
60
			if (!doFacsEditionStep()) return;
61
		}
62
		
63
		// remove extra XSL edition defintions (except default and facs) -> they will be recreated by the doPostEditionXSLStep call
58 64
		for (EditionDefinition eDef : project.getEditionDefinitions()) {
59 65
			if (eDef.getName() != "facs" && eDef.getName() != "default") {
60 66
				eDef.delete();
......
280 286
		println ""
281 287
		return true;
282 288
	}
289
	
290
	public List<String> getXSLEditionsToBuild() {
291
		def names= []
292
		File xslDirectory = new File(module.getSourceDirectory(), "xsl/4-edition")
293
		if (xslDirectory.exists()) {
283 294

  
295
			def xslFiles = xslDirectory.listFiles()
296
			xslFiles = xslFiles.sort() { f ->
297
				try {
298
					return Integer.parseInt(f.getName().substring(0, f.getName().indexOf("-")))
299
				} catch(Exception e) {}
300
				return -1;
301
			}
302
			def editionsCreated = [:]
303
			for (File xslFile : xslFiles) {
304
				if (xslFile.isDirectory() || xslFile.isHidden() || !xslFile.getName().endsWith(".xsl")) continue;
305
				if (!xslFile.getName().matches("[1-9]{1,3}-.+")) continue;
306

  
307
				String xslName = xslFile.getName().substring(2); // remove the "1-", "2-", etc.
308
				int idx2 = xslName.indexOf(".")
309
				if (idx2 > 0) xslName = xslName.substring(0, idx2)
310
				else {
311
					println "$xslFile is not a '.xsl' file"
312
					continue;
313
				}
314
				int idx3 = xslName.indexOf("-")
315
				if (idx3 < 0) {
316
					println "$xslFile file does not follow the '{Number}-{editionName}-{step}.xsl' name pattern"
317
					continue;
318
				}
319
				String pagerStep = xslName.substring(idx3 + 1);
320
				String editionName = xslName.substring(0, idx3);
321

  
322
				int idx = editionName.indexOf(".")
323
				if (idx > 0) editionName = editionName.substring(0, idx);
324
				
325
				names << editionName
326
			}
327
		}
328
		return names;
329
	}
330

  
284 331
	/**
285 332
	 * read from $bindir/txm and write the result in $bindir/txm
286 333
	 *

Formats disponibles : Unified diff