gpt4 book ai didi

java - 找不到 CustomXmlDataStoragePart!正在退出..使用 docx4j 添加 XML 到 Word 时出错

转载 作者:行者123 更新时间:2023-12-02 12:02:40 26 4
gpt4 key购买 nike

    public void xmlToWordExport() throws Exception {

String input_DOCX = "D:/Temp/data_template/template.docx";
String input_XML = "D:/eclipse/jaxb.xml";
String OUTPUT_DOCX = "D:/eclipse-workspace/PWCRAR/OUT_ContentControlsMergeXML.docx";
WordprocessingMLPackage wordMLPackage = Docx4J.load(new File(input_DOCX));
CustomXmlDataStoragePart customXmlDataStoragePart
= CustomXmlDataStoragePartSelector.getCustomXmlDataStoragePart(wordMLPackage);
if (customXmlDataStoragePart==null) {
System.out.println("Couldn't find CustomXmlDataStoragePart! exiting..");
return;
}
System.out.println("Getting " + input_XML);


FileInputStream xmlStream = new FileInputStream(new File(input_XML));



Docx4J.bind(wordMLPackage, xmlStream, Docx4J.FLAG_BIND_INSERT_XML | Docx4J.FLAG_BIND_BIND_XML | Docx4J.FLAG_BIND_REMOVE_SDT);

//Save the document
Docx4J.save(wordMLPackage, new File(OUTPUT_DOCX), Docx4J.FLAG_NONE);
System.out.println("Saved: " + OUTPUT_DOCX);
}

错误:org.docx4j.openpackaging.exceptions.Docx4JException:找不到 CustomXmlDataStoragePart!退出..

xml click here

为什么找不到 CustomXmlDataStoragePart?如何解决?

最佳答案

CustomXmlDataStoragePartSelector 旨在根据 OpenDoPE 规范使用内容控件来处理文档:请参阅 http://www.opendope.org

设置文档的最简单方法是使用 Word 插件之一,http://www.opendope.org/downloads/authoring-friendly/setup.exe或更旧/更丑http://www.opendope.org/downloads/authoring-advanced/setup.exe

进一步查看http://www.opendope.org/implementations.html

关于java - 找不到 CustomXmlDataStoragePart!正在退出..使用 docx4j 添加 XML 到 Word 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47130614/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com