7 Replies Latest reply on Mar 6, 2008 12:49 PM by (Olav_Kvern)

    eventlistener with after import xml

    Level 1
      I added the a file testStartup.jsx wit the following code in Startup Scripts folder. the alert in main is diaplayed as soon as i open indesign. But when i import xml the alerts in myEventInfo and processFootnotes are not displayed. Could you please tell me what iam missing. This is working with File - Place menu. What event i shall use to trigger after import xml menu option

      #targetengine "session"

      main();
      function main(){

      alert("about to add listeners");
      var myApplicationEventListener = app.eventListeners.add("beforeImport",myEventInfo, false);
      myEventInfo, false);

      var myEventListener = app.addEventListener ("afterImport", processFootnotes, false);
      }

      function myEventInfo(myEvent){
      var myString = "Current Target: " + myEvent.currentTarget.name;
      alert(myString);
      }

      function processFootnotes(){
      alert("Start");

      }
        • 1. Re: eventlistener with after import xml
          srakete Level 1
          Hi Soni,
          as your script shows, the events afterImport and beforeImport are triggered by placing a file onto the layout, not by importing an xml-file.
          What exactly do you want to do with the xml before and after the import?

          Before the import you may want to transform the xml with XSL. And having imported the xml into the document you may work with XML-Rules before placing it in a textframe. Once you have it placed in the textframe you can use the powerful combination of GREP and XML rules.
          I am sure you will be able to process those footnotes.

          Stefan Rakete
          www.indesignscript.de
          • 2. Re: eventlistener with after import xml
            Level 1
            Hi Stefan,

            Actuall i added beforeimport just for test. I wrote some script to process the footnote tags in xml (both in normal text and the one with in table) and to add footnotes in indesign. I tested the script from script panel. Now what I need is, I want to execute that script auomatically after importing the xml (into our template), instead of user runs it.

            Could you please tell me how can i achieve this

            Thanks,
            suneetha
            • 3. Re: eventlistener with after import xml
              srakete Level 1
              If I understand right, the user is doing the xml Import ? Can you not add a dialog for the user to choose the xml, import the xml, do you footnote processing all in one script ?

              Stefan
              • 4. Re: eventlistener with after import xml
                Level 1
                Yes user will open the template and import the xml with File - Import XML menu option.

                Iam processing all the footnote tags of xml in one script file
                • 5. Re: eventlistener with after import xml
                  Level 1
                  Hi soni/Suneetha,

                  What Stefan is saying is: create a script that leads the user through the process. If you do this, you don't have to worry about event listeners/event handlers at all. Since there is no specific event generated by the Import XML process, this seems like a good approach.

                  Thanks,

                  Ole
                  • 6. Re: eventlistener with after import xml
                    Level 1
                    To do everything in one script, is there any possibility of getting the standard import xml code and appeding my script to that as a continution. If so where can find thats
                    • 7. Re: eventlistener with after import xml
                      Level 1
                      Hi soni/Suneetha,

                      You can find an example of importing XML in the ImportXML.jsx script that's in the Scripting Guide scripts archive. Direct link:

                      http://wwwimages.adobe.com/www.adobe.com/products/indesign/scripting/downloads/indesign_cs 3_guide_scripts.zip

                      Thanks,

                      Ole