First, I would like to thank you for this magnificent library, it really solves a lot of problems.
I have a doubt about xml binding. I can bind normal content, and it works well, the problem I have is binding xhtml. Supposedly, it should convert any escaped tags into WordML format, but I keep seeing the tags in the output document.
I've referred to this post http://www.docx4java.org/forums/data-binding-java-f16/how-to-set-the-od-xpath-t1340.html , and I get the correct document, but I can seem to get a correct result.
It didn't changed the html content, as if it was not binded. I managed to change it by adding
- Code: Select all
<w:dataBinding w:xpath="/document[1]/data[1]/htmlProperty[1]" w:storeItemID="{C44A086F-0ABF-48CC-ACB0-932E9DBB4B2F}"/>
Here's the original file:
And here's the resulting file:
Here's my java code:
- Code: Select all
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
String xml = "<document><data><htmlProperty><p>it shoud change</p></htmlProperty>"
+ "</data><today>18 Feb 2016</today><currentTime>09:37</currentTime></document>";
WordprocessingMLPackage wordMLPackage = Docx4J.load(file.getInputstream());
Docx4J.bind(wordMLPackage, xml, Docx4J.FLAG_BIND_INSERT_XML);
OpenDoPEHandler odh = new OpenDoPEHandler(wordMLPackage);
wordMLPackage = odh.preprocess();
Docx4J.save(wordMLPackage, bos, Docx4J.FLAG_BIND_INSERT_XML);
bos.close();
} catch (Exception ex) {
ex.printStackTrace();
}
Any help is appreciated, I'm sure it's something silly I'm not seeing
I forgot, I'm using docx4j-ImportXHTML 3.2.2