xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Jamison <rjami...@lincom-asg.com>
Subject Re: Binary data in XML documents
Date Fri, 06 Oct 2000 14:27:43 GMT


Sean Kelly wrote:

> Folks:
>
> I'm working on a project that returns an XML document as the result of a
> query.  Sometimes, we want to return a small binary object, like an image or
> a sound bite, in the document.  As an example:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE result ...>
> <result>
>   <name>John Q. Public</name>
>   <phone>+1 234 567 8900</phone>
>   <portrait>...</portrait>
> </result>
>
> where the <portrait> tag in this case would contain some binary data.
> Normally, we'd just put the URL to a portrait in there, but often the binary
> data lives somewhere that's not HTTP accessible.
>
> I'm curious to know how other people have encoded binary data in XML
> documents.  Anyone?

Sean,

I would suggest using Base64 encoding.  Several examples of
Java encoders/decoders are available on the web.  You can pretty
much encode anything that way.   The & < and >  will not be in
the data stream.


<portrait file="JQPublic.jpg">
BQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAA
AAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIA
AAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZ
AAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAA

  etc.......

IAAAACEAAAAiAAAAIwAAACQAAAAlAAAAJgAAACc
AAAAoAAAAKQAAACoAAAArAAAALAAAAC0A
AAAuAAAALwAAADAAAAAxAAAAMgAAADMAAAA0
AAAA/v///zYAAAA3AAAAOAAAADkAAAA6AAAA
OwAAADwAAAD+////PgAAAD8AAAB
</portrait>



Bob Jamison
LinCom Corp




Mime
View raw message