Author Topic: XML export requests  (Read 6805 times)

Offline MikeA

  • Member
  • **
  • Posts: 63
    • View Profile
XML export requests
« on: June 12, 2008, 02:15:47 AM »
Please consider changing Photo Mechanic's XML export format. The present format is:

 <key>file_size</key>
 <string>18.7MB</string>
 <key>date</key>
 <string>4/12/2008</string>
 <key>time</key>
 <string>2:44:00 PM</string>

But this kind of generic tagging scheme, with the content of each "key" describing the purpose of the next "string" in the XML file, doesn't do what XML tagging was designed to do: unambiguously describe the nature or purpose of a discrete piece of data. XML elements should be specific kinds of containers, as it were. For example:

 <fileSize>18.7MB</fileSize>
 <date>4/12/2008</date>
 <!-- Please use ISO date format if possible: 2008-04-12 -->
 <time>2:44:00 PM</time>

And/or, use attributes for unambiguous description:

 <IPTC_FIELDS
   City="Stockholm"
   Country="Sweden"
   Keywords="comma-separated keyword list goes here"
 />

or

 <IPTC_FIELDS>
   <city>Stockholm</city>
   <country>Sweden</country>
   ... etc.etc.
 </IPTC_FIELDS>

The XML file certainly needn't be as grim-looking as XMP, but surely it should be far more XML-like than it is at the moment.

Other things I noticed about the XML-export feature: it doesn't write a final carriage-return+line-feed to the file, something that a few text-processing utilities will interpret as meaning that the output file isn't an actual text file. If the user-named XML output file already exists, there is no overwrite warning. If the output file exists but is unwriteable for some reason, PM doesn't exactly crash, but it does present a runtime-error dialog that appears after the program has tried to write to the output file. The dialog box is probably useful for diagnostic purposes ("(eval):642:in `kickoff_background_export') but requires some guesswork by the user to determine what went wrong.

Thanks.

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 20128
    • View Profile
    • Camera Bits, Inc.
Re: XML export requests
« Reply #1 on: June 12, 2008, 06:48:49 AM »
Mike,

Please consider changing Photo Mechanic's XML export format. The present format is:

 <key>file_size</key>
 <string>18.7MB</string>
 <key>date</key>
 <string>4/12/2008</string>
 <key>time</key>
 <string>2:44:00 PM</string>

But this kind of generic tagging scheme, with the content of each "key" describing the purpose of the next "string" in the XML file, doesn't do what XML tagging was designed to do: unambiguously describe the nature or purpose of a discrete piece of data. XML elements should be specific kinds of containers, as it were. For example:

 <fileSize>18.7MB</fileSize>
 <date>4/12/2008</date>
 <!-- Please use ISO date format if possible: 2008-04-12 -->
 <time>2:44:00 PM</time>

And/or, use attributes for unambiguous description:

 <IPTC_FIELDS
   City="Stockholm"
   Country="Sweden"
   Keywords="comma-separated keyword list goes here"
 />

or

 <IPTC_FIELDS>
   <city>Stockholm</city>
   <country>Sweden</country>
   ... etc.etc.
 </IPTC_FIELDS>

The XML file certainly needn't be as grim-looking as XMP, but surely it should be far more XML-like than it is at the moment.

Other things I noticed about the XML-export feature: it doesn't write a final carriage-return+line-feed to the file, something that a few text-processing utilities will interpret as meaning that the output file isn't an actual text file. If the user-named XML output file already exists, there is no overwrite warning. If the output file exists but is unwriteable for some reason, PM doesn't exactly crash, but it does present a runtime-error dialog that appears after the program has tried to write to the output file. The dialog box is probably useful for diagnostic purposes ("(eval):642:in `kickoff_background_export') but requires some guesswork by the user to determine what went wrong.

Those are nice suggestions, but if we were to just change the format of the XML it might upset a number of people that have come to depend upon the way it is formatted now.  We don't want that.

The XML exporter used to be written in C++ and was completely closed off for the enterprising user.  It no longer is written that way.  It is now a template that you can copy to your own user exporter templates folder and modify as you see fit.  Based on your posting I expect that this is something that you would be quite capable of doing yourself.

I'll look into the issue of a missing line feed at the end of the output and the issue with the existing file issue you mentioned.

If you need any help in adjusting the XML exporter template to your own needs, please feel free to ask questions.

-Kirk


Offline MikeA

  • Member
  • **
  • Posts: 63
    • View Profile
Re: XML export requests
« Reply #2 on: June 12, 2008, 11:52:02 AM »
Those are nice suggestions, but if we were to just change the format of the XML it might upset a number of people that have come to depend upon the way it is formatted now.  We don't want that.

