Bug 214816

Summary: Error with new XML Format if tag-name contains characters that are not valid as XML Tags
Product: [Applications] kphotoalbum Reporter: Dominik Stadler <dominik.stadler>
Component: XML backendAssignee: KPhotoAlbum Bugs <kpabugs>
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version: 4.0 (KDE4)   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:

Description Dominik Stadler 2009-11-16 15:13:58 UTC
I have a custom category called "Jahreszeit/Stimmung", this is in use since a long time (i.e. from the time the app was still called KimDaBa). It seems there is a new format for the index.xml file which breaks this now!

When starting KPA (I am using 4.1.1 compiled for Ubuntu/Kubuntu), I get something like "Error in row XX, column XX in .../index.xml" and the location is when the string "Jahreszeit/Stimmung" is used as XML Tag now:

  <image width="1600" Jahreszeit/Stimmung="1" Orte="6" startDate="2001-02-01T11:30:49" height="1200" md5sum="ff26a3e252ad65b74942885f0e0aba67" Personen="4,15" file="Img0015/dscn0629.jpg" endDate="2001-02-01T11:30:49" label="dscn0629" angle="0" Stichwörter="32" />


Not sure when this change to the XML format was done, I think 4.0.2 did still work and 4.1 might have introduced this problem.
Comment 1 Dominik Stadler 2009-11-16 16:33:56 UTC
the change in format is as follows:

previously a tag in the index.xml looked as follows:

  <image width="1600" startDate="2001-01-01T13:30:07" height="1200" md5sum="aeee29c985d036f97ef53ef2811995a9" file="Paul, Lara und Samuel/dscn0885.jpg" endDate="2001-01-01T13:30:07" label="dscn0885" angle="90" >
   <options>
    <option name="Jahreszeit_Stimmung" >
     <value value="Fasching" />
    </option>
    <option name="Orte" >
     <value value="Oberkappel" />
    </option>
    <option name="Personen" >
     <value value="Paul" />
    </option>
   </options>
  </image>

now it looks like this:

  <image width="1200" Jahreszeit/Stimmung="7" Orte="6" startDate="2001-01-01T13:30:07" height="1600" md5sum="aeee29c985d036f97ef53ef2811995a9" Personen="18" file=XXX.jpg" endDate="2001-01-01T13:30:07" label="dscn0885" angle="90" />

so the item "Jahreszeit/Stimmung" was an XML-VALUE before and is an XML-TAG now. However XML puts much tighter restrictions on what an XML-TAG can contain, that's where the problem occurs.

as a workaround, replacing this with e.g. underscore to "Jahreszeit_Stimmung" allowed me to continue
Comment 2 Dominik Stadler 2009-11-21 17:55:48 UTC
I got the following suggestion on the mailing list:
"Seems like you checked the "Choose speed over readability for index.xml on the
Dtabase backend tab in the settings dialog."

Unchecking this option fixed my problem after I manually changed the XML and reverted it again later. 

However I still think KPA should handle that case gracefully or at least warn the user in the options dialog that this is the case, i.e. special characters in the categories will prevent KPA from loading this database in the future!!
Comment 3 Miika Turkia 2012-01-23 20:59:00 UTC
Git commit 1e000f14a92540f67d9a7598488d9acbf9f6b4b2 by Miika Turkia.
Committed on 23/01/2012 at 21:47.
Pushed by mturkia into branch 'master'.

Encode special characters in XML attribute names

Special characters that are not allowed by XML spec in attribute name
are encoded in hex using following notation _.XX

M  +8    -0    Settings/DatabaseBackendPage.cpp
M  +4    -0    Settings/DatabaseBackendPage.h
M  +15   -1    XMLDB/FileReader.cpp
M  +15   -1    XMLDB/FileWriter.cpp

http://commits.kde.org/kphotoalbum/1e000f14a92540f67d9a7598488d9acbf9f6b4b2