Please find sample attached.
Removing some stuff for clarity, it contains:
Using xml Syntax Highlighting
<w:sdt>
<w:sdtPr>
<w:alias w:val="Repeat: wUz7G"/>
<w:tag w:val="od:repeat=wUz7G"/>
</w:sdtPr>
<w:sdtContent>
<w:p >
<w:sdt>
<w:sdtPr>
<w:alias w:val="Data value: CpZN3"/>
<w:tag w:val="od:xpath=CpZN3"/>
<w:dataBinding w:xpath="/elements[1]/element[1]" w:storeItemID="{1AB8AB41-29D1-436E-ACF3-78F891FDF452}"/>
<w:text w:multiLine="1"/>
</w:sdtPr>
<w:sdtContent>
<w:r>
<w:t>el1
</w:t>
</w:r>
</w:sdtContent>
</w:sdt>
<w:sdt>
<w:sdtPr>
<w:tag w:val="od:RptPosCon=GekJx"/>
</w:sdtPr>
<w:sdtContent>
<w:r>
<w:t>,
</w:t>
</w:r>
</w:sdtContent>
</w:sdt>
</w:p>
</w:sdtContent>
</w:sdt>
Parsed in 0.002 seconds, using
GeSHi 1.0.8.4
in other words, a repeat with a bind in it, followed by an sdt with od:RptPosCon tag.
That tag is like a condition, in that its content only appears if it is "true". But unlike a condition, the tag points directly to an entry in the XPaths part (ie NOT the conditions part). The easiest way to add od:RptPosCon in the authoring tool is to add/specify an XPath, then alter the tag from od:xpath to od:RptPosCon (which you can do via the Word Developer tab).
You should be able to use an XPath such as:
- Code: Select all
// If first entry in repeat
position()=1
// If not the first entry in repeat
position()>1"
// If second entry in repeat
position()=2
// if second last entry in repeat
position()=last()-1"
// if last entry in repeat
position()=last()
// not last
position()!=last()
In dusting off this code, I had to make a minor fix:-
https://github.com/plutext/docx4j/commi ... fc7f75ec87It won't work without that...