Copy link to clipboard
Copied
It seems like I posted something like this a long time ago, but I am not sure. I have some table elements in an FrameMaker document that I want to write out to XML with ExtendScript. I find the XML object in ExtendScript very useful and I am hoping to use that instead of isolating each table and using Save As XML. I suppose I need some kind of recursive function to write the elements and attributes to XML, but if anyone has an algorithm already developed, I would appreciate seeing it (or just having it described in pseudocode). Thank you very much. -Rick
Copy link to clipboard
Copied
Dear Rick,
Not sure if my answer is relevant to your query. But i had developed a script in vba.
I copy the table from Fm to word file.
Run the vba script, which simply wraps the respective elements around the content in each cell.
The logic i had used is.
1. The script selects the cell which is accomplished using select property.
2. Using the methods insertbefore and insertafter the respective elements are inserted around the selected cell.
3. This is done until the last cell in the table.
Copy link to clipboard
Copied
Hi Rick,
I did something like that for the Adobe S1000D applicability handling system. I'm not at liberty to share the Adobe source code for that, but here's a general walk through of what I did:
This method is really quick and to be honest feels more natural that FrameMaker's built-in XML handling as it does away with the need for read/write rules and EDD/template management.
Copy link to clipboard
Copied
Excellent Ian, thank you very much! I really like the ExtendScript XML object. I wish it was more feature rich, like with Xpath 3.1 support, but it is pretty good as is. I will try your approach. Fortunately, the table structure is pretty simple so it should be straight forward to script. Thanks again!
Copy link to clipboard
Copied
Yes the XML object is very useful. I've been using it to pre-check XML documents where the doctype is the same for about 120 different schemas. I can query the content using the XPath 1.0 then select the required XML application for FrameMaker. It's so fast you wouldn't know it was happening!
In the past I've used XML as the format for configuration files using the ES XML object, but now I do that in JSON using the public domain JavaScript to JSON converter (json2.js). You only need to save the ES object as JSON then write it to a file. Reading is just as easy and converts the JSON back into an ES object. Couldn't be easier!
Copy link to clipboard
Copied
Are you using the json2.js converter right from ExtendScript? Can I go in either direction? I might want to store my tables as json files and then read them back in as XML.
Copy link to clipboard
Copied
Yes Rick, the json2.js file can be included just as you would with an ExtendScript file.
You convert an ExtendScript object to json using JSON.stringify(). To read from a json text file back into an ES object use JSON.parse().
I guessed that if you need an easy way to export reusable content JSON could be a more direct route than XML. Another useful feature to consider is that XSLT 3.0 can be used to read or write JSON too. So I have used JSON as configuration file that is initially written by ExtendScript and then used as a way to inject data into a FrameMaker pre or post XSLT transformation.
Copy link to clipboard
Copied
Thanks for the generous help Ian. This might be useful for this project. I have a series tables that are modified after they are imported into FrameMaker (basically the sort order is updated to match a drawing). Each table is reused in multiple documents. Instead of using the default table on import, a script will use a lookup to see if the table has already been updated; if so, the updated table will be imported in its place. It may be more convenient to store the updated tables as JSON instead of XML. Thanks again.