XML DTD help for binary data (repost)

Rick Jelliffe ricko at allette.com.au
Wed Jun 17 07:27:55 BST 1998

> From:  Gang He

> I am working on writing a XML DTD to describe a data file. The file will
> contain some binary data. I understand that I can use Entity and
> Notation to do the job. But for some reason I have to make the file
> containing the binary data a XML document file. Could someone please
> tell me whether I can use PCDATA for the binary data directly or I
> should make all binary characters into character references and then put
> them in PCDATA? And if I need make all binary characters into character
> references first, is there any way to convert the binary character into
> character reference automatically?

An XML text document can only contain characters allowed by the XML spec.

So there are many characters you cannot use: the "function" characters below
  for example. So even if with numeric character references, XML is not
a format that can be used for direct transmission of binary data. You cannot
put � in a document, for example.

You have to encode the binary data in some other notation, and put this
encoded data in the element. (You can mark up which encoding you are using
in an attribute. This may help you if you decide to change notation at some
future time.)

The most common notation to use is Base64. You can find base 64 specified in
an RFC.

You can make a more efficient encoding by using all the available
characters. There are sevearal thousand, so you might want to invent your
own Base4K  encoding, for example, if it was really a big problem.

XML is not a compound document archiving or transmission format.

Rick Jelliffe

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)

More information about the Xml-dev mailing list