Remove $cf[xhtml][endtags]

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Remove $cf[xhtml][endtags]

Post by cmb » Tue Oct 09, 2012 11:48 pm

Hello Community,

since CMSimple_XH 1.5.4 an explicit Content-Type header is sent. But I had overlooked the special requirements for XHTML, where the Content-Type should be specified as application/xhtml+xml, if the UA accepts it. This holds for (X)HTML5 as well.

So we should consider doing so, e.g. by replacing cmsimple/cms.php line 393ff with:

Code: Select all

if (!headers_sent($tempFile, $tempLine)) {
    $temp = $cf['xhtml']['endtags'] == 'true'
        && strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false
        ? 'application/xhtml+xml' : 'text/html';
    header('Content-Type: ' . $temp . '; charset=' . $tx['meta']['codepage']);
} else { 
Unfortunately this switches UAs to XML parsing, what is not as forgiving than HTML parsing -- just try it! ;)

So we have to delay this change, and clean all invalid XHTML in the core first. Then we should introduce it in CMSimple_XH 1.6, explicitely pointing out, that the XHTML might make trouble with plugins and templates, and users should only set xhtml_endtags=true, if all pages deliver valid XHTML.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XHTML and Content-Type

Post by cmb » Wed Oct 17, 2012 6:34 pm

I just found an interesting article: XHTML—What’s the Point?
Christoph M. Becker – Plugins for CMSimple_XH

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: XHTML and Content-Type

Post by Gert » Wed Oct 17, 2012 6:58 pm

cmb wrote:I just found an interesting article: XHTML—What’s the Point?
Interesting information:

Text last modified: 2001-11-13 ;)

(Have a look at bottom of the linked site)

Gert
Gert Ebersbach | CMSimple | Templates - Plugins - Services

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XHTML and Content-Type

Post by cmb » Wed Oct 17, 2012 7:16 pm

Hello Gert,

I had a look at the date of the last modification. The information is nonetheless true: XHTML served as text/html is quite pointless as almost every browser will (and has to) be able to cope with tag soup. And that still holds for (X)HTML5.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XHTML and Content-Type

Post by cmb » Sun Feb 03, 2013 2:34 am

Hello Community,

I'm afraid we'll have to reconsider the XHTML conformance of CMSimple_XH. The problem is not so much the markup, but the JavaScript. Try to request the following code in a file:

Code: Select all

<?php
header('Content-Type: application/xhtml+xml');
?>
<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
        <script type="text/javascript">
            function test() {
                $("#test").html("<p>testing</p>")
            }
        </script>
    </head>
    <body onload="test()">
        <div id="test"></div>
    </body>
</html>
Nothing happens. Now comment out the line where header() is called and request the file again! The problem is not specific to jQuery; you'll get the same result with the following definition of test():

Code: Select all

            function test() {
                document.getElementById("test").innerHTML = "<p>testing</p>";
            }
"innerHTML" is simply not defined for X(HT)ML documents. And if I'm not mistaken, this is only the tip of the iceberg. Having a simple API which produces valid HTML and XHTML probably requires a bloated compatibility layer + several restrictions. Of course it's possible to simply neglect the "web standards" (in this case http://www.w3.org/TR/xhtml-media-types/#media-types) and deliver XHTML as "text/html", but actually there's no point in doing so except satisfying the W3C validator...

Currently I'm tending towards dropping support for XHTML, even if it's much cleaner and less demanding for the parsers; but it seems to place quite some additional burden upon the developers. I may be mistaken here, so I suggest to examine this issue further.

But even if we don't support "real" XHTML in the future, we might stick with the name "CMSimple_XH" by just redefining the meaning: "extremly HTML conforming" ;) And I'm quite sure somebody else could come up with something better...

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XHTML and Content-Type

Post by cmb » Tue Mar 05, 2013 12:32 pm

Hello Community,

this issue has to be decided upon. We have a vote ("XHTML Content-Type") to change the Content-Type for XHTML documents, but doing so will surely break several plugins (due to wrong markup and some JavaScript, which simply doesn't work for XHTML).

So what now?

Some further info on the topic: https://developer.mozilla.org/en-US/doc ... _for_XHTML.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XHTML and Content-Type

Post by cmb » Wed Apr 10, 2013 12:04 am

Gert wrote:
cmb wrote:I just found an interesting article: XHTML—What’s the Point?
Interesting information:

Text last modified: 2001-11-13 ;)
Just found http://www.w3.org/International/articles/serving-xhtml/.

Interesting information:
Übersetzung der englischen Version vom 2010-08-20. Letzte Änderung der übersetzten Version am 2011-01-26 GMT.
Even more interesting: the text is published by W3C and was modified after the HTML5 standardization had begun.

Extremly interesting:
Leider unterstützt der Internet Explorer bis einschließlich Version 8 keine als XML ausgelieferten Dateien wie es eine Reihe anderer Browser tut.
So it seems XTHML has a (is the?) future. However, I'm still not sure, how to handle DOM incompatibilities...
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XHTML and Content-Type

Post by cmb » Fri Apr 12, 2013 10:39 am

Upps, it seems I've forgotten the most important point: as IE 8 doesn't accept XHTML documents delivered with an XML media type (it offers the file for download), we have to postpone this change. Dropping front-end support for IE 8 in CMSimple_XH 1.6 is no option (it should not even be offered as config option). I'll move the roadmap item to 1.7 for reconsideration.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Remove $cf[xhtml][endtags]

Post by cmb » Fri Oct 24, 2014 1:55 pm

Hello Community,

I have though about this issue again, and I think it is best to drop support for XHTML due to the browser and JavaScript incompatibilities. A very nice "side-effect" would be that we could avoid all those tag() calls or alternative ways to allow for valid HTML or XHTML syntax depending on the config option $cf[xhtml][enttags]. The only drawback would be that those users having set $cf[xhtml][endtags]="true" and using an XHTML Doctype would get errors when validating their pages, but this could easily be fixed by an update script for content.htm, or even simpler by switching to the HTML5 Doctype.

For XH 1.7 I suggest to
  • remove (i.e. hardcode them for backward compatibility with plugins) the config options $cf[xhtml][endtags] and $cf[xhtml][amp] (the latter is already hidden since XH 1.6)
  • deprecate function tag() and make it a no-op (i.e. simply return the string argument)
  • encourage the usage of the HTML5 doctype
  • change our "quality standards" in this regards
To reflect my new suggestion, I have changed the title of this thread and the roadmap item respectively.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: Remove $cf[xhtml][endtags]

Post by svasti » Fri Oct 24, 2014 2:57 pm

+1

Post Reply