• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to update Frame table field from XML file

Community Beginner ,
Nov 22, 2019 Nov 22, 2019

Copy link to clipboard

Copied

Hi,

New to Extendscript but not to programming.

I have a large Frame doc with hundreds of parts tables, all with the same format. I want to update a PARTNUMBER2 field in these tables based on a PARTNUMBER1 field. The data is coming from an XML file.

This is what I want to do in pseudocode:

For each PARTNUMBER1 in the XML file:

Find each occurrence of PARTNUMBER1 in each Frame table;

Update the corresponding PARTNUMBER2 with the data from the XML file.

Can anyone point me to an example that I might be able to figure out how to modify to suit my needs?

Thanks! 

TOPICS
Scripting

Views

402

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Nov 25, 2019 Nov 25, 2019

Copy link to clipboard

Copied

Hi,

 

This is totally possible, but it's not trivial for a beginner. Even if you have programming experience, there is an additional hurdle to understand how to manipulate FM documents programmatically. But it is quite possible.

 

ExtendScript has built-in features to load and parse XML. A quick review of the documentation indicates that XPath queries are supported. So, the XML side of the task may be the easiest. See the JavaScript Tools Guide (from the script editor, Help > JavaScript Tools Guide CC).

 

For inserting the text in the document, that is more complicated. And the level of complication depends heavily on one factor... are these documents structured? If not, the task is a bit harder. But certainly not impossible.

 

Given the complexity of this operation, that's as much as I can say at this point. This can all be done, but it will be work. Certainly, there are no handy examples of this specific task.

 

There are some general ExtendScript samples here:

 

http://www.weststreetconsulting.com/WSC_ExtendScriptSamples.htm

 

Hope this helps.

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 25, 2019 Nov 25, 2019

Copy link to clipboard

Copied

Another approach is to set this up as a structured FrameMaker document so that you can import the XML directly. You could apply an automatic pre-processing transform that would use XSLT to update the XML as it is imported into FrameMaker.

 

Your entire manual doesn't have to be structured, just the parts chapters. I use this "mixed" approach when writing scripts to make complicated TOCs or LEP (lists of effective pages) that can't be generated using FrameMaker's built-in tools. I use my script to collect the required data into an temporary XML "map." Then I open this map with FrameMaker, applying a custom tranform as it opens. It gives me a fully-formatted, structured FrameMaker file with the required information and hypertext links to the rest of the book.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 25, 2019 Nov 25, 2019

Copy link to clipboard

Copied

I agree with Russ, though; any approach is going to be relatively complex to set up. While I can provide some general guidelines on this forum, there will be limits on specific code I can provide. I would certainly consider looking at this as a paid project. If you are interested, please contact me offlist. Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 03, 2019 Dec 03, 2019

Copy link to clipboard

Copied

Thanks for the replies. I usually try to determine whether it will take me more time to figure out how to automate a task or just do it manually. In this case it looks like figuring out how to automate will take a good bit of time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2019 Dec 03, 2019

Copy link to clipboard

Copied

LATEST

If you have budget, it may be worth investigating a scripting solution. I have done a bunch of these for other clients and the payback is typically pretty significant.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines