1 Reply Latest reply on Jun 10, 2010 2:12 PM by [Jongware]

    JS: XMP Children of Children

    lanejd

      I know this may be a simple question to answer, but I am stuck. I am not a programmer, but I am trying to learn, and I am working with an actual programmer on this project, but he is not very familiar with scripting in InDesign, so I am trying to get him the high-level information he needs and he in turn helps me understand how to use that programmatically. So far this has worked really well within InDesign, but now I am venturing into the uncharted waters of XMP.

       

      I am trying to write a script that will add XMP metadata to images. The idea is to run a script that will allow me to manually position the images in InDesign and then store that information in the XMP of the image so that the next time I use that image (running a different script), it will automatically position itself according to the XMP metadata. The image's XMP needs to hold position data for a number of material types and it needs to be extensible (hence the XMP), but looking through the documentation I am not able to decipher how to inject XMP data with multiple children into the image file, or how to add a child later on. I have been successful in putting a single property into a file's XMP data using the following script:

       

      new ExternalObject('lib:AdobeXMPScript');
      xmpFile = new XMPFile(
           'file.png', 
           XMPConst.FILE_PNG, 
           XMPConst.OPEN_FOR_UPDATE
      );
      xmpData = new XMPMeta();
      
      xmpData.setProperty(
           XMPConst.NS_PNG, 
           'propertyName', 
           'data'
      );
      

       

      I have a schema in mind for the data and I am trying to keep it human-readable so that it can be more easily used in the future. I just can't figure out how to inject a parent --> child --> etc. type schema into the XMP.

       

      Is there any documentation that anyone can point to that can help me understand this a little better? I have read the XMP section in the JavaScript Tools Guide and, while I admit I don't understand most of it, I can't seem to locate any information on how this would be done. Is there a section within that section that I can show my progammer that would help him understand how to do this?

       

      Thanks in advance for any help you can give.