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.