Index: TXM/trunk/bundles/org.txm.utils.core/META-INF/MANIFEST.MF
===================================================================
--- TXM/trunk/bundles/org.txm.utils.core/META-INF/MANIFEST.MF	(revision 3920)
+++ TXM/trunk/bundles/org.txm.utils.core/META-INF/MANIFEST.MF	(revision 3921)
@@ -86,7 +86,7 @@
  org.eclipse.osgi.util;bundle-version="3.3.0";visibility:=reexport,
  org.eclipse.core.runtime;visibility:=reexport,
  org.eclipse.core.net;bundle-version="1.2.200";visibility:=reexport,
- org.txm.libs.saxon;bundle-version="9.0.0";visibility:=reexport,
+ org.txm.libs.saxon;bundle-version="12.0.0";visibility:=reexport,
  org.txm.libs.colt;bundle-version="1.2.0";visibility:=reexport,
  org.txm.libs.itext;bundle-version="2.1.5";visibility:=reexport,
  org.txm.libs.msoffice;bundle-version="1.0.0";visibility:=reexport,
Index: TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/xml/ExecXSLDOMMacro.groovy
===================================================================
--- TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/xml/ExecXSLDOMMacro.groovy	(revision 3920)
+++ TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/xml/ExecXSLDOMMacro.groovy	(revision 3921)
@@ -1,77 +0,0 @@
-package org.txm.macro.xml;
-// STANDARD DECLARATIONS
-
-import org.kohsuke.args4j.*
-import groovy.transform.Field
-import org.txm.rcpapplication.swt.widget.parameters.*
-import org.txm.importer.ApplyXsl2;
-import javax.xml.transform.stream.*
-import javax.xml.transform.dom.DOMResult
-import org.w3c.dom.*
-
-
-// BEGINNING OF PARAMETERS
-@Field @Option(name="XSLFile", usage="an example file", widget="File", required=true, def="file.xsl")
-def XSLFile = new File(System.getProperty("user.home"),"TXM/xsl/identity.xsl")
-
-@Field @Option(name="intputDirectory", usage="an example folder", widget="Folder", required=true, def="in")
-def intputDirectory = new File(System.getProperty("user.home"),"xml/TESTS2/xml")
-
-//@Field @Option(name="parameters", usage="an example folder", widget="Text", required=false, def="")
-def parameters = [:]
-
-@Field @Option(name="dom", usage="XSLT Result is - true:  a DOM Element. false - a XSLT Result is XMLStreamReader", widget="Boolean", required=true, def="true")
-def dom
-
-@Field @Option(name="debug", usage="Show debug messages, value = true|false", widget="Boolean", required=true, def="false")
-def debug
-
-if (!ParametersDialog.open(this)) return;
-// END OF PARAMETERS
-
-// USER MANIPULATIONS
-
-def processDOMResult(File inputXMLFile, def resultnode) {
-	// with resultnode a Element : https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Element.html
-	println inputXMLFile.getName()+" -> "+ resultnode.getTagName()
-}
-
-// END USER MANIPULATIONS
-
-println "Use XSL $XSLFile with parameters $parameters"
-println "Processed directory: $intputDirectory"
-
-def files = [] 
-ApplyXsl2 a = new ApplyXsl2(XSLFile.getAbsolutePath());
-intputDirectory.eachFileMatch(~/.+\.(xml|XML)/) { XMLFile ->
-	String name = XMLFile.getName()
-	try {
-		def result = process(a, XMLFile, [:]);
-		if (dom) processDOMResult(XMLFile, result.getNode().getDocumentElement());
-		else processSaxResult(XMLFile, result);
-		files << XMLFile
-	} catch (Exception e) {
-		println "Warning: XSL transformation of '$name' failed with error=$e with "
-		if (debug) e.printStackTrace(); 
-	}
-}
-
-def process(ApplyXsl2 a, File inputXMLFile, def args) throws Exception {
-	for (String k : args.keySet()) {
-		if (!this.setParam(k, args[k]))
-			return false;
-	}
-	
-	def result = null;
-	if (dom) result = new DOMResult();
-	else {
-		XMLStreamReader xmlreader = new XMLStreamReader();
-		PipedInputStream inpipe = new PipedInputStream(xmlreader
-		PipedOutputStream outpipe = new PipedOutputStream();
-		result = new StreamResult(new BufferedOutputStream(new FileOutputStream(xmloutfile)));
-	}
-	a.transformer.transform(new StreamSource(inputXMLFile), result);
-	a.cleanMemory(); // save memory
-	a.resetParams()
-	return result;
-}
\ No newline at end of file
Index: TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/xml/GetXPathMacro.groovy
===================================================================
--- TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/xml/GetXPathMacro.groovy	(revision 3920)
+++ TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/xml/GetXPathMacro.groovy	(revision 3921)
@@ -16,12 +16,12 @@
 
 // STANDARD DECLARATIONS
 
-import javax.xml.bind.helpers.DefaultValidationEventHandler
 import javax.xml.xpath.XPathConstants
 import javax.xml.namespace.NamespaceContext
+import javax.xml.transform.stream.StreamSource
 import javax.xml.XMLConstants
 
-import net.sf.saxon.dom.DocumentBuilderFactoryImpl
+import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
 import net.sf.saxon.xpath.XPathFactoryImpl
 import net.sf.saxon.s9api.Processor
 import net.sf.saxon.s9api.Serializer
@@ -30,6 +30,7 @@
 import org.kohsuke.args4j.Option
 import groovy.transform.Field
 
+import org.txm.importer.GetXPath
 import org.txm.rcp.swt.widget.parameters.*
 import org.txm.scripts.importer.XPathResult
 
@@ -41,25 +42,25 @@
 // (available widget types: Query, File, Folder, String, Text, Boolean, Integer, Float and Date)
 
 @Field @Option(name="srcFile", usage="XML source file", widget="File", required=false, def="")
-def srcFile
+		def srcFile
 
 @Field @Option(name="srcDirectory", usage="XML source directory", widget="Folder", required=false, def="")
-def srcDirectory
+		def srcDirectory
 
 @Field @Option(name="filterByFileExtension", usage="filter by file extension", widget="Boolean", required=false, def="true")
-def filterByFileExtension
+		def filterByFileExtension
 
 @Field @Option(name="fileExtension", usage="file extension to filter (eg .xml)", widget="String", required=false, def=".xml")
-def fileExtension
+		def fileExtension
 
 @Field @Option(name="XPath", usage="XPath expression", widget="String", required=true, def="//tei:title/text()")
-def XPath
+		def XPath
 
 @Field @Option(name="lineNumber", usage="print line number", widget="Boolean", required=false, def="true")
-def lineNumber
+		def lineNumber
 
 @Field @Option(name="wrapLines", usage="wrap output lines longer than 100 characters", widget="Boolean", required=false, def="true")
-def wrapLines
+		def wrapLines
 
 //@Field @Option(name="interactive", usage="open parameters dialog box", widget="Boolean", required=true, def="true")
 //def interactive
@@ -75,284 +76,31 @@
 lineNumberLen = 0
 columnNumberLen = 0
 
-def newDocBuilder = { ->
-
-		DocumentBuilderFactoryImpl factory = new DocumentBuilderFactoryImpl()
-		factory.setNamespaceAware(true)
-		return factory.newDocumentBuilder()
-		
-		/*
-		use catalog
-		use local DTD
-		use entity resolver
-		
-		import org.apache.xml.resolver.tools.CatalogResolver;
-import java.util.Properties;
-import java.io.*;
-import javax.xml.transform.*;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-tFactory = TransformerFactory.newInstance()
-resolver = new CatalogResolver()
-tFactory.setURIResolver(resolver)
-
-                transformer.setURIResolver(resolver);
-                transformer.transform(new StreamSource(xmlFile), new 
-StreamResult(new FileOutputStream(outFile)));
-
-To set an EntityResolver from a Java application, you need to create a
-SAXSource rather than a stream source, to instantiate your own XMLReader
-(the SAX parser), set the EntityResolver on the XMLReader, and then do
-saxSource.setXMLReader().
-
-
-catalog.xml
-
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-  <public publicId="-//W3C//DTD HTML 4.01 Transitional//EN" uri="dummy.dtd"/>
-  <system systemId="http://www.w3.org/TR/html4/loose.dtd" uri="dummy.dtd"/>
-</catalog>
-
-dummy.dtd
-<!ELEMENT html ANY>srcFile
-		
-		
-		*/
-}
-
-def newDoc = { builder, file ->
-
-		return builder.parse(file)
-}
-
-def newXpath = { config ->
-
-		def xfactory = new XPathFactoryImpl()
-		xfactory.setConfiguration(config)
-		def xpath = xfactory.newXPath()
-		
-		xpath.setNamespaceContext(new NamespaceContext() {
-			String TEINS = "http://www.tei-c.org/ns/1.0"
-			String MENS = "http://www.menota.org/ns/1.0"
-			String BFMNS = "http://bfm.ens-lsh.fr/ns/1.0"
-			String TXMNS = "http://textometrie.org/1.0"
-			String XINS = "http://www.w3.org/2001/XInclude"
-			String XHTMLNS = "http://www.w3.org/1999/xhtml"
-			String FNNS = "http://www.w3.org/2005/xpath-functions"
-
-			String TEINSNAME = "tei"
-			String MENSNAME = "me"
-			String BFMNSNAME = "bfm"
-			String TXMNSNAME = "txm"
-			String XINSNAME = "xi"
-			String XHTMLNSNAME = "xhtml"
-			String FNNSNAME = "fn"
-
-			public String getNamespaceURI(String prefix) {
-				if (prefix == null) throw new NullPointerException("Null prefix")
-				else if (TEINSNAME.equals(prefix)) return TEINS
-				else if (MENSNAME.equals(prefix)) return MENS
-				else if (BFMNSNAME.equals(prefix)) return BFMNS
-				else if (TXMNSNAME.equals(prefix)) return TXMNS
-				else if (XINSNAME.equals(prefix)) return XINS
-				else if (XHTMLNSNAME.equals(prefix)) return XHTMLNS
-				else if (FNNSNAME.equals(prefix)) return FNNS
-				else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) return XMLConstants.XML_NS_URI
-				return XMLConstants.NULL_NS_URI
-			}
-
-			public String getPrefix(String uri) {
-				if (uri == null) throw new NullPointerException("Null prefix")
-				else if (TEINS.equals(uri)) return TEINSNAME
-				else if (MENS.equals(uri)) return MENSNAME
-				else if (BFMNS.equals(uri)) return BFMNSNAME
-				else if (TXMNS.equals(uri)) return TXMNSNAME
-				else if (XINS.equals(uri)) return XINSNAME
-				else if (XHTMLNS.equals(uri)) return XHTMLNSNAME
-				else if (FNNS.equals(uri)) return FNNSNAME
-				else if("http://www.w3.org/XML/1998/namespace") return XMLConstants.XML_NS_PREFIX
-				else if (XMLConstants.XML_NS_URI.equals(uri)) return XMLConstants.XML_NS_PREFIX
-				else XMLConstants.NULL_NS_URI
-			}
-	
-			public Iterator getPrefixes(String uri) {throw new UnsupportedOperationException()	}
-		})
-		
-		xpath.setNamespaceContext(new NamespaceContext() {
-			String TEINS = "http://www.tei-c.org/ns/1.0"
-			String MENS = "http://www.menota.org/ns/1.0"
-			String BFMNS = "http://bfm.ens-lsh.fr/ns/1.0"
-			String TXMNS = "http://textometrie.org/1.0"
-			String XINS = "http://www.w3.org/2001/XInclude"
-			String XHTMLNS = "http://www.w3.org/1999/xhtml"
-			String FNNS = "http://www.w3.org/2005/xpath-functions"
-
-			String TEINSNAME = "tei"
-			String MENSNAME = "me"
-			String BFMNSNAME = "bfm"
-			String TXMNSNAME = "txm"
-			String XINSNAME = "xi"
-			String XHTMLNSNAME = "xhtml"
-			String FNNSNAME = "fn"
-
-			public String getNamespaceURI(String prefix) {
-				if (prefix == null) throw new NullPointerException("Null prefix")
-				else if (TEINSNAME.equals(prefix)) return TEINS
-				else if (MENSNAME.equals(prefix)) return MENS
-				else if (BFMNSNAME.equals(prefix)) return BFMNS
-				else if (TXMNSNAME.equals(prefix)) return TXMNS
-				else if (XINSNAME.equals(prefix)) return XINS
-				else if (XHTMLNSNAME.equals(prefix)) return XHTMLNS
-				else if (FNNSNAME.equals(prefix)) return FNNS
-				else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) return XMLConstants.XML_NS_URI
-				return XMLConstants.NULL_NS_URI
-			}
-
-			public String getPrefix(String uri) {
-				if (uri == null) throw new NullPointerException("Null prefix")
-				else if (TEINS.equals(uri)) return TEINSNAME
-				else if (MENS.equals(uri)) return MENSNAME
-				else if (BFMNS.equals(uri)) return BFMNSNAME
-				else if (TXMNS.equals(uri)) return TXMNSNAME
-				else if (XINS.equals(uri)) return XINSNAME
-				else if (XHTMLNS.equals(uri)) return XHTMLNSNAME
-				else if (FNNS.equals(uri)) return FNNSNAME
-				else if("http://www.w3.org/XML/1998/namespace") return XMLConstants.XML_NS_PREFIX
-				else if (XMLConstants.XML_NS_URI.equals(uri)) return XMLConstants.XML_NS_PREFIX
-				else XMLConstants.NULL_NS_URI
-			}
-	
-			public Iterator getPrefixes(String uri) {throw new UnsupportedOperationException()	}
-		})
-		
-	return xpath
-}
-
-def getXPath = { xpath, doc ->
-
-	return xpathProc.evaluate(xpath, doc, XPathConstants.NODESET)
-}
-
-builder = newDocBuilder()
-config = builder.getConfiguration()
-if (lineNumber) {
-	config.setLineNumbering(true)
-}
-xpathProc = newXpath(config)
-
-def serializeNode(node) {
-	processor = new Processor(false)
-	serializer = processor.newSerializer()
-	// Other properties found here: http://www.saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/Serializer.Property.html
-	serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes")
-	serializer.setOutputProperty(Serializer.Property.INDENT, "yes")
-	xdmNode = new XdmNode(node.getUnderlyingNodeInfo())
-	return(serializer.serializeNodeToString(xdmNode))
-}
-
-def printValue(node) {
-
-//	println "beginning of printValue"
-	//println "result type is of type "+node.getClass()
-		switch (node.getNodeType()) {
-
-            		case 1: // element
-            			//println "case 1 : "+node.getClass()
-//            			println "beginning of case 1"
-            			if (lineNumber) {
-            				print sprintf("%${lineNumberLen}d, %${columnNumberLen}d: ", node.getUnderlyingNodeInfo().getLineNumber(), node.getUnderlyingNodeInfo().getColumnNumber())
-            			}
-            			if (wrapLines) {
-            				println WordUtils.wrap(serializeNode(node).replaceAll(/\r\n+/, " ").replaceAll(/\r+/, " ").replaceAll(/\n+/, " ").replaceAll(/ +/, " "), 100)
-            			} else {
-            				println serializeNode(node)
-            			}
-            			break
-
-            		case 2: // attribute
-            			//println "case 2 : "+node.getClass()
-//            			println "beginning of case 2"
-            			if (lineNumber) {
-            				print sprintf("%${lineNumberLen}d, %${columnNumberLen}d: ", node.getUnderlyingNodeInfo().getLineNumber(), node.getUnderlyingNodeInfo().getColumnNumber())
-            			}
-            			if (wrapLines) {
-            				println WordUtils.wrap(serializeNode(node).replaceAll(/\r\n+/, " ").replaceAll(/\r+/, " ").replaceAll(/\n+/, " ").replaceAll(/ +/, " "), 100)
-            			} else {
-            				println serializeNode(node)
-            			}
-                     	break
-
-            		default:
-            			//println "other case : "+node.getClass()
-//            			println "beginning of case 3"
-            			if (lineNumber) {
-            				print sprintf("%${lineNumberLen}d, %${columnNumberLen}d: ", node.getUnderlyingNodeInfo().getLineNumber(), node.getUnderlyingNodeInfo().getColumnNumber())
-            			}
-            			if (wrapLines) {
-            				println WordUtils.wrap(serializeNode(node).replaceAll(/\r\n+/, " ").replaceAll(/\r+/, " ").replaceAll(/\n+/, " ").replaceAll(/ +/, " "), 100)
-            			} else {
-            				println serializeNode(node)
-            			}
-                     	break
-        		}
-//		println "end of printValue"
-}
-
-// from http://stackoverflow.com/questions/453018/number-of-lines-in-a-file-in-java
-def countLines(File file) throws IOException {
-    InputStream is = new BufferedInputStream(new FileInputStream(file));
-    try {
-        byte[] c = new byte[1024];
-        int lineCount = 0;
-        int maxColumn = 0
-        int columnCount = 0;
-        int readChars = 0;
-        boolean endsWithoutNewLine = false;
-        while ((readChars = is.read(c)) != -1) {
-            for (int i = 0; i < readChars; ++i) {
-            	columnCount++
-                if (c[i] == '\n') {
-                    ++lineCount
-                    if (columnCount > maxColumn) { maxColumn = columnCount }
-                    columnCount=0
-                }
-            }
-            endsWithoutNewLine = (c[readChars - 1] != '\n');
-        }
-        if(endsWithoutNewLine) {
-            ++lineCount;
-        }
-        //println "maxColumn = "+maxColumn
-        return [lineCount, maxColumn]
-    } finally {
-        is.close();
-    }
-}
-
 if ((srcDirectory==null || srcDirectory.size() == 0) && (srcFile==null || srcFile.size() == 0)) { println "** GetXPathMacro: at least a source file or a source directory must be specified."; return}
 
 if (srcDirectory!=null && srcDirectory.size() > 0 && srcDirectory.exists()) {
-
+	
 	def files = srcDirectory.listFiles()
 	if (files == null || files.size() == 0) {
 		println "** GetXPathMacro: No files in $srcDirectory"
 		return
 	}
 	files.sort()
-
+	
 	def noFileSearched = true
 	
+	xpathProc = GetXPath.build()
+	
 	println "GetXPath: input directory = '$srcDirectory', XPath = $XPath"
-
-	for (def xmlFile : files) {
 	
+	for (def xmlFile : files) {
+		
 		String name = xmlFile.getName()
 		
 		if (filterByFileExtension && !name.endsWith(fileExtension)) { continue }
-	
+		
 		println "\n-- $name"
-			
+		
 		noFileSearched = false
 		
 		if (lineNumber) {
@@ -360,37 +108,123 @@
 			lineNumberLen = Math.log10(maxLine)+1 as int
 			columnNumberLen = Math.log10(maxColumn)+1 as int
 		}
-
-		doc = newDoc(builder, xmlFile)
-		res = getXPath(XPath, doc)
-
-//		println "res = "+res
-
-				if (res.getLength() == 0) {
+		
+		//res = xpathProc.evaluateExpression(XPath, new StreamSource(xmlFile), XPathConstants.NODESET);
+		res = GetXPath.evaluateExpressionToObject(xpathProc, xmlFile, XPath, XPathConstants.NODESET)
+		if (res.getLength() == 0) {
 			println "No result."
 		} else res.each { printValue(it) }
 	}
-
+	
 	if (noFileSearched) { println "** GetXPath: no file searched." }
-
+	
 } else if (srcFile!=null && srcFile.exists()) {
-			def xmlFile = srcFile
-			String name = xmlFile.getName()
+	
+	def xmlFile = srcFile
+	String name = xmlFile.getName()
+	
+	println "GetXPath: file = '$xmlFile', XPath = $XPath"
+	
+	if (lineNumber) {
+		(maxLine, maxColumn) = countLines(xmlFile)
+		lineNumberLen = Math.log10(maxLine)+1 as int
+		columnNumberLen = Math.log10(maxColumn)+1 as int
+	}
+	
+	res = GetXPath.evaluateExpressionToObject(XPath, srcFile, XPathConstants.NODESET);
+	
+	if (res.getLength() == 0) {
+		println "No result."
+	} else res.each { printValue(it) }
+}
 
-			println "GetXPath: file = '$xmlFile', XPath = $XPath"
-			
+// FUNCTIONS
+
+def serializeNode(node) {
+	processor = new Processor(false)
+	serializer = processor.newSerializer()
+	// Other properties found here: http://www.saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/Serializer.Property.html
+	serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes")
+	serializer.setOutputProperty(Serializer.Property.INDENT, "yes")
+	xdmNode = new XdmNode(node.getUnderlyingNodeInfo())
+	return(serializer.serializeNodeToString(xdmNode))
+}
+
+def printValue(node) {
+	
+	//	println "beginning of printValue"
+	//println "result type is of type "+node.getClass()
+	switch (node.getNodeType()) {
+		
+		case 1: // element
+		//println "case 1 : "+node.getClass()
+		//            			println "beginning of case 1"
 			if (lineNumber) {
-				(maxLine, maxColumn) = countLines(xmlFile)
-				lineNumberLen = Math.log10(maxLine)+1 as int
-				columnNumberLen = Math.log10(maxColumn)+1 as int
+				print sprintf("%${lineNumberLen}d, %${columnNumberLen}d: ", node.getUnderlyingNodeInfo().getLineNumber(), node.getUnderlyingNodeInfo().getColumnNumber())
 			}
-			
-			doc = newDoc(builder, srcFile)
-			res = getXPath(XPath, doc)
+			if (wrapLines) {
+				println WordUtils.wrap(serializeNode(node).replaceAll(/\r\n+/, " ").replaceAll(/\r+/, " ").replaceAll(/\n+/, " ").replaceAll(/ +/, " "), 100)
+			} else {
+				println serializeNode(node)
+			}
+			break
+		
+		case 2: // attribute
+		//println "case 2 : "+node.getClass()
+		//            			println "beginning of case 2"
+			if (lineNumber) {
+				print sprintf("%${lineNumberLen}d, %${columnNumberLen}d: ", node.getUnderlyingNodeInfo().getLineNumber(), node.getUnderlyingNodeInfo().getColumnNumber())
+			}
+			if (wrapLines) {
+				println WordUtils.wrap(serializeNode(node).replaceAll(/\r\n+/, " ").replaceAll(/\r+/, " ").replaceAll(/\n+/, " ").replaceAll(/ +/, " "), 100)
+			} else {
+				println serializeNode(node)
+			}
+			break
+		
+		default:
+		//println "other case : "+node.getClass()
+		//            			println "beginning of case 3"
+			if (lineNumber) {
+				print sprintf("%${lineNumberLen}d, %${columnNumberLen}d: ", node.getUnderlyingNodeInfo().getLineNumber(), node.getUnderlyingNodeInfo().getColumnNumber())
+			}
+			if (wrapLines) {
+				println WordUtils.wrap(serializeNode(node).replaceAll(/\r\n+/, " ").replaceAll(/\r+/, " ").replaceAll(/\n+/, " ").replaceAll(/ +/, " "), 100)
+			} else {
+				println serializeNode(node)
+			}
+			break
+	}
+	//		println "end of printValue"
+}
 
-//			println "res = "+res
-			
-			if (res.getLength() == 0) {
-				println "No result."
-			} else res.each { printValue(it) }
+// from https://stackoverflow.com/questions/453018/number-of-lines-in-a-file-in-java
+def countLines(File file) throws IOException {
+	InputStream is = new BufferedInputStream(new FileInputStream(file));
+	try {
+		byte[] c = new byte[1024];
+		int lineCount = 0;
+		int maxColumn = 0
+		int columnCount = 0;
+		int readChars = 0;
+		boolean endsWithoutNewLine = false;
+		while ((readChars = is.read(c)) != -1) {
+			for (int i = 0; i < readChars; ++i) {
+				columnCount++
+				if (c[i] == '\n') {
+					++lineCount
+					if (columnCount > maxColumn) { maxColumn = columnCount }
+					columnCount=0
+				}
+			}
+			endsWithoutNewLine = (c[readChars - 1] != '\n');
+		}
+		if(endsWithoutNewLine) {
+			++lineCount;
+		}
+		//println "maxColumn = "+maxColumn
+		return [lineCount, maxColumn]
+	} finally {
+		is.close();
+	}
 }
Index: TXM/trunk/bundles/org.txm.libs.saxon/META-INF/MANIFEST.MF
===================================================================
--- TXM/trunk/bundles/org.txm.libs.saxon/META-INF/MANIFEST.MF	(revision 3920)
+++ TXM/trunk/bundles/org.txm.libs.saxon/META-INF/MANIFEST.MF	(revision 3921)
@@ -79,7 +79,7 @@
  org.xmlresolver.tools,
  org.xmlresolver.utils
 Bundle-Name: Saxon
-Bundle-Version: 9.0.0
+Bundle-Version: 12.0.0
 Bundle-ClassPath: .,
  lib/jline-2.14.6.jar,
  lib/saxon-he-12.2.jar,
Index: TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/ApplyXSLDOM.java
===================================================================
--- TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/ApplyXSLDOM.java	(revision 0)
+++ TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/ApplyXSLDOM.java	(revision 3921)
@@ -0,0 +1,70 @@
+package org.txm.importer;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Element;
+
+/**
+ * Process a ResultDom after applying a XSL to XML files of a directory
+ * 
+ * Java conversion of ExelXSLDom macro
+ * 
+ * @author mdecorde
+ *
+ */
+public abstract class ApplyXSLDOM {
+	// STANDARD DECLARATIONS
+	
+	public boolean debug = true;
+		
+	public abstract void processDOMResultToFile(File inputXMLFile, Element resultnode);
+	
+	// END USER MANIPULATIONS
+	
+	public void processFile(File xslFile, File inputDirectory, File outputDirectory, HashMap<String, String> args) throws TransformerConfigurationException {
+		System.out.println("Processing directory: $inputDirectory");
+		
+		ApplyXsl2 a = new ApplyXsl2(xslFile.getAbsolutePath());
+		File[] toProcess = inputDirectory.listFiles();
+		for(File XMLFile : toProcess) {
+			
+			if (!XMLFile.isFile()) continue;
+			if (!XMLFile.canRead()) continue;
+			if (XMLFile.isHidden()) continue;
+			if (!XMLFile.getName().toLowerCase().endsWith(".xml")) continue;
+			
+			String name = XMLFile.getName();
+			try {
+				DOMResult result = _process(a, XMLFile, null);
+				
+				processDOMResultToFile(XMLFile, (Element)result.getNode());
+				File resultFile = new File(outputDirectory, XMLFile.getName());
+			} catch (Exception e) {
+				System.out.println("Warning: XSL transformation of '$name' failed with error=$e with ");
+				if (debug) e.printStackTrace(); 
+			}
+		}
+	}
+	
+	private DOMResult _process(ApplyXsl2 a, File inputXMLFile, HashMap<String, String> args) throws Exception {
+		
+		if (args != null) {
+			for (String k : args.keySet()) {
+				if (!a.setParam(k, args.get(k)))
+					return null;
+			}
+		}
+		
+		DOMResult result = new DOMResult();
+		
+		a.transformer.transform(new StreamSource(inputXMLFile), result);
+		a.resetParams();
+		return result;
+	}
+}

Property changes on: TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/ApplyXSLDOM.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/GetXPath.java
===================================================================
--- TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/GetXPath.java	(revision 0)
+++ TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/GetXPath.java	(revision 3921)
@@ -0,0 +1,84 @@
+package org.txm.importer;
+
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathEvaluationResult;
+import javax.xml.xpath.XPathExpressionException;
+
+import net.sf.saxon.Configuration;
+import net.sf.saxon.xpath.XPathFactoryImpl;
+
+/**
+ * XPath wrapper
+ * 
+ * @author mdecorde
+ *
+ */
+public class GetXPath {
+	
+	public static XPath build() {
+		
+		XPathFactoryImpl xfactory = new XPathFactoryImpl();
+		Configuration config = new Configuration();
+		config.setLineNumbering(true);
+		xfactory.setConfiguration(config);
+		
+		XPath xpath = xfactory.newXPath();
+		xpath.setNamespaceContext(new PersonalNamespaceContext());
+		return xpath;
+	}
+	
+	
+	public static XPathEvaluationResult<?> evaluateExpression(XPath xpath, File xmlFile, String xpathstring) throws XPathExpressionException {
+		
+		return xpath.evaluateExpression(xpathstring, new StreamSource(xmlFile));
+	}
+	
+	public static <T extends Object> T evaluateExpressionToObject(XPath xpath, File xmlFile, String xpathstring, Class<T> type) throws XPathExpressionException {
+		
+		return xpath.evaluateExpression(xpathstring, new StreamSource(xmlFile), type);
+	}
+	
+	public static Object evaluateToObject(XPath xpath, File xmlFile, String xpathstring, QName qname) throws XPathExpressionException {
+		
+		return xpath.evaluate(xpathstring, new StreamSource(xmlFile), qname);
+	}
+	
+	public static String evaluateToString(XPath xpath, File xmlFile, String xpathstring) throws XPathExpressionException {
+		
+		return xpath.evaluate(xpathstring, new StreamSource(xmlFile));
+	}
+	
+	
+	public static XPathEvaluationResult<?> evaluateExpression(File xmlFile, String xpathstring) throws XPathExpressionException {
+		
+		XPath xpath = build();
+		
+		return xpath.evaluateExpression(xpathstring, new StreamSource(xmlFile));
+	}
+	
+	public static <T extends Object> T evaluateExpressionToObject(File xmlFile, String xpathstring, Class<T> type) throws XPathExpressionException {
+		
+		XPath xpath = build();
+
+		return xpath.evaluateExpression(xpathstring, new StreamSource(xmlFile), type);
+	}
+	
+	public static Object evaluateToObject(File xmlFile, String xpathstring, QName qname) throws XPathExpressionException {
+		
+		XPath xpath = build();
+		
+		return xpath.evaluate(xpathstring, new StreamSource(xmlFile), qname);
+	}
+	
+	public static String evaluateToString(File xmlFile, String xpathstring) throws XPathExpressionException {
+		
+		XPath xpath = build();
+		
+		return xpath.evaluate(xpathstring, new StreamSource(xmlFile));
+	}
+}

Property changes on: TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/GetXPath.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/InstallRUserPart.java
===================================================================
--- TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/InstallRUserPart.java	(revision 3920)
+++ TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/InstallRUserPart.java	(revision 3921)
@@ -19,6 +19,8 @@
 		scriptsDirectory.mkdirs();
 		BundleUtils.copyFiles("org.txm.statsengine.r.core", "", "", "R/", scriptsDirectory, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 		
+		BundleUtils.getBundleFile("org.txm.statsengine.r.core");
+		
 		return dir.exists() && scriptsDirectory.exists();
 	}
 
Index: TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java
===================================================================
--- TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java	(revision 3920)
+++ TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java	(revision 3921)
@@ -129,10 +129,11 @@
 		}
 		File rpluginDir = new File(bundleDir, "res"); //$NON-NLS-1$
 		File rRootDir = new File(rpluginDir, os);
-		File execFile = new File(rRootDir, "bin/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$
-		File execFile2 = new File(rRootDir, "bin/exec/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$
+		File rBinRootDir = new File(rRootDir, "bin");
+		File execFile = new File(rBinRootDir, extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$
+		File execFile2 = new File(rBinRootDir, "exec/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$
 		if (osName.contains("windows")) { // R second exec file path is different //$NON-NLS-1$
-			execFile2 = new File(rRootDir, "bin/x64/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$
+			execFile2 = new File(rBinRootDir, "x64/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$
 		}
 		if (!execFile.canExecute() && !execFile.setExecutable(true)) { // first test if file is executable then try setting it executable
 			Log.warning(TXMCoreMessages.bind("Error while setting execution file rights to: {0}.", execFile.getAbsolutePath()));
@@ -142,16 +143,16 @@
 			Log.warning(TXMCoreMessages.bind("Error while setting execution file rights to: {0}.", execFile2.getAbsolutePath()));
 		}
 		
-		if (!osName.contains("windows") && !execFile.canExecute()) {  //$NON-NLS-1$
+		if (!osName.toLowerCase().contains("windows")) {  //$NON-NLS-1$
 			try {
-				Log.fine(TXMCoreMessages.bind("Setting execution file rights to: {0}.", rRootDir.getAbsolutePath()));
-				Process p = Runtime.getRuntime().exec("chmod -R +x " + rRootDir.getAbsolutePath()); //$NON-NLS-1$
+				Log.fine(TXMCoreMessages.bind("Setting execution file rights to: {0}.", rBinRootDir.getAbsolutePath()));
+				Process p = Runtime.getRuntime().exec("chmod -R +x " + rBinRootDir.getAbsolutePath()); //$NON-NLS-1$
 				new StreamHog(p.getInputStream(), false);
 				new StreamHog(p.getErrorStream(), false);
 				p.waitFor();
 			}
 			catch (Exception e) {
-				Log.severe(TXMCoreMessages.bind("Error while setting execution file rights to: {0}.", rRootDir.getAbsolutePath()));
+				Log.severe(TXMCoreMessages.bind("Error while setting execution file rights to: {0}.", rBinRootDir.getAbsolutePath()));
 				e.printStackTrace();
 				return;
 			}
Index: TXM/trunk/bundles/org.txm.concordance.rcp/src/org/txm/concordance/rcp/messages/ConcordanceUIMessages.java
===================================================================
--- TXM/trunk/bundles/org.txm.concordance.rcp/src/org/txm/concordance/rcp/messages/ConcordanceUIMessages.java	(revision 3920)
+++ TXM/trunk/bundles/org.txm.concordance.rcp/src/org/txm/concordance/rcp/messages/ConcordanceUIMessages.java	(revision 3921)
@@ -13,8 +13,6 @@
 public class ConcordanceUIMessages extends NLS {
 	
 	private static final String BUNDLE_NAME = "org.txm.concordance.rcp.messages.messages"; //$NON-NLS-1$
-	
-	
 
 	public static String action_text_reset_column_widths;
 	
@@ -28,7 +26,6 @@
 	public static String ampLeftContextLengthInWords; 
 	public static String ampRightContextLengthInWords; 
 	
-	
 	public static String reference; 
 	public static String inf; 
 	public static String sup; 
