W3C home > Mailing lists > Public > www-validator@w3.org > April 2006

DTD in X(HT)MLs

From: Vasil Rangelov <boen.robot@gmail.com>
Date: Sat, 1 Apr 2006 20:59:45 +0300
To: <www-validator@w3.org>
Message-ID: <000001c655b6$112f01e0$5c579453@mmea27da57e006>
Hello. I just made some experiments with a kind of odd idea. I wanted to
have XHTML document to hold per page data in a structured manner and add the
common data (menus, header, etc.) by styling the XHTML with XSLT (and of
course the presentation with CSS but that's another thing). There were many
odd situations with the validator I would like to tell you about.

I hoped that since XHTML is XML based language, I could apply XSLT to it and
it will validate and all. And it did. Despite the reference for the XSLT in
my XHTML (<?xml-stylesheet type="text/xsl" href="test.xsl"?>), the document
validated. However, all browsers ignored the reference, since there was the
html extension. And so I decided to give the file XML extension instead.

I hoped that since XHTML is XML based language, old browsers would treat the
file as (X)HTML and new browsers as XML styled with XSLT. That didn't happen
though. The DTD in the X(HT)ML was treated as if it's invalid. All browsers
and the validator said it. I wonder how come the DTD is valid in an XML
based language but not in XML itself...

I decided to remove the DTD from the XML. It was all right. The XSLT worked
with all XSLT enabled browsers and old ones would have probably treaded this
file as XHTML since it uses the same elements. But as expected, the
validator said there's no DTD in the XML and because of that it was invalid.
But there is a way though. Could the validator please be made so that it
tries to look into referenced XSLT file for the output's DTD? After all,
older browsers don't care about DTDs and new ones all support XSLT and would
use it's DTD instead.

I removed the DTD originally to ensure that it's the source of the errors I
got in the browsers. So I put it back and started altering it with a variety
of combinations with the hope that some would work AND validate. There was
one combination which gave odd results. When the URL in the DTD's reference
is missing, the XML file validates, but fails to display at all in IE6 and
Opera 9. IE6 gives an error message and Opera doesn't show anything. Only
Firefox shows the XML styled with XSLT this way. Is Firefox's behavior right
or is the validator wrong here?

For the sake of completeness, here is the code without the URL:

1.      <?xml version="1.0" encoding="windows-1251"?> 

2.      <?xml-stylesheet type="text/xsl" href="test.xsl"?> 

3.      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "" > 

4.      <html> 

5.      <head> 

6.      <meta http-equiv="Content-Type" content="text/html;
charset=windows-1251" /> 

7.      <title>Untitled Document</title> 

8.      </head> 

9.      <body> 

10.  <div>блабла</div> 

11.  </body> 

12.  </html>

And the XSLT:

1.      <?xml version="1.0" encoding="windows-1251"?>

2.      <?xml-stylesheet type="text/xsl" href="test.xsl"?> 

3.      <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

4.      <xsl:template match="/">

5.      <html>

6.      <head>

7.      <title>TEST</title>

8.      </head>

9.      <body>

10.  <ul>

11.  <li>

12.  <xsl:value-of select="/html/head/title" />

13.  </li>

14.  </ul>

15.  </body>

16.  </html>

17.  </xsl:template>

18.  </xsl:stylesheet>

All the tests were done on my computer which has installed Apache server on
it. That's why I don't give a link to the page instead- Because it's likely
that the computer might be turned off when you check it. Besides, this is
all tests. Nothing "live" to worry about... yet.
Received on Sunday, 2 April 2006 02:19:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:21 GMT