XML: content bundled with presentation?
March 31, 2009
There is a growing interest in Domain Specific Languages (DSL), and feeling that this technology would eventually render XML obsolete. Consider the following example of “2+2=4” written in XML:
Aside from being insulting to reader’s intelligence, can you spot what is wrong with it? Where do these tree node annotations are coming from? Consider a grammar for expression parser:
constraint : expression ‘<‘ expression
| expression ‘=‘ expression
expression : expression ‘+’ expression
In formal languages and parser theory world we have clear separation of the data (that is “2+2=4”), on one hand, and the schema describing the structure of the data (that is the expression grammar), on the other. In XML world the data and the schema are bundled together into some caricature of the parse tree. Yes, skipping parsing as the hard part of the job is somewhat handy, but what happened to the famous programming principle “Separate content from presentation”?