DITA and XMetaL Discussion
severin.foreman September 17, 2009 at 1:14 pm
Convert <table> to <simpletable>September 17, 2009 at 1:14 pmParticipants 8Replies 9Last Activity 13 years, 4 months ago
Is there a quick and easy way to convert a standard DITA table to a DITA simpletable?Derek Read September 17, 2009 at 7:15 pm
Reply to: Convert <table> to <simpletable>September 17, 2009 at 7:15 pm
Can't think of a really easy way. Copy and paste would normally work with XMetaL Author (the base product) for tables, but the DITA customization (included with XMetaL Author Enterprise) overrides some of the built-in paste functionality and interferes with that in this case.
A script or a script + XSLT could probably be written (in theory) — not that I'm volunteering at this point, but it would be an interesting challenge to try. If I wasn't so busy I could probably do something fairly fast, but I'm swamped at the moment. Maybe one day soon (unless someone else beats me to it).dcramer September 17, 2009 at 8:15 pm
Reply to: Convert <table> to <simpletable>September 17, 2009 at 8:15 pm
I'll write that xslt if you'll write the script. I'm envisioning an XMetaL macro that runs a xslt on the currently selected content and replaces the selection with the result of the xslt. It would also need to obfuscate entity reference before running the xslt on the xml (e.g. change &foo; to @@foo; before running the xslt, then @@foo; back to &foo; after running the xslt…it would be up to the user to understand the limitation that the content of the entity won't be processed). Another possibility would be to run the xslt on the currently selected content and then put the result of the xslt in the clipboard. The the user can either past over the current contents or move it somewhere else (e.g. if you've converted the element into something that is not valid in the current context).
Bonus points if I can make it use Saxon 9 as the xslt processor (and so use xslt 2.0)
Then I could give my users “Convert X to Y” macros powered by simple xslts.severin.foreman September 17, 2009 at 9:48 pm
Reply to: Convert <table> to <simpletable>September 17, 2009 at 9:48 pm
I wrote an XSLT 2.0 file today that recurses over a directory structure (limited to two levels deep) and writes the output in a separate folder. I'll paste the contents of the file at the bottom of this message if anyone is interested. However, be warned that it was developed to fit my own requirements and comes with no warranties whatsoever.
Currently it handles only concept and task topic types becuase those were the only topic types I needed to convert. Feel free to adapt it for use with a macro as you see fit. I ran it from a .bat file that calls Saxon Java from the command line and runs the XSLT against itself (the stylesheet is both the s: and xsl: argument).
Derek Read September 21, 2009 at 8:17 pm
Reply to: Convert <table> to <simpletable>September 21, 2009 at 8:17 pm
Note that there is the potential for a transformation from
to be “lossy”. The table model doesn't have a concept of merged cells while a regular (CALS)
does. However, even properly handling a transform from a
with merged cells to a
using XSLT seems like it would be hard to me.
Having said that, let's not give up here even if there are limitations. I've got a script that uses XSLT and MSXML to do a basic sort of a DITA (CALS) table within the XMetaL itself (the table is replaced with a sorted version). I might see if I can pare down Severan's XSLT to just the table portion and get that working with my script (by replacing my XSLT). Hard to describe, but once you see it you might see the benefits of having this working directly within the editor itself.
Can't promise anything really quickly at the moment, but perhaps as a first step I'll post the table sorting script and then maybe if someone else has time they could adapt it to use the table portion of this XSLT instead of my table sorting XSLT.
I'll try to get the table sorting script up soon (not sure if it needs clean-up, better commenting, etc).severin.foreman September 21, 2009 at 8:26 pm
Reply to: Convert <table> to <simpletable>September 21, 2009 at 8:26 pm
Good point about the conversion being lossy due to simpletable limitations. In addition to not supporting column and row spanning, I think that simpletables also allow only one header row, and there is no support for table groups.
If my teammate were using some of the more complex table features, I would have recommended keeping the information in a table element!
SeverinDerek Read September 21, 2009 at 8:48 pm
Reply to: Convert <table> to <simpletable>September 21, 2009 at 8:48 pm
Right, so, assuming the person is knowledgeable enough to know what they are doing (ie: when it is a good time to use simpletable vs table) we're probably OK.
Such a script might simply only be able to give an error in these cases like: “sorry, can't do that” (and then hopefully nothing happens to the original table) unless we put quite a bit of effort into it to detect beforehand if any of these more advanced table structures are there.dcramer September 21, 2009 at 9:22 pm
Reply to: Convert <table> to <simpletable>September 21, 2009 at 9:22 pm
Cool! I look forward to seeing the table sorting macro.
DavidDerek Read September 22, 2009 at 12:44 am
Reply to: Convert <table> to <simpletable>September 22, 2009 at 12:44 am
I've posted my table sort demo here: http://forums.xmetal.com/index.php/topic,458.msg
If someone wants to take the same idea + Severin's XSLT that would be great. I'm not sure how soon I can get to that (stuff I do is generally also delayed by the need for me to write up something really nice, clearly worded, containing our legal statements, etc).
To integrate my script with Severin's XSLT would probably require his XSLT to be cut down to
only, and my script would need to be modified to pass the entire
rather than just the
I was also thinking it might be nice to insert the
after the existing
(without removing it) so the author can compare the two in case they lose something in the conversion. Then they could easily manually delete the original
if they don't want it.Derek Read September 23, 2009 at 12:03 am
Reply to: Convert <table> to <simpletable>September 23, 2009 at 12:03 am
- You must be logged in to reply to this topic.