Page 1 of 1

tag part of text

PostPosted: Fri Oct 25, 2013 1:11 am
by thebruuu
Hi

I need to update dynamically an existing docx document.

That's the flow my program should have:

1. Take in input an existing word document
2. Add an xml property to a specific table in order to uniquely identify the table (don't care about the way the table is identified or which is the table)
...
3. Save the document.
Later...
4. Open the docx file
5. Use this unique property value to find the table to be updated.
6. update the table

nb: I am fully aware that if smone plays in Word with the doc the specific property would be erased .... but I don't care.

First solution I am thinking about is to create a new control based on tables which would output <w:tblPr w:myID="gotcha" >.
As I am kind of rookie with docx4j, openXML and Jaxb Is this the right way to design it?

Could you help me write down this new control pls? :oops:

Any feedback welcome
Thanks
Bruno

Re: tag part of text

PostPosted: Fri Oct 25, 2013 7:12 am
by jason
There are a few different ways to do this; see generally: http://stackoverflow.com/questions/1918 ... 6#19213466

With current nightly builds of docx4j, you can also use paraId and textId. This might be best.

Alternatively http://stackoverflow.com/questions/1777 ... osoft-word suggests putting the ID in table caption, but I've never tried that.

Also, you can put a table in a content control, and put an ID or arbitrary tag on that.

As you can see, lots of options. What is best depends on what you want to do in your step 6 update table (insert data into existing cells, or add rows, or format it etc etc)

Re: tag part of text

PostPosted: Fri Oct 25, 2013 11:02 pm
by thebruuu
Jason thanks a lot for your suggestions! I really appreciated...

I already considered the caption ID, but I don't fancy it given that the user may see that and delete it on purpose.
At first sight, content control Id looks like a very good option.
Meanwhile I investigated OpenDoPE ... but there might be some license problems wrt to that.

Thanks a lot! :mrgreen:

Re: tag part of text

PostPosted: Sat Oct 26, 2013 4:39 pm
by jason
thebruuu wrote:Meanwhile I investigated OpenDoPE ... but there might be some license problems wrt to that.


Not sure what you are worried about here?