6 Replies Latest reply on Jun 10, 2008 5:00 AM by Patrick Leckey

    Read specific xmlns

    John.Kordas Level 1
      Can anyone tell me if this is possible?<br /><br />In the console I type this.metadata; and get<br /><br /><x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.0-c316 44.253921, Sun Oct 01 2006 17:08:23"><br /> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><br />  <rdf:Description rdf:about=""<br />    xmlns:xap="http://ns.adobe.com/xap/1.0/"<br />    xmlns:dc="http://purl.org/dc/elements/1.1/"<br />    xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/"<br />    xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"<br />    xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"<br />    xmlns:illustrator="http://ns.adobe.com/illustrator/1.0/"<br />    xmlns:pdf="http://ns.adobe.com/pdf/1.3/"<br />   xap:ModifyDate="2008-06-06T12:00:52+10:00"<br />   xap:CreateDate="2008-06-06T12:00:52+10:00"<br />   xap:MetadataDate="2008-06-06T12:00:52+10:00"<br />   dc:format="application/pdf"<br />   xapMM:DocumentID="uuid:5aa68b72-0d3c-7d46-8f2c-a3ddc3402225"<br />   xapMM:InstanceID="uuid:a7c80703-af0c-9047-aac8-fcc8f99ac9aa"<br />   Iptc4xmpCore:Location="City"/><br /> </rdf:RDF><br /></x:xmpmeta><br /><br />If I wanted to check via javascript that Iptc4xmpCore:Location has a value how do I return that value?<br /><br />Any suggestion would be appreciated.
        • 1. Re: Read specific xmlns
          Patrick Leckey Level 3
          You can read the section in the JavaScript for Acrobat API Reference on Doc.metadata, specifically Example 3. It shows how to do what you are asking.
          • 2. Re: Read specific xmlns
            John.Kordas Level 1
            Thanks PDL,

            I've seem this example but having a problem understanding how to call a container. I've been able to write to the metadata using that example but I'm can not seem to return the data.

            example:

            var AdsMLPPName = "AdsML Company"
            var AdsMLPPContact = "AdsML Contact"
            var AdsMLPPEmail = "AdsML Email"
            var meta = this.metadata;
            var myXMPData = new XML(meta);
            myx = new Namespace("adobe:ns:meta/");
            myrdf = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
            mypdf = new Namespace("http://ns.adobe.com/pdf/1.3/");
            myxap = new Namespace("http://ns.adobe.com/xap/1.0/");
            mydc = new Namespace("http://purl.org/dc/elements/1.1/");
            myAdsML = new Namespace("http://adsml.org/xmlns/");
            var p = myXMPData.myrdf::RDF.myrdf::Description;

            if (p.@myAdsML::Marked.toString() == "" )
            {p[0] +=
            {AdsMLPPName}
            {AdsMLPPContact}
            {AdsMLPPEmail}

            } else {
            p.@myAdsML::PreperssName = AdsMLPPName;
            p.@myAdsML::PrepressContact = AdsMLPPContact;
            p.@myAdsML::PrepressEmail = AdsMLPPEmail;
            }
            //Convert myXMPData into a string
            myNewXMPStr=myXMPData.toXMLString();
            //and assign it to the document metadata
            this.metadata = myNewXMPStr;

            This is fine but if I want to check the value of AdsML:PrepressName="AdsML Company" for example if i try metadata.PrepressName it returns undefined.
            • 3. Re: Read specific xmlns
              Patrick Leckey Level 3
              > if i try metadata.PrepressName it returns undefined

              That certainly doesn't give me enough information to help you. How have you defined your 'metadata' variable and the PrepessName namespace object?
              • 4. Re: Read specific xmlns
                John.Kordas Level 1
                I have a dialog box that has 3 fields.

                When the user completes the dialog and click ok these 3 variables passed here:

                var AdsMLPPName = "AdsML Company" //Dialog variable 1 goes here
                var AdsMLPPContact = "AdsML Contact" //Dialog variable 2 goes here
                var AdsMLPPEmail = "AdsML Email" //Dialog variable 3 goes here

                Using the code above the variable values are put into the pdf metadata under the http://adsml.org/xmlns/ namespace defined by myAdsML = new Namespace("http://adsml.org/xmlns/");

                The problem I'm having is understanding how to check if these variables have been assigned previously and return them so I can display them is my dialog.

                Is it possible to check if the pdf has the http://adsml.org/xmlns/ namespace assigned and if so does a PrepressName, Contact and Email exist.

                Does this help?
                • 5. Re: Read specific xmlns
                  John.Kordas Level 1
                  Ok the answer seems to be :<br /><br />myXMPData.myrdf::RDF.myrdf::Description.myAdsML::PrepressName;<br /><br />will return AdsML Company.<br /><br />I've go through the script line by line. Do you have to create a new XML()?<br /><br />var meta = this.metadata;<br />var myXMPData = new XML(meta);<br /><br />if I try for example meta::RDF i get:<br /><br />reference to undefined XML name <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.0-c316 44.253921, Sun Oct 01 2006 17:08:23">\r\..................<br /><br />I'd like to check if a specific namespace has been added and if so does a specific description exist?<br /><br />Any suggestions would be appreciated.
                  • 6. Re: Read specific xmlns
                    Patrick Leckey Level 3
                    Considering Doc.metadata simply returns the XML formated XMP metadata in a string, why not use the JavaScript search() method to simply see if your definition is contained in the string?