General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Table – Merging Multiple Cells

  • linjinwei

    Table – Merging Multiple Cells

    Participants 4
    Replies 5
    Last Activity 13 years, 10 months ago

    Why is it that XMetal only allows merging of one cell at a time. How to I make it able to merge multiple cells in one go?

    Thanks in advance

    Reply

    Derek Read

    Reply to: Table – Merging Multiple Cells

    The product simply does not have this feature. We may add it in the future.

    Reply

    linjinwei

    Reply to: Table – Merging Multiple Cells

    But is it possible for me to customize it so that it can be done? If so, where can I change it?

    Sorry to ask so much because this will affect my project…

    Reply

    Su-Laine Yeo

    Reply to: Table – Merging Multiple Cells

    I don't think this feature can be added through customization. However, if you aren't already doing this, make sure you're displaying the Table toolbar, as it has buttons that make it much faster to merge cells.

    Reply

    Derek Read

    Reply to: Table – Merging Multiple Cells

    But is it possible for me to customize it so that it can be done? If so, where can I change it?

    You might also wish to take a step back and ask if the table model supported by your DTD or Schema is really going to support the type of output you wish to produce, or perhaps more clearly, allow you to easily transform from one to the other. If you have complete control over this choice  then this is the best time to ask those questions. For example, if you know the majority of your final output will be HTML, then perhaps selecting the HTML table model would be best. That way, when it comes to transforming tables in XML to HTML no transformation (in theory) would be necessary. On the other hand, you may have a specific tool or XSLT that is really good at transforming CALS to HTML, in which case you may wish to use CALS. If you make up your own (not CALS and not HTML) then you should be aware that the special table editing functionality provided for those table models will not apply.

    To try to answer your actual question…

    There is no way to make simple changes that will enable this feature. For users of XMetaL Author the simplest solution, obviously, would be to wait for a release that contains the function.

    In theory though, I think there might be enough APIs in XMetaL Author to create a script that would do this. Such a script would very much depend on the table model you are working with (ie: what does it mean when you “merge cells” because each table model is slightly different). This is why knowing which DTD or Schema you are using is important. However, I suspect that your limited understanding of XML might mean that it would be difficult for you to create such a solution, even if you were to find the appropriate APIs in the XMetaL Developer Programmer's Guide and come up with appropriate logic. If this is a feature you must have you can contact your XMetaL sales rep and ask them for a quote on implementing the feature for your specific case (and at a minimum the people that do this work will want to know which DTD or Schema you are using).

    The theoretical script I'm thinking of that might do what you want would have logic similar to the following:

    1. Store the beginning and end of the selection as a Range object.
    2. Check to see if the user's selection is inside a table using. Using InContextOfType() is probably good enough. If you are not in a table then exit.
    3. Find out how many child elements of what you have selected are rows. getNodesByXPath might be a quick way to do this. This is where you might need to know what table model you are using (HTML uses

    while CALS uses and semantic could be anything). If there is more than one row then exit.
    4. Find out how many first child elements of the user's selection are table cells. Again, this is probably going to be specific to the table model and different for HTML and CALS. You might use getNodesByXPath, or you might try to walk the DOM and use InContextOfType(), or their might be other smarter ways to do this.
    5. Place a Range at the start of the user's original selection. I think at this point we can assume we are somewhere inside a table cell.
    6. Merge right as many times as required to merge everything the user selected. This is why we counted the number of cells in step #4. One API that does this is MergeCellRight().
    7. Try to restore something similar to the user's original selection. This might be tricky because you have changed a bunch of nodes inside it, so you might need to make a new selection. This is why we stored start and end Range objects in step #1.

    Actually getting it to work would be the hard part. In some cases MergeCellRight() may fail. That would likely be the case if a cell is already merged across rows (possible in some table models), in which case do you just stop? Do you back up and undo all the merges you already did? Does the script need to be smart enough to figure out that this would happen ahead of time and tell the user they can't do what they want to do?

    Reply

    linjinwei

    Reply to: Table – Merging Multiple Cells

    Thank you for the thorough explaination.

    It is true that my knowledge of XML is limited and I dont think it is possible for me to create such a script. I guess the only solution is to wait…

    Reply

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

Lost Your Password?

Products
Downloads
Support