House of Hackers

I posted an article with the same headline on xhtmlforum.de in early 2007 describing the problems with extensible XHTML, XML-DTD's and the W3C's solution. If you're not intersted in this special topic I recommend you not to read this post. It's especially ment for webserver administrators not using a wCMS. The original article was written in german and is referenced later in the text. The difficulty level of this article is "moderate".


The reason to write such an article - which at first seems to be only of academical interest - is because that topic was forgotten for quite a while. At first I was sending an E-Mail to the W3C's mailing list requesting information on the XHTML FAQ (Chapter 12) questioning "Does Microsoft Internet Explorer accept the media type application/xhtml+xml?". We all know the problems with Microsofts incompatible non standardized software, but a lot of us have to develop software or applications which have to be standardized and run well on it. That topic was already heavily discussed on the web so I'm gonna leave this behind for now. The interesting part is that any common XHTML DTD can be replaced by a "special" crafted DTD the W3C has not yet recommended for implementation.

INDEX.HTML
*********************************************************************
[?xml version="1.0" encoding="UTF-8"?]
[?xml-stylesheet href="./database/d@ta/style/xsl/dtd.xsl"
type="text/xsl"?]
[!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"]
[html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"]

*********************************************************************

DTD.XSL
*********************************************************************
[?xml version="1.0" encoding="UTF-8"?]
[xsl:stylesheet version="1.0"
xmlns: xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"]
[xsl:template match="/"]
[copy-of select="."/]
[/xsl:template]
[/xsl:stylesheet]

*********************************************************************

This dtd.xsl is therefore much better formed than the original W3C recommendation for a DTD implementation to let MSIE parse files that actually are not delivered as text/palin but as application file from a webserver to any user agent (browser). As you have probably noticed I was including a new line at first. Furthermore I included the FO-namespace. Any changes made by me are marked in red in the original post. After extensive research only regarding the "wellformedness" of that new dtd-file I still had no clue if my implementation was better than that one offerd by the W3C. Most documents available in the net introduce such documents with a [stylesheet] tag and omitd versioning, charset or something else. But sometimes it's better to include more than to little information.



W3C's stylesheet workaround couldn't solve the problem because though all these definitions every single browser has it's own implementation to handle files it's "own" way. Or in other words any mime configuration in your webserver overrides whaterer is given in your documents DTD. The idea behind the whole thing was to avoid scripting in PHP to control DTD distribution. Finally a reply from the W3C workgroup responsible for such things replied with the following:

"Although you are serving the document as XML, and it gets parsed as XML, the browser thinks it has received text/html, and so your XHTML 1.0 document must follow many of the guidelines for serving to legacy browsers. Your XHTML document will continue to work on browsers that accept XHTML 1.0 as application/xml."

This didn't help anything because it didn't clearify the role of the server when delivering files and it didn't take my corrected stylesheet into account...



One month of research later I wrote a last message on that thread to finally solve the issue. It stated that my XSL-sheet was indeed better formed than the W3C's. I had to make some changes though to make this DTD valid as well:

[?xml version="1.0" encoding="UTF-8"?]
[xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"]
[xsl:template match="/"]
[xsl:copy-of select="."/]
[/xsl:template]
[/xsl:transform]


Furthermore I figured out why this sheet just works the way it does. In short it's an XML root node replacement strategy which finally pastes structure parts and result structure fragments to the result structure. This finally brings us to the point at which that damn old MSIE sends all data through the internal XML parser. This parser also existed in recent IE versions! But I was buggy and inactive the most time.

The last question was if there's a possible way to deliver different documents of different mime type without some pre-selection script. It is not! Even with the W3C's suggested workaround it's impossible to handle that. Have a look at that large php script within the last post I wrote on xhtmlforum.de. Any files prior DTD is replaced by the following lines then:

[?php
$enforce = "on";
include("./database/d@ta/script/php/dtd.php");
?]


Therefore "enforce" controls the usage of XHTML 1.1 or 1.0 Strict. The HTML 4.01 part was disabled by myself. Oh, and a nicely build .htaccess is also recommended. ;-)

Thanks for reading!

Share 

Add a Comment

You need to be a member of House of Hackers to add comments!

Join this Ning Network

shoks Comment by shoks on June 9, 2008 at 10:10pm
Cooler Blogeintrag ... Bin ihn noch am verdauen. hmmm

About

pdp pdp created this Ning Network.

© 2009   Created by pdp on Ning.   Create a Ning Network!

Badges  |  Report an Issue  |  Privacy  |  Terms of Service

Sign in to chat!