Skip navigation
T Schneider
Currently Being Moderated

XMPToolKit v5.1.2 Problem (Bug?)

Aug 31, 2011 4:15 AM

Hi,
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 (?)
Thomas
 
Replies
  • Currently Being Moderated
    Sep 6, 2011 9:25 AM   in reply to T Schneider

    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.

     

    Regards

    Jörg

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 7, 2011 3:09 AM   in reply to T Schneider

    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

    Jörg

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points