Skip to main content
Participating Frequently
August 16, 2013
Question

Automating an unstructured text selection into a new DITA document

  • August 16, 2013
  • 1 reply
  • 1339 views

Hi everyone,

Lately I've been thinking that it would come in handy to have a script that would allow me to select/highlight (using a mouse) a few words of text in an unstructured FM document, and then choose from a dropdown menu the kind of DITA doc (Task, Concept, or Reference) that I want to paste the text into. Upon making the selection, a new FM DITA page would be automatically generated with the copied text pasted in between its title tags.

Is the kind of automation I'm looking for within the realm of possiblity using ExtendScript? It seems like I might be able to cobble together some scripts I've found to take care of the copying & pasting and the dropdown menu, but I have yet to figure out how to write a script that will create and open a new document in FrameMaker.

Any thoughts?

This topic has been closed for replies.

1 reply

Legend
August 20, 2013

Cronos75,

I'll offer a few thoughts since no one else has. I'm not sure, though, that I'll be very helpful.

I think the biggest challenge here is the invocation of a structuring mechanism, not general document management. It is normally very simple to open a new document with the Open() method, once you figure out how the input parameter scheme works. The addition of the DITA structure, though, is a different story. Presumably, you would need to invoke the Structure Generator using a conversion table which is possible, but this process could have much risk for error. You would probably have to paste the text into a separate file, structure it, then copy it into the existing DITA structure in the target file. Lots of things could go wrong there.

Anyway, I'm sure what you want to do is possible with ES, but you'll have lots of work to do.

Russ

4everJang
Legend
August 20, 2013

Cronos,

I have done plenty of conversion projects in the past years and from my experience I can only give you one very good advice about this: FORGET IT.

Creating a script that allows selecting a piece of text in an unstructured document and convert it into a valid DITA file is not something you should even want to create. It is impossible to capture all the possible errors due to text selections that are impossible to structure.

You have two options to go forward building on this idea:

1. Create somthing that allows copying the currently selected piece of text into an existing DITA document, in which case the selected text should always be wrapped into something that cannot invalidate the structure. I would suggest gluing all paragraph text together so that you have one single paragraph and wrap that content into a single <p> element in your existing DITA file. Although this method might sound like a good idea, I do not think it is.

2. Structure the entire document and save it as DITA - if you can make it valid DITA, that is. This process can be highly optimized using scripts to pre- and post-process the document (removing some horrible unstructured stuff before conversion and augmenting the resulting structure after).

I hope you will find my advice useful. I am not trying to step on anyone's toes, just helping you to learn from my experience.

Kind regards

Jang