Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportTextsMetadataMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportTextsMetadataMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportTextsMetadataMacro.groovy	(revision 1948)
@@ -1,13 +1,14 @@
 // STANDARD DECLARATIONS
 package org.txm.macroproto.export
 
+import org.txm.searchengine.cqp.CQPSearchEngine
+import org.txm.searchengine.cqp.corpus.*
 import org.kohsuke.args4j.*
 import groovy.transform.Field
 import org.txm.rcp.swt.widget.parameters.*
-import org.txm.searchengine.cqp.corpus.*
 import org.txm.Toolbox
 
-if (!(corpusViewSelection instanceof Corpus)) {
+if (!(corpusViewSelection instanceof CQPCorpus)) {
 	println "Please select a corpus first"
 	return
 }
@@ -23,7 +24,7 @@
 if (!ParametersDialog.open(this)) return
 
 // BEGINNING
-def Corpus corpus = corpusViewSelection
+CQPCorpus corpus = corpusViewSelection
 def CQI = CQPSearchEngine.getCqiClient()
 def writer = tsvFile.newWriter("UTF-8")
 def internalTextProperties = ["project", "base", "path"]
@@ -40,9 +41,9 @@
 	properties[0] = properties[idi]
 	properties[idi] = tmp
 } else if (idi == -1) {
-println sprintf("** Warning: incoherent metadata content found for %s corpus - no 'id' metadata found", corpus)
-println "** Aborting"
-return
+	println sprintf("** Warning: incoherent metadata content found for %s corpus - no 'id' metadata found", corpus)
+	println "** Aborting"
+	return
 }
 
 // getting values for all texts and all text metadata
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportTextContentMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportTextContentMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportTextContentMacro.groovy	(revision 1948)
@@ -1,8 +1,9 @@
 // STANDARD DECLARATIONS
 package org.txm.macro.export
 
+import org.txm.searchengine.cqp.CQPSearchEngine
 import org.txm.searchengine.cqp.corpus.*
-import org.txm.searchengine.cqp.corpus.query.Query
+import org.txm.searchengine.cqp.corpus.query.CQLQuery
 import org.txm.Toolbox
 import org.txm.utils.i18n.LangFormater;
 import org.apache.commons.lang.StringUtils;
@@ -12,7 +13,7 @@
 
 println "corpora selection: "+corpusViewSelection
 
-if (!(corpusViewSelection instanceof Corpus)) {
+if (!(corpusViewSelection instanceof CQPCorpus)) {
 	println "Please select a corpus"
 	return;
 }
@@ -31,7 +32,7 @@
 
 if (!exportDir.exists()) exportDir.mkdirs()
 
-Corpus corpus = corpusViewSelection
+CQPCorpus corpus = corpusViewSelection
 CQI = CQPSearchEngine.getCqiClient();
 
 def lineSeparatorStructure = corpus.getStructuralUnit(lineSeparatorStructureName)
@@ -41,7 +42,7 @@
 	return;
 }
 
-def breaks_pos = Arrays.asList(corpus.query(new Query("[]</"+lineSeparatorStructureName+">"),"test", false).getEnds())
+def breaks_pos = Arrays.asList(corpus.query(new CQLQuery("[]</"+lineSeparatorStructureName+">"),"test", false).getEnds())
 println breaks_pos
 
 println "Exporting $corpus text content to $exportDir"
@@ -73,7 +74,7 @@
 		if (breaks_pos.contains(p)) words[j] = words[j] +"\n" 
 	}
 	writer.println LangFormater.format(StringUtils.join(words, " "),
-				corpus.getAttribute("lang"));
+				corpus.getLanguage());
 	writer.close();
 }  
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/conversion/EuroPressToXML2018Macro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/conversion/EuroPressToXML2018Macro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/conversion/EuroPressToXML2018Macro.groovy	(revision 1948)
@@ -3,7 +3,7 @@
 
 import groovy.xml.QName
 import java.text.DecimalFormat
-import org.txm.importer.DomUtils
+import org.txm.utils.xml.DomUtils
 import org.txm.importer.ValidateXml
 import org.w3c.tidy.Tidy
 import groovy.util.XmlParser
@@ -13,6 +13,9 @@
 import org.jsoup.Jsoup
 import org.jsoup.nodes.Document.OutputSettings.Syntax
 
+// README
+// This macros needs the following libraries: jsoup-1.11.3.jar and jtidy
+
 // BEGINNING OF PARAMETERS
 
 @Field @Option(name="inputDir", usage="The directory containing the html files, to export from the Europress portal", widget="Folder", required=true, def="")
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/debug/RVersionMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/debug/RVersionMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/debug/RVersionMacro.groovy	(revision 1948)
@@ -1,7 +1,12 @@
 // Copyright © 2016 ENS de Lyon, CNRS, University of Franche-Comté
 // Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
+//
 // @author sheiden
+
 package org.txm.macro.debug
+
+import org.txm.statsengine.r.core.RWorkspace
+
 def r = RWorkspace.getRWorkspaceInstance()
 
 println r.eval("R.version.string").asString()
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/misc/RenameFilesMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/misc/RenameFilesMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/misc/RenameFilesMacro.groovy	(revision 1948)
@@ -1,37 +1,307 @@
+package org.txm.macro.misc
 // STANDARD DECLARATIONS
-package org.txm.macro.misc
 
+// README this macros needs the jtidy JAR library
+
+import groovy.xml.QName
+
+import java.nio.charset.Charset
+import java.text.DecimalFormat
+import org.txm.utils.xml.DomUtils;
+import org.txm.importer.ValidateXml;
+import org.w3c.tidy.Tidy
+import groovy.util.XmlParser
 import org.kohsuke.args4j.*
 import groovy.transform.Field
 import org.txm.rcp.swt.widget.parameters.*
 
 // BEGINNING OF PARAMETERS
+@Field @Option(name="rootDir", usage="The directory contains the 'orig' directory which contains the html files", widget="Folder", required=false, def="/path")
+File rootDir = new File("");
 
-@Field @Option(name="inputDirectory",usage="TXT directory", widget="Folder", required=false, def="txt")
-File inputDirectory;
+@Field @Option(name="encoding", usage="HTML encoding", widget="String", required=false, def="iso-8859-1")
+String encoding = "iso-8859-1" // HTML files encoding
 
-// **change this parameter**
-@Field @Option(name="extension",usage="Regexp de l'extension des fichiers à modifier", widget="String", required=true, def='\\.txt')
-def extension = "\\.trs"
+@Field @Option(name="debug", usage="show debug messages. Values = true, false", widget="String", required=false, def="false")
+def debug = "true" // set true to debug the script
 
-// **change this parameter**
-@Field @Option(name="find",usage="Expression régulière", widget="String", required=true, def='’')
-def find = "Bobine"
-
-// **change this parameter**
-@Field @Option(name="replaceWith",usage="Chaîne de remplacement", widget="String", required=false, def='\'')
-def replaceWith = ""
-
-
 // Open the parameters input dialog box
 if (!ParametersDialog.open(this)) return;
 
+debug = ("true" == debug)
 // END OF PARAMETERS
 
