DITA and XMetaL Discussion

XMetaL Community Forum DITA and XMetaL Discussion How to add table caption?

  • ghkrause

    How to add table caption?

    Participants 9
    Replies 10
    Last Activity 13 years, 7 months ago

    We 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 tagged and in jounalist's Article the tag name is </p> <caption>.<br /><b>a) How to make “Table > Insert Caption” to insert <title> in 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 add to tables via “Insert Element” but not in normal view.</p> <p>Your help is appreciated!

    Reply

    Derek Read

    Reply to: How to add table caption?

    The 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

    ):

    <?xm-replace_text Title?>

     

     
     


    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.</p> <p>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.

    Reply

    Derek Read

    Reply to: How to add table caption?

    To 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).</p> <p>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).

    Reply

    Derek Read

    Reply to: How to add table caption?

    One 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.

    Reply

    Derek Read

    Reply to: How to add table caption?

    I 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 <i>seems</i> (note the emphasis) easily modified to support your need, I offer the following…</p> <p>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):</p> <p>C:Program FilesXMetaL 5.1AuthorDITAXACssharedDitaDocHandlerActions_Table.js</p> <p>The prototype function that inserts the table in this case is called “doTable” and could be modified using code similar to the following:</p> <p> if ( strElement == “table”) {<br /> rng.InsertCALSTable(intRows,intCols,strElement,blnHeader);<br /> //add two new lines to insert title element<br /> rng.MoveToElement(“table”,false);<br /> rng.InsertElement(“title”);<br /> rng.Select();<br /> rng = null;<br /> Dlg=null; return;<br /> }</p> <p>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).</p> <p>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.</p> <p>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.

    Reply

    ghkrause

    Reply to: How to add table caption?

    Thanks 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 want the code snippet provided helps us in our customization.</p> <p>One question still unanswered:<br />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?</p> <p>I assume I have to place a call of doTable inside the ctm file:<br /><oninsertelementlist><br />  <oninsertelement><br />    <name>table</name><br />    <insertelemscript><br />      <![CDATA[doTabel() ]]><br />    </insertelemscript><br />  </oninsertelement><br /></oninsertelementlist></p> <p>Is this correct? I have not seen any sample for <insertelemscript> …</insertelemscript>

    Reply

    ghkrause

    Reply to: How to add table caption?

    I 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.

    Reply

    Derek Read

    Reply to: How to add table caption?

    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.

    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.

    Reply

    ghkrause

    Reply to: How to add table caption?

    Ok. 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 🙂

    Reply

    chunsbedt

    Reply to: How to add table caption?

    This is a very interesting and helpful topic. Thanks!
    I'm trying to do something similar with XMEE 5.1 w/ DITA

    In 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?

    Reply

    ghkrause

    Reply to: How to add table caption?

    I 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;}

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support