base64-encoding versus CDATA-escaping
Hi,
I am wondering about the pros and cons of using base64-typed data versus
using a CDATA section.
If I want to transfer data contained in an xml document I can either
a) put the data in an element whose data is CDATA escaped. This can give me
trouble with encoding, primarily between iso8859 and UTF16.
or
b) base64-encode the data and put in an element with datatype base64. This
give me no trouble with the encoding.
What are the pros and cons with these different ways?
Since MS is heavily using base64 in NET-ish, isnt this the way to go?
/k
Re: base64-encoding versus CDATA-escaping
MS is moving toward DIME for attachments. Here's a short quote from MSDN:
"Direct Internet Message Encapsulation (DIME) is a lightweight, binary
message format that can be used to encapsulate one or more
application-defined payloads of arbitrary type and size into a single
message construct. Each payload is described by a type, a length, and an
optional identifier. Both URIs and MIME media type constructs are supported
as type identifiers. The payload length is an integer indicating the number
of octets of the payload. The optional payload identifier is a URI enabling
cross-referencing between payloads. DIME payloads may include nested DIME
messages or chains of linked chunks of unknown length at the time the data
is generated. DIME is strictly a message format: it provides no concept of a
connection or of a logical circuit, nor does it address head-of-line
problems. "
You can find more here:
(http://msdn.microsoft.com/downloads/...s/sample.asp?u
rl=/msdn-files/027/002/108/msdncompositedoc.xml)
"kurt sune" <apa@apa.com> wrote in message
news:3e06ef49@tnews.web.devx.com...
> Hi,
> I am wondering about the pros and cons of using base64-typed data versus
> using a CDATA section.
>
> If I want to transfer data contained in an xml document I can either
>
> a) put the data in an element whose data is CDATA escaped. This can give
me
> trouble with encoding, primarily between iso8859 and UTF16.
>
> or
>
> b) base64-encode the data and put in an element with datatype base64. This
> give me no trouble with the encoding.
>
> What are the pros and cons with these different ways?
>
> Since MS is heavily using base64 in NET-ish, isnt this the way to go?
>
> /k
>
>
>
>
>
Re: base64-encoding versus CDATA-escaping
Use a CDATA section if you don't expect the processes that will process your
XML to understand base64. Otherwise you are free to use which ever technology
you prefer. CDATA is XML's native method for handling data that should not
be parsed, and, therefore, you can expect any XML processor to understand
the contents of the CDATA section. base64 encoded sections, on the other
hand, will obviously require a processor to decode the section before it
can be used.
You have probably noticed that the base64 encoding algorithm adds a considerable
amount of bloat to a file. CDATA sections, therefore, shouldn't contain that
bloat. A method that may help reduce the base64 bloat is to gzip the content
prior to base64 encoding.
If you are having trouble with encoding (iso8859 and UTF16), then try specifying
the encoding in the xml prolog:
<?xml version="1.0" encoding="UTF-8"?>
Furthermore, base64 encoding your unparsed data requires two possibly unnecessary
additional steps:
1. base64 encoding your data
2. base64 decoding your data
Best Regards,
Jim J. Marion
"kurt sune" <apa@apa.com> wrote:
>Hi,
>I am wondering about the pros and cons of using base64-typed data versus
>using a CDATA section.
>
>If I want to transfer data contained in an xml document I can either
>
>a) put the data in an element whose data is CDATA escaped. This can give
me
>trouble with encoding, primarily between iso8859 and UTF16.
>
>or
>
>b) base64-encode the data and put in an element with datatype base64. This
>give me no trouble with the encoding.
>
>What are the pros and cons with these different ways?
>
>Since MS is heavily using base64 in NET-ish, isnt this the way to go?
>
>/k
>
>
>
>
>