I can understand that. If ever you decide to create an alternative output format, perhaps it could be a user preference. The default would be the format now in use; existing customers' routines wouldn't be compromised.

Quote
The XML exporter used to be written in C++ and was completely closed off for the enterprising user.

Aha, I bet that explains the missing final line-ending. (I can think of at least one other export-to-XML package, available via simple function call -- the dev never needs to roll his own XML writer -- that also omits the line-ending at the end of the file. The truly charming ones are export-to-XML routines that write everything on a single line.)(Don't get me started. :-)

Quote
Based on your posting I expect that this is something that you would be quite capable of doing yourself.

Yes, parsing the XML output file and changing its format would be a relatively simple thing (as would adding the missing cr/lf pair at the end of the file).

Quote
If you need any help in adjusting the XML exporter template to your own needs, please feel free to ask questions.

Thanks, I will. It will be an odd way to think of XML, but I think a Perl script that treats the file in "line-wise" fashion (rather than DOM fashion) wouldn't be so difficult to write...

Offline bellinghamherald

  • Newcomer
  • *
  • Posts: 5
    • View Profile
Re: XML export requests
« Reply #3 on: February 20, 2009, 12:24:08 PM »
Quote
The XML exporter used to be written in C++ and was completely closed off for the enterprising user.  It no longer is written that way.  It is now a template that you can copy to your own user exporter templates folder and modify as you see fit.  Based on your posting I expect that this is something that you would be quite capable of doing yourself.

I'll look into the issue of a missing line feed at the end of the output and the issue with the existing file issue you mentioned.

If you need any help in adjusting the XML exporter template to your own needs, please feel free to ask questions.

Where is the XML template exactly? I am using the 4.6 beta version.

Thanks

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 20128
    • View Profile
    • Camera Bits, Inc.
Re: XML export requests
« Reply #4 on: February 20, 2009, 12:38:59 PM »
Quote
The XML exporter used to be written in C++ and was completely closed off for the enterprising user.  It no longer is written that way.  It is now a template that you can copy to your own user exporter templates folder and modify as you see fit.  Based on your posting I expect that this is something that you would be quite capable of doing yourself.

I'll look into the issue of a missing line feed at the end of the output and the issue with the existing file issue you mentioned.

If you need any help in adjusting the XML exporter template to your own needs, please feel free to ask questions.

Where is the XML template exactly? I am using the 4.6 beta version.

Thanks

What OS are you running?  The location of the template varies by OS.

-Kirk

Offline bellinghamherald

  • Newcomer
  • *
  • Posts: 5
    • View Profile
Re: XML export requests
« Reply #5 on: February 20, 2009, 12:49:17 PM »
MAC OSX

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 20128
    • View Profile
    • Camera Bits, Inc.
Re: XML export requests
« Reply #6 on: February 20, 2009, 01:40:00 PM »
MAC OSX

OK, then from the Finder, Control-click on the Photo Mechanic application, choose "Show Package Contents" from the contextual menu.  Then open the Contents folder.  Then open the builtin_templates folder.  Then open the export folder.  Then copy the XML folder to a location outside of the application.  The template file is called "template-main.rb" which resides in the XML folder.  Make your modifications, and then use the Preferences dialog's Files tab and set the "Location of user Exporter templates:" to the folder containing your duplicate XML folder.  I suggest also changing the internal name of the template (in the .rb file) so that you can distinguish between the original XML template and your custom XML template.

HTH,

-Kirk

Offline bellinghamherald

  • Newcomer
  • *
  • Posts: 5
    • View Profile
Re: XML export requests
« Reply #7 on: February 20, 2009, 02:33:24 PM »
Perfect. Thanks for the quick response.

Offline bellinghamherald

  • Newcomer
  • *
  • Posts: 5
    • View Profile
Re: XML export requests
« Reply #8 on: March 04, 2009, 11:48:27 AM »
And where is the XML export template on the PC?

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 20128
    • View Profile
    • Camera Bits, Inc.
Re: XML export requests
« Reply #9 on: March 04, 2009, 12:09:43 PM »
And where is the XML export template on the PC?

For most users it will be in this path:

C:\Program Files\Camera Bits\Photo Mechanic 4.6\builtin_templates\export\XML

-Kirk

Offline bellinghamherald

  • Newcomer
  • *
  • Posts: 5
    • View Profile
Re: XML export requests
« Reply #10 on: March 04, 2009, 12:27:11 PM »
On the PC I was using 4.4 and it appears it didn't have that template. I upgraded and can see it now. Thanks for the help.