Revision 1971 tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy

XTZImporter.groovy (revision 1971)
132 132
		if ("true".equals(cleanDirectories)) {
133 133
			new File(module.getBinaryDirectory(), "tokenized").deleteDir()
134 134
			new File(module.getBinaryDirectory(), "src").deleteDir()
135
			new File(module.getBinaryDirectory(), "split").deleteDir()
135 136
		}
136 137
	}
137 138

  
......
144 145
	 */
145 146
	public boolean doFixSurrogates() {
146 147
		File srcDirectory = new File(module.getBinaryDirectory(), "src")
147
		srcDirectory.mkdir()
148
		
148 149
		def files = inputDirectory.listFiles()
149 150
		if (files == null) {
150 151
			reason = "No file to process in $inputDirectory"
151 152
			return false;
152 153
		}
153

  
154
		srcDirectory.deleteDir() // clean before copying
155
		srcDirectory.mkdir()
156
		
154 157
		for (File file : files) {
155 158
			def outputFile = new File(srcDirectory, file.getName());
156 159
			if (file.getName().toLowerCase().endsWith(".xml")) {
......
171 174
	 *
172 175
	 */
173 176
	public boolean doSplitMergeXSLStep() {
174
		File srcDirectory = new File(module.getBinaryDirectory(), "src")
175
		srcDirectory.mkdir()
176
		xslParams["output-directory"] = srcDirectory.getAbsoluteFile().toURI().toString();
177

  
177
		
178
		File splitedDirectory = new File(module.getBinaryDirectory(), "split")
179
		splitedDirectory.deleteDir()
180
		
178 181
		File xslDirectory = new File(module.getSourceDirectory(), "xsl/1-split-merge")
179 182
		println "-- Split-Merge XSL Step with $xslDirectory"
180 183
		def xslFiles = xslDirectory.listFiles()
181 184
		if (xslDirectory.exists() && xslFiles != null && xslFiles.size() > 0) {
182

  
185
			
186
			splitedDirectory.mkdir()
187
			xslParams["output-directory"] = splitedDirectory.getAbsoluteFile().toURI().toString();
188
			
183 189
			xslFiles.sort()
184 190
			for (File xslFile : xslFiles) {
185 191
				if (xslFile.isDirectory() || xslFile.isHidden() || !xslFile.getName().endsWith(".xsl")) continue;
186 192
				//if (!xslFile.getName().matches("[1-9]-.+")) continue;
187 193

  
188
				if (ApplyXsl2.processImportSources(xslFile, inputDirectory.listFiles(), xslParams, false)) {
194
				if (ApplyXsl2.processImportSources(xslFile, inputDirectory.listFiles(), xslParams)) {
189 195
					println ""
190 196
				} else {
191 197
					reason = "Fail to apply split-merge XSL: $xslPath"
192 198
				}
193 199
				break; // THERE IS ONLY ONE XSL FILE TO APPLY
194 200
			}
195
			inputDirectory = srcDirectory; // the files to process are now in the "src" directory
201
			inputDirectory = splitedDirectory; // the files to process are now in the "src" directory
196 202
		} else {
197 203
			//println "Nothing to do."
198 204
		}
......
248 254
		File frontXSLdirectory = new File(module.getSourceDirectory(), "xsl/2-front")
249 255
		println "-- Front XSL Step with the $frontXSLdirectory directory."
250 256
		def xslFiles = frontXSLdirectory.listFiles()
257
		
258
		xslParams["output-directory"] = outputDirectory.getAbsoluteFile().toURI().toString();
259
		
251 260
		if (frontXSLdirectory.exists() && xslFiles != null && xslFiles.size() > 0) {
252 261

  
253 262
			xslFiles.sort()

Also available in: Unified diff