[ZPT] Is PageTemplates doing xhtml conversion? Should it?

John Morton jwm@plain.co.nz
Thu, 30 Aug 2001 01:28:47 +1200


I've been playing around with HTML tidy[1], using it to test some page=20
templates that are part of a skin for a CMF product I've written. The -as=
xml=20
flag is very useful for finding non-xhtml compliance problems in the=20
templates, and various other goodies (you're not suppose to use a span in=
side=20
a select, for example so you have to use optgroup, but they mess up the=20
rendering in konqueror from kde 2.1...).

Anyway, upon using the date widget template I wrote inside Zope, I kept
getting a problem with the javascript I was using. A quick glance at the=20
source showed that the select tags had both onchange and onChange attribu=
tes,=20
the first being the source version, and the second being the attribute th=
at=20
was supposed to replace the source version. So I spent an hour or so tryi=
ng=20
to determine if this was a weird netscape bug before settling on it being=
 a=20
PageTemplates behaviour. I loaded a test template up and punched in a var=
iety=20
of dodgey tags and saved it. Low and behold, all the tags droped to lower=
=20
case, but the singletons (<br>) stayed as is. When I tried again with mac=
ro=20
expansion turned off, they stayed capitalized.=20

I consider this a bug, at least in so far as it causes unexpected, 'magic=
'=20
behaviour and that runs against one of the main principles of ZTP, as=20
described in the vision statement.

Some possible solutions:

 1) Turn off the case munging inside the METAL code. Leaving people's htm=
l=20
 alone won't cause any harm.

 2) If TAL statements won't be processed unitl after METAL statements and=
 the
 METAL code converts elements and attributes to lower case, then it's=20
 reasonable to require tal:attributes statement to only use lower case
 attribute arguments, and throw an error, or at least a warning, if the a=
re=20
 supplied something else.

 3) Create a munging property that template users can set to 'none',
 'transitional' and 'full'. None will leave the template alone, transitio=
nal=20
 will do the case munging done now, while 'full' will try to convert the =
=20
 document to xhtml, doing things like complaining about images without
 alt tags, tables without summaries, spans when you should be using the
 appropriate grouping tag and so forth.

The first is easy, the second might break things that work now and possib=
ly=20
break TAL as a stand alone library, and the third is hard work (but the m=
ost=20
rewarding I think). In the mean time, avoid using capitalized attributes,=
 I=20
guess.=20

(But for the record, ZPT is a joy to use. Just being able to feed these=20
things into  an html validator and still have them render is the hoopiest=
=2E)

[1] http://www.w3.org/People/Raggett/tidy/

John
=20