3 Replies Latest reply on May 10, 2009 2:55 PM by Kasyan Servetsky

    From XMLElement to Page Item

    jsantaelena

      Hi All,

       

       

      I have a page with two frames: a Graphic Frame and a Text Frame. These two are tagged to a XMLElement. From a XMLRule I'm trying to set their contents. To set the text content, i'm using XMLElementsetContents(VariableTypeUtils.createString("my text")). But, to set the graphic content I'm having problems. I'm trying to use the XMLElement.getXMLContent(), but I don't know how to narrow it to use. Anybody has a code snippet to do this or an adivice for me?

       

      Thanks,

      Best Regards.

        • 1. Re: From XMLElement to Page Item
          Kasyan Servetsky Level 5

          Here is an example of how I did it:

          http://www.kasyan.ho.com.ua/downloads/XML%20Import.zip

          Take a look at the function ProcessAd().

           

          Kasyan

          1 person found this helpful
          • 2. Re: From XMLElement to Page Item
            jsantaelena Level 1

            Thank you for reply.

             

            But, I'm using Java Corba, and I'm not finding the myPic[0].constructor.name equivalent.

             

            If I'm undestanding your script, there is no way to get the associated frame from a xml element (like we can do with associatedXMLElement from a frame)? But I couldn't see how are you positioning the new placed image at the same position of the xml element associated frame.

            • 3. Re: From XMLElement to Page Item
              Kasyan Servetsky Level 5

              If I'm undestanding your script, there is no way to get the associated frame from a xml element (like we can do with associatedXMLElement from a frame)?

              Here is a sample script that shows how to find the associated page item for an XML element. You can download all of them from ID scripting page. They show all can do with XML (37 samples) and XML-rules (22 samples).

               

              This script was made for a very specific workflow – myPic[0].constructor.name == "Story" – checks if the placed file is image or text.

              I just wanted to show you a general idea: how to place a graphics by XML-rule.

              File's name is stored in XML-attribute:

              var myPicFile = new File (myImagesFolder + "/" + xmlAttributes.item("file").value);

              then I place the file

              var myPic = app.activeWindow.activePage.place(myPicFile, myBounds, undefined, false, false);