0 Replies Latest reply on Sep 30, 2008 2:14 PM by GagnonEric

    [CS2][AS] Make XML import map is calling a refresh on styles?

    GagnonEric Level 1
      If this can be of use to someone else... it's probably not CS2,AS specific.. but this is what i use.

      It's the second time i have a bug like this, where changing the order of my calls is fixing the problem. With this one, i was getting random missing font error (times(1)) while batching documents(wich make the batch script batch crash as there is a modal dialog open). Not always on the same document, it was really fustrating as i was not able to get my finger on the problem!

      I actually knew the source of the problem as i had added a fix (maybe not the best solution, but it was working well) that actually was removing the style from all the text frame (i noticed that using map style to tag was not always working well(when text frame had overriden?), so that's why i added code to reset the style before doing a map. But i was not understanding why it was happening so randomly...

      I tought at first it was happening during save (as it reopen the document) but after a few experimentation it looked like it was occuring during the import map redefinition (See code below: make XML import map with properties {markup tag:tStyle, mapped style:tStyle}).

      Looks like the make XML import is calling some sort of document refresh wich then pop the font missing dialog (even with never interact as script preferences!)! (missing font is actually a bug i had also in other circumstances.. exemple when you have a extra return at the end of a tagged text (outside the tag)). A bit unexpected, i really tought that creating a xml import map was just creating data structure in document model to be used later on by the auto style call...

      The problematic script:

      tell application "Adobe InDesign CS2"
      set myDocument to document 1
      tell myDocument
      --Reset styles.
      set applied character style of every text of every text frame of every spread to character style 1
      set applied paragraph style of every text of every text frame of every spread to paragraph style 1

      --Create a tag to style mapping.
      set tList to name of every XML tag
      set tNumItems to count of tList

      repeat with i from 1 to tNumItems
      set tStyle to item i of tList
      make XML import map with properties {markup tag:tStyle, mapped style:tStyle}
      end repeat

      --Map the XML tags to the defined styles.
      auto style
      end tell
      end tell

      And the working solution (just moved the reset of style after the import map creation loop):

      tell application "Adobe InDesign CS2"
      set myDocument to document 1
      tell myDocument
      --Create a tag to style mapping.
      set tList to name of every XML tag
      set tNumItems to count of tList

      repeat with i from 1 to tNumItems
      set tStyle to item i of tList
      make XML import map with properties {markup tag:tStyle, mapped style:tStyle}
      end repeat

      --Reset styles.
      set applied character style of every text of every text frame of every spread to character style 1
      set applied paragraph style of every text of every text frame of every spread to paragraph style 1

      --Map the XML tags to the defined styles.
      auto style
      end tell
      end tell