XMetaL Tips and Tricks
Derek Read September 22, 2009 at 11:59 pm
Script Example: Convert DITA table to simpletableSeptember 22, 2009 at 11:59 pmParticipants 0Replies 1Last Activity 13 years, 2 months ago
Tested with XMetaL Author Enterprise 5.1.1.017 and 220.127.116.11 on Windows XP with CALS tables inside DITA topics.
Allow authors of DITA documents to transform a CALS
This script also demonstrates how to build an XSLT in script and pass it, together with a chunk of XML (in this case a
), to MSXML, which then returns a string (or perhaps throws an error). The existing element (in this case a
) is then replaced, in this case by what should be a
, assuming everything went well. This concept might be used to do any number of transforms on your document if you like working with XSLT.
Before using this script please read the notes and comments in the MCR file (which also includes some legal stuff). Basically, this code is provided as a demo and should be treated as if it were completely untested. I have tested it as best I can, but it has not gone through our regular rigorous test process. You may also wish to adapt this code by altering the XSLT and / or the script logic itself as you may find that the functionality does not meet the exact needs of your end users, etc.
Please also do not use this script without the permission of the people that maintain your XMetaL installation (if that isn't you). Although the possibility is low given the way I have coded this it could conflict with special customizations or scripts, 3rd party tools or plug-ins, a specific work-flow they have set up and wish you to follow, or any number of other things I cannot even guess at. I would recommend telling them about your wish to have something like this and let them integrate it and test it for you.
1. Unzip attached ZIP file.
2. Place MCR file in the Startup folder of your XMetaL Author Enterprise installation.
3. Restart XMetaL Author Enterprise if already running.
Note: You must be logged in to download attachments on this forum.
The script relies on the availability of Microsoft's MSXML COM control (ActiveX). This should be the case on the vast majority of Windows XP and Vista machines. However, if you do run into a situation where the script is throwing an error regarding MSXML that is the first place to look and the first thing to check for as it is possible to unregister this control or otherwise disable it or in theory perhaps remove it altogether.
Warning: Do not use this script with real content until you are satisfied it passes your testing.
1. Open or create a new DITA test document that contains a
2. Place cursor inside the
3. Run the script called “Demo: Convert DITA table to simpletable”.
4. If your document is messed up you should probably be able to undo the entire script with one Undo operation.
Modifications, Extending Code, and Known Limitations:
See comments in the MCR file.
Thanks to Severin Foreman for sharing his XSLT code. I reused a portion of it in this script (specifically, just the part that deals with tables as my script doesn't need to work on the entire document). Original XSLT is here: http://forums.xmetal.com/index.php/topic,457.msg1432.html#msg1432
The majority of the script is based on another demo script written for sorting CALS tables (ie: DITA, DocBook, etc) that also uses XSLT and MSXML (written by me): http://forums.xmetal.com/index.php/topic,458.msg
Also, dcramer's notes (http://forums.xmetal.com/index.php/topic,458.msg1447.html#msg1447) regarding entities would apply equally well to this script. However, (ideally) hopefully most people do not need to use entities with DITA, which promotes the use of DITA conref as the preferred method for dealing with bits of reusable XML.Derek Read September 23, 2009 at 12:15 am
Reply to: Script Example: Convert DITA table to simpletableSeptember 23, 2009 at 12:15 am
Note: I've looked more closely at the XSLT now and see a reference to an attribute called “newwindow”. I assume this is something specific to Severin's environment (original source of the XSLT) as there is no such attribute officially in DITA that I am aware of.
That portion of the XSLT is basically telling it to copy all attributes except some specific ones (newwindow, frame, domains, class, and DITAArchVersion), so it shouldn't hurt anything. I won't bother making modifications though. Just pointing it out in case you are wondering. If this is a concern you should test for that and make mods as necessary if you find it is mucking stuff up.
- You must be logged in to reply to this topic.