Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
phw_DTD
A plugin that allows serving Textpattern documents as application/xhtml+xml, with a DTD of XHTML1.1 to browsers that support it. Other browsers just get XHTML1.0 with text/html as mime type. See also this thread.
Additionally, the plugin use ob_gzhandler to compress(gzip) the files as send to the browsers. (saves a bit of bandwidth…)
This plugin use a variation of the Keystone method.
- in your page templates, delete everything you have at the top of the document, including the opening
[head]
tag, and replace by [txp:phw_dtd /]; - You’ll need to modify one Textpattern file: publish.php (on line 170, it is sending headers as text/html; the line can be commented out, as the plugin will take care of those headers.
==============
//comment out the following line in textpattern/publish.php
// header(“Content-type:text/html; charset=utf-8”);
==============
<del>download phw_DTD.txt.gz .</del>
==============
[edit 20050918] Updated for Textpattern 4.0, see post belowLast edited by phiw13 (2005-09-18 01:31:37)
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: phw_DTD
Looks good. Just to clarify a couple of things for me. When you say remove the opening “head” tag I presume you don’t mean the whole of the “head” section just the “opening” tag.
This “ob_gzhandler”. Do I need to do anything for this to work or is it an automatic thing via PHP to the server? Nice site by the way. :grin:
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: phw_DTD
1. just the opening [head] tag, not the whole section :-)
2. “ob_gzhandler”, no you don’t need to do anything more. I use it because my servers are not configured to use mod_gzip and partners.
If your server use mod_gzip (like textdrive does), then you can delete the line.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: phw_DTD
OK. Thanks for that.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: phw_DTD
Philippe: I notice you’ve got the XML prolog in there, which will toss IE into quirks mode. As I’d always understood it, if you’re serving UTF-8 or specifying your charset via the Content-Type
header then the prolog is not necessary. Or is it?
You cooin’ with my bird?
Offline
Re: phw_DTD
1/ The xml prolog should only appear for Gecko and Opera with that plugin. All others get text/html without prolog.
2/ I could be wrong, but for application/xhtml+xml, the prolog is required, as we’re dealing with xml here. For text/html, it is a different matter, sending the charset via the Content-Type
header is tecnically enough.
Although it is not a bad practice to add it (the charset) as a meta tag, or within the xml prolog. Just in case the user saves the document on the local drive.
(I think this is correct, strong fever and a bout of flu, brain is kind of running on low power).
P.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: phw_DTD
Looking at the spec, I’m not really sure:
Definition: XML documents should begin with an XML declaration which specifies the version of XML being used.
And then it shows two examples which are said to be well-formed: one with the prolog and one without. I’m guessing that means it the prolog can be omitted, but I’ll have to research it some more to be certain.
Good point about saving the document, though, I may leave it in for that…
Edit: I’ve got this working on my site now, though I edited the plugin to always send an XHTML 1.0 Strict DOCTYPE and to include the XFN Profile in the head
tag, since I’m trying to figure out a way to integrate that now that I can do arbitrary HTML with Markdown… I did decide to leave the prolog in for conforming browsers.
Last edited by ubernostrum (2005-02-19 12:53:17)
You cooin’ with my bird?
Offline
Re: phw_DTD
about the xml declaration, form the xhtml1.0 specs
An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. …
And in the Xhtml 1.1 document, there is a sample piece of code, including the xml declaration.
link
It is a good thing to leave it in.
Note: if you use XHTML 1.0 Strict, you can even use an ID on the html tag …
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: phw_DTD
From the second link you provided:
Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16.
So XHTML 1.1 is stricter than XML? I was under the impression that XML would allow you to omit the declaration, even on non-UTF documents, if you were specifying the encoding via a “higher” protocol like HTTP…
But then character encoding issues in XML are a mess, so I guess I shouldn’t be surprised that there aren’t clear answers.
You cooin’ with my bird?
Offline
Re: phw_DTD
Can you use both zem_redirect and this one? Under which order should they be put in the page?
VC3 :: weblog :: my wishlist
Offline
Re: phw_DTD
I haven’t tried zem_redirect myself, but I guess that it should work. Put zem_redirect first, followed by phw_DTD at the very top of your template.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
#12 2005-05-14 19:13:08
- davidm
- Member
- From: Paris, France
- Registered: 2004-04-27
- Posts: 719
Offline