Program: 185105
Project: 185105
Buggy source:
/** 
 * Preprocess content controls which have tag "od:condition|od:repeat". The algorithm is as follows: Look at each top level SDT (ShallowTraversor).   If it does not have a real data binding, it might have a bindingrole tag we need to process (processBindingRoleIfAny). Conditionals are easy. processRepeat method: - clones the sdt n times - invokes DeepTraversor which changes xpath binding on descendant sdts (both sdts with real bindings and sdts with bindingrole tags). It is not the job of DeepTraversor to expand out any other repeats it might encounter, or to resolve conditionals. Those things are done by ShallowTraversor, to which control returns, as it continues its traverse. The implementation of 13 Sept 2010 replaced the previous XPath based implementation, which did not support nested repeats.  I've chosen to build this around TraversalUtil, instead of using XSLT, and this seems to have worked out nicely. The implementation of 10 October 2010 replaced the v1 conventions implementation with a v2 implementation.  The main method in this class can convert v1 documents to v2. The v2 implementation is not yet complete. All v1 features are implemented, but not the new v2 stuff (eg complex conditions).
 * @param documentPart
 * @throws Docx4JException
 */
public static void preprocess(WordprocessingMLPackage wordMLPackage) throws Docx4JException {
  MainDocumentPart documentPart=wordMLPackage.getMainDocumentPart();
  if (wordMLPackage.getMainDocumentPart().getXPathsPart() == null) {
    throw new Docx4JException("String_Node_Str");
  }
 else {
    xPaths=wordMLPackage.getMainDocumentPart().getXPathsPart().getJaxbElement();
  }
  if (wordMLPackage.getMainDocumentPart().getConditionsPart() != null) {
    conditions=wordMLPackage.getMainDocumentPart().getConditionsPart().getJaxbElement();
  }
  org.docx4j.wml.Document wmlDocumentEl=(org.docx4j.wml.Document)documentPart.getJaxbElement();
  Body body=wmlDocumentEl.getBody();
  shallowTraversor.wordMLPackage=wordMLPackage;
  new TraversalUtil(body,shallowTraversor);
}

Fixed version (ground truth):
/** 
 * Preprocess content controls which have tag "od:condition|od:repeat". The algorithm is as follows: Look at each top level SDT (ShallowTraversor).   If it does not have a real data binding, it might have a bindingrole tag we need to process (processBindingRoleIfAny). Conditionals are easy. processRepeat method: - clones the sdt n times - invokes DeepTraversor which changes xpath binding on descendant sdts (both sdts with real bindings and sdts with bindingrole tags). It is not the job of DeepTraversor to expand out any other repeats it might encounter, or to resolve conditionals. Those things are done by ShallowTraversor, to which control returns, as it continues its traverse. The implementation of 13 Sept 2010 replaced the previous XPath based implementation, which did not support nested repeats.  I've chosen to build this around TraversalUtil, instead of using XSLT, and this seems to have worked out nicely. The implementation of 10 October 2010 replaced the v1 conventions implementation with a v2 implementation.  The main method in this class can convert v1 documents to v2. The v2 implementation is not yet complete. All v1 features are implemented, but not the new v2 stuff (eg complex conditions).
 * @param documentPart
 * @throws Docx4JException
 */
public static void preprocess(WordprocessingMLPackage wordMLPackage) throws Docx4JException {
  MainDocumentPart documentPart=wordMLPackage.getMainDocumentPart();
  if (wordMLPackage.getMainDocumentPart().getXPathsPart() == null) {
    throw new Docx4JException("String_Node_Str");
  }
 else {
    xPaths=wordMLPackage.getMainDocumentPart().getXPathsPart().getJaxbElement();
    log.debug(XmlUtils.marshaltoString(xPaths,true,true));
  }
  if (wordMLPackage.getMainDocumentPart().getConditionsPart() != null) {
    conditions=wordMLPackage.getMainDocumentPart().getConditionsPart().getJaxbElement();
    log.debug(XmlUtils.marshaltoString(conditions,true,true));
  }
  org.docx4j.wml.Document wmlDocumentEl=(org.docx4j.wml.Document)documentPart.getJaxbElement();
  Body body=wmlDocumentEl.getBody();
  shallowTraversor.wordMLPackage=wordMLPackage;
  new TraversalUtil(body,shallowTraversor);
}