-
Notifications
You must be signed in to change notification settings - Fork 7
/
xhtml.txt
7 lines (4 loc) · 2.32 KB
/
xhtml.txt
1
2
3
4
5
6
7
= XHTML: XML vs HTML =
Just about all HTML content used in a Nevow application should be XHTML: {{{loaders.htmlstr}}} and {{{loaders.htmlfile}}} are deprecated, and tend to behave strangely at the best of times anyway, so in order to make use of the nevow templating features which are implemented as namespaced XML attributes elements, you should only be using {{{loaders.xmlfile}}} and maybe {{{loaders.xmlstr}}}. I'll leave the issue of stan content aside for now. Currently (see #665), however, a Nevow application will be serving what is meant to be XHTML (and thus XML) content, with a {{{text/html}}} content type instead. This has a variety of implications on application code, many of which are discussed at http://hixie.ch/advocacy/xhtml and do not need to be repeated here.
In a non-athena application, the resulting output served to the browser will typically be devoid of any nevow-namespaced elements and attributes, and thus it does not matter as much whether the content is parsed by an HTML parser or an XML parser. However, athena-using applications will have athena-namespaced elements and attributes in the content that is served up, and some degree of strangeness thus occurs when the content is parsed by a browser's HTML parser. For example, an element like athena:handler will show up as a DOM element of name 'ATHENA:HANDLER' instead of an element named 'handler' in the {{{http://divmod.org/ns/athena/0.7}}} namespace. In addition, it seems that unknown elements may interact weirdly with specific DOM elements (such as tables). Combined with the fact that athena applications are likely to be doing fairly extensive manipulations of the DOM, having the browser parse the content correctly with an XML parser presents several fairly compelling advantages.
On the other hand, invoking the XML parser comes with its own set of caveats; once again, http://hixie.ch/advocacy/xhtml details these quite well, but a few of them are of specific interest here. The various differences in semantics can cause breakage in existing working applications, but another caveat is that stan and the flattening system are completely unaware of XML namespaces. You can create tag instances named like {{{<athena:handler>}}} and attributes named like {{{xmlns:athena}}}, but it is easy to accidentally emit XML that has missing or incorrect XML namespace declarations.