使用dita java api 处理.docx文件时,总是出现 [ERROR] Could not find Word document 'file:/F:/java/test/out/userguide.ditamap'

44 views
Skip to first unread message

xinwen xia

unread,
Jan 3, 2021, 1:57:05 AM1/3/21
to DITA-OT Users
这是我的代码和异常截图,希望有大佬能够帮我看一下,不胜感激
我用cmd执行dita -i xxx.docx -f word2dita 时没有any questions,but use java api 时就会出现file not found error ,但是我使用FileInputStream能够读取文件,我百思不得其解,希望有大佬能够解决



xinwen xia

unread,
Jan 3, 2021, 2:05:08 AM1/3/21
to DITA-OT Users
代码在这
代码.PNGlog.PNG
exception.PNG

Toshihiko Makita

unread,
Jan 4, 2021, 12:24:45 AM1/4/21
to DITA-OT Users
一世,我对org.dita4publishers.word2dita不太了解,但是据我所知,https://github.com/dita4publishers/org.dita4publishers.word2dita/blob/develop/build-word2dita.xml的输入Word文档为word.doc。 它应该在属性中给出。 日志错误消息恰好在此build-word2dita.xml的第24至25行上输出。 为什么不修改Java程序以赋予word.doc属性Word文档的完整路径?

Regards,
-- 
/*----------------------------------------------------------------------------------- 
 Toshihiko Makita
 Development Group. Antenna House, Inc. Ina Branch
 Web site:
 http://www.antenna.co.jp/
 http://www.antennahouse.com/
 ------------------------------------------------------------------------------------*/   

2021年1月3日日曜日 16:05:08 UTC+9 xinwe...@gmail.com:

wjl0...@gmail.com

unread,
Jan 9, 2021, 1:26:33 AM1/9/21
to Toshihiko Makita, DITA-OT Users
您们研究的很深入了。
但是如果要将docx文件转为xml,为何不用word软件先另存为word xml文件,最后再处理这个xml文件。这样难度降低一些。

---原始邮件---
发件人: "Toshihiko Makita"<toshihik...@gmail.com>
发送时间: 2021年1月4日(周一) 中午1:24
收件人: "DITA-OT Users"<dita-o...@googlegroups.com>;
主题: [dita-ot] Re: 使用dita java api 处理.docx文件时,总是出现 [ERROR] Could not find Word document 'file:/F:/java/test/out/userguide.ditamap'
--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/06bfe08c-1bc5-4fc7-90a7-c7e0d7b86e75n%40googlegroups.com.

Toshihiko Makita

unread,
Jan 10, 2021, 4:45:28 AM1/10/21
to DITA-OT Users
您收到的错误消息可能是DITA-OT错误。 我收到了相同的错误消息。

为避免此错误,请提供一个虚拟输入文件作为参数,并在word.doc属性中指定原始.docx文件的路径。

package Word2DitaTest;

import org.dita.dost.Processor;
import org.dita.dost.ProcessorFactory;
import org.dita.dost.exception.DITAOTException;
import java.io.File;

public class Word2Dita {

public static void main(String[] args) throws DITAOTException{
final File ditaDir = new File("D:/DITA-OT/dita-ot-3.6");
final File tempDir = new File("D:/DITA-OT/dita-ot-3.6/temp");
final File outDir  = new File("D:/DITA-OT/dita-ot-3.6/out");
final File mapFile  = new File("D:/DITA-OT/dita-ot-3.6/dummy.xml");
final String docxFile = "D:/My_Documents/Temp/test.docx"; 
// Create a reusable processor factory with DITA-OT base directory
ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir);
// and set the temporary directory
pf.setBaseTempDir(tempDir);

// Create a processor using the factory and configure the processor
Processor p = pf.newProcessor("word2dita")
.setInput(mapFile)
.setOutputDir(outDir)
.setProperty("nav-toc", "partial")
.setProperty("word.doc", docxFile);

// Run conversion
p.run();
}

}

该程序的输入文件,日志文件和输出文件已附加。

Hope this helps your development.

-- 
/*---------------------------------------------------------------------------------- 

 Toshihiko Makita
 Development Group. Antenna House, Inc. Ina Branch
 Web site:
 http://www.antenna.co.jp/
 http://www.antennahouse.com/
 -----------------------------------------------------------------------------------*/   


2021年1月3日日曜日 15:57:05 UTC+9 xinwe...@gmail.com:
log.txt
test.docx
out.zip
Reply all
Reply to author
Forward
0 new messages