3 Replies Latest reply on Jul 18, 2008 9:42 AM by GagnonEric

    CS2 AS: Scripted "Import XML" is not working (like manual import does)

    GagnonEric Level 1
      I have problem where importing a XML (merge import + delete unmatched) by script simply doesnt work, where the manual import works 100% fine!!??

      (I'm exporting the XML, refill it with new text data (localisation process actually), and bring the xml back to commit the change in the Indesign document).

      With the script, the XML get imported as a child in the XML

      I have xml structure like:

      root
      node

      and get something like

      root
      node
      root
      node

      My code looks like this (sorry for the formatting):

      tell application "Adobe InDesign CS2"
      tell XML import preferences
      set create link to XML to false
      set ignore unmatched incoming to true
      set ignore whitespace to false
      set import style to merge import
      set import text into tables to false
      set import to selected to false
      set repeat text elements to false
      set remove unmatched existing to true
      end tell

      try
      import XML (document 1) from pFilePath
      on error pmsg
      display dialog pmsg
      end try
      end tell

      Is there something obvious that i'm misssing??

      ps: I have checked the XML structure correspondance already.. but i dont think that's the cause of problem as the manual import is working.

      Thanks for any help!

      Eric
        • 1. Re: CS2 AS: Scripted "Import XML" is not working (like manual import does)
          GagnonEric Level 1
          Oh well, oh well...

          After trying a few other things, i was able to figure out that what was the problem: the XML import preferences has to be set at document level, not application level!

          I suppose that the logic behind this is application level= interaction with UI and document level= interaction with script.. but it's kind of weird to save application state preference at document level and surely havent seen any documentation on that behavior.

          Anyway.. Let's move on!
          • 2. Re: CS2 AS: Scripted "Import XML" is not working (like manual import does)
            Level 1
            Hi Eric,

            If you can see the behavior in the user interface, you can see it in scripting. I think it makes perfect sense to have the XML import preferences set at the document level, because some documents need one set of preferences; other documents need another. I think (hope) that the user documentation covers the differences between application and document preferences (if not, I do, in my book).

            If you see a preferences object on both the application and the document, assume you want to use the document preferences. Unless you're trying to set preferences for new documents.

            Thanks,

            Ole
            • 3. Re: CS2 AS: Scripted "Import XML" is not working (like manual import does)
              GagnonEric Level 1
              Hi!

              If you would have two different script acting on the same documents but with different settings (ex. one would append sections and the other update the complete data)... wouldnt it be dangererous to rely on the document recorded xml import preferences??? You have use case where you rely on this??

              ps: It's really just to discuss as my "batch" works 100% fine now!

              Eric