====== Switching to XHTML 1.0 Strict ======
DokuWikis default doctype is XHTML 1.0 Transitional and its default content-type "text/html". But with the 2006-03-09 release much attention was paid to making it as strict as possible.
See also [[tips:xhtml5|how to switch to XHTML 5]].
If you want to switch to XHTML 1.0 Strict and/or to a application/xhtml+xml content-type, here is what to do:
===== Doctype =====
If you only want to change the Doctype, just change each Doctype declaration from
to
in
* ./lib/tpl//main.php
* ./lib/tpl//detail.php
* ./lib/tpl//mediamanager.php
* ./inc/actions.php inside ''if($act == 'export_xhtml'){'' for the "export_html" mode
===== Content-type =====
Changing the doctype to XHTML 1.0 Strict without adjusting the content-type can make sense. But often you would want to change the content-type as well.
As many user agents cannot yet handle a document served as "application/xhtml+xml" (eg. the IE), it is good practice to use **[[http://www.autisticcuckoo.net/archive.php?id=2004/11/03/content-negotiation|content negotiation]]**.
So, in all files mentioned above (main.php, etc.) you can put something like this:
\n";
echo "\n";
} else {
header("Content-type: text/html");
echo "\n";
}
?>
Or you can find other solutions [[Google>content negotiation xhtml|searching the web]] that suits your purpose better.
The test for W3C_Validator is recommended since the [[http://validator.w3.org/|validator]] currently doesn't use content negotiation. The vary header avoids problems where a proxy server otherwise might serve a cached xml version to a non xml compliant browser.
===== Entities =====
Another (quite big) issue that has to be taken care of, if you decide to switch to an xml content-type, concerns entities.
In XML no other named entities than ''<'', ''>'', ''"'' and ''&'' should be used (otherwise it may lead to parsing errors, ie. the page won't be displayed at all). In the case of DokuWiki I recommend to **replace each visible named entity to its utf-8 character**; and **each non-visible named entity** (like '' '') **to its numeric entity** (preferably decimal).
That is the trickier part of converting to Strict. FIXME Maybe someone can write a script that does that!?
===== Problems with the latest release (2009-02-14) =====
==== Invalid elements ====
There are few spots where some invalid elements are used deliberately:
* ''target="_blank"'' is used in the link to open the media manager (which you can see when you have JavaScript turned off) and in the media manager itself to "view original file"
* ''autocomplete="off"'' is used once in the config manager
Unfortunately ''align'' is used every time an image is used (although a corresponding class is also used). This was done to have images aligned in feeds as well. I filed a [[bug>1351|bug report for the improper use of "align"]] a while ago.
==== JavaScript errors ====
There are quite a few [[bug>1569|JavaScript errors (documented in the bug tracker as well)]] when using DokuWiki with a strict Doctype.
==== Warning on "hidden" scripts ====
"XML parsers are permitted to silently remove the contents of comments. Therefore, you should not use comments to "hide" scripts or style sheets."