Douglas W Philips wrote: > On Wed, Apr 7, 2010 at 4:39 AM, Hussein Shafie <[email protected] > <mailto:[email protected]>> wrote: > > XMLmind DITA Converter (ditac) is programmed [a] to detect such non-zero > exit code and [b] then to exit itself with a code greater than 0. > > > > Therefore it should work fine and we currently don't see which bug we > > could fix here. > > The problem is that ditac invokes something like: > > cmd.exe /s /c "fo2docx.bat foo.fo <http://foo.fo> bar.docx" > > > ?? My ditac_1_2_0/bin/ditac.bat invokes java directly. > When I modify that .bat file to put echo %ERRORLEVEL% immediately after > the java command, I see it print 0. If I deliberately make a typo in my > .ditamap file (for example), then I see a non-zero exit code and > everything works as I expect. >
--> ditac.bat which is basically: java com.xmlmind.ditac.convert.Converter %* works as expected. Your problem does not come from here. --> fo2docx.bat which is basically: java com.xmlmind.fo.converter.Driver -outputFormat=docx %* works as expected. Your problem does not come from here. --> com.xmlmind.ditac.convert.Converter *internally* (that is, you cannot see it unless you read the Java source code) invokes the following helper applications: Apache FOP, Render XEP and XMLmind XSL-FO Converter. It does so by executing something like: cmd.exe /s /c "fo2docx.bat foo.fo bar.docx" Now, in the above case, for an unknown reason, *cmd.exe*, always exits with a 0 (success) code whatever fo2docx.bat may return. Therefore com.xmlmind.ditac.convert.Converter thinks that fo2docx.bat ran OK and, in consequence, com.xmlmind.ditac.convert.Converter itself exits with a 0 (success) code. In summary, your problem is caused by *cmd.exe* not forwarding the exit code of its /c argument, when this /c argument happens to be a .bat file. We currently don't see how to fix this problem. > The bug seems to be that, when java gets the error that the file is in > use, it is exiting with a zero error status. Here is the stack trace: > ditac: ERROR: java.io.FileNotFoundException: C:\...\Source\some.docx > (The process cannot access the file because it is being used by another > process) > ditac: ERROR: at java.io.FileOutputStream.open(Native Method) > ditac: ERROR: at java.io.FileOutputStream.<init>(Unknown Source) > ditac: ERROR: at java.io.FileOutputStream.<init>(Unknown Source) > ditac: ERROR: at > com.xmlmind.fo.converter.docx.DocxTranslator.endDocument(DocxTranslator.java:390) > > ditac: ERROR: at > com.xmlmind.fo.converter.Converter.endDocument(Converter.java:517) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(Unknown > Source) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocume > nt(Unknown Source) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown > Sourc > e) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown > Sourc > e) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown > Source > ) > ditac: ERROR: at > com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown > Source) > ditac: ERROR: at javax.xml.parsers.SAXParser.parse(Unknown Source) > ditac: ERROR: at > com.xmlmind.fo.converter.Converter.convert(Converter.java:383) > ditac: ERROR: at com.xmlmind.fo.converter.Driver.convert(Driver.java:493) > ditac: ERROR: at com.xmlmind.fo.converter.Driver.main(Driver.java:601) > ------ > > Again, when I induce an error in the source files I get a non-zero exit > status. > I have understood the problem you have reported in your previous email and I managed to reproduced it *exactly* (same Java stack trace). It took me 3 hours to understand what happened and to suggest a workaround. Please take the time to carefully read my answer to your previous email. --- PS: Such problem cannot happen on Mac OS X and on Linux. It is really specific to Window's cmd.exe. ---- PS 2: By design, XMLmind XML Editor and XMLmind XSL Utility, which both tightly integrate XMLmind DITA Converter, have no such problem. Moreover these graphical applications both automatically detect the case where the generated .docx file (or .pdf file) is already opened in MS-Word (or in Acrobat Reader). -- XMLmind DITA Converter Support List [email protected] http://www.xmlmind.com/mailman/listinfo/ditac-support

