You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Praveen Boinee <pr...@gmail.com> on 2008/01/18 11:30:56 UTC

storing image data in xml

Dear Developers

I would like to know if its possible to  write image data in XML format
using xerces in C++?. The image has to be loaded dynamically based on the
data stored in xml. we cannot store the image  location as a xml attribute.

any C++ code sample would be very much appreciated

Many Thanks

RE: storing image data in xml

Posted by Jesse Pelton <js...@PKC.com>.
An image typically IS binary data (though it may contain textual
metadata).  That's why you need to encode it as text.  If your images
are in some format that represents the data in text (if there is such a
thing), you can just include the data in text nodes - assuming that the
text is consistent with whatever character encoding the document uses
(UTF-8, UTF-16, etc).

To encode an image, you'd load it into a buffer, perhaps by reading it
from a disk file.  Pass the buffer to Base64::encode(), and it will
return a string with the base64-encoded data.

-----Original Message-----
From: Praveen Boinee [mailto:praveen.boinee@gmail.com] 
Sent: Friday, January 18, 2008 8:56 AM
To: c-users@xerces.apache.org
Subject: Re: storing image data in xml

Hi Jesse

Thanks a lot for th info.
Are there any classes available in xerces to convert an image to binary
data?

Regards
Praveen

On Jan 18, 2008 5:21 AM, Jesse Pelton <js...@pkc.com> wrote:

> You'll need to encode the binary data in some text representation.  A
> base64 encoding is typically used for this sort of thing, and as it
> happens, Xerces provides a Base64 class (see
> http://xerces.apache.org/xerces-c/apiDocs/classBase64.html).  When
> creating a document, you'll need to encode the data as text, create a
> text node using that text, and append the  text node to some element
in
> your document (assuming you're using the DOM).  When reading, you'll
> fetch the text and decode it to binary form before using it.
>
> I don't have any code.
>
> -----Original Message-----
> From: Praveen Boinee [mailto:praveen.boinee@gmail.com]
> Sent: Friday, January 18, 2008 5:31 AM
> To: c-users@xerces.apache.org
> Subject: storing image data in xml
>
> Dear Developers
>
> I would like to know if its possible to  write image data in XML
format
> using xerces in C++?. The image has to be loaded dynamically based on
> the
> data stored in xml. we cannot store the image  location as a xml
> attribute.
>
> any C++ code sample would be very much appreciated
>
> Many Thanks
>

Re: storing image data in xml

Posted by Praveen Boinee <pr...@gmail.com>.
Hi Jesse

Thanks a lot for th info.
Are there any classes available in xerces to convert an image to binary
data?

Regards
Praveen

On Jan 18, 2008 5:21 AM, Jesse Pelton <js...@pkc.com> wrote:

> You'll need to encode the binary data in some text representation.  A
> base64 encoding is typically used for this sort of thing, and as it
> happens, Xerces provides a Base64 class (see
> http://xerces.apache.org/xerces-c/apiDocs/classBase64.html).  When
> creating a document, you'll need to encode the data as text, create a
> text node using that text, and append the  text node to some element in
> your document (assuming you're using the DOM).  When reading, you'll
> fetch the text and decode it to binary form before using it.
>
> I don't have any code.
>
> -----Original Message-----
> From: Praveen Boinee [mailto:praveen.boinee@gmail.com]
> Sent: Friday, January 18, 2008 5:31 AM
> To: c-users@xerces.apache.org
> Subject: storing image data in xml
>
> Dear Developers
>
> I would like to know if its possible to  write image data in XML format
> using xerces in C++?. The image has to be loaded dynamically based on
> the
> data stored in xml. we cannot store the image  location as a xml
> attribute.
>
> any C++ code sample would be very much appreciated
>
> Many Thanks
>

RE: storing image data in xml

Posted by Jesse Pelton <js...@PKC.com>.
You'll need to encode the binary data in some text representation.  A
base64 encoding is typically used for this sort of thing, and as it
happens, Xerces provides a Base64 class (see
http://xerces.apache.org/xerces-c/apiDocs/classBase64.html).  When
creating a document, you'll need to encode the data as text, create a
text node using that text, and append the  text node to some element in
your document (assuming you're using the DOM).  When reading, you'll
fetch the text and decode it to binary form before using it.

I don't have any code.

-----Original Message-----
From: Praveen Boinee [mailto:praveen.boinee@gmail.com] 
Sent: Friday, January 18, 2008 5:31 AM
To: c-users@xerces.apache.org
Subject: storing image data in xml

Dear Developers

I would like to know if its possible to  write image data in XML format
using xerces in C++?. The image has to be loaded dynamically based on
the
data stored in xml. we cannot store the image  location as a xml
attribute.

any C++ code sample would be very much appreciated

Many Thanks