DITA and XMetaL Discussion
XMetaL Community Forum › DITA and XMetaL Discussion › How to add table caption?
-
ghkrause March 4, 2009 at 12:59 pm
How to add table caption?
March 4, 2009 at 12:59 pmParticipants 9Replies 10Last Activity 13 years, 11 months agoWe are using XMEE 5.1 with DITA. We use the menu item “Table > Insert Table…” to insert a standard table with header and body. Our writer's guide demands caption/title with every table. However, the menu item “Table > Insert Caption” is always grey in DITA topics!!
I tried article template from Journalist demo and there it works. Note: in DITA the caption is taggedand in jounalist's Article the tag name is .
a) How to make “Table > Insert Caption” to insertin DITA tables??
b) Why is there no option for caption/title in DITA dialog “Insert Table” ? How to fix this?
Note: The journalist article's dialog is different.
c) Any sample code for concept-ditabase.ctm file how to redirect insertion of “table” to use dialog “Insert Table”? Any better place to customize?
Note: With image this happens out-of-the-box, no entry in.
Current workaround: With tags-on view I can addto tables via “Insert Element” but not in normal view. Your help is appreciated!
Derek Read March 4, 2009 at 9:42 pm
Reply to: How to add table caption?
March 4, 2009 at 9:42 pmThe Journalist demo uses HTML tables and so it is quite different with regard to table structure. That customization is also implemented in a very different way for DITA in that we have a “smart insert” feature that does not always use settings in the CTM file among other things. That is why you are seeing these differences.
The quick solution to your issue (one that will work immediately) is to not use the Insert Table item from the Tables menu and instead to use the Insert Element window to insert a table. This should give you the following (as defined in the CTM file's mini template section for
):
The Insert Table properties dialog bypasses the CTM mini template settings above when creating tables. I will file a feature request to provide an option in the Insert Table dialog to allow people to optionally (as with the “Insert Header” checkbox) insert the
element. We could try to hack around and change this functionality as it is currently implemented but the DITA functionality is still really supposed to be a closed system and it would be best to properly implement this through our development team, have it tested and then released in a future release.
Derek Read March 4, 2009 at 9:56 pm
Reply to: How to add table caption?
March 4, 2009 at 9:56 pmTo answer the question about enabling the Insert Caption option in the Insert Table menu. That option is only available when the current DTD uses the HTML table model for tables. There is no equivalent Insert Title option when CALS tables are being used because the underlying system (XMetaL Author) upon which the DITA functionality sits assumes that if
is desired it will be automatically inserted by the people that created that customization. When the DITA functionality (which is a customization) was implemented this feature was left out (by mistake I suspect). So, as answered in my previous post, I will ask that we add this functionality, and until then the simplest option is to use the workaround (also described in my previous post).
Derek Read March 4, 2009 at 10:12 pm
Reply to: How to add table caption?
March 4, 2009 at 10:12 pmOne more thing. I see that the CTM settings do not include
. You will probably want to modify the mini template to include them. While you are in there you may wish to modify the mini template to include a number of rows and columns that is more suitable to your everyday (average) table size. Derek Read March 4, 2009 at 10:31 pm
Reply to: How to add table caption?
March 4, 2009 at 10:31 pmI can see how even my workaround would be quite annoying for people with requirements to always have the
inserted. That, together with the fact that this code seems (note the emphasis) easily modified to support your need, I offer the following… For someone very familiar with scripting (perhaps partners already providing their own form of front line support for our products), that is not afraid to be using an unsupported installation of XMetaL Author Enterprise the script that performs the CALS table insertion is located in the following file (default installation on English Windows XP):
C:Program FilesXMetaL 5.1AuthorDITAXACssharedDitaDocHandlerActions_Table.js
The prototype function that inserts the table in this case is called “doTable” and could be modified using code similar to the following:
if ( strElement == “table”) {
rng.InsertCALSTable(intRows,intCols,strElement,blnHeader);
//add two new lines to insert title element
rng.MoveToElement(“table”,false);
rng.InsertElement(“title”);
rng.Select();
rng = null;
Dlg=null; return;
}This is all offered in good faith. Please don't complain if it doesn't work. I've filed a feature request to officially add something like this (possibly to include a checkbox option) for a future release (we cannot say when, or if, a particular feature will be implemented).
Such changes as described above are not unsupported and so I cannot actually officially recommend doing this. The code is there though, so I also cannot stop you from finding it. “Unsupported” basically means that if you make changes to any part of the DITA functionality and they don't work with the rest of the system you should simply back out the changes. This one seems fairly safe but has obviously not undergone any form of testing on our side. Make sure you test any changes you make before deployment to anyone for anything but testing purposes (ie: to production systems). Even then, you really are on your own.
And as stated previously, the DITA functionality is a closed system and so we may alter any code in future releases. Our installers may not detect changes to files considered to be “owned” by our installation, so any such changes might be lost (and might need to be reimplemented) if you do an installation Repair, Uninstall then Install, or an upgrade to a newer release, including patches.
ghkrause March 5, 2009 at 12:33 pm
Reply to: How to add table caption?
March 5, 2009 at 12:33 pmThanks a lot for the advice and especially for acknowledging that it is a valid customer expectation 🙂
We already started to use the mini template, I forgot to mention.
The option in the table.xft file is definitely what I am looking for but as we always wantthe code snippet provided helps us in our customization. One question still unanswered:
c) Any sample code for concept-ditabase.ctm file how to redirect insertion of “table” to use dialog “Insert Table”? Any better place to customize?I assume I have to place a call of doTable inside the ctm file:
table
Is this correct? I have not seen any sample for
… ghkrause March 5, 2009 at 12:52 pm
Reply to: How to add table caption?
March 5, 2009 at 12:52 pmI made it !! Here is my own answer to question c):
file concept-ditabase.ctm:[…]
table
JScript
xmdita_fn_nulTable(); ]]>
Derek, please confirm that I am allowed to call xmdita_fn_nulTable(). In case this is a DITA implementation internal function then please let me know what to call in CTM file.
Derek Read March 5, 2009 at 8:56 pm
Reply to: How to add table caption?
March 5, 2009 at 8:56 pmDerek, please confirm that I am allowed to call xmdita_fn_nulTable(). In case this is a DITA implementation internal function then please let me know what to call in CTM file.
I'm not sure I can really answer this last question. Officially, none of the changes discussed in this post are supported. However, if it works for this particular release then that may be the solution for you, for this release. We may break your changes with any future release because any or all of the files that make up the DITA customization might be altered. If we implement the feature you have asked for in an OOTB release (perhaps 6.0) then you will not need this change any longer.
ghkrause March 5, 2009 at 9:09 pm
Reply to: How to add table caption?
March 5, 2009 at 9:09 pmOk. I understand your answer and I am glad that I have neither to wait till 6.0 nor have to write many lines of code to achieve what I need.
We have set “Insert Header” by default “true” in table.xft dialog. Ok enters table with title using the template for title and we can reach the form via insert element list and menu Table.
That's a lot for now and I am surprised no one else made a comment that he needs this, too.
Anyone that need a hint can reply to this post, I am following up if possible 🙂chunsbedt May 7, 2009 at 5:33 pm
Reply to: How to add table caption?
May 7, 2009 at 5:33 pmThis is a very interesting and helpful topic. Thanks!
I'm trying to do something similar with XMEE 5.1 w/ DITAIn my case, i want each cell in a normal table to include a
tag when the table is inserted. I've been able to get a
tag in the first cell using a modification of the js code provided by Derek Read. But i have not been able to make it apply to all cells in the table. My code is below:
[code]if ( strElement == “table”) {
rng.InsertCALSTable(intRows,intCols,strElement,blnHeader);
//added two new lines to insert para element in each cell
rng.MoveToElement(“TableEntry”,false);
rng.InsertElement(“p”);
rng.Select();
rng = null;
Dlg=null; return;
}[/code]Any suggestions how/if this can work?
ghkrause May 7, 2009 at 6:14 pm
Reply to: How to add table caption?
May 7, 2009 at 6:14 pmI would build a loop and not use the insertElement method as it works with selection object only. Sorry, code is not testedn just as a hint …
if ( strElement == “table”)
{rng.InsertCALSTable(intRows,intCols,strElement,blnHeader);
//added new lines to insert para element in each cell
var entryList = rng.getElementsByTagName(“entry”);
For Each entryElem in entryList {
pElem = ActiveDocument.createElement(“p”);
entryElem.appendChild(pElem);
}
rng = null;
Dlg = null;
return;} -
AuthorPosts
- You must be logged in to reply to this topic.