Page 1 of 1

Header and footer parts splitting up in several files

PostPosted: Sat Jan 15, 2011 1:09 am
by Franke
I need to search the header and footer parts of a template for bookmarks and replace the surrounding P with new text. I get the parts like this:

headerPart = (HeaderPart)wordMLPackage.getParts().get(new PartName("/word/header2.xml"));

How come, and what causes headers and footers to split into several xml documents? Doing small changes in the template changes the number of xml files, how am I supposed to know which xml-file to read without using trial and error? I basicly want code that can withstand changing the template document slightly without having to recode it. The non-interesting parts (header1.xml and header3.xml in this case) often contains almost nothing, just a w:hdr with a w:p containing a w:pStyle but no textruns.

Re: Header and footer parts splitting up in several files

PostPosted: Sun Jan 16, 2011 8:02 pm
by jason
Franke wrote:How come, and what causes headers and footers to split into several xml documents? Doing small changes in the template changes the number of xml files


You mean doing changes in Word, not docx4j, right?

Franke wrote:how am I supposed to know which xml-file to read without using trial and error?


Have a look at http://dev.plutext.org/trac/docx4j/brow ... rList.java

Re: Header and footer parts splitting up in several files

PostPosted: Mon Jan 17, 2011 9:19 pm
by Franke
Thank you, it works better now.