Page 1 of 1

Table add row via XML ?

PostPosted: Fri Oct 18, 2013 12:09 am
by bloodsoil
Hey,

is it actually possible to add a row to a table by XML code ?
I think here about something like:

first row:
"/CV/Basic[1]/profEdu[1]/item[1]/year[1]"

second row:
"/CV/Basic[1]/profEdu[1]/item[2]/year[1]"

If isn't, how do I add such row ?

My goal is to build a table depends on amount of strings.

Re: Table add row via XML ?

PostPosted: Fri Oct 18, 2013 7:30 am
by jason
Sure, use one of the OpenDoPE Word AddIns to wrap a od:repeat content control around the table row (/CV/Basic[1]/profEdu[1]), then bind individual cells to /CV/Basic[1]/profEdu[1]/item[1]/year[1] etc

OpenDoPEHandler will then take care of creating the table rows to match count(/CV/Basic[1]/profEdu[1]/item)

I assume you're using content control data binding, given that you've posted in this forum. But if you aren't, you can always use docx4j to do the work of adding each table row programmatically....

Re: Table add row via XML ?

PostPosted: Fri Oct 18, 2013 7:50 pm
by bloodsoil
Hi Jason,

Ok, that's great.
Everytime I "Make content repeat..." it looks like this:
Image

but it doesn't ganerete any XML-code or something. Is it ok ?
I saw your example "countries" but I don't know, how do you did it :(

Here is also my whole xml code:
Code: Select all
<CV xnmls="">
   <Basic>
      <nameOfStaff nameOfStaff=""/>
      <profession profession=""/>
      <dayOfBirth dayOfBirth=""/>
      <withFirmYear years=""/>
      <nationality nationality=""/>
      <memberInProsSoc memberInProsSoc=""/>
      <keyQualifications keyQualifications=""/>
      <profEdu>
         <item>
            <year year="y1"/>
            <school school="s1"/>
         </item>
      </profEdu>
      <specEdu>
         <item>
            <year/>
            <school/>
         </item>
      </specEdu>
      <countries country=""/>
      <emplRec>
         <item>
            <year/>
            <text/>
         </item>
      </emplRec>
   </Basic>
   <Project>
      <Test2>
      </Test2>
   </Project>
</CV>


The idea is to make profEdu, specEdu, emplRec repeatable.

Re: Table add row via XML ?

PostPosted: Sat Oct 19, 2013 8:01 am
by jason
Looks like you may be repeating the whole table, not just the table row.

Here is what a repeating table row looks like:

tr_bind.png
tr_bind.png (3.06 KiB) Viewed 1911 times


To inject your XML, see for current nightlies:

https://github.com/plutext/docx4j/blob/ ... geXML.java

or, the old lower level way:

https://github.com/plutext/docx4j/blob/ ... geXML.java