XML vs the Dreaded Whitespace

Rick Jelliffe ricko at allette.com.au
Thu Dec 11 10:57:59 GMT 1997

Attached is a repost summary of the white-space characters available in
XML from ISO 10646.  Of course, it is still up to applications to implement
them correctly. 

At the moment, spaces and newlines are very overloaded which causes all
sorts of problems.  So it would solve many problems to use these characters.

For example, if you want a hard return, use the hard return character 

and if you need non-collapsing white-space, use   

In this particular case, one thing to do is put an attribute at the top-level element
to prevent collapsing and stripping of spaces and tabs.  As far as CR/LF, 
I think the XML spec can only be interpreted to mean that

   <!ENTITY cr     "&#13;">
   <!ENTITY lf     "&#10;">


should be preserved.  This is because 2.11 

"To simplify the tasks of applications, wherever an external 
parsed entity or the literal entity value of an internal parsed 
entity contains either the literal two-character sequence 
"#xD#xA" or a standalone literal #xD, an XML processor must 
pass to the application the single character #xA. (This behavior 
can conveniently be produced by normalizing all line breaks 
to #xA on input, before parsing.)"

So normalization *should* apply only to direct characters, not
references.  However, I dont think you can trust parsers to
do this.  So if you want to send facsimile documents
with whitespace preserved, you might find you have to
use a Unicode private-use-area character to substitute for CR.
Your application at the other end has to replace that character
again to reconstruct the document.

For example, you could use

	<!ENTITY cr  "&#xF00D" >

This is a case where you want to do something that is definitely
contrary to the simplifying rules of XML, so don't be alarmed
that you have to use markup (which you give a significance to)
rather than being able to do it direct. 

Rick Jelliffe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: space (1).htm
Type: application/octet-stream
Size: 2841 bytes
Desc: space (1).htm (Internet Document (HTML))
Url : http://mailman.ic.ac.uk/pipermail/xml-dev/attachments/19971211/7421f8e2/space1.obj

More information about the Xml-dev mailing list