Home Forums DITA and XMetaL Discussion Templates for table row inserts Reply To: Templates for table row inserts

Derek Read

Reply to: Templates for table row inserts

You are correct. When you insert a table using the dialogs and menu items they ignore the minitemplates in the CTM. There is no way around this currently, short of re-coding the scripts that build the table (which we do not expect clients to do).

Making modifications to the CTM files for DITA is not something we support. In fact, making changes to the DITA functionality in general is limited to a small set of very specific changes we have tried to anticipate the need for (CSS, XML Templates and one JS file that lets you override some very specific code). However, what is supported and what isn't supported is not documented (because we did not anticipate that anyone would attempt to do what you are doing so the DITA solution is considered “closed”). We recently gave a webinar on the subject that you may wish to view. See “Fine-tuning the DITA authoring experience: Customizing the XMetaL DITA customization”) here http://na.justsystems.com/webinars.php

I might suggest a different approach but please don't attempt this unless you are fully willing to support the end user yourself (ie: modify your scripts to accommodate their exact needs) as we can't support these kinds of customizations for DITA. For other customizations (non-DITA) we can comment on code you write but not write it for you. You might provide an MCR file that runs at the application level (placed in the Startup folder) that would maintain one or more custom table rows (as strings) or even entire tables or other chunks of XML (either hard coded or in a configuration file of some kind). Depending on how much hand-holding you need to provide to the user you might be able to get away with a script as simple as the following:

[code]//XMetaL Script Language JScript:
//Build a chunk of XML to insert.
//Customize as necessary or load from config file, etc.
var xmlStr = “”;
xmlStr += ““;
xmlStr += “

xmlStr += “

xmlStr += “I'm bold text“;
xmlStr += ““;

//Try to find a valid location to insert what we just built and insert it:
var rng = ActiveDocument.Range;
if(rng.FindPasteLocation(xmlStr)) {

You could then connect those macros to buttons on a toolbar if you like. This should be fairly safe as they would be user-initiated macros. Just don't give them an event name and you should generally be OK. If what you are pasting is valid they should work in all document types (if you need to restrict that or you run into tricky cases — and tables very likely will be because of their structure — then your code will need to be more complex).

In the end it might make a lot more sense to submit a feature request containing as much detail about your needs as possible to XMetaL Support so they can log it and try to champion it for a future release. The more detail about your needs you can provide the easier it may be to argue for such a feature.