-println "In $inputDirectory..."
-inputDirectory.eachFileMatch(~/.*$extension/) { file ->               // for each file matching extension
-		println " renaming: "+file.getName()
-		String name = file.getName()
-		name = name.replaceAll(find, replaceWith)
-		file.renameTo(new File(file.getParentFile(), name))
-	}
\ No newline at end of file
+String corpusName = rootDir.getName()
+File srcDir = new File(rootDir, "orig");
+File outDir = new File(rootDir, "xhtml");
+File outDir2 = new File(rootDir, corpusName);
+File rejected = new File(rootDir, "duplicates");
+File tmpDir = new File(rootDir, "tmp");
+
+
+if (!srcDir.exists()) {
+	println "STOP, srcDir does not exists $srcDir"
+	return;
+}
+
+outDir.deleteDir()
+outDir.mkdir()
+outDir2.deleteDir()
+outDir2.mkdir()
+rejected.deleteDir()
+rejected.mkdir()
+tmpDir.deleteDir()
+tmpDir.mkdir()
+
+def allTags = new HashSet<String>();
+def allStyles = new HashSet<String>();
+def allClasses = new HashSet<String>();
+def newPrefix = "Numéro de document : "
+int itext = 1;
+def formater = new DecimalFormat("0000");
+int LIMITDIFF = 10
+def metadatas = ["DocPublicationName", "DocHeader"]
+def files = []
+srcDir.eachFileMatch(~/.*\.html/){ htmlFile -> files << htmlFile}
+files = files.sort()
+
+def done = new HashSet<String>();
+def ignored = []
+def allTitles = [:]
+def dones = [:]
+def ignoreds = []
+
+def getText(def node) {
+	//if (debug) println "node: "+node
+	String s = " ";
+	if (node instanceof String) {
+		s += " "+node
+	} else {
+		for(def c : node.children())
+			s += " "+getText(c)
+	}
+	//println " "+s.replace("\n", " ").trim();
+	return " "+s.replace("\n", " ").trim();
+}
+
+println "Nb of HTML files: "+files.size()
+for (File htmlFile : files) {
+	println "Processing file $htmlFile"
+	File tmpHTML = new File(tmpDir, htmlFile.getName())
+	tmpHTML.withWriter("UTF-8") { writer -> 
+		String txt = htmlFile.getText(encoding)
+		txt = txt.replaceAll("<p></p>", " ");
+		txt = txt.replaceAll("<p> </p>", " ");
+		txt = txt.replaceAll("<br>", "<br> ");
+		writer.write(txt)
+	}
+	
+	String name = htmlFile.getName()
+	name = name.substring(0, name.lastIndexOf("."));
+
+	File xhtmlFile = new File(outDir, name+".xhtml")
+
+//	Tidy tidy = new Tidy(); // obtain a new Tidy instance
+//	tidy.setXHTML(true); // set desired config options using tidy setters
+//	tidy.setInputEncoding("UTF-8")
+//	tidy.setOutputEncoding("UTF-8")
+//	tidy.setShowErrors(0)
+//	tidy.setShowWarnings(false)
+	xhtmlFile.withWriter("UTF-8") { out ->
+		def doc = org.jsoup.Jsoup.connect(tmpHTML.toURI().toURL().toString());
+		println "current charset: "+doc.charset()
+		doc.charset(Charset.forName("UTF-8"))
+		println "current charset: "+doc.charset()
+		out.println(doc.outerHtml​())
+	}
+
+	if (ValidateXml.test(xhtmlFile)) {
+		def root = new XmlParser().parse(xhtmlFile)
+		def tables = root.body.table.tbody.tr.td
+		if (tables.size() == 0) tables = root.body.table.tr.td
+		//println "Nb of txt : "+tables.size()
+
+		for (def text : tables) {
+			String sign = ""
+		
+			if (! text instanceof groovy.util.Node) { println "NOT NODE: "+text; continue; }
+			//println "TEXT "
+			//text.setName("text")
+			boolean endOfText = false;
+			def textMetadatas = [:]
+			for (String metadata : metadatas) {
+				textMetadatas[metadata] = ""
+			}
+			for (def subtable : text.table) text.remove(subtable)	
+			
+			for (def p : text.table.p) p.addChild(" ")		
+			
+			for (def child : text.span) {
+				if ("color:red; font-weight:bold".equals(child.@style)) {
+					//text.remove(child)
+					if (debug) "Found bold: "+child
+					child.replaceNode { node -> w(expFound: "y", child.text())}
+				}
+			}
+			
+			def startIgnoringText = false
+			def tmp =""
+			def ichar = 0
+			String title = "";
+			def ignoredText = ""
+			def children = text.children()
+			for (int idx = 0 ; idx < children.size() ; idx++) {
+				
+				def child  = children[idx]
+				if (debug) println "child: $child"
+			
+				if (startIgnoringText) {
+					if (debug) println "Ignoring text : "+ignoredText
+					if (child instanceof String) ignoredText += child
+					else ignoredText += child.text()
+					
+					def t = text.children().remove(idx);
+					//if (tmp.length() > 0) println "removing : "+t
+					idx--
+					continue; // next child
+				}
+			
+				if (child instanceof String) {
+					//println " "+child
+					ichar += child.length()
+				} else {
+					ichar += child.text().length()
+					//		allTags.add(child.name().getLocalPart())
+					//		allClasses.add(child.@class)
+					//		allStyles.add(child.@style)
+					def nn = child.name()
+					
+					try {nn = nn.getLocalPart()} catch(Exception e) {}
+					switch (nn) {
+						case "br": break;
+						case "span":
+						if (debug) println "Found span $child"
+							String classV = child.@class
+							String style = child.@style
+							if (classV != null) {
+								if (metadatas.contains(classV)) {
+									textMetadatas[classV] = (textMetadatas[classV] + " " + child.text()).trim()
+									text.remove(child);
+									idx--
+									//println "METADATA: "+classV + " = "+child.text().trim().length();
+								} else if ("TitreArticleVisu" == classV) {
+									title += getText(child)//.text().trim().replaceAll("\n", " ")+ " "
+									child.name = new QName(child.name().getNamespaceURI(), "head", child.name().getPrefix())
+								} else {
+									println "UNKNOWED CLASS: "+classV + " = "+child.text().trim().length();
+								}
+							} else if (style != null) {
+								if ("color:red; font-weight:bold".equals(style)) {
+									//child.replaceNode { node -> w(expFound: "test")	}
+									//println "KEYWORD: "+child.text().trim();
+								} else {
+									println "UNKNOWED STYLE: '"+style+"' = "+child.text().trim();
+								}
+							} else {
+								println "UNKNOWED SPAN: "+child.text().trim();
+							}
+							break;
+
+						case "a": break
+						case "w": break;
+						case "b":
+							startIgnoringText = true;
+							tmp = child.text()
+							//if (tmp.length() > 0) println "START REMOVING FROM : "+tmp
+							text.remove(child);
+							idx--
+							break;
+						case "i": break;
+						case "font":
+							if (debug) println "Found font $child"
+							String style = child.@style
+							if ("font-style:italic;" == style) {
+								if (debug) println "ITALIC: "+getText(child).trim();
+								child.replaceNode { node -> i(getText(child))}
+							} else if ("font-weight:bold;") {
+								if (debug) println "BOLD: "+getText(child).trim();
+								child.replaceNode { node -> b(getText(child))}
+							} else {
+								println "FSTYLE: '"+style+"' = "+getText(child).trim();
+							}
+							break;
+						default: println child.name()
+					}
+				}
+			}
+			
+			//rename td to text
+			text.name = new QName(text.name().getNamespaceURI(), "text", text.name().getPrefix())
+			
+			//Write metadatas
+			for( String metadata : metadatas) {
+				text.attributes().put(metadata, textMetadatas[metadata])
+				//sign+= " "+textMetadatas[metadata].trim()
+			}
+			
+			// get document number
+			ignoredText = ignoredText.replaceAll("\n", " ")
+			int iNo= ignoredText.indexOf(newPrefix);
+			//println ignoredText
+			if (iNo >= 0) {
+				String no =ignoredText.substring(iNo+newPrefix.length()).trim()
+				text.attributes().put("idnews", no)
+				//sign += " "+no
+				text.attributes().put("date", no.substring(5,9)+"-"+no.substring(9,11)+"-"+no.substring(11,13))
+				text.attributes().put("yyyymmdd", no.substring(5,13))
+				text.attributes().put("yyyymm", no.substring(5,11))
+				text.attributes().put("yyyy", no.substring(5,9))
+				text.attributes().put("mm", no.substring(9,11))
+				text.attributes().put("dd", no.substring(11,13))
+			}
+			
+			//sign += " "+ichar
+			sign += " "+title
+			
+			if (allTitles[title] == null) allTitles[title] = ichar
+			if (Math.abs(allTitles[title] - ichar) > LIMITDIFF) {
+				sign += " "+ichar
+			}
+			File xmlFile;
+			if (done.contains(sign)) {
+				ignored << sign
+				xmlFile = new File(rejected, name+"_"+formater.format((itext++))+".xml")
+				ignoreds << xmlFile.getName()
+			} else {
+				done << sign;
+				xmlFile = new File(outDir2, name+"_"+formater.format((itext++))+".xml")
+				dones[sign] = xmlFile
+			}
+			def writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(xmlFile) , "UTF-8")); //$NON-NLS-1$
+				writer.println "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+				new XmlNodePrinter(writer).print(text)
+		}
+	}
+}
+
+if (ignored.size() > 0) {
+	File ignoredFile = new File (rejected, "ignored.txt");
+	ignoredFile.withWriter("UTF-8") { writer ->
+		writer.println "TOTAL: "+ignored.size()
+		for (int i = 0 ; i < ignored.size() ; i++) {
+			def sign = ignored[i]
+			writer.println "\n**DUPLICATE\n "
+			writer.println "keeped="+dones[sign];
+			writer.println "rejected="+ignoreds[i];
+			writer.println "SIGN="+sign
+			writer.println "\n"
+		}
+	}
+	println "TOTAL IGNORED: "+ignored.size()
+}
+
+println "TOTAL TEXT: $itext"
+if (!debug) {
+	outDir.deleteDir()
+	tmpDir.deleteDir()
+}
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/misc/TXM2CoNLL2009Macro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/misc/TXM2CoNLL2009Macro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/misc/TXM2CoNLL2009Macro.groovy	(revision 1948)
@@ -1,13 +1,14 @@
 package org.txm.macro.misc
-import org.txm.export.conll2009.ToCoNLL2009
 
+import org.txm.scripts.export.conll2009.ToCoNLL2009
+
 import java.io.File;
 import org.txm.searchengine.cqp.corpus.*
 import org.kohsuke.args4j.*
 import groovy.transform.Field
 import org.txm.rcp.swt.widget.parameters.*
 
