Skip to main content
February 14, 2013
Answered

[FM10] Some support needed with book save as XML

  • February 14, 2013
  • 2 replies
  • 2531 views

Hi there,

I'm in a process to convert loads of old non structured FM manuals into structured formats, and though it all works fine there is a lot of repetition involved I'd like to get rid off. I'm having a bit of experience with extendscript for indesign, but the documentation for FM is rather poor. So if someone can get me started or provide some codesnippets to make my job a bit more pleasant it would be highly appreciated 🙂

My processes :

First I open a book, and for each file I run the 'Generate conversion Table' command. The missing paragraph tags need to be added to an existing Conversion table called 'conversion_table'.

Question 1 : Can I use some code to do this automatically ? So all fm files in the book get opened (silent or not does not really matter) , missing tags are added to the existing table, and fm file is closed again.

Second : I clean up the conversion table so output is a bit streamlined. That's a manual process anyway so no issues

Third : I structure the book using the table. Pretty straight forward also so no problem here

Last step : I save all fm files as docbook 2.1 format, but again this requires me to open all fm files one by one, select 'save as XML', select docbook as format and save the file itself.

Question 2 : Can I also here use some code so all fm files in the book are opened, saved as XML using docbook format , and closed again with me leaning back and looking at my PC doing the dirty job for me. To push my luck it would be great if I could also integrate step 3

I guess all of this would be rather simple for a seasoned programmer, but I'm cracking my teeth on it. Therefore anybody that can point me in the right direction or provide some code that could get me running would make my day for sure

Thanks in advance!

K.

This topic has been closed for replies.
Correct answer frameexpert

I agree with Russ; you have a lot going on. I would suggest splitting your question into multiple posts, one for each step in the process. Most of us like to help, but I do this for a living so I can't spend too much time posting complete solutions for free. But here is some code that will automate your third step:

CallClient ("Structure Generator",  "InputDocId " + inputId);

CallClient ("Structure Generator",  "RuleDocId " + convId);

CallClient ("Structure Generator",  "StructureDoc");

The inputId and convId variables are the id properties of the input document and the conversion table document, respectively. For example, if you are structuring the active document, you would do this to get the inputId:

var inputId = app.ActiveDoc.id;

There are also commands to add new entries to an existing conversion table. The best place to get this information is in the FDK manuals. You will have to "translate" the information from C to ExtendScript, but at least you have something to start with. I don't think any of the Structure Generator information is in the ExtendScript documentation.

Rick

2 replies

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
February 18, 2013

I agree with Russ; you have a lot going on. I would suggest splitting your question into multiple posts, one for each step in the process. Most of us like to help, but I do this for a living so I can't spend too much time posting complete solutions for free. But here is some code that will automate your third step:

CallClient ("Structure Generator",  "InputDocId " + inputId);

CallClient ("Structure Generator",  "RuleDocId " + convId);

CallClient ("Structure Generator",  "StructureDoc");

The inputId and convId variables are the id properties of the input document and the conversion table document, respectively. For example, if you are structuring the active document, you would do this to get the inputId:

var inputId = app.ActiveDoc.id;

There are also commands to add new entries to an existing conversion table. The best place to get this information is in the FDK manuals. You will have to "translate" the information from C to ExtendScript, but at least you have something to start with. I don't think any of the Structure Generator information is in the ExtendScript documentation.

Rick

www.frameexpert.com
February 18, 2013

Thanks both,

Fully understand and agree that I probably pushed my luck a bit :-)

Let's try again on some part already. I'm able to run a script to save it as XML, and I probably can figure outhow to get it done on booklevel with the examples available, but I'm still struggling with the structured save part. Saving as XML works fine, and I found some example for the SDK, but I can't find the right syntax to do it on the extendscript Toolkit as that's a bit less intimidating for me.

This is what I have now :

var doc,  name, saveParams, i;

doc = app.ActiveDoc;

name = doc.Name;

fullName = name.replace(".fm",".xml");

saveParams = GetSaveDefaultParams();

returnParams = new PropVals();

i = GetPropIndex(saveParams, Constants.FS_FileType);

saveParams.propVal.ival =Constants.FV_SaveFmtXml;

i = GetPropIndex(saveParams, Constants.FS_StructuredSaveApplication);

saveParams.val.propVal.ival = "XDocBook"; <- this doesnt'work, any advice on what the exact syntax would be ?

doc.Save(fullName, saveParams, returnParams);

doc.Close(Constants.FF_CLOSE_MODIFIED);

Regards,

Koen

frameexpert
Community Expert
Community Expert
February 18, 2013

Since XDocBook is a string, it is probably .sval:

saveParams.val.propVal.sval = "XDocBook";

www.frameexpert.com
Legend
February 18, 2013

Hi K,

Since nobody has responded, I thought I would add a little something, although probably not what you are asking for. Your requirements are well-suited for ExtendScript automation; however, they represent a fairly advanced usage of it. It could take some time to develop these scripts, more time than somebody can likely give you on a simple user-to-user forum post. So, I think that might be why you are having trouble getting responses.

This is a good place to ask specific questions about ES code, but yours is quite broad. I'm almost sure you would need to pay someone to write all that code. My suggestion is to back up a bit and start learning about ES at a lower level, then maybe  the way forward will eventually start to make more sense to you.

Russ