[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Binary content and allowed characters in XML


xml allowed characters
I don't think readability alone is a sufficient reason to forbid binary
content from appearing in an XML document.

What defines the set of allowed characters in XML content ? Is it technical
reasons, or readability reasons ?

Technical reasons are related to the need of simplicity of implementation of
XML parsers. XML parsers should be allowed to follow a very simple set of
states and rules, being implemented as finite-state automata with very few
states.

This means, for example, that you have to forbid certain delimiter
characters from appearing in names, attribute values or text nodes, the best
example being '<'. We could remove this limitation with various tricks, but
this would complicate the parser and/or the serializer.

I think technical reasons alone forbid a very small set of characters from
appearing in the content : it may be limited to '<', whitespaces and
quotation marks, depending on the state of the parser (e.g. in text nodes
whitespaces and quotation marks are allowed).

Moreover, the fact that some character have to be forbidden is simply due to
the fact that XML parsing uses delimiter characters ; there are other ways
of encoding XML-like labeled trees that do not use delimiter characters. For
example, we could encode the length of each content string instead of
marking its end by a state-dependent stop character. I'm not sure this would
complicate the parser. This way, strings could be composed of any arbitrary
byte sequence, which would mean that we could encode text as well as binary
data in XML, at the cost of readability (no one wants to read all those
bytes encoding the length of strings).

The problem is, readability is a subjective concept. There's no character
encoding that both contains all required characters for a given language and
that are readable on all platform. If you define readability by "I can read
it with vi under my Unix variant", you'll have hard times trying to find
such an encoding.

Forget about english-centric character encoding. Lots of people have to
encode content with weird accentuated characters (I'm French so I know a bit
about that), and many more people don't have a 26 character alphabet, but
bunches of ideograms. Chances are that an XML file containing Kanji
characters in not readable on vi running on whatever Unix variant.

How do you define readability in this context ? How do you justify the fact
that you cannot directly embed binary data within an XML document, whereas
Kanji text would look to me as binary data, on my occidental computer ?

I don't think the readability of the serialized form is so important. What
matters to me is the fact that I can correctly exchange labeled trees while
keeping the serialization/parsing process simple and platform-independent.

XML answers this need, as long as labels and values are 'text', whatever it
means for the W3C (once again, UTF-8 string is no longer text for me as soon
as I've got French accentuated characters in my strings). But for binary
data, I have to use tricks. I don't want to.

Regards,
Nicolas Lehuen

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.