[TYPO3-50-general] Templating Engine - Validation and Autocompletion

Sebastian KurfŸürst sebastian at typo3.org
Thu Oct 23 22:28:25 CEST 2008

[ It's a long mail, but I hope it is still worth reading :-) ]

Hello everybody,

(I use a new thread here because I think most people care about 
validation, and many people mentioned it that this was important.)

I've spent the most of the last two days to dive into DTDs, XML Schema, 
Eclipse XML editing, and these topics. (Those who follow on [3] might 
have noticed ;-) ). I've come up with some conclusions and and ideas how 
we might proceed - and I have some really cool video to show - so read on!

What is Validation?

As many people say that they want fully validatable templates, I think 
we need to talk about what this really means.
1) Many people mean "Well-Formedness" [1] by that. This means the 
document has to be syntactically correct, and there won't be any 
semantics checking.
2) Really validating the input file against a DTD / XML Schema 
Definition. This means we actually want to check the Syntax and the 
Semantics as well.

Let's take an example:
Many say that "PHPTal Templates are validatable", and this is correct, 
but they can _not_ be validated really because the PHPTal Developers did 
not write a DTD or Schema for that.
I bet they'd like to, but actually it is quite difficult to "extend" 
XHTML by some tags (See [2] for more information on that).

It is easily possible in most Templating Systems to create well-formed 
XML documents (smarty, phptal, ....., beer3 as well).
However, I do not know a single templating system where you can actually 
_validate_ the template (which is a mixture of templating tags and 
XHTML, that's why validation is so difficult). [I don't count XSLT as a 
template engine here :-)]

Do We Need Validation?

What we typically care about is that the resulting page is XHTML 
conformant. It would be really nice to check all this during input time, 
however this turns out to be quite difficult:
The XHTML DTD/Schemas were not made for extensibility, for a long time. 
(See [4])
However, this changed some time ago with the "XHTML Modularization" [2] 
W3C Recommendation. They basically restructured their DTDs and Schemas 
to allow adding custom tags to them - which is what we would like to do.

The last two days, I first tried to add an example tag, and I could not 
even get their pre-packaged examples (which they provide as ZIP file, 
everything included) running in my eclipse with proper validation and 

That's why, after a long phone call with Bastian, we decided to move the 
focus a bit for now:

Most people know the XHTML tags, and know the attributes they need in 
their daily life. Besides, there are nice editors for it (like the 
Eclipse HTML editor), providing Autocompletion etc.
However, what they don't know, is what templating tags exist, and what 
arguments they have - so I think most people need some autocompletion 
and want some help in this area.

And this leads us to the new topic:


The approach we are following now is as follows:
1) We write a pseudo-HTML XML Schema, which (currently) allows all HTML 
tags with all attributes, and does not care about the nesting.
-> To me, that's not really a big problem, because I can XHTML validate 
the template _output_ and for real autocompletion, I could use the 
Eclipse HTML editor f.e.

2) There is some automatic Schema generated from the view helpers, which 
  includes the documentation of them, parameter names, mandatory 
parameters, etc.
-> If you include this Namespace, then you'll get Autocompletion and 
inline help -- see for yourself below!

This means we have perfectly validatable templates (according to our XML 
Schema, which does currently _not_ fit perfectly to the XHTML Schema), 
and I can use Helper-Autocompletion. For HTML Autocompletion, we can 
just use an HTML editor.

In case somebody is not satisfied with the custom XHTML Schema, I'd be 
perfectly happy to take any solutions concerning either a more perfect 
XHTML Schema definition, or maybe somebody even makes it work with the 
standard extensible schema (which would be the non-plus-ultra solution).

So what this really means is that all our view helpers will have an 
automatically generated Schema with them, and you can see right in your 
editor if you missed a mandatory argument or added one argument too 
much, etc.

Autocompletion - The Video

That's the URL:


The XML Schemas behind this demo are currently hand-written, but are 
written in a way that they can be easily generated. I just wanted to 
show you how it feels like to have such an autocompletion :-)
I think it's just amazing - and nobody apart from JSP taglibs (which are 
hard to write) has such a feature IMO :-)

Why Schema / no DTD - as DTDs are much easier to write?

- Because Schema can specify Comments which are used by Eclipse, DTD not
- Because DTDs don't support namespaces (that's the main problem).

OK - I think that's it, I would be really happy about your thoughts! Do 
you like it so far? Should we implement it? Do you see some drawbacks?


[1] http://en.wikipedia.org/wiki/XML#Well-formed_documents:_XML_syntax
[2] http://www.w3.org/TR/xhtml-modularization/
[3] http://code.typo3.org/status/
[4] This is because the schema defines f.e. "the <html>-Tag has
	exactly two children: <head>, and <body>, and _NOTHING MORE_.
	Thus, we have to modify the schema and can't just extend it.

More information about the TYPO3-project-5_0-general mailing list