Page 1 of 1

Table captions?

PostPosted: Wed Jan 05, 2011 8:44 am
by cvonsee
Hi -

The WordprocessingML spec indicates that table captions should be found in the "tblCaption" child of "TblPr", but in docx4j 2.6.0 I'm not finding a tblCaption (or similar) member in that class. Are table captions supported in docx4j 2.6.0?

Thanks for a great tool!


Cheers
Chris

Re: Table captions?

PostPosted: Wed Jan 05, 2011 10:49 am
by jason
Looking at the definition of CT_TblPrBase in wml.xsd in our SVN, there is no table caption element. That's because wml.xsd is based on ECMA-376, first edition (as opposed to 2ed, which was not available when I JAXBified it).

2ed adds 2 elements to the definition of CT_TblPrBase; these are tblCaption and tblDescription.

If you really need tblCaption, it would be fairly straightforward to add these to wml.xsd, and use XJC to regenerate the JAXB classes. Either you or I could do that. Instructions for doing so are in a comment at the top of the wml.xsd file.

hth .. Jason

Re: Table captions?

PostPosted: Thu Jan 14, 2016 5:05 am
by crherman7
Jason,

docx4j is a great tool! To go along with this thread, I was able to regenerate the wml classes with tblCaption using the xjc directions a the top of the schema file. I then recompiled docx4j using ant dist and was able to get the tblCaption value in a test case. The method that does not work and spits out an error is the VariablePrepare.prepare method. I get the following error message:

[Fatal Error] :33:1: The end-tag for element type "xsl:template" must end with a '>' delimiter.
Exception in thread "main" javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.SAXParseException; lineNumber: 33; columnNumber: 1

So besides regenerating the wml jaxb classes using the stated directions with xjc and recompiling docx4j with ant dist, can you think of any steps I would be missing to accomplish this update?

Thanks in advance!

Chris

Re: Table captions?

PostPosted: Thu Jan 14, 2016 6:20 am
by crherman7
Jason

Actually better question would be is, if you had to regenerate all jaxb classes and recompile everything how would you go about doing this?

I only ask this because the more investigating I do I realize that when I regenerate the wml jaxb classes not all are created such as SdtElement.java is not created. There is no mention of SdtElement in the xsd folder so I wonder how and where it was created?

Re: Table captions?

PostPosted: Thu Jan 14, 2016 6:33 pm
by jason
crherman7 wrote:[Fatal Error] :33:1: The end-tag for element type "xsl:template" must end with a '>' delimiter.
Exception in thread "main" javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.SAXParseException; lineNumber: 33; columnNumber: 1


This is completely unrelated. I guess you modified filter.xslt accidentally: https://github.com/plutext/docx4j/blob/ ... ilter.xslt

Re: Table captions?

PostPosted: Thu Jan 14, 2016 6:37 pm
by jason
crherman7 wrote:Actually better question would be is, if you had to regenerate all jaxb classes and recompile everything how would you go about doing this?

I only ask this because the more investigating I do I realize that when I regenerate the wml jaxb classes not all are created such as SdtElement.java is not created. There is no mention of SdtElement in the xsd folder so I wonder how and where it was created?


That's right, there are certain handcoded classes and edits, so there is a manual step after re-generation, of adding these changes back in. And unfortunately, its not just a matter of a simple diff, since xjc generates some stuff in a random order, adding a lot of noise to the diff.

For this reason, I tend to avoid wholesale regeneration of the wml classes these days; for most changes, its easier to patch one or 2 existing classes with the relevant changes from xjc.

Re: Table captions?

PostPosted: Fri Jan 15, 2016 1:51 am
by crherman7
Jason

Thanks for pointing me to the correct file! There is a missing ">" in the filter.xslt but it is also missing in that file on the github repo. I made the hand manipulations as you suggested and all functionality is working including the tblCaption. Thanks for the help, much appreciated!

Cheers,
Chris

Re: Table captions?

PostPosted: Sat Jan 16, 2016 1:51 pm
by jason
Great :-)

Happy to accept pull requests, preferably against branch VERSION_3_3_0, rather than master.

Re: Table captions?

PostPosted: Thu Apr 13, 2023 1:31 pm
by jason
This has been implemented for a good while now.

Just added tblDescription, fixing https://github.com/plutext/docx4j/issues/540