3 Replies Latest reply on Mar 18, 2008 4:51 AM by (hp_)

    place xml in anchored textframe

      hi all,

      i'm using IDCS3 and javascript. i tried to place a xmlElement into an anchored textFrame and got the error:
      "Elements cannot be place into an inline."

      code is (shortened):
      ] _anchoredFrame = _xmlEbene0.xmlElements.item(_refElement).xmlElements[i].insertionPoints.item(0).textFrame s.add();
      ] _xmlElement.placeXML(_anchoredFrame);

      anyway i can place the element into a ordinary textFrame and cut/paste this frame into the inline frame.

      seems like a pretty dirty workaround. questions arise:
      1. am i missing something?
      2. wherre is the problem in inserting xml into inline textFrames?
      3. is my workaround a bug or feature -> is indesign likely to crash with such documents? is there any problem with xml handling further on?

      thanks for any information,
        • 1. Re: place xml in anchored textframe
          Level 1
          hi all,

          some additionally information about the outcomes of the script:

          with the above workaround (cut/paste) inDesign messes the xml up.
          the original placed (and cutted) xmlElement is now inserted as a xmlElement "Story" inserted at the anchored position in the xml tree.
          this is of course not intended (but easy fixed with renaming)

          by the way: this seems to affect any cut/paste operation with xmlElements. in my opinion this is sort of bug in inDesign xml handling.

          • 2. Re: place xml in anchored textframe
            srakete Level 1
            Hi Gregor,

            I have done something similar with Xml Rules. The method I used was placeIntoInlineFrame:

            function processElement(){
            this.name = "processElement";
            this.xpath = "//root/myElement";
            this.apply = function(myElement, myRuleProcessor){

            var myTextframe = myElement.placeIntoInlineFrame([25,2.78])
            myTextframe.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
            myTextframe.anchoredObjectSettings.anchorPoint = AnchorPoint.BOTTOM_RIGHT_ANCHOR;
            myTextframe.anchoredObjectSettings.horizontalAlignment = HorizontalAlignment.RIGHT_ALIGN;
            myTextframe.anchoredObjectSettings.horizontalReferencePoint = AnchoredRelativeTo.TEXT_FRAME;

            return false;

            Hope this helps


            • 3. Re: place xml in anchored textframe
              Level 1
              hi stefan,

              cool this works - just got the proof of concept working. i hadn't thougt to realize such an operation with xmlRules.

              there's nothing to add to the above rule!

              thanks a lot.