[!-- START variable --]
Test: ${test-id}
Description ${test-description}
Failing Machines:
[!-- START test-variable2--]
${machine-name}
[!-- END test-variable2 --]
..... There may be more than one repeated section .......
[!-- END variable --]
So what I wanted to do was basically step through the object list find the start and the end copy everything between and for every input (I'll populate through a database) use the template and duplicate the section. The question I have is how do i copy and paste back in the list of nodes saying I only have the start text node as a pointer and there doesn't seem to be a method to do that like a table where you know the exact parent node etc
Or am I doing it totally wrong and is there any better API's / easier way to do that. Any help would be appreciated Im new to this and have been flung in the deep end with no time
![Sad :(](https://www.docx4java.org/forums/images/smilies/icon_e_sad.gif)
- Code: Select all
public void processRepeatedSection(List<Object> list, RepeatedSectionObjectList rso){
String lookup = rso.getIdentifier();
LinkedList objectList = new LinkedList();
boolean foundStart = false;
boolean foundEnd = false;
// Start point
Text textElementStart = new Text();
// Build our repeated sectionList
for (Object obj: list){
if (obj instanceof Text){
Text textElement = (Text) obj;
if (textElement.getValue().indexOf("[!-- START "+lookup+" --]") > -1){
foundStart = true;
}
if (textElement.getValue().indexOf("[!-- END "+lookup+" --]") > -1){
foundEnd = true;
}
if (foundStart && !foundEnd){
objectList.add(obj);
}
}
// At this point maybe i can copy the list and replace values and call myself for repeated nested statements
}
}