3 Replies Latest reply on Sep 7, 2011 3:09 AM by Jörg Ehrlich

    XMPToolKit v5.1.2 Problem (Bug?)

    T Schneider Level 2
      I have started using v5.1.2 of the ToolKit, and I have run into a problem.
      In the XMP specification Part 2 page 9 states:
      The namespaces define a set of properties. In any given XMP Packet, a property may be absent or present:
      Absent: The property has no value. Properties are absent until given a value for the first time.
      Present: The property has a defined value. A present property may have the empty string as its value; this is different from an absent property. However, writers are encouraged not to set properties with a value of the empty string.
      But version 5.1.2 of the XMPToolKit removes empty properties in some cases (as opposed to v4.4.2).
      One example is the ApplyTemplate function. The function removes all empty properties / structures when merging two XMP
      To see an example of this add an extra property at line 138 in XMPCoreCoverage.cpp :
      static const char * kSimpleRDF =
      "  <rdf:Description rdf:about='Test:XMPCoreCoverage/kSimpleRDF' xmlns:ns1='ns:test1/' xmlns:ns2='ns:test2/'>"
      "    <ns1:SimpleProp>Simple value</ns1:SimpleProp>"
      "    <ns1:SimplePropEmpty></ns1:SimplePropEmpty>"
      "    <ns1:ArrayProp>"
      When you run the example, the "SimplePropEmpty" property gets removed by the ApplyTemplate function.
      If you look in the code of the XMPToolKit it actually looks like this is done on purpose. One example, lines 709 - 715 in XMPUtils-FileInfo.cpp:
      if ( valueIsEmpty ) {
           if ( deleteEmpty && (destNode != 0) ) {
                delete ( destNode );
                destParent->children.erase ( destPos );
           return; // ! Done, empty values are either ignored or cause deletions.
      But if there is to be difference between absent and present, but empty, properties, then these should be preserved (?)
        • 1. Re: XMPToolKit v5.1.2 Problem (Bug?)
          Jörg Ehrlich Adobe Employee

          Hi Thomas,


          empty values are indeed a difficult topic in general, but what you describe is actually "as designed".

          All normal XMPCore APIs treat empty values just like non-empty values. But there are utility functions like ApplyTemplate, that interpret empty values sometimes different, depending on the parameters they are given.

          Please refer to the XMP Toolkit SDK Programmer’s Guide for further details regarding the available parameters for this function.




          • 2. Re: XMPToolKit v5.1.2 Problem (Bug?)
            T Schneider Level 2

            Hi Jörg,


            Thank you for the answer. I have reread the documentation and I can see that I did not read it properly the first time. My mistake.


            The ApplyTemplate function in version 5 replaced the AppendProperties function from version 4. The AppendProperties preserved empty properties in the XMP data that was merged in. This is a feature we rely on, so I had to make a few changes to the ApplyTemplate to get it to also merge empty properties.


            Would you consider adding another parameter for the ApplyTemple function, so that is possible to get to preserve empty properties ?


            Thank you,


            Thomas Schneider

            • 3. Re: XMPToolKit v5.1.2 Problem (Bug?)
              Jörg Ehrlich Adobe Employee

              Hi Thomas,


              I can understand that this API change causes confusion.

              The name change for the function should also emphasize the intended semantic of it. The previous function did a mixture of template operations and simple merging of XMP packets which resulted in unexpected results sometimes. The new API was meant to make the expected result more clear.

              The second parameter of the new API should really be considered a "template" that defines how properties are treated in a given XMP packet and not a second XMP that is merged into the other one. For a template, empty properties have a certain semantic according to the provided parameters for the template operation. This is a difference to the "normal" empty value behavior. This has mainly historical reasons and cannot be easily changed.


              Hope this helps

              Kind regards