
Hi, On Wed, 2005-12-21 at 15:15 +0100, Werner F. Bruhin wrote: [...]
Yeap, that works. Also the resulting file is huge (e.g. a 88kb JPEG results in a XML of over 2MB). I brought this down by doing a PIL.image.thumbnail, but are there some other ways to reduce the XML file size?
Yes, zip it either using Libxml2's gzip-compression support or as an additional layer on your side.
I am not sure I understand, but will look up in the libxml2 doc. But I think I prefer going with your solution of the href, but see below.
There's e.g. xmlSetDocCompressMode(xmlDocPtr doc, int mode) to specify the compression mode for saving: http://www.xmlsoft.org/html/libxml-tree.html#xmlSetDocCompressMode
I also noticed that "</imageasstring>" is "overlapped" by the last line of the image data.
With 'overlapped', you mean something like "b64b64b64gestring>" ?
I attached an image.
I assume the image shows only a snippet of the XML, right? If yes, then it looks normal to me. Have you tried viewing it with a simple text editor? [...]
Note that your approach of putting the binary data into an XML file is a rather uncommon approach, as one normally tends to attach the binary resources via references; i.e. something like <image-ref>mypic.jpg</image-ref>.
I don't like the base64 approach, but I saw this in some files also they used the CDATA element (which I think is DTD stuff?)
http://www.w3.org/TR/2004/REC-xml-20040204/#sec-cdata-sect CDATA is merely out there to ease direct editing of the XML file. Putting base64 into CDATA has zero benefit.
You say attach? Is this happening by XML magic or would I have to ensure that "mypic.jpg" is in the same folder and/or uri location?
The latter. On your side, you would read the URI from the XML and load the image file. If you need not sending the stuff to somewhere then there's no real need to squeeze the image data into a single XML file. The XML file holds the meta data, the image file holds the binary data.
In the XML Schema I have as a choice either base64 or the URL (wouldn't mind to get rid of the base64 stuff), which is defined as:
<xs:element name="imageurl" type="xs:anyURI" minOccurs="0"> </xs:element>
Is that how you would have defined image-ref?
Rather: <xs:choice> <xs:element name="data" type="xs:base64Binary"> <xs:element name="uri" type="xs:anyURI"> </xs:choice> Some people would prefer not to use the 'image' prefix for the tag-names: <image> <mode>RGB</mode> <size>(540, 982)</size> <uri>file:///data/images/pic.jpg</uri> This is a matter of preference of course. I recommend asking XML and its peripherals related questions at xml-dev@lists.xml.org. Regards, Kasimier