I have a word document which was generated with docx4j, when i unzip the docx file, the contents of folder is
the contents of ./word/document.xml is as below
the relationship xml has below relationship
<Relationship Target="../chunk.docx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Id="rId3"/>
when we unzip chunk.docx it has below file contents
and the ./word/document.xml has below contents
relationship document xml has below contents
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Target="styles.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Id="rId1"/>
<Relationship Target="settings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Id="rId2"/>
<Relationship Target="../chunk.docx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Id="rId3"/>
<Relationship Target="../chunk2.docx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Id="rId4"/>
<Relationship Target="../chunk3.docx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Id="rId5"/>
<Relationship Target="../chunk4.docx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Id="rId6"/>
<Relationship Target="../chunk5.docx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Id="rId7"/>
similarly when i unzip the chunk.docx it has below file contents
and ./word/document.xml has below contents
How to read the content of word document via java code
i have tried below way
File docxFile = new File(filePath);
WordprocessingMLPackage wordprocessingMLPackage = WordprocessingMLPackage.load(docxFile);
MainDocumentPart mainDocumentPart = wordprocessingMLPackage.getMainDocumentPart();
List<Object> textNodes = mainDocumentPart.getJAXBNodesViaXPath(TEXT_NODEX_XPATH, true);
But it is giving 0 textNodes, Can anyone help how can i read this type of word docx using java