5 Replies Latest reply on Sep 15, 2009 11:09 AM by Dave Saunders

    Using XML tags to generate index entries

    dnblack3

      Before I start this, just want to say that I tried to search through the forum to see if this issue had been raised before, but apparently the search functionality has been "disabled by your administrator".

       

      I've got a document that I need to create an index for and I have certain topics and names that need to go into an index.  I'd like to script the creation of index entries for these items, as each document could be up to 800 pages long and indexing that would be, em, tedious.  Enter the personal computer....

       

      I've tried using the FindTextPreferences, but I don't think it can search for tags, so this may have to be done at import (or export).

       

      Anybody done this before or have a couple lines that would show how to do it?

       

      Thanks

       

      D

        • 1. Re: Using XML tags to generate index entries
          Bob Stucky Adobe Employee

          I might suggest looking at XML Rules (starts on page 141 of the IDCS4 Scripting guide).

           

          I did it that way for one project, it worked well and was reasonably fast. My code allowed multiple taxonomies in the index so was a bit too complex to put forth as an example. To simply scan for tags is pretty straightforward and well represented in the scripting guide.

           

          Bob

          1 person found this helpful
          • 2. Re: Using XML tags to generate index entries
            dnblack3 Level 1

            Thanks for the reply, Bob. I looked into that and there are good examples of finding XML elements. I suppose the problem I'm having, though, is about selecting those elements and inserting them into the index.  I'm trying to create the index and add the index entries.  I tried to do it originally by finding all text with a certain paragraph style, but that included symbols, inadvertently.  So I wanted to do something through XML rules, but when doing a find and replace, I can use the:

            Set found_words =  myDocument.FindText();

             

            and then use

             

            Set myIndex= myDocument.Indexes.Add()

             

            to create the index and loop through the paragraphs to add entries to the index.  I'm having trouble creating the index and finding a way to take the words and add them to the index, that's all.

            • 3. Re: Using XML tags to generate index entries
              Dave Saunders Level 4

              You need to first add topics to the index and then add page references to the topics.

               

              Dave

              • 4. Re: Using XML tags to generate index entries
                dnblack3 Level 1

                I'm using the following code to add the topic, but I have the feeling I'm missing something.

                 

                Set myIndex = myDocument.Indexes.Add()

                Set myTopicName = myXMLElement.Texts.Item(1).Contents
                Set myTopic = myIndex.Topics.Add(myTopicName)

                • 5. Re: Using XML tags to generate index entries
                  Dave Saunders Level 4

                  This is VB rather than JS so I'm not 100% comfortable, but that looks right. Does the topic appear in the Index panel when you run that?

                   

                  To get references though, you now need to add PageReference objects to the Topic.

                   

                  Dave