title: copy table from templates with fixed place using Apache Poi
body: <p>I have a table in the docx template.
  Depending on the number of objects, I have to duplicate the table as many times as I have objects. Duplicate tables must be after the table from the template.
  I have several tables in the template that should behave like this.</p>
  
  <p>XmlCursor take the place of the first table from the template and put the next one there. I want to insert the next table after the previous one, which I added myself, but xmlcursor does not return the table item I added, but returns "STARTDOC"</p>
  
  <pre><code>XmlCursor cursor = docx.getTables().get(pointer).getCTTbl().newCursor();
  cursor.toEndToken();
  
  while (cursor.toNextToken() != XmlCursor.TokenType.START) ;
  
  XWPFParagraph newParagraph = docx.insertNewParagraph(cursor);
  newParagraph.createRun().setText("", 0);
  cursor.toParent();
  cursor.toEndToken();
  while (cursor.toNextToken() != XmlCursor.TokenType.START) ;
  docx.insertNewTbl(cursor);
  
  CTTbl ctTbl = CTTbl.Factory.newInstance();
  ctTbl.set(docx.getTables().get(numberTableFromTemplate).getCTTbl());
  XWPFTable tableCopy = new XWPFTable(ctTbl, docx);
  docx.setTable(index + 1, tableCopy);
  </code></pre>