4 Replies Latest reply on Mar 6, 2017 5:18 AM by arekh2792424

    An idea regarding XML and JS that I would like to make happen!

    arekh2792424 Level 1

      Hello world!

           I am working on a project and had an idea I was wondering if it would be possible to accomplish with indesign / javascript. I currently have a script  that creates files and adds a time-stamp, a name of who created the file, and some other variables in a footer section of the document. I got to thinking, that since all of those variables are already recorded if there was a way to have a script export these strings to a XML file to create a library of all documents that were created, when, by whom, etc. Is there a way to record specific object contents into an XML database? I am scripting for a business and it would a massive tool for us were we able to see all of this data in a single clean database that is done by a computer as opposed to the short hand, hand written, often incomplete notes we have now. I am open to any and all ideas suggestions, etc!

        • 1. Re: An idea regarding XML and JS that I would like to make happen!
          Mikie9 Level 1

          Here is a function of mine that writes the data from a variable to an xml file. You would probably have to play with the formatting some because mine is a simple one line xml file that I am writing but that shouldn't be hard to do.

           

          function breakWrite(){

           

              breakPointXml.open('r');

              breakPointXmlRead=breakPointXml.read();

              breakPointXml.close;

              var breakPointXmlObj = new XML(breakPoint);

              breakPointXmlObj2 = new File();

              breakPointXmlObj2.open('w');

              breakPointXmlObj2.write(breakPointXmlObj);

              breakPointXmlObj2.copy(breakPointXml);

              }

          1 person found this helpful
          • 2. Re: An idea regarding XML and JS that I would like to make happen!
            arekh2792424 Level 1

            Thank you so much for your input! I admit this is my first time working with writing XML interactions in javascript, would you mind giving me some notes on how your script works and what the different lines of code are doing?

            • 3. Re: An idea regarding XML and JS that I would like to make happen!
              Kasyan Servetsky Level 5

              Hi there,

               

              I don’t quite understand why you decided to keep this info in the footer section of the document; you must have a good reason for this: maybe you need to print it, or you already have loads of such documents and have to deal with what you have. But if I were you, I’d keep it in metadata because of the following reasons:

              • It’s easy to get/set metadata by script
              • It’s easy to see and modify it for the user: in the ‘File info’ dialog box, or in Bridge
              • Metadata is copied to exported files: e.g. if you export a pdf and send it to a print shop, they will be able to see the info – who created it, etc.

              05-03-2017 15-15-06.png

              Anyway, if you applied properly a paragraph style (and/or character style), it will be easy to duplicate it to metadata. 

              Then I would use a really awesome utility created by Phil Harvey called ExifTool to create a CSV-file containing the metadata from all the documents in a certain folder.

              For example, to get all XMP info from the files in the "D:\Test" folder I’d type this line:

               exiftool -csv -r -xmp:all "D:\Test">"D:\Test\meta out.csv"
              

              05-03-2017 14-56-43.png

              ExifTool creates a CSV-file like so:

              05-03-2017 14-57-00.png

              which can be imported, say, to Excel (or Access, or a database)

              05-03-2017 14-58-51.png

              Now in Excel, you can see all the info I entered in InDesign:

              05-03-2017 15-00-04.png

              If necessary, you can export it from Excel as XML-file.

              This is one of the few approaches that came to my mind.

               

              Hope this helps.

               

              Regards,

              Kas

              1 person found this helpful
              • 4. Re: An idea regarding XML and JS that I would like to make happen!
                arekh2792424 Level 1

                WOW Thank you so much this is what I was looking for! Actually both of those reasons for keeping the footer are correct, I work at a print shop and we not only print all of our files, but have loads of them and keep a physical filing system still (I know -.-). I will do some experimenting and investigation with this but i do believe this is exactly what I had in mind! Much obliged.