Re: XML vs the Dreaded Whitespace
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 xml:space="preserve" 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 " "> <!ENTITY lf " "> <p> </p> 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 "" > 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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format