0 Replies Latest reply on Feb 23, 2010 7:02 PM by shi-sru-

    various weird javascript/xml related behaviors

    shi-sru-

      Hi all,

       

      I am new to scripting with Adobe and InDesign and perhaps it is my script that is not well thought but

      below are some unexpected behaviors I have seen so far.

      (This suppose an in design file which elements are related to an xml tree)

       

      - duplicate groups:

       

      when i duplicate a group containing elements related to the xml, the related xml elements are added at the wrong place:

      ------------------

      <root>

      <prod>

            <title/>

            <description/>

      </prod>

      </root>

       

      duplicating the group containing those elements will result in:

       

      <root>

      <prod>

            <title/>

             <description/>

             <description/>

            <title/>

      </prod>

      </root>

      ------------------

       

      the prod tag is indeed not attached to anything but why place them here (i would find more logical to add them on the root)?

      should i do this in an other way??

      duplicate the prod in the xml tree and then add them on the page (is this possible ?)

      attach the prod tag to a Story will solve this? (instead of copying the group, i'll copy a story containing the group?)

       

      - remove xml element associated to an object on the page

       

      works fine for Story :

      ....associatedXMLElement.remove();

      it will remove the corresponding tag in the xml tree and live the pageItem on the page with the text

      but with graphics,it will erase both of them (the xml tag and the graphic on the page)

      i guess that the linkage is lost but i don't loose the text when removing text based item...

       

      - reassigning geometricBounds to a group.

      i duplicate each group and place them on the page one after an other.

      if need so , i move them to a new page.

      As i use the duplicate function (it seems that groups[0] is equivalent to the last duplicated item, stack?),

      i use the offset related to the last group duplicated.

      when i move to the second page, obviously the offset is plaining wrong so I ve tried to reassign the geometricBounds of the very first group.

      for some reason, it does place the group back at the same position but loose the graphic in the mean time...

      i have changed it so that i calculate the proper offset when moving to a new page anyway, but still wondering why.

       

      - loosing the appliedParagraphStyle with placeXML:

       

      $.writeln(elm.parentStory.appliedParagraphStyle.name) ->displays the proper style
      children[child].placeXML(elm);

      $.writeln(elm.parentStory.appliedParagraphStyle.name) ->displays the default style

       

      That's all for now...

      I have been doing this for only 2 days now so it is far to be 'in design' minded