2 Replies Latest reply on Feb 25, 2010 4:08 AM by Kasyan Servetsky

    XML & Scripting Questions

    forsythes Level 1

      Hello all, I've been reading through the examples adn tutorials and trying a few things out, but just can't seem to get ANYTHING to work. Here's what I would like to do:

       

      I have an xml file. Let's say it's a list of books (LibraryBooks.xml):

       

      <library>

           <book>

                <title>Flatland</title>

                <author>Abbott, Edwin</author>

                <summary>Flatland: A Romance of Many Dimensions is an 1884 novella by Edwin  Abbott Abbott, still popular among mathematics and computer science  students, and considered useful reading for people studying topics such  as the concept of other dimensions.</summary>

           </book>

           <book>

                <title>The Stars, Like Dust</title>

                 <author>Asimov, Isaac</author>

                 <summary>The book is part of Asimov's Galactic Empire series. It takes place  before the actual founding of the Galactic Empire, and even before  Trantor has become important.</summary>

            </book>

           <book>

                <title>From the Dust Returned</title>

                 <author>Bradbury, Ray</author>

                 <summary>From the Dust Returned is a fix-up fantasy novel by Ray Bradbury. The novel is largely comprised from a series of short  stories which Bradbury had written decades earlier, centering around a  family of vampires.</summary>

            </book>

      ...

      </library>        

       

      I have a script that creates an indesign document with facing pages and two linked text columns on each page.

      I want to create repeating sections which will repeat (and flow to the next column if necessary) inside the text columns and will display my data from the xml file as:

       

      [begin repeated area]

      <title>[tab]<author>[linebreak]

      <summary>

      [end repeated area]

       

      I have ZERO idea where to start or how to accomplish this. I've tried going throuh the example file "XMLRulesExampleData.xml" but I am getting an error:


      JavaScript Error!


      Error Number 54:

      Error String: Uncaught JavaScript exception: ReferenceError: myDocument is undefined


      File: C:\Program Files\Adobe\Adobe InDesign CD4\Scripts\xml rules\glue code.jsx

      Line: 78

      Source:                                throw e;

       

      So, four questions...

      1) How do I fix the error?

      2) Is glue code.jsx required for what I want to do?

      3) Are there any good SCRIPTING tutorials out there for this? I can only find step-by-step tutorials for doing things through the GUI.

      4) If there's no good tutorials out there, can someone please give me an example or walk me through it?

       

      Thanks!

        • 1. Re: XML & Scripting Questions
          forsythes Level 1

          UPDATE -- I got the file to the point where everything is dumping into my textFrame. Unfortunately, it still isn't quite right. My font styles only map properly when I keep ignoreWhiteSpace set to false. Also, everything is run together:

           

          [Flatland][Abbott, Edwin][Flatland: A  Romance of Many Dimensions is an 1884 novella by Edwin  Abbott Abbott,  still popular among mathematics and computer science  students, and  considered useful reading for people studying topics such  as the  concept of other dimensions.][The Stars, Like  Dust][Asimov, Isaac][The book is  part of Asimov's Galactic Empire series. It takes place  before the  actual founding of the Galactic Empire, and even before  Trantor has  become important.][From the Dust  Returned][Bradbury, Ray][From the Dust  Returned is a fix-up fantasy novel by Ray Bradbury. The novel is largely  comprised from a series of short  stories which Bradbury had written  decades earlier, centering around a  family of vampires.]

           

          How do I separate each element so that the styles map properly AND how do I place the elements so that the document ends up looking like this:

           

          [Flatland]     [Abbott, Edwin]

          [Flatland: A  Romance of Many Dimensions is an 1884 novella by Edwin  Abbott Abbott,  still popular among mathematics and computer science  students, and  considered useful reading for people studying topics such  as the  concept of other dimensions.]

           

          [The Stars, Like  Dust]     [Asimov,  Isaac]

          [The  book is  part of Asimov's Galactic Empire series. It takes place  before the  actual founding of the Galactic Empire, and even before  Trantor has  become important.]

           

          [From the Dust  Returned]     [Bradbury, Ray]

          [From the Dust  Returned is a fix-up fantasy novel by Ray Bradbury. The novel is largely  comprised from a series of short  stories which Bradbury had written  decades earlier, centering around a  family of vampires.]

           

          Thanks!

          • 2. Re: XML & Scripting Questions
            Kasyan Servetsky Level 5

            1) The error says that myDocument is undefined --

            Make sure that your script contains the following line somewhere at start:

            var myDocument = app.activeDocument;

             

            2) glue code.jsx is required only if you are going to use XML rules.

             

            3) Check out XML and XML Rules chapters in InDesign Scripting Guide, and supporting sample files.

             

            4) Some time ago I read a book called Designer's Guide to Adobe  InDesign and XML -- in chapter7, it provides an example of creating a book catalog with XML -- seems quite close to what you want.

             

            Kasyan