2
edits
| Line 236: | Line 236: | ||
=== Authors who want to write XHTML, but use content negotiation to serve HTML as text/html to user agents that don't support XHTML === | === Authors who want to write XHTML, but use content negotiation to serve HTML as text/html to user agents that don't support XHTML === | ||
This is the group to whom the XSL transformations are relevant. Serving ''both'' XHTML and HTML requires a transformation, usually using XSL. My suggestion would require one additional template rule. Given such authors will often be transforming not only vanilla XHTML, but XForms, SVG, etc. to HTML equivalents, such a template rule is but a drop in an ocean of XSL complexity. (I expect such complexity to be increasingly standardized as XHTML is more widely adopted.) | This is the group to whom the XSL transformations are relevant. Serving ''both'' XHTML and HTML requires a transformation, usually using XSL. My suggestion would require one additional template rule. Given such authors will often be transforming not only vanilla XHTML, but XForms, SVG, etc. to HTML equivalents, such a template rule is but a drop in an ocean of XSL complexity. (I expect such complexity to be increasingly standardized as XHTML is more widely adopted.) | ||
Another way to serve both html and xhtml is to use a libxml2 based tool, such as PHP DOMDocument class, to construct your document. | |||
First you look at the $_SERVER['HTTP_ACCEPT'] variable to see if the client accepts application/xhtml+xml. If it does, you construct (or import) your document in a DOMDocument object using an xhtml Doctype. If it doesn't, you construct (or import) your document in a DOMDocument object using an html Doctype. | |||
Then to serve, you use print $doc->saveXML() for xhtml capable clients and $doc->saveHTML() for the rest. No need to use an XSL transform. | |||
Most server side dynamic languages have bindings to libxml2 that allow for this kind of thing. | |||
== Appendix A: What about WHATWG? == | == Appendix A: What about WHATWG? == | ||
edits