From: Henrik Martensson Date: 2006-01-27T17:54:22+09:00 Subject: Re: Valid XML PIs for ERB On Thu, 2006-01-26 at 12:13, leoboiko@gmail.com wrote: > Hi. Why doesn't ERB work with valid XML processing instructions, as > suggested by lots of people[1]? Is there any good reason we're stuck > with invalid, nonstandard, Microsoft-inspired "<%...%>" tags? It > shouldn't be difficult to allow both syntaxes (someone even made a > patch[2]), and .rhtml files could finally be valid XHTML. Historical reasons, mostly. HTML started out as inspired by SGML, rather than compliant with SGML. The people who built the first web servers didn't know much about SGML, and so they reinvented processing instructions in an annoyingly incompatible manner. Ever since, web frameworks have been built on a solid foundation of don't-bother-me-with-the-basics-of-SGML/XML-processing. Quite successfully too, which really grates my cheese. :-) In addition to the non-compliant syntax there are problems with how the <%...%> tags are used. It is very common for them to contain either procedural instructions, such as in PHP and Rails, or to be tightly coupled to procedures, such as ASP.NET and Java tag libraries. None of this is good from an SGML/XML point of view. The SGML/XML paradigm says "separate information from processing so that the same information can be processed by many different applications". This is quite different from the OO idea of "bunch data and operations together in an object". (Apologies for the vast oversimplification.) A processing instruction, when used as originally intended, indicates that something should be done, and what that something is. It should not indicate which piece of software that will perform the action. A well written processing system (again, from an SGML/XML point of view) uses templates that are independent of the templating system, so that they can be processed by other software if need be, just as you suggest. I am no Rails expert, but as I understand it, Rails is one of the few, MVC based web application framework that can easily be taught to understand processing instructions. It is possible to add new templating systems fairly easily. If someone added an XML compliant templating system, Rails would have a strong competitive advantage with SGML/XML aware organizations, for example in the automotive, telecommunications, and electronics industries. An alternative is to skip the MVC framework bit altogether, and build Transformation View based applications instead. Not much framework support that I know of, but a paradigm that fits the problem better than MVC in many cases. With a Transformation View based application, you would most likely deal with XML parsers and an XML transformation system directly, and the problem on non-compliant tagging never arises. /Henrik -- http://kallokain.blogspot.com/ - Blogging from the trenches of software development http://www.henrikmartensson.org/ - Reflections on software development http://testunitxml.rubyforge.org/ - The Test::Unit::XML Home Page http://declan.rubyforge.org/ - The Declan Home Page