I've been using a content negotiation script in PHP on my main server so I decided to get working on one for HFS. This script will check the Accept header of the user-agent to determine if it can accept pages served as application/xhtml+xml. If it cannot, it will fallback on text/html. There is also an if block to serve pages as application/xhtml+xml if the user agent happens to be a validator.
To use it, simply place it anywhere in the page you want negotiated. An obvious place is a header section included in all pages.
Warning! When pages are served as real XHTML they are parsed by the browser using stricter rules than HTML soup. The RAWR template I use crashes on a parse error and I suspect most of the available templates will.
{.comment |
{.set |MIME_TYPE|text/html.}
{.if | {.count substring |application/xhtml+xml|{.header|Accept.}.}
| {: {.if not |{.count substring |application/xhtml+xml;q=0|{.header|Accept.}.}
| {: {.set |MIME_TYPE|application/xhtml+xml.} :}
| {: {.if | {.count substring |application/xhtml+xml;q=0.|{.header|Accept.}.}
| {: {.set |MIME_TYPE|application/xhtml+xml.} :}
.} :}
.} :}
.}
{.if | {.or
| {.count substring |W3C_Validator|{.header|User-Agent.}.}
| {.count substring |WDG_SiteValidator|{.header|User-Agent.}.}
| {.count substring |W3C-checklink|{.header|User-Agent.}.}
| {.count substring |Web-Sniffer|{.header|User-Agent.}.}
| {.count substring |FeedValidator|{.header|User-Agent.}.}
| {.count substring |Poodle predictor|{.header|User-Agent.}.}
| {.count substring |Leknor.com gzip tester|{.header|User-Agent.}.}
.}
| {: {.set |MIME_TYPE|application/xhtml+xml.} :}
.}
{.add header |Vary: Accept.}
{.add header |Content-type: {.call |MIME_TYPE.}; charset=UTF-8.}
.}
This is my first time using macros, so please let me know if I made a mistake

It seemed to work in my testing.
8063