Bug #2208

Mis à jour par Sebastien Jacquot il y a plus de 8 ans

XTZ import fails when applying xsl\4-edition\1-default-html.xsl (Windows) at the copying step, log:

<pre>
-- Applying C:\Tools\Textometrie\___corpus\xml\_livrets_opera_final\livrets_opera_original\xsl\4-edition\1-default-html.xsl XSL to 75 files with parameters: {import-xml-path=file:/C:/Tools/Textometrie/___corpus/xml/_livrets_opera_final/livrets_opera_original/import.xml, number-words-per-page=500, output-directory=file:/C:/Users/s/TXM/corpora/LIVRETSOPERAORIGINAL/HTML/LIVRETSOPERAORIGINAL/default/, pagination-element=pb} on directory C:\Users\s\TXM\corpora\LIVRETSOPERAORIGINAL\txm\LIVRETSOPERAORIGINAL result written in C:\Users\s\TXM\corpora\LIVRETSOPERAORIGINAL\HTML\LIVRETSOPERAORIGINAL\default
.copying inputfile in: C:\tmp\01_CADMUS.xml
java.io.FileNotFoundException: \tmp\01_CADMUS.xml (Le chemin d’accès spécifié est introuvable)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
at org.txm.utils.io.FileCopy.copy(FileCopy.java:81)
at org.txm.utils.io.FileCopy.copy(FileCopy.java:56)
at org.txm.importer.ApplyXsl2.process(ApplyXsl2.java:284)
at org.txm.importer.ApplyXsl2.processImportSources(ApplyXsl2.java:408)
at org.txm.importer.ApplyXsl2$processImportSources.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.txm.importer.xtz.XTZPager.doPostEditionXSLStep(XTZPager.groovy:308)
at org.txm.importer.xtz.XTZPager.process(XTZPager.groovy:54)
at org.txm.importer.xtz.ImportModule$2.run(ImportModule.java:155)
Exception in thread "Thread-40" java.lang.NullPointerException
at org.txm.utils.io.FileCopy.copy(FileCopy.java:91)
at org.txm.utils.io.FileCopy.copy(FileCopy.java:56)
at org.txm.importer.ApplyXsl2.process(ApplyXsl2.java:284)
at org.txm.importer.ApplyXsl2.processImportSources(ApplyXsl2.java:408)
at org.txm.importer.ApplyXsl2$processImportSources.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.txm.importer.xtz.XTZPager.doPostEditionXSLStep(XTZPager.groovy:308)
at org.txm.importer.xtz.XTZPager.process(XTZPager.groovy:54)
at org.txm.importer.xtz.ImportModule$2.run(ImportModule.java:155)
</pre>

Seems to be linked with C:\tmp\01_CADMUS.xml path and debug mode enabled (/org.txm.core/src/groovy/org/txm/importer/ApplyXsl2.java).

<pre>
public boolean process(File xmlinfile, File xmloutfile) throws TransformerException, IOException {

// bufferize result in a String
StringWriter strWriter = new StringWriter();
StreamResult out = new StreamResult(strWriter);

if (debug) {
File inputfile_copy = new File("/tmp", xmlinfile.getName());
System.out.println("copying inputfile in: "+inputfile_copy.getAbsolutePath());
inputfile_copy.delete();
FileCopy.copy(xmlinfile, inputfile_copy);
}

transformer.transform(new StreamSource(xmlinfile), out);

// then write the result in the result file
if (xmloutfile != null) {
BufferedWriter w = new BufferedWriter(new FileWriter(xmloutfile));
w.write(strWriter.toString());
w.close();

if (debug) {
File inputfile_copy = new File("/tmp", xmlinfile.getName());
String s = Diff.diffFile(inputfile_copy, xmloutfile);
if (s.length() > 0) { // for ultra debug ?
System.out.println("Result "+xmlinfile.getName()+" VS "+ xmloutfile.getName()+" diff="+s);
} else {
System.out.println("Warning: no diff between "+inputfile_copy+" and "+ xmloutfile);
}
}
}

cleanMemory();
return true;
}
</pre>

Also the tmp files seem to not be deleted.

h3. Solution 1 (store the files in tmp user directory)

* use System.getProperty("java.io.tmpdir") to retrieve the platform tmp directory
* use inputfile.deleteOnExit() to destroy the tmp file when JVM exits

h3. Solution 2 (store the files in current corpora directory)

* use the current corpus absolute path + "tmp/"
* use inputfile.deleteOnExit() to destroy the tmp file when JVM exits

h3. Misspelling

* replace ".copying inputfile in:" with ".copying inputfile to:"



Retour