General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion CALS Table Manipulation

  • scotth

    CALS Table Manipulation

    Participants 0
    Replies 1
    Last Activity 10 years, 10 months ago

    I am using XMAX 6.0 for the project that I am currently working on. My schema makes use of CALS tables. I am able to insert these tables properly. However, I am running into some issues when performing certain manipulations after the fact. First, adding a thead or tfoot after the table insertion results in a thead or tfoot that is not rendered in XMAX for display and edit by the user. Second, I cannot seem to add tgroup elements and have them rendered in the same manner that the initial tgroup is rendered. I looked over the programmer documentation, but could not find an additional methods for adding these elements. What is the best way to perform each of these actions in XMAX?

    Reply

    Derek Read

    Reply to: CALS Table Manipulation

    There are no specific methods for inserting tgroup, thead, tbody, or tfoot elements after a table has been inserted (thead and tfoot can be inserted when a table is created, as documented for the InsertCALSTable API).

    You should be able to create a Range, move it after a tgroup and then insert a new tgroup there. Your new tgroup will need to have at least one row with at least one entry to be visible. Note that your DTD will need to support multiple tgroup elements inside a table (the CALS standard itself allows this, but some schemas might restrict it to just one). Here's an example:

    [code]//XMetaL Script Language JScript:
    var rng = ActiveDocument.Range;
    if (rng.InContextOfType(“tablecell”)) {
    if (rng.MoveToElement(“tgroup”,false)) {
    rng.SelectAfterNode(rng.ContainerNode);
    //build up your tgroup as a string here, using whatever logic makes the most sense to you (loops, etc)…
    var tgroup = '

    ';
    rng.PasteString(tgroup);
    }
    }[/code]

    Note that in this case your DTD needs to support

    inside in your CALS table, which is the standard OASIS model. One example of a DTD that does not allow tfoot is DITA.

    Anytime you make changes to a table structure in script that are not immediately rendered (this would be the case pretty much anytime you do anything but insert a complete table, or mimic a user action as above) you can call the API formatGraphicTable() to force it to be rendered as a table, or update those bits that are not currently rendered as such. An explanation of why this is the case is included in the docs for this API. If the script above was altered to use DOM or individual InsertElement() calls then that would be necessary.

    You may find it easier to enable Plain Text view in XMAX when working with this type of code as it is possible to insert parts of a table that cannot be rendered as a table due to lack of entry elements, etc. Or you might code for XMetaL Author and then once it is working there move it to your XMAX application.

    Reply

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

Lost Your Password?

Products
Downloads
Support