Generating my own XML with -p and would like to encode '<' and '>' only

Started by yarda, February 23, 2016, 05:57:30 PM

Previous topic - Next topic

yarda

Hello,

for my weired purposes, I am trying to generate my own XML file with -p option and a FMT file. Works just fine. Tho' it is not encoding '<' or '>' which I understand.

If I add -h to my command line, it goes ahead and encodes these; however, it encodes other characters too, which I do not like/want. I would like to stick to the translation of '<' and '>' only. Having them not encoded, it gives me warnings like the following one: "Warning: XMP format error (no closing tag for C) - ./image.jpg.xml" for "<C>" in my photo description.

It looks like a warning only, manipulating "<C>" as I want at the end. However, is it really true under any circumstances? Cannot I run into any theoretical troubles having '<', '>' not encoded in my pseudo-XML files?

Thank you,
Yarda.

Phil Harvey

Hi Yarda,

Quote from: yarda on February 23, 2016, 05:57:30 PM
Tho' it is not encoding '<' or '>' which I understand.

You can define a Filter to do this for you.

QuoteIf I add -h to my command line, it goes ahead and encodes these; however, it encodes other characters too, which I do not like/want.

You must also encode the ampersand (&). I think you wanted -E, not -h, however this alse encodes the quotes which you don't want, so the Filter may be the best route:

exiftool -api "filter=s/>/&gt;/g;s/</&lt;/g" ...

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yarda

Thank you, it works like a charm in 10.10. I tried with 9.98 which is marked as stable by Gentoo folks, but that is a different story. Thank you again. exiftool is pretty flexible with regexp.

Phil Harvey

This is frustrating to me.  I guess I need a disclaimer saying that any advice I give is relative to the current version of ExifTool.  This particular feature was added in version 10.05 back in Nov 2015.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yarda

No offense! Appreciate your prompt responses - no doubts. Lesson learned, no more bugging comments like that even for reference of others. :) On some systems, sadly, I can only install what has been officially labeled as stable, quite frustrating policies... So for me what matters is since which version are the mentioned features available. I am not saying that I need to know that from you in your replies, I understand it would only delay your comments, not to mention that considering of weired policies of others would bug even myself. :) Cheers, Yarda....

Phil Harvey

Hi Yarda,

Sorry.  I was just a bit edgy because this has happened a number of times recently.

Interesting that 9.98 is marked as stable.  I didn't think that ExifTool could ever be marked as stable because it must continue to evolve to support new camera models as they are released.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yarda

They'll eventually approve them all, I hope, it only takes time... https://packages.gentoo.org/packages/media-libs/exiftool