[jdom-interest] Qe: Binary data in XML

Tom Oinn tmo at ebi.ac.uk
Wed May 30 05:03:59 PDT 2001

Ken Rune Helland wrote:
> At 12:17 PM 5/30/2001 +0200, Martin Gerlach wrote:
> >Is it possible to store binary data in a XML Document, maybe
> >CDATA-Section or something else? Or is this not allowed at...
> >I don't mean a reference to binary files, i mean binary data
> >itself to store in a XML-File.
> >
> >Thanks in advance for any reply ...
> I think you best option is to use someting like
> base64 encoding of the binary data, since base64
> doesent use any of the XML spesific caracters you
> dont even need to use CDATA. and it works even with
> 7-bit ASCII files/transmission.
> The backside is that the data will take 1/3 more
> space and the computing time to encode and decode
> the data.

That's true, but as you now have a lower information density in that
block it should compress really well. I suspect that if you gzip your
encoded content and compare to the gzip size of the content before
encoding it you'll find it's quite similar. Given that Java has very
good facilities for filtering input and output streams through
compression algorithms your storage / network bandwidth (usage
dependant) problems should go away. There's still the extra encode /
decode cost, but these algorithms are pretty simple and should run fast
enough IMHO.


"Bad kitty! Give me my crudely 
 fashioned weapon back!"
"mew."				http://sluggy.com

More information about the jdom-interest mailing list