XSLT and HTML 5 problems
by Pascal Opitz on December 9 2008, 17:47
Sometimes I'm really getting annoyed about the lack of control that XSLT sometimes gives about what target formats are supported and what output it generates
I'm trying to utilize a canvas tag, and excanvas. Now the problem that I'm having is that excanvas is hooking up to onreadystatechange, and therefore will be executed before the ondomready event that jQuery offers.
Which means I have to either do inline JS, and generate the canvas tags per JS, in order to create valid HTML 4, or I have to use the HTML 5 Doctype and can write the canvas tag in there just like that.
Problem is: XSLT 1.0 doesn't support the HTML 5 to generate a doctype, and the output encoding meta tag that it selfishly applies is not valid in HTML 5 either. Any ideas anyone?
Quite a fruitful discussion in the comments.
So for anyone else who's reading this: Bottom line is that, even with existing technology for XSLT, it is possible to create HTML 5.
The first issue we were discussing was the DTD. HTML 5 in its current draft caters the generation with XSLT by providing a fallback DTD:
<!DOCTYPE html PUBLIC "XSLT-compat">
The other issue was the meta tag with the charset attribute, that HTML 5 introduces in order to target the character set:
<meta charset="..." />
It is just not possible to generate exactly that with libXSL, because libXSL forcefully replaces it with an HTML 4 style meta tag.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
This is not a problem though, as the old meta tag in its encoding state is a valid declaration of the character set, too.