Delayed XML Formatting

 

Preformatted XML files are larger than their delayed formatted counterparts because of the increased character count. The smaller size achieved by delayed formatting can only be seen as very small, if not negligible optimization. However, the real reason preformatted XML should be avoid is it encourages bad practices.

Allow me to explain; by saving formatting with the data it becomes necessary to define style guides for the creation of XML documents. The programs that use the XML however will ignore all this styling, so the only real gain of preformatted XML is it makes viewing easier for the creator. But what happens when the creator sends this document to another developer who prefers a different formatting? Or what if the creator adapts new style guidelines for XML viewing?  In both of these cases there is not easy way for the developers to make these changes without changing the file which holds the data. The solution is to use delayed formatting on XML, and to encourage the development of tools that can apply styling to XML files for human viewing and editing without saving that styling in the file.  By leaving all styling up to the viewer/editor we can achieve smaller XML documents, more intelligent xml viewing/editing tools, and most importantly a decoupling of style and data.

 

Separate your data and your style, website styling is best done with CSS, and formatting of XML is best done by the viewer/editor.

 

Previous Post