ExifTool Forum

ExifTool => Newbies => Topic started by: csp on February 26, 2020, 01:24:29 AM

Title: Adding a custom attribute instead of a custom tag
Post by: csp on February 26, 2020, 01:24:29 AM
First of all thanks to anyone willing to read/help with the below, I've been pulling my hair out trying to solve this problem with Exiftool but I've finally succumbed to asking for help.

I'm trying to add a custom attribute (at least this is what I would call it due to working with XML/HTML), however it appears I'm not understanding the documentation or it's simply not a valid case (perhaps?), for example, using my custom config I get the following output:


<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
  <xmp:CustomAttribute>test</xmp:CustomAttribute>
</rdf:Description>
</rdf:RDF>


Here is my config:


%Image::ExifTool::UserDefined = (
  'Image::ExifTool::XMP::xmp' => {
     CustomAttribute => {
         Writable => 'string',
     },
  },
);   
1; # end



However, I'm trying to achieve the following:


<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'
  xmp:CustomAttribute='test'>
</rdf:Description>
</rdf:RDF>


I've tried several different configs which result in the same output, or simply error due to invalid config files/unwritable tags.

Is this possible with exiftool?
Title: Re: Adding a custom attribute instead of a custom tag
Post by: StarGeek on February 26, 2020, 01:58:42 AM
I think what you want is to add -api Compact=Shorthand.

See this post (https://exiftool.org/forum/index.php?topic=9096.msg46974#msg46974) for an example.  If I recall correctly, the xmpshorthand used in that post has been replaced (see this thread for details (https://exiftool.org/forum/index.php?topic=10217.msg53347)) by the -api Compact option (https://exiftool.org/ExifTool.html#Compact).
Title: Re: Adding a custom attribute instead of a custom tag
Post by: Phil Harvey on February 26, 2020, 06:54:07 AM
Yes.  -api XMPShorthand is now -api Compact=Shorthand, but the old option still works.

- Phil
Title: Re: Adding a custom attribute instead of a custom tag
Post by: csp on February 26, 2020, 05:40:17 PM
Thank you very much StarGeek and Phil, admittedly I did see this in the documentation (when searching for XMP) however thought it was only for visual spacing and such.
Title: Re: Adding a custom attribute instead of a custom tag
Post by: Phil Harvey on February 26, 2020, 09:33:13 PM
It is just visual.  The actual structure of the underlying XMP doesn't change with this option.  It is only the format of the serialization that is different.

- Phil