[jdom-interest] Binary files as XML content

Amy Lewis amyzing at talsever.com
Sun Oct 22 12:34:33 PDT 2000


Not quite sure how this is directly related to JDOM.  Is it?

On Sun, Oct 22, 2000 at 08:14:47AM -0700, Aspi Siganporia wrote:
>Is it invalid to use binary data as content of XML elements, even if
>it is part of a CDATA section.
>
>I wanted to build a file transfer function on top of XML. It works
>fine except that it complains about "Invalid XML character" when I try
>with binary files like .tar or .jpg.
>
>So, is my assumption correct that XML contents should only be
>printable text?

I believe that this is true for HTML as well, or for anything traveling
over HTTP; I'm fairly certain that you have to MIME-encode anything
outside the 7-bit ASCII range for HTTP (possibly not true, or possibly
dependent upon HTTP version; I'm not checking, just remembering).

>I suppose that would force me to build file transfer by reading /
>writing over Servlet input/output streams.

Or base 64 encode everything using the XML transport that you have. 
Or, for that matter, uuencode or binhex it, but base 64 is a more
"standard" option.

>Just want to double check before I change course.
>
>Does anyone know of public domain utility Java methods to do that?

File transfer?  Like getting the input/output stream from URI or
URIConnection?  Not sure what it is that you're asking for ...

Amy!
-- 
Amelia A. Lewis          alicorn at mindspring.com          amyzing at talsever.com
Confidence: a feeling peculiar to the stage just before full comprehension
of the problem.



More information about the jdom-interest mailing list