Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Autorun script that adds elements to an XML file on open with Notify event

$
0
0

Hello,

I am working with FrameMaker 2019 and I try to add some elements to an xml file based on a custom application when a new xml file is selected by the user.

I have managed to set the notification (with Constants.FA_Note_PostOpenXML) and register the script in FM, but I have to following strange behavior:

1. The object property of the Notify function does not seem to reflect the new xml doc object

2. By selecting the app.ActiveDoc object in order to insert elements in the xml file these elements are actually inserted but are not shown unless I first select to create a new xml file (with any type of structured application).

 

The code I use is as follows:

 

Notification(Constants.FA_Note_PostOpenXML , true);

function Notify (note, object, sparam, iparam) {
switch (note) {
     case Constants.FA_Note_PostOpenXML:     doWork();          break;     }
}

function doWork() {
     var doc = app.ActiveDoc;     var flow = doc.MainFlowInDoc;     var elemBook = flow.HighestLevelElement;     var ELEM_BOOK_META = doc.GetNamedElementDef("book-meta");     // ... more element definitions          var elementBookMeta = ELEM_BOOK_META.NewElement(elemBook.TextRange.end);      // ... adding more elements to to the xml ...
}

 

As stated above,

If I pass the object parameter to my doWork function the elements are not added to the xml.

By executing doc.Redisplay() or doc.Reformat() the xml does not get updated with the added elements.

The only way to see the added elements is to create a new xml file (whatever structured application but for sake of simplicity assume that I always create xml files for my custom app) and come back to the previously created xml file.

 

Does anyone have any ideas for this behavior or how I can get the script to update the xml with my new elements?

Any help is appreciated.

Thanks.


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>