You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by David Cahill <da...@may.ie> on 2002/11/26 13:43:27 UTC
Storing Base64 data in Xindice
Hi,
I have converted my binary data(image) into Base64 encoding as required by
Xindice. Do I now simply cut and paste this Base64 representation into my
image element in the XML document and then copy the whole XML document into
a collection in Xindice? How best do I extract and then decode this image
element when its stored in the database?
Many thanks,
David
RE: Storing Base64 data in Xindice
Posted by Heinrich Götzger <go...@gmx.net>.
On Tue, 26 Nov 2002, Stefan Lischke wrote:
>> I have converted my binary data(image) into Base64 encoding as required by
>> Xindice. Do I now simply cut and paste this Base64 representation into my
>> image element in the XML document and then copy the whole XML
>> document into
>> a collection in Xindice? How best do I extract and then decode this image
>> element when its stored in the database?
>
>i thought about this too, but i decided not to use xindice to store non xml
>data. But maybe my decision was wrong has anybody any experience with non
>xml data and xindice
Almost a year ago I tried to store data which I'm not aware of whether
they're String or not into Xindice.
The question is: How should Xindice handle Blobs (if it should be able to
handel them anyway)?
My solution was using CDATA. This still remains some risk if the stored
data contains ']]'. So BASE64 Encoding looks good to me as well. Infact
you don't need the CDATA, since '<' or '>' is not part of the BASE64
Alphabet. But you need the time of processing the encoder and the decoder.
Now I paste some java code from my Xindice proxy:
// some global defines
private final String BEGCON_TOKEN = "<content><![CDATA[";
private final String ENDCON_TOKEN = "]]></content>";
private final String XML_PI_TOKEN = "<?xml version=\"1.0\"?>";
// storing document into database
// content holds my binary data
byte[] conten;
[..]
String data = "BEGCON_TOKEN" + new String(.content) + "ENDCON_TOKEN";
XMLResource resource = (XMLResource) col.createResource(id, "XMLResource");
resource.setContent(data);
col.storeResource(resource);
// retreiving document from database using id
[..]
XMLResource resource = (XMLResource) col.getResource(id);
String con = (String)resource.getContent();
// content holds the raw data
byte[] content =
con.substring( XML_PI_TOKEN.length() + 1 + BEGCON_TOKEN.length(),
con.length() - ENDCON_TOKEN.length() ).getBytes();
// convert content to whatever it's supposed to be, images, wav files,
// Strings, XMLBinding, whatever....
So, I hope this helps a bit.
I would drop the CDATA now and work with content as BASE64 encoded String.
kind regards
Heinrich
--
http://www.xmlBlaster.org
RE: Storing Base64 data in Xindice
Posted by Heinrich Götzger <go...@gmx.net>.
Mit freundlichen Grüßen
Heinrich Götzger
--
http://www.xmlBlaster.org
RE: Storing Base64 data in Xindice
Posted by Stefan Lischke <li...@novacom.net>.
Hi,
> I have converted my binary data(image) into Base64 encoding as required by
> Xindice. Do I now simply cut and paste this Base64 representation into my
> image element in the XML document and then copy the whole XML
> document into
> a collection in Xindice? How best do I extract and then decode this image
> element when its stored in the database?
i thought about this too, but i decided not to use xindice to store non xml
data. But maybe my decision was wrong has anybody any experience with non
xml data and xindice
thanx stefan