7 Replies Latest reply on Aug 3, 2009 12:46 AM by liedzeit

    Scripting Tags

    Roy Marshall Level 1

      Hi

       

      I want to look at Tags in InDesign XML, with a view to script some features.

      Can someone give me a link to some recourses for this part of InDesign?

       

      Cheers

       

      Roy

        • 1. Re: Scripting Tags
          liedzeit Level 2

          You mean like "take a look at the Adobe example scripts in the XML folder"?

           

          What exactly do you want to do?

           

          Ralf

          • 2. Re: Scripting Tags
            Roy Marshall Level 1

            Hi Ralph.

             

            I did hunt for some sample scripts, but I dont appear to have them.  What I really want to do before launching into a scripting project, is understand how the XML tags work.  I have had a quick squiz through the documentation, but maybe need to look deeper.  I could only find some very basic online, old CS1 pages.

             

            What I am ultimately looking to do is work on a page that has been already populated using an Applescript, from an export from a database.

             

            i need to be able to tag the paragraphs, and compare at a later date with a dump from the database to look for any changes in the data, then to alert to any changes, and allow the user to update with the new data.  This is adventurous, and possible way over my head, but as this point, I ned to understand how tags work, and get a feel to the ability, and limitations with using them.

             

            Thanks

             

            Roy

            • 3. Re: Scripting Tags
              [Jongware] Most Valuable Participant

              XMLElements are strange beasts.

               

              Document | XMLElement | XMLItem
              XMLItem
              XMLElement
              Cell | Character | EPS | Image | InsertionPoint | Line | PDF | PICT | PageItem | Paragraph | Story | Table | Text | TextColumn | TextStyleRange | WMF | Word | XMLAttribute | XMLComment | XMLElement | XMLInstruction | XMLItem

               

              is the object hierarchy (XMLElement in the center is the base object; above are parents, below are descendents). As you can see, an XML element can be part of another XML element, and also contain XML elements. That mimicks the "tree" structure of an actual XML document. At the very top is usually a document, which only has one XML element (per definition!). This one is the one usually called "Root" when you start tagging a document, but you can name it whatever you like.

               

              The XMLItem is sort of generic XML placeholder -- it can 'contain' basic XML blocks such as a DTD, a comment, a PI instruction, or .. an XML element. You probably won't need it at this point

               

              The root XML element may contain any number of further xmlElements, and these again as well, until you end up with a basic block (usually a paragraph, but I have to tag stuff even inside that).

              So a useful basic function to have is a recursive tree walker, that starts at the top and stops when it has found a certain element. (I have one for you, but not at the mo'.)

               

              Best is to start with a fully tagged file -- open the XML structure pane on the left side to see what the relations look like -- and write a few functions to find arbitrary items in your document. You can use the 'contents' property of the XML element to check what text it contains.

               

              (End of XML 1.0.1)

              1 person found this helpful
              • 4. Re: Scripting Tags
                Roy Marshall Level 1

                many thanks, gives me something to do now!!!!!!

                 

                Cheers

                 

                Roy

                • 5. Re: Scripting Tags
                  liedzeit Level 2

                  Roy,

                  get yourself the sample scripts

                   

                  Download the InDesign Scripting Guide scripts (ZIP,                                    648k                                   )

                   

                  and then go thru the XML examples. I would start with an empty document and build up more and more complex stuff. Start with CreateXMLElement for example. But you can of course do it like jongware suggested start with a fully tagged document. That is if you have one.

                  The biggest problem will be to decided for a specific structure for all your documents and then stick to it.

                   

                  Ralf

                  1 person found this helpful
                  • 6. Re: Scripting Tags
                    Roy Marshall Level 1

                    HI Ralph.

                     

                    These are the very scripts I was looking for.  They will help me on my quest.  I am only on CS3, so maybe dont have these scripts on a CS3 install.

                    Out of interest, I know that not a great deal changed (unlike cs2>cs3) with CS4 and scripting, but can you see any problems with me uing these on CS3?

                    I have tried a couple and looks ok.

                     

                    Thanks again.

                     

                    Roy

                    • 7. Re: Scripting Tags
                      liedzeit Level 2

                      Roy,

                      I do not think that there is a difference between 3 and 4 in this respect. For CS3 you can get the same scripts but you would have to hunt for them yourself. Adobe is kind enough to hide some of the resources. So a scripter has to prove himself capable of finding them.

                      Good luck,

                      Ralf