-if (!(corpusViewSelection instanceof Corpus)) {
+if (!(corpusViewSelection instanceof CQPCorpus)) {
 	println "Select a corpus or a sub-corpus"
 	return;
 }
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/RemoveTag.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/RemoveTag.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/RemoveTag.groovy	(revision 1948)
@@ -1,135 +0,0 @@
-// Copyright © 2010-2013 ENS de Lyon.
-// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
-// Lyon 2, University of Franche-Comté, University of Nice
-// Sophia Antipolis, University of Paris 3.
-// 
-// The TXM platform is free software: you can redistribute it
-// and/or modify it under the terms of the GNU General Public
-// License as published by the Free Software Foundation,
-// either version 2 of the License, or (at your option) any
-// later version.
-// 
-// The TXM platform is distributed in the hope that it will be
-// useful, but WITHOUT ANY WARRANTY; without even the implied
-// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-// PURPOSE. See the GNU General Public License for more
-// details.
-// 
-// You should have received a copy of the GNU General
-// Public License along with the TXM platform. If not, see
-// http://www.gnu.org/licenses.
-// 
-// 
-// 
-// $LastChangedDate:$
-// $LastChangedRevision:$
-// $LastChangedBy:$ 
-//
-package org.txm.macro.edition;
-
-import javax.xml.parsers.*
-import javax.xml.transform.*
-import javax.xml.transform.dom.DOMSource
-import javax.xml.transform.stream.StreamResult
-import javax.xml.xpath.*
-
-import org.txm.metadatas.*
-import org.txm.utils.*
-import org.w3c.dom.Document
-import org.w3c.dom.Element
-
-/**
- * Removes tags of XML file given a XPath. 
- * @author mdecorde
- *
- */
-public class RemoveTag {
-	File outfile
-	String xpath
-	Document doc
-	
-	public RemoveTag(def root, def outfile, def xpath)
-	{
-		this.doc = root
-		this.outfile = outfile
-		this.xpath = xpath
-		
-		process()
-	}
-	
-	/**
-	 *
-	 * @param xmlfile the xmlfile
-	 * @param outfile the outfile
-	 * @param xpath the XPath
-	 */
-	public RemoveTag(File xmlfile, File outfile, String xpath)
-	{
-		this.outfile = outfile
-		this.xpath = xpath
-		
-		def domFactory = DocumentBuilderFactory.newInstance();
-		domFactory.setNamespaceAware(true); // never forget this!
-		DocumentBuilder builder = domFactory.newDocumentBuilder();
-		this.doc = builder.parse(xmlfile);
-		
-		process()
-	}
-	
-	private void process() {
-		def expr = XPathFactory.newInstance().newXPath().compile(xpath);
-		def nodes = expr.evaluate(doc, XPathConstants.NODESET);
-		
-		if (nodes != null)
-		for(def node : nodes)
-		{
-			//println "Remove node "+node
-			Element elem = (Element)node;
-			elem.getParentNode().removeChild(node);
-		}
-		save()
-		doc = null
-	}
-	
-	/**
-	 * Save.
-	 *
-	 * @return true, if successful
-	 */
-	private boolean save()
-	{
-		if (outfile == null) return true;
-	
-		try {
-			// Création de la source DOM
-			Source source = new DOMSource(doc);
-			
-			// Création du fichier de sortie
-				Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8")); 
-			Result resultat = new StreamResult(writer);
-			
-			// Configuration du transformer
-			TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
-			Transformer transformer = fabrique.newTransformer();
-			transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-			transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 
-			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); 
-			
-			// Transformation
-			transformer.transform(source, resultat);
-			writer.close();
-			return true;
-		} catch (Exception e) {
-			org.txm.utils.logger.Log.printStackTrace(e);
-			return false;
-		}
-	}
-	
-	public static void main(String[] args) {
-		RemoveTag rt = new RemoveTag(
-			new File("/home/mdecorde/TXM/corpora/graal/import.xml"),
-			new File("/home/mdecorde/TXM/corpora/graal/import-o.xml"),
-			"//edition[@name='courante']"
-			)
-	}
-}
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/AddFacsAttributeMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/AddFacsAttributeMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/AddFacsAttributeMacro.groovy	(revision 1948)
@@ -1,90 +0,0 @@
-package org.txm.macro.edition
-
-import org.kohsuke.args4j.*
-import groovy.transform.Field
-import org.txm.rcp.swt.widget.parameters.*
-
-try { println "ARGS=$args";} catch(Exception e) {args = [:]}
-
-// BEGINNING OF PARAMETERS
-@Field @Option(name="sourceDirectory", usage="Directory containig XML-TXM or XML SRC files", widget="Folder", required=true, def="src")
-def sourceDirectory
-
-@Field @Option(name="imageDirectory", usage="directory containing the ordered images files in subdirectories", widget="Folder", required=true, def="img")
-def imageDirectory
-
-@Field @Option(name="outputDirectory", usage="Output directory", widget="Folder", required=true, def="out")
-def outputDirectory
-
-@Field @Option(name="element", usage="The element to upgrade", widget="String", required=true, def="pb")
-def element
-
-@Field @Option(name="attribute", usage="The attribute to add", widget="String", required=true, def="facs")
-def attribute
-
-@Field @Option(name="prefix", usage="The image path prefix, if empty then the absolute file path is used", widget="String", required=true, def="../img/")
-def prefix
-
-// Open the parameters input dialog box
-if (args.size() == 0) {
-	if (!ParametersDialog.open(this)) return;
-} else {
-	monitor = args["monitor"];
-	sourceDirectory = args["sourceDirectory"]
-	imageDirectory = args["imageDirectory"]
-	outputDirectory = args["outputDirectory"]
-	element = args["element"]
-	attribute = args["attribute"]
-	prefix = args["prefix"]
-}
-// END OF PARAMETERS
-
-println "Parameters: "
-println " sourceDirectory: $sourceDirectory"
-println " imageDirectory: $imageDirectory"
-println " outputDirectory: $outputDirectory"
-println " element: $element"
-println " attribute: $attribute"
-
-assert(sourceDirectory.exists())
-assert(imageDirectory.exists())
-
-outputDirectory.deleteDir()
-outputDirectory.mkdir()
-
-if (!outputDirectory.exists()) {
-	println "Error: failed to create $outputDirectory"
-	return;
-}
-
-def srcFiles = []
-sourceDirectory.eachFile() { file ->
-	if (!file.isDirectory() && !file.isHidden() && file.getName().endsWith(".xml") && file.getName() != "import.xml") srcFiles << file
-}
-println "srcFiles=$srcFiles"
-
-for (def subdir : imageDirectory.listFiles()) {
-	if (!subdir.isDirectory()) continue;
-	
-	String name = subdir.getName();
-	File srcFile = new File(sourceDirectory, name+".xml")
-	if (!srcFile.exists()) { println "Warning: missing source file: $srcFile"; continue }
-	
-	def imgFiles = subdir.listFiles().sort()
-	if (imgFiles.size() == 0) { println "Warning: no image in $subdir"; continue }
-	
-	def imgPaths = []
-	for (def img : imgFiles) {
-		if (img.isFile() && !img.isHidden()) {
-			if (prefix != null && prefix.length() > 0)
-				imgPaths << prefix+name+"/"+img.getName()
-			else
-				imgPaths << img.getAbsolutePath()
-		}
-	}
-	
-	println "Processing '$name' directory with "+imgPaths.size()+" images."
-	
-	AddAttributeValuesInXML builder = new AddAttributeValuesInXML(srcFile, element, attribute, imgPaths);
-	builder.process(new File(outputDirectory, srcFile.getName()));
-}
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildFacsEditions.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildFacsEditions.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildFacsEditions.groovy	(revision 1948)
@@ -1,168 +0,0 @@
-package org.txm.macro.edition
-
-import org.txm.scripts.importer.*
-import org.xml.sax.Attributes
-import org.txm.importer.scripts.filters.*
-import java.util.ArrayList
-import javax.xml.parsers.*
-import javax.xml.stream.*
-import java.net.URL
-import org.xml.sax.InputSource
-import org.xml.sax.helpers.DefaultHandler
-
-class BuildFacsEditions {
-
-	private def url
-	private def inputData
-	private def factory
-	private XMLStreamReader parser
-	OutputStreamWriter writer
-	StaxStackWriter pagedWriter = null
-
-	File editionDir
-	File xmlFile
-	File htmlFile
-	def pages = []
-	def tag, attribute, txtname, corpusname
-	boolean firstWord
-	boolean cutBefore = true;
-	boolean debug = false;
-	
-	public BuildFacsEditions(File xmlFile, File editionDir, String corpusname, String txtname, String tag, String attribute, boolean debug) {
-		inputData = xmlFile.toURI().toURL().openStream()
-		factory = XMLInputFactory.newInstance()
-		parser = factory.createXMLStreamReader(inputData)
-		
-		this.xmlFile = xmlFile
-		this.editionDir = editionDir
-		this.tag = tag
-		this.attribute = attribute
-		this.txtname = txtname
-		this.debug = debug
-	}
-	
-	int n = 1;
-	private boolean createNextOutput()
-	{
-		try {
-			def tags = closeMultiWriter();
-			for (int i = 0 ; i < tags.size() ; i++) {
-				String tag = tags[i]
-				if ("body" != tag) {
-					tags.remove(i--)
-				} else {
-					tags.remove(i--) // remove "body"
-					break; // remove elements until "body tag
-				}
-			}
-			if (wordid != null) {//wordid = "w_0";
-				//println " add page $n $wordid, page=$pages"
-				pages << ["$n", wordid]
-				n++
-			}
-			// Page suivante
-			
-			htmlFile = new File(editionDir, "${txtname}_${n}.html")
-			firstWord = true
-	//println "SET FIRST WORD=true"
-			pagedWriter = new StaxStackWriter(htmlFile, "UTF-8");
-			if (debug) println "Create file $htmlFile"
-			pagedWriter.writeStartDocument("UTF-8", "1.0")
-			pagedWriter.writeStartElement("html");
-			pagedWriter.writeEmptyElement("meta", ["http-equiv":"Content-Type", "content":"text/html","charset":"UTF-8"]);
-			pagedWriter.writeEmptyElement("link", ["rel":"stylesheet", "type":"text/css","href":"txm.css"]);
-			pagedWriter.writeEmptyElement("link", ["rel":"stylesheet", "type":"text/css","href":"${corpusname}.css"]);
-			pagedWriter.writeStartElement("head");
-			pagedWriter.writeStartElement("title")
-			pagedWriter.writeCharacters(corpusname+" Edition - Page "+n)
-			pagedWriter.writeEndElement(); // </title>
-			pagedWriter.writeEndElement() // </head>
-			pagedWriter.writeStartElement("body") //<body>
-
-			pagedWriter.writeStartElements(tags);
-			
-			wordid = "w_0"; // default value if no word is found
-			return true;
-		} catch (Exception e) {
-			System.out.println(e.getLocalizedMessage());
-			return false;
-		}
-	}
-	
-	private def closeMultiWriter()
-	{
-		if (pagedWriter != null) {
-			def tags = pagedWriter.getTagStack().clone();
-
-			if (firstWord) { // there was no words
-				pagedWriter.writeCharacters("");
-				pagedWriter.write("<span id=\"w_0\"/>");
-			}
-			pagedWriter.writeEndElements();
-			pagedWriter.close();
-			return tags;
-		} else {
-			return [];
-		}
-	}
-	
-	private writeImg(String src) {
-		pagedWriter.writeStartElement("div");
-		pagedWriter.writeEmptyElement("img", ["src":src, "width":"100%"]);
-		pagedWriter.writeEndElement(); // </div>
-	}
-	
-	String wordid = null;
-	public def process() {
-		
-		boolean start = false
-		String localname
-		
-		createNextOutput();
-		
-		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
-			switch (event) {
-				case XMLStreamConstants.START_ELEMENT:
-					localname = parser.getLocalName();
-					switch (localname) {
-						case "text":
-							start = true
-						break;
-						case "w":
-							if (firstWord) {
-								wordid = parser.getAttributeValue(null, "id");
-								//println "found word: $wordid"
-								firstWord = false;
-							}
-						break;
-						case tag:
-							if (debug) println "** TAG $tag $attribute : "+parser.getAttributeValue(null, "id");
-							String imgPath = parser.getAttributeValue(null, attribute);
-							if (imgPath == null) {
-								println "ERROR in $xmlFile no value found for $tag@$attribute at location "+parser.getLocation().getLineNumber()
-							} else {
-								if (cutBefore) {
-									if (debug) println " cut before"
-									createNextOutput()
-									if (debug) println " write img $imgPath"
-									writeImg(imgPath)
-								} else {
-									if (debug) println " write img $imgPath"
-									writeImg(imgPath)
-									if (debug) println " cut after"
-									createNextOutput()
-								}
-							}
-							//firstWord = true;
-						break;
-					}
-				break;
-			}
-		}
-		if (parser != null) parser.close();
-		if (inputData != null) inputData.close();
-		closeMultiWriter()
-		pages << ["$n", wordid] // add the last page (no pb encountered
-		return pages
-	}
-}
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/FacsEditionBuilderMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/FacsEditionBuilderMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/FacsEditionBuilderMacro.groovy	(revision 1948)
@@ -1,207 +0,0 @@
-package org.txm.macro.edition
-
-// STANDARD DECLARATIONS
-
-import org.kohsuke.args4j.*
-import groovy.transform.Field
-import org.txm.rcp.swt.widget.parameters.*
-import org.txm.objects.*
-import org.txm.searchengine.cqp.corpus.*;
-import org.w3c.dom.*
-import org.txm.utils.xml.DomUtils
-import org.txm.Toolbox
-
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-import org.txm.rcp.commands.*
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-
-try { println "ARGS=$args";} catch(Exception e) {args = [:]}
-
-def corpus = null
-if (args.size() == 0) {
-	if (!(corpusViewSelection instanceof MainCorpus)) {
-		println "This marcro works with a MainCorpus selection. Aborting"
-		return;
-	}
-	println "Working on $corpusViewSelection corpus"
-	corpus = corpusViewSelection
-} else {
-	monitor = args["monitor"];
-}
-
-// BEGINNING OF PARAMETERS
-@Field @Option(name="editionName", usage="the edition name to create", widget="String", required=true, def="facs")
-def editionName
-
-@Field @Option(name="tag", usage="The tag to upgrade", widget="String", required=true, def="pb")
-def tag
-
-@Field @Option(name="attribute", usage="The attribute to add", widget="String", required=true, def="facs")
-def attribute
-
-@Field @Option(name="debug", usage="Debug mode", widget="Boolean", required=false, def="true")
-def debug = false
-
-// END OF params
-if (args.size() == 0) {
-	if (!ParametersDialog.open(this)) return;
-} else {
-	monitor = args["monitor"];
-	attribute = args["attribute"]
-	tag = args["tag"]
-	editionName = args["editionName"]
-}
-
-if (args.size() == 0) { // the "corpus" variable exists
-	binDirectory = corpus.getProject().getProjectDirectory()
-	txmDirectory = new File(binDirectory, "txm/"+corpus.getID().toUpperCase())
-	tokenizedDirectory = new File(binDirectory, "tokenized")
-	HTMLDirectory = new File(binDirectory, "HTML")
-	newEditionDirectory = new File(HTMLDirectory, corpus.getID().toUpperCase()+"/"+editionName)
-	params = corpus.getProject().params
-} else { // the "corpus" variable does not exist, get informations from the "args" map
-	binDirectory = args["binDirectory"]
-	txmDirectory = args["txmDirectory"]
-	params = args["params"]
-	tokenizedDirectory = new File(binDirectory, "tokenized")
-	HTMLDirectory = new File(binDirectory, "HTML")
-	corpusName = params.getCorpusName()
-	newEditionDirectory = new File(HTMLDirectory, corpusName.toUpperCase()+"/"+editionName)
-}
-
-println "Parameters:"
-println "	attribute = $attribute"
-println "	tag =  $tag"
-println "	editionName =  $editionName"
-
-if (!HTMLDirectory.exists()) {
-	println "ERROR: can't find this corpus 'HTML' directory: $HTMLDirectory. Aborting"
-	return false;
-}
-
-File workDirectory = txmDirectory
-if (!workDirectory.exists()) {
-	println "XML-TXM directory ($txmDirectory) not found. Using XML tokenized directory instead: "+tokenizedDirectory
-	workDirectory = tokenizedDirectory
-}
-if (!workDirectory.exists()) {
-	println "XML tokenized directory not found: "+tokenizedDirectory
-	println "Aborting."
-	return false
-}
-
-println "Working directory=$workDirectory"
-
-//0- clean previous edition if any : html files, import.xml
-if (newEditionDirectory.exists()) {
-	println "** Old version of $editionName edition found."
-	println " removing the 'edition' reference from the corpus configuration."
-	File tempParam = new File(binDirectory, "import.xml.cpy")
-	RemoveTag rt = new RemoveTag(
-			params.root.getOwnerDocument(), // will be updated
-			null, // don't create a new import.xml
-			"//edition[@name='$editionName']"
-			)
-	println " delete $newEditionDirectory"
-	newEditionDirectory.deleteDir()
-	
-	//printDOM(params.root.getOwnerDocument())
-}
-
-//2- fix import.xml
-println "** Updating corpus configuration..."
-// for edition list
-def corpusElem = params.getCorpusElement()
-params.addEditionDefinition(corpusElem, editionName, "groovy", "FacsEditionBuilderMacro");
-
-//1- create HTML files
-println "** Building new edition HTML files..."
-
-println " Creating edition '$editionName' directory: '$newEditionDirectory'"
-newEditionDirectory.mkdir()
-for (def xmlFile : workDirectory.listFiles()) {
-	if (xmlFile.isHidden() || xmlFile.isDirectory()) continue // ignore
-	String txtname = xmlFile.getName()
-	int idx = txtname.lastIndexOf(".")
-	if (idx > 0) txtname = txtname.substring(0,idx)
-
-	// create a page per "pb" element found in the xml-txm file
-	println " Building HTML pages of text=$txtname"
-	BuildFacsEditions builder = new BuildFacsEditions(xmlFile, newEditionDirectory, params.name, txtname, tag, attribute, debug);
-	def newPages = builder.process()
-	if (newPages == null || newPages.size() == 0) {
-		println "WARNING: no edition files created with $xmlFile"
-	}
-		
-	println " Building edition references in corpus configuration"
-	
-	Element corpusElement = params.getCorpusElement();
-	//println "corpusElement $corpusElement"
-	Element textsElem = params.getTextsElement(corpusElement);
-	//println "textsElem $textsElem"
-	Element textElem = params.getTextElement(textsElem, txtname);
-	if (textElem == null) { // just in case
-		textElem = params.addText(textsElem, txtname, xmlFile)
-	}
-	//println "textElem $textElem with txtname=$txtname"
-	Element editionElem = params.addEdition(textElem, editionName, newEditionDirectory.getAbsolutePath(), "html"); // add a new edition to the "text" node
-	for (def pagedef : newPages) {
-		params.addPage(editionElem, pagedef[0], pagedef[1]);
-	}
-}
-
-//printDOM(params.root.getOwnerDocument())
-
-//3- Save and reload the corpus
-println " Saving corpus configuration..."
-File paramFile = new File(binDirectory, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);
-
-
-//4- Reload Corpora
-if (args.size() == 0) {
-	Toolbox.restart();
-	monitor.syncExec(new Runnable() {
-				public void run() {
-					RestartTXM.reloadViews();
-				}
-			});
-}
-
-//5- Done
-println "New edition created."
-
-//printDOM(params.root.getOwnerDocument())
-
-
-
-def printDOM(def doc) {
-	if (!debug) return;
-	try {
-		// Création de la source DOM
-		Source source = new DOMSource(doc);
-		
-		// Création du fichier de sortie
-		StreamResult resultat = new StreamResult(new PrintWriter(System.out));
-		
-		// Configuration du transformer
-		TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
-		Transformer transformer = fabrique.newTransformer();
-		transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
-		transformer.setOutputProperty(OutputKeys.INDENT, "yes");  //$NON-NLS-1$
-		transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");  //$NON-NLS-1$
-		
-		// Transformation
-		transformer.transform(source, resultat);
-		// writer.close();
-		return true;
-	} catch (Exception e) {
-		e.printStackTrace();
-		return false;
-	}
-}
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/EditionUpdaterMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/EditionUpdaterMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/EditionUpdaterMacro.groovy	(revision 1948)
@@ -1,263 +0,0 @@
-package org.txm.macro.edition
-// STANDARD DECLARATIONS
-
-import org.kohsuke.args4j.*
-import groovy.transform.Field
-import org.txm.rcp.swt.widget.parameters.*
-import org.txm.objects.*
-import org.txm.searchengine.cqp.corpus.*;
-import org.w3c.dom.*
-import org.txm.scripts.importer.*
-import org.txm.Toolbox
-import java.io.*
-
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-import org.txm.rcp.commands.*
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.txm.utils.io.FileCopy
-
-try { println "ARGS=$args";} catch(Exception e) {args = [:]}
-
-def corpus = null
-if (args.size() == 0) {
-	if (!(corpusViewSelection instanceof MainCorpus)) {
-		println "This marcro works with a MainCorpus selection. Aborting"
-		return;
-	}
-	println "Working on $corpusViewSelection corpus"
-	corpus = corpusViewSelection
-} else {
-	monitor = args["monitor"];
-}
-
-// BEGINNING OF params
-
-@Field @Option(name="xslEdition", usage="XSL to build the HTML edition - if empty uses 'txm-edition-xtz.xsl'", widget="File", required=false, def="txm-edition-xtz.xsl")
-def xslEdition
-
-@Field @Option(name="xslPages", usage="XSL to build the edition pages - if empty uses 'txm-edition-page-split.xsl'", widget="File", required=false, def="txm-edition-page-split.xsl")
-def xslPages
-
-@Field @Option(name="editionName", usage="The edition name to produce", widget="String", required=false, def="default")
-String editionName
-
-@Field @Option(name="useTokenizedDirectory", usage="Use the 'XML/w' of the 'tokenized' directory instead of the 'XML-TXM' files", widget="Boolean", required=false, def="false")
-def useTokenizedDirectory = false
-
-@Field @Option(name="debug", usage="Enable debug mode: temporary files are not deleted", widget="Boolean", required=false, def="false")
-def debug = false
-
-// END OF params
-if (args.size() == 0) {
-	if (!ParametersDialog.open(this)) return;
-} else {
-	monitor = args["monitor"];
-	xslEdition = new File(args["xslEdition"])
-	xslPages = new File(args["xslPages"])
-	editionName = args["editionName"]
-	useTokenizedDirectory = args["useTokenizedDirectory"]
-}
-
-if (args.size() == 0) { // corpus informations
-	defaultEditionName = corpus.getDefaultEdition()
-	corpusName = corpus.getID()
-	binDirectory = corpus.getProject().getProjectDirectory()
-	txmDirectory = new File(binDirectory, "txm/"+corpusName.toUpperCase())
-	params = corpus.getProject().params
-} else { // the "corpus" variable does not exists
-	defaultEditionName = "default"
-	binDirectory = args["binDirectory"]
-	txmDirectory = args["txmDirectory"]
-	params = args["params"]
-	corpusName = params.getCorpusName()
-}
-
-if (editionName == null || editionName.length() == 0) {
-	editionName = defaultEditionName
-}
-println "Parameters:"
-println "	xslEdition = $xslEdition"
-println "	xslPages = $xslPages"
-println "	editionName = $editionName"
-println "	useTokenizedDirectory = $useTokenizedDirectory"
-
-File TXMHOME = new File(Toolbox.getTxmHomePath())
-File xslDirectory = new File(TXMHOME, "xsl")
-if (xslEdition == null || xslEdition.getName() == "txm-edition-xtz.xsl")
-	xslEdition = new File(xslDirectory, "txm-edition-xtz.xsl")
-if (xslPages == null || xslPages.getName() == "txm-edition-page-split.xsl")
-	xslPages = new File(xslDirectory, "txm-edition-page-split.xsl")
-
-println "XSLs: "+xslEdition.getName()+" & "+ xslPages.getName()
-println ""
-
-
-if (useTokenizedDirectory) {
-	println "Using the 'tokenized' directory instead of the 'txm' directory to get XML files"
-	txmDirectory = new File(binDirectory, "tokenized")
-}
-File HTMLDirectory = new File(binDirectory, "HTML")
-File HTMLCorpusDirectory = new File(HTMLDirectory, corpusName.toUpperCase())
-File defaultEditionDirectory = new File(HTMLCorpusDirectory, editionName)
-
-File cssDirectory = new File(TXMHOME, "css")
-File cssDefaultEditionDirectory = new File(defaultEditionDirectory, "css")
-File cssTXM = new File(cssDirectory, "txm.css")
-File cssTEI = new File(cssDirectory, "tei.css")
-boolean newEdition = false;
-
-if (!txmDirectory.exists()) {
-	println "ERROR: can't find this corpus 'txm' directory: $txmDirectory. Aborting"
-	return false;
-}
-if (!defaultEditionDirectory.exists()) {
-	println "This is a new edition"
-	newEdition = true;
-	defaultEditionDirectory.mkdir()
-	if (!defaultEditionDirectory.exists()) {
-		println "HTML directory could be created: $defaultEditionDirectory. Aborting"
-		return false
-	}
-}
-if (!cssTXM.exists()) {
-	println "WARNING: can't find the $cssTXM CSS file. Aborting"
-	return false;
-}
-if (!cssTEI.exists()) {
-	println "WARNING: can't find the $cssTEI CSS file. Aborting"
-	return false;
-}
-if (!xslEdition.exists()) {
-	println "Error: can't find $xslEdition XSL file"
-	return false;
-}
-if (!xslPages.exists()) {
-	println "Error: can't find $xslPages XSL file"
-	return false;
-}
-
-defaultEditionDirectory.mkdir()
-cssDefaultEditionDirectory.mkdir()
-FileCopy.copy(cssTXM, new File(cssDefaultEditionDirectory, cssTXM.getName()))
-FileCopy.copy(cssTEI, new File(cssDefaultEditionDirectory, cssTEI.getName()))
-
-//1- Back up current "HTML" directory
-if (!newEdition) {
-	File backupDirectory = new File(binDirectory, "HTML-"+defaultEditionDirectory.getName()+"-back")
-	backupDirectory.mkdir()
-	println "Backup of $defaultEditionDirectory directory to $backupDirectory..."
-	for (File f : defaultEditionDirectory.listFiles()) {
-		String name = f.getName()
-		if (f.isDirectory() || f.isHidden()) continue
-		
-		File rez = new File(backupDirectory, f.getName())
-		
-		if (debug) println " file $f >> $rez"
-		else print "."
-		
-		if (!FileCopy.copy(f, rez)) {
-			println "Error: failed to backup $f"
-			return false;
-		}
-	}
-	println ""
-}
-
-//2- Apply edition XSL
-println "Applying XSL 1: $xslEdition..."
-ApplyXsl2 applier = new ApplyXsl2(xslEdition);
-def htmlFiles = []
-for (File f : txmDirectory.listFiles()) {
-	String name = f.getName()
-	String txtname = name.substring(0, name.lastIndexOf("."));
-	File rez = new File(HTMLCorpusDirectory, txtname+".html")
-
-	if (!f.isDirectory() && !f.isHidden() && name.endsWith(".xml") && !name.equals("import.xml")) {
-	
-		if (debug) println " file $f >> $rez"
-		else print "."
-	
-		if (!applier.process(f, rez)) {
-			println "Error: failed to process $f"
-			return false
-		} else {
-			htmlFiles << rez
-		}
-	}
-}
-println ""
-
-//3- Apply pages XSL
-println "Applying XSL 2: $xslPages..."
-ApplyXsl2 applier2 = new ApplyXsl2(xslPages);
-applier2.setParam("editionname", editionName)
-applier2.setParam("cssname", corpusName)
-for (File f : htmlFiles) {
-	String name = f.getName()
-	String txtname = name.substring(0, name.lastIndexOf("."));
-	File rez = new File(defaultEditionDirectory, txtname+"-pages.html")
-	
-	if (debug) println " file $f >> $rez"
-	else print "."
-	
-	if (!applier2.process(f, rez)) {
-		println "Error: failed to process $f"
-		return false
-	} else {
-		if (!debug) rez.delete()
-	}
-}
-println ""
-
-// clean temp files
-if (!debug) {
-	for (File f : htmlFiles) {
-		f.delete()
-	}
-}
-
-//4- register new edition if any (copy edition)
-
-if (editionName != defaultEditionName) {
-	println "Update corpus configuration"
-	
-	// remove edition declaration if any
-	RemoveTag rt = new RemoveTag(
-			params.root.getOwnerDocument(), // will be updated
-			null, // don't create a new import.xml
-			"//edition[@name='$editionName']"
-			)
-
-	def corpusElem = params.getCorpusElement()
-	params.addEditionDefinition(corpusElem, editionName, "xsl", "XSLEditionBuilder"); // declare the new edition
-	
-	for (def text : corpus.getTexts()) {
-		Element textElem = text.getSelfElement()
-		def defaultEdition = text.getEdition(defaultEditionName)
-		if (defaultEdition == null) { println "Error: no default edition with name="+defaultEditionName; return false} 
-		Element editionElem = params.addEdition(textElem, editionName, defaultEditionDirectory.getAbsolutePath(), "html");
-		def pages = defaultEdition.getPages()
-		for (int i = 1 ; i <= pages.size() ; i++) {
-			def page = pages[i-1]
-			params.addPage(editionElem, "$i", page.getWordId());
-		}
-	}
-	
-	File paramFile = new File(binDirectory, "import.xml");
-	DomUtils.save(params.root.getOwnerDocument(), paramFile);
-}
-
-//5- Reload Corpora
-if (args.size() == 0) { // the user run the macro
-	Toolbox.restart();
-	monitor.syncExec(new Runnable() {
-			public void run() {
-				RestartTXM.reloadViews();
-			}
-		});
-}
-println "New edition created."
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/AddAttributeValuesInXML.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/AddAttributeValuesInXML.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/AddAttributeValuesInXML.groovy	(revision 1948)
@@ -1,88 +0,0 @@
-package org.txm.macro.edition
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import org.txm.scripts.importer.*
-
-/**
- * Add a attribute value map in a XML file
- * Warning: if an attribute already exists its value won't be changed
- */
-class AddAttributeValuesInXML extends StaxIdentityParser {
-	File xmlFile;
-	String tag, attribute;
-	List<String> values;
-	HashMap<String, String> attributesMap;
-	boolean result;
-
-	public AddAttributeValuesInXML(File xmlFile, String tag, String attribute, List<String> values)
-	{
-		super(xmlFile.toURI().toURL());
-		this.xmlFile = xmlFile;
-		this.tag = tag;
-		this.attribute = attribute;
-		this.values = values;
-	}
-
-	public boolean process(File outfile) {
-		this.result = false;
-		boolean ret = super.process(outfile)
-		return this.result & ret;
-	}
-
-	
-	/**
-	 * Rewrite the processStartElement() to update/add attributes
-	 */
-	int n = 0;
-	public void processStartElement()
-	{
-		if (localname != tag) {
-			super.processStartElement()
-		} else {
-			String prefix = parser.getPrefix();
-//TODO: uncomment for TXM 0.7.6
-//			if (INCLUDE == localname && XI == prefix) {
-//				processingXInclude();
-//				return;
-//			}
-
-			if (prefix.length() > 0)
-				writer.writeStartElement(Nscontext.getNamespaceURI(prefix), localname)
-			else
-				writer.writeStartElement(localname);
-
-			for (int i = 0 ; i < parser.getNamespaceCount() ; i++) {
-				writer.writeNamespace(parser.getNamespacePrefix(i), parser.getNamespaceURI(i));
-			}
-
-			// get attributes
-			HashMap<String, String> attributes = new HashMap<String, String>();
-			for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
-				attributes[parser.getAttributeLocalName(i)] = parser.getAttributeValue(i);
-			}
-			// add/update the value
-			if (n < values.size()) {
-				attributes[attribute] = values[n]; 
-			} else {
-				println "ERROR: not enough values to insert for file $xmlFile, at XML parser location: l="+parser.getLocation().getLineNumber()+",c="+parser.getLocation().getColumnNumber()+")."
-			}
-			n++
-			
-			// write attributes
-			for (def k : attributes.keySet()) {
-				writer.writeAttribute(k, attributes[k])
-			}
-		}
-	}
-	
-	@Override
-	public void after() {
-		super.after();
-		
-		if (n != values.size()) {
-			println "ERROR: number of $tag ("+n+") missmatch the number of values to insert: "+values.size()
-		}
-	}
-}
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildXTZEditions.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildXTZEditions.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildXTZEditions.groovy	(revision 1948)
@@ -1,146 +0,0 @@
-package org.txm.macro.edition
-
-import org.txm.scripts.importer.*
-import org.xml.sax.Attributes
-import org.txm.importer.scripts.filters.*
-import java.util.ArrayList
-import javax.xml.parsers.*
-import javax.xml.stream.*
-import java.net.URL
-import org.xml.sax.InputSource
-import org.xml.sax.helpers.DefaultHandler
-
-class BuildXTZEditions {
-
-	private def url
-	private def inputData
-	private def factory
-	private XMLStreamReader parser
-	OutputStreamWriter writer
-	StaxStackWriter pagedWriter = null
-
-	File editionDir
-	File xmlFile
-	File htmlFile
-	def pages = []
-	def txtname, corpusname
-	int wordsPerPage = 500
-	boolean firstWord
-	boolean cutBefore = true;
-	
-	public BuildFacsEditions(File xmlFile, File editionDir, String corpusname, String txtname, int wordsPerPage) {
-		inputData = xmlFile.toURI().toURL().openStream()
-		factory = XMLInputFactory.newInstance()
-		parser = factory.createXMLStreamReader(inputData)
-		
-		this.xmlFile = xmlFile
-		this.editionDir = editionDir
-		this.txtname = txtname
-		this.wordsPerPage = wordsPerPage
-	}
-	
-	int n = 0;
-	private boolean createNextOutput()
-	{
-		try {
-			def tags = closeMultiWriter();
-			for (int i = 0 ; i < tags.size() ; i++) {
-				String tag = tags[i]
-				if ("body" != tag) {
-					tags.remove(i--)
-				} else {
-					tags.remove(i--) // remove "body"
-					break; // remove elements until "body tag
-				}
-			}
-			n++
-			htmlFile = new File(editionDir, "${txtname}_${n}.html")
-			firstWord = true
-
-			pagedWriter = new StaxStackWriter(htmlFile, "UTF-8");
-
-			pagedWriter.writeStartDocument("UTF-8", "1.0")
-			pagedWriter.writeStartElement("html");
-			pagedWriter.writeEmptyElement("meta", ["http-equiv":"Content-Type", "content":"text/html","charset":"UTF-8"]);
-			pagedWriter.writeEmptyElement("link", ["rel":"stylesheet", "type":"text/css","href":"txm.css"]);
-			pagedWriter.writeEmptyElement("link", ["rel":"stylesheet", "type":"text/css","href":"${corpusname}.css"]);
-			pagedWriter.writeStartElement("head");
-			pagedWriter.writeStartElement("title")
-			pagedWriter.writeCharacters(corpusname+" Edition - Page "+n)
-			pagedWriter.writeEndElement(); // </title>
-			pagedWriter.writeEndElement() // </head>
-			pagedWriter.writeStartElement("body") //<body>
-
-			pagedWriter.writeStartElements(tags);
-			return true;
-		} catch (Exception ee) {
-			System.out.println(ee);
-			return false;
-		}
-	}
-	
-	private def closeMultiWriter()
-	{
-		if (pagedWriter != null) {
-			def tags = pagedWriter.getTagStack().clone();
-
-			if (firstWord) { // there was no words
-				pagedWriter.writeCharacters("");
-				pagedWriter.write("<span id=\"w_0\"/>");
-				pages << ["$n", "w_0"]
-			}
-			pagedWriter.writeEndElements();
-			pagedWriter.close();
-			return tags;
-		} else {
-			return [];
-		}
-	}
-	
-	private writeImg(String src) {
-		pagedWriter.writeStartElement("div");
-		pagedWriter.writeEmptyElement("img", ["src":src]);
-		pagedWriter.writeEndElement(); // </div>
-	}
-	
-	public def process() {
-		String wordid = "w_0"
-		boolean start = false
-		String localname
-		
-		createNextOutput();
-		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
-			switch (event) {
-				case XMLStreamConstants.START_ELEMENT:
-					localname = parser.getLocalName();
-					switch (localname) {
-						case "text":
-							start = true
-						break;
-						case "w":
-							if (firstWord) {
-								wordid = parser.getAttributeValue(null, "id");
-								firstWord = false;
-							}
-						break;
-						case "pb":
-							if (cutBefore) {
-								pages << ["$n", wordid]
-								// WRITE PB
-								createNextOutput()
-							} else {
-								createNextOutput()
-								pages << ["$n", wordid]
-								// WRITE PB
-							}
-						break;
-					}
-				break;
-			}
-		}
-		closeMultiWriter()
-		if (parser != null) parser.close();
-		if (inputData != null) inputData.close();
-		return pages
-	}
-}
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/imports/ExecuteImportScriptMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/imports/ExecuteImportScriptMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/imports/ExecuteImportScriptMacro.groovy	(revision 1948)
@@ -1,38 +0,0 @@
-package org.txm.macro.imports
-
-import org.kohsuke.args4j.*
-import groovy.transform.Field
-import org.txm.rcp.swt.widget.parameters.*
-import org.txm.rcp.commands.*
-
-@Field @Option(name="scriptFile", usage="an example file", widget="File", required=true, def="xxxLoader.groovy")
-File scriptFile
-
-@Field @Option(name="paramFile", usage="an example file", widget="File", required=true, def="import.xml")
-File paramFile
-
-if (!ParametersDialog.open(this)) return;
-
-File script = scriptFile // if not done, using scriptFile raise a Cast exception to 'groovy.lang.Reference'
-File param = paramFile
-if (!script.getName().endsWith(".groovy")) {
-	println "Error: the selected file is not a Groovy script: $script"
-	return
-}
-if (!param.getName().endsWith(".xml")) {
-	println "Error: the selected file is not a XML import parameter file: $param"
-	return
-}
-
-println "Runnin import with $scriptFile and $paramFile"
-
-monitor.syncExec(new Runnable() {
-	public void run() {
-		try {
-			String path = script.getAbsolutePath()
-			ExecuteImportScript.executeScript(script.getAbsolutePath(), param);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-});
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/imports/TeiHeader2MetadataCSVMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/imports/TeiHeader2MetadataCSVMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/imports/TeiHeader2MetadataCSVMacro.groovy	(revision 1948)
@@ -100,3 +100,4 @@
 
 writer.close()
 
+println "Done: "+CSVoutputFile.getAbsolutePath()
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/utils/ApplyPropertiesMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/utils/ApplyPropertiesMacro.groovy	(revision 0)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/utils/ApplyPropertiesMacro.groovy	(revision 1948)
@@ -0,0 +1,98 @@
+// Copyright © 2017 ENS de Lyon, CNRS, University of Franche-Comté
+// Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
+// @author sheiden
+
+package org.txm.macro.utils
+
+import org.kohsuke.args4j.*
+import groovy.transform.Field
+import org.txm.rcpapplication.swt.widget.parameters.*
+import org.txm.utils.Timer
+import org.txm.importer.XPathResult
+
+@Field @Option(name="propertiesFile", usage="properties parameter file", widget="File", required=true, def="")
+def propertiesFile
+
+@Field @Option(name="macroFile", usage="macro .groovy file", widget="File", required=true, def="")
+def macroFile
+
+// Open the parameters input dialog box
+if (!ParametersDialog.open(this)) return 1
+
+def scriptName = this.class.getSimpleName()
+
+params = new Properties()
+if (propertiesFile.exists() && propertiesFile.canRead()) {
+	props = new InputStreamReader(new FileInputStream(propertiesFile) , "UTF-8")
+	params.load(props)
+	props.close()
+} else {
+	println "** $scriptName: '$propertiesFile' file not readable."
+	return 1
+}
+
+macro = macroFile.getName()
+macro = macro.substring(0, macro.lastIndexOf(".groovy"))
+
+pkg = macroFile.getParentFile().getAbsolutePath()
+pkg = pkg.substring(pkg.indexOf("/TXM/scripts/macro/")+"/TXM/scripts/macro/".length())
+pkg = pkg.replace("/", ".")
+
+fullclassname = "$pkg.$macro"
+println "Calling $fullclassname..."
+
+clazz = Class.forName(fullclassname)
+if (clazz == null) {
+	println "** Class for name=$fullclassname not found. Aborting."
+	return
+}
+
+for (def f : clazz.getDeclaredFields()) {
+	def parameter = f.getAnnotation(Option.class);
+	if (parameter == null || parameter.widget() == null || parameter.name() == null) {
+		continue
+	}
+	
+	String name = parameter.name()
+	if (params.get(name) == null) continue
+	
+	String strValue = params.get(name)
+	String widget = parameter.widget()
+
+	switch(widget) {
+		case "File":
+		case "FileOpen":
+		case "FileSave":
+		case "Folder":
+			params.put(name, new File(strValue))
+			break;
+//		case "Date":
+//			params.put(name, ...)
+//			break
+		case "Float":
+			params.put(name, Float.parseFloat(strValue))
+			break
+		case "Integer":
+			params.put(name, Integer.parseInt(strValue))
+			break
+		case "String":
+		case "Text":
+			break
+		case "Boolean":
+			params.put(name, Boolean.parseBoolean(strValue))
+			break
+	}
+}
+
+res = gse.run(clazz, [
+	"args":params,
+				"selection":selection,
+				"selections":selections,
+				"corpusViewSelection":corpusViewSelection,
+				"corpusViewSelections":corpusViewSelections,
+				"monitor":monitor,
+				"editor":editor,
+				"stringArgs":stringArgs,
+				"timer":timer])
+
+if (!res) println "** $scriptName: problem calling $macro."
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/commands/CrossedPartitionBuilderMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/commands/CrossedPartitionBuilderMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/commands/CrossedPartitionBuilderMacro.groovy	(revision 1948)
@@ -6,16 +6,18 @@
 
 import org.txm.rcp.swt.widget.parameters.*
 import org.txm.searchengine.cqp.corpus.*
-import org.txm.utils.logger.Log;
+import org.txm.searchengine.cqp.corpus.Partition
+import org.txm.utils.logger.Log
 import org.txm.rcp.views.*
 
 //BEGINNING OF PARAMETERS
-def corpus = corpusViewSelection
-if (!(corpus instanceof Corpus)) {
+if (!(corpusViewSelection instanceof CQPCorpus)) {
 	println "Error: this macro should be run with a Corpus selected"
 	return
 }
 
+corpus = corpusViewSelection
+
 @Field @Option(name="structuralUnit", usage="the structural Unit to use", widget="String", required=true, def="text")
 String structuralUnit = "text"
 
@@ -46,7 +48,7 @@
  * Create partition with advanced CQL queries and autoname the parts.
  * Can create partitions by defining a multi-level structural units hierarchy or by defining several properties values for one structural unit.
  * Can define some structural units to remove from the resulting parts subcorpus.
- * 
+ *
  */
 
 // TODO: add this variables to the macro parameters
@@ -156,7 +158,7 @@
 	 * Init the generator and process.
 	 * @param corpusName
 	 */
-	public Partition createPartition(Corpus corpus, boolean debug,
+	public Partition createPartition(CQPCorpus corpus, boolean debug,
 			String partitionName, String partNamePrefix,
 			def structuralUnits, def structuralUnitProperties,
 			def structuralUnitToIgnore, String expandTarget) 	{
@@ -213,7 +215,10 @@
 
 			// Creating the partition
 			if (!DEBUG  && queries.size() == partNames.size()) {
-				return corpus.createPartition(PARTITION_NAME, queries, partNames);
+				Partition partition = new Partition(corpus)
+				partition.setParameters(PARTITION_NAME, queries, partNames);
+				partition.compute()
+				return partition
 			}
 		} else {
 			println "Error: Structural units count or structural units properties count error.";
@@ -222,13 +227,13 @@
 	}
 
 	/**
-	 * Recurse through structural units and structural units properties of corpus and create the queries and the part names. 
+	 * Recurse through structural units and structural units properties of corpus and create the queries and the part names.
 	 * @param corpus the corpus or subcorpus
 	 * @param index the index for recursion
 	 * @param tmpQuery the temporary query for creating subcorpus part
 	 * @param tmpPartName the temporary part name of the subcorpus part
 	 */
-	protected void process(Corpus corpus, int index, String tmpQuery, String tmpPartName)	{
+	protected void process(CQPCorpus corpus, int index, String tmpQuery, String tmpPartName)	{
 		// End of array
 		if (index >= STRUCTURAL_UNITS.size()) {
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/commands/AdvancedPartitionMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/commands/AdvancedPartitionMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/commands/AdvancedPartitionMacro.groovy	(revision 1948)
@@ -5,19 +5,18 @@
 package org.txm.macro.commands
 
 // STANDARD DECLARATIONS
-
 import org.txm.rcpapplication.swt.widget.parameters.*
 import org.txm.searchengine.cqp.corpus.*
-import org.txm.rcpapplication.views.CorporaView
+import org.txm.rcp.views.corpora.CorporaView
 
 def scriptName = this.class.getSimpleName()
 
-if (!(corpusViewSelection instanceof Corpus)) {
+if (!(corpusViewSelection instanceof CQPCorpus)) {
 	println "** $scriptName: please select a Corpus in the Corpus view."
 	return 0
 }
 
-def corpus = corpusViewSelection
+CQPCorpus corpus = corpusViewSelection
 
 // PARAMETERS ...................................
 // - NAME: name of the partition to build
@@ -54,7 +53,9 @@
 	
 	println "Building partition on $corpus (size = "+(corpus.getSize())+")."
 	
-	partition = corpus.createPartition(NAME, QUERIES, PARTNAMES)
+	partition = new Partition(corpus)
+	partition.setParameters(NAME, QUERIES, PARTNAMES)
+	partition.compute()
 	
 	def list = Arrays.asList(partition.getPartSizes())
 
@@ -72,4 +73,3 @@
 	println "** $scriptName: PARTNAMES.size() != QUERIES.size(), ("+PARTNAMES.size()+" != "+QUERIES.size()+")."
 	return 0
 }
-
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/r/ExecRMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/r/ExecRMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/r/ExecRMacro.groovy	(revision 1948)
@@ -20,9 +20,7 @@
 	((Index)sel).asRMatrix()
 	symbol = "t("+((Index)sel).getSymbol()+'$data)'
 	prop = ((Index)sel).getProperties().toString()
-}
-
-if (symbol == null) {
+} else {
 	println "Selection is not an Index. Aborting."
 	return
 }
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/BuildWordPropTableMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/BuildWordPropTableMacro.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/BuildWordPropTableMacro.groovy	(revision 1948)
@@ -34,16 +34,21 @@
 import org.txm.functions.concordances.*
 import org.txm.functions.concordances.comparators.*
 import org.txm.searchengine.cqp.ReferencePattern
+
+import java.util.List
+
 import org.kohsuke.args4j.*
 import groovy.transform.Field
 import org.txm.rcp.swt.widget.parameters.*
 
-def corpus = corpusViewSelection
-if (!(corpus instanceof Corpus)) {
+if (!(corpusViewSelection instanceof CQPCorpus)) {
 	println "Error: you must select a corpus or a subcorpus to export properties"
 	return false;
 }
 
+CQPCorpus corpus = corpusViewSelection
+
+
 @Field @Option(name="properties", usage="columns to inject separated by commas", widget="String", required=true, def="p1, p2, ... , pn")
 		def properties = "pos"
 
@@ -134,8 +139,9 @@
 //query = new Query(Query.fixQuery(query))
 def viewprops = [word]
 viewprops.addAll(annots)
-def concordance = new Concordance(corpus, query, word, viewprops, referencePattern, referencePattern, leftcontextsize, rightcontextsize)
-
+Concordance concordance = new Concordance(corpus)
+concordance.setParameters(query, [word], [word], [word], viewprops, viewprops, viewprops, referencePattern, referencePattern, leftcontextsize, rightcontextsize)
+concordance.compute()
 //println "Conc done "+(System.currentTimeMillis()-start)
 
 def writer = tsvFile.newWriter("UTF-8");
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/setup/FixFeaturePluginDeclaration.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/setup/FixFeaturePluginDeclaration.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/setup/FixFeaturePluginDeclaration.groovy	(revision 1948)
@@ -6,11 +6,11 @@
 
 
 String home = System.getProperty("user.home")
-File rcpSrc = new File(home, "workspace441/org.txm.rcp")
-File productFile = new File(rcpSrc, "rcp.product")
+File rcpSrc = new File(home, "workspace047/org.txm.rcp.feature")
+File productFile = new File(rcpSrc, "feature.xml")
 
 //File dir = new File("/home/mdecorde/ECLIPSE/babel/babel-kepler/features/org.eclipse.babel.nls_eclipse_ru_4.3.0.v20131123020001")
-File dir = new File("/home/matthieu/ECLIPSE/eclipse_babel/features/org.eclipse.babel.nls_eclipse_ru_4.4.0.v20150804100819")
+File dir = new File(home, "workspace047/babel/eclipse/features/org.eclipse.babel.nls_eclipse_fr_4.7.0.v20190126095834")
 
 File origFeatureFile = new File(dir, "feature_orig.xml") // will be created if not, and parsed
 File featureFile = new File(dir, "feature.xml")
@@ -25,9 +25,11 @@
 // get used plugin IDs
 def product = slurper.parse(productFile.toURI().toString())
 def usedPlugins = new HashSet<String>()
-for (def plugin : product.plugins.plugin) {
-	usedPlugins.add(plugin.@id)
+
+for (def plugin : product.requires.import) {
+	usedPlugins.add(plugin.@plugin)
 }
+
 println "Number of plugins declared in product: "+usedPlugins.size()
 
 // Fix feature : remove unused plugins and fix @os @ws @arch and @nl attributes
@@ -80,11 +82,10 @@
 //	}
 	
 	if (remove) {
-		plugin.replaceNode {}
+		plugin.parent().remove(plugin)
+	} else if (!usedPlugins.contains(hostid)) {
+		plugin.parent().remove(plugin)
 	}
-//	if (!usedPlugins.contains(hostid)) {
-//		plugin.replaceNode {}
-//	}
 }
 
 println "WRITE RESULT FEATURE"
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/export/conll2009/ToCoNLL2009.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/export/conll2009/ToCoNLL2009.groovy	(revision 1947)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/export/conll2009/ToCoNLL2009.groovy	(revision 1948)
@@ -8,9 +8,8 @@
 import java.util.List;
 
 import org.txm.searchengine.cqp.CqpDataProxy;
-import org.txm.searchengine.cqp.corpus.Corpus
 import org.txm.searchengine.cqp.corpus.*
-import org.txm.searchengine.cqp.corpus.query.Query
+import org.txm.searchengine.cqp.corpus.query.CQLQuery
 
 class ToCoNLL2009 {
 
@@ -27,9 +26,9 @@
 	 * @param encoding the encoding of the outfile
 	 * @return true, if successful
 	 */
-	public boolean process(File outfile, Corpus corpus, StructuralUnitProperty sentenceUnit, Property word, Property lemme, Property pos, String encoding)
+	public boolean process(File outfile, CQPCorpus corpus, StructuralUnitProperty sentenceUnit, Property word, Property lemme, Property pos, String encoding)
 	{
-		def matches = corpus.query(new Query("<s> []+ </s>"), "TMPEXPORTCONNL", false).getMatches()
+		def matches = corpus.query(new CQLQuery("<s> []+ </s>"), "TMPEXPORTCONNL", false).getMatches()
 		if (debug) println matches.size()
 		int npositions = 0;
 		for (def match : matches) npositions += match.length +1
@@ -88,7 +87,7 @@
 	}
 
 	public static void main(String[] args) {
-		Corpus corpus = null
+		CQPCorpus corpus = null
 		File outfile = new File("/home/mdecorde/Bureau/conn_export.tsv")
 		String encoding = "UTF-8"
 
