XHTML Doctype?

U

UKuser

Hi Folks,

The following code works fine in FF & IE

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml;" />
<title>Simple Example </title>
</head>

<body style="background-color:red;">
<p>test line of text X</p>
</body>
</html>

However add the doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
and serve as an xml file and it errors with the following (IE errors)

The server did not understand the request, or the request was invalid.
Error processing resource 'http://www.w3.org/TR/xhtm...

The copy.xsl is:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:eek:utput method="xml" encoding="utf-8"/>
<xsl:template match="/">
<xsl:copy-of select="node()"/>
</xsl:template>
</xsl:stylesheet>

Any thoughts unless I'm missing the obvious would be great. I'll keep
investigating and see if I fix it.

Thanks

A
 
T

Tom Wright

UKuser said:
However add the doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
and serve as an xml file and it errors with the following (IE errors)

The server did not understand the request, or the request was invalid.
Error processing resource 'http://www.w3.org/TR/xhtm...

The copy.xsl is:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:eek:utput method="xml" encoding="utf-8"/>
<xsl:template match="/">
<xsl:copy-of select="node()"/>
</xsl:template>
</xsl:stylesheet>

Any thoughts unless I'm missing the obvious would be great. I'll keep
investigating and see if I fix it.

I know when I set up an XML to HTML transform a couple of years ago, I
couldn't get browsers to reliably interpret XHTML sent as text/xml
correctly, so I altered it to send XHTML as text/html using the following
output declaration:

<xsl:eek:utput method="xml" omit-xml-declaration="yes" encoding="UTF-8"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="no"
media-type="text/html" />

This worked and works just fine, but browsers may have moved on and may be
better at accepting xml now - I've not experimented again since I got it
working.
 
D

David Carlisle

UKuser said:
Hi Folks,

The following code works fine in FF & IE

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml;" />
<title>Simple Example </title>
</head>

<body style="background-color:red;">
<p>test line of text X</p>
</body>
</html>

However add the doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
and serve as an xml file and it errors with the following (IE errors)

The server did not understand the request, or the request was invalid.
Error processing resource 'http://www.w3.org/TR/xhtm...

The copy.xsl is:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:eek:utput method="xml" encoding="utf-8"/>
<xsl:template match="/">
<xsl:copy-of select="node()"/>
</xsl:template>
</xsl:stylesheet>

Any thoughts unless I'm missing the obvious would be great. I'll keep
investigating and see if I fix it.

Thanks

A

IE can't read that DTD (a documented non conformance of msxml, it
doesn't allow you to default namespace attributes)
In the xhtml+MathML DTD (eg from
www.w3.org/math/DTD/mathml2/xhtml+mathml-f.dtd
I hand edited the xhtml bits of the combined dtd so that it would work.
so you could use that one, or better don't specify teh dtd at all, if
you do specfy it IE really tries to go and fetch it each time, which is
slow, and thrashes the w3c server almost to death if everyone pings the
dtd all the time

David
 
P

Peter Flynn

David Carlisle wrote:
[...]
IE can't read that DTD (a documented non conformance of msxml,

<sigh/>
....and we had catalog resolution and federated mirroring of DTDs working
over a decade ago with Panorama as a Netscape plugin...

///Peter
 
U

UKuser

David Carlisle wrote:

[...]
IE can't read that DTD (a documented non conformance of msxml,

<sigh/>
...and we had catalog resolution and federated mirroring of DTDs working
over a decade ago with Panorama as a Netscape plugin...

///Peter

I have managed to make this work where the DTD is hosted locally
(served as application/xml):

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
localhost/sites/dtd/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Simple Example </title>
</head>

<body style="background-color:red;">
<p>test line of text X</p>

</body>
</html>

I needed to download the DTD and referenced docs but it seems to work
 
D

David Carlisle

UKuser said:
David Carlisle wrote:

[...]
IE can't read that DTD (a documented non conformance of msxml,
<sigh/>
...and we had catalog resolution and federated mirroring of DTDs working
over a decade ago with Panorama as a Netscape plugin...

///Peter

I have managed to make this work where the DTD is hosted locally
(served as application/xml):

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
localhost/sites/dtd/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Simple Example </title>
</head>

<body style="background-color:red;">
<p>test line of text X</p>

</body>
</html>

I needed to download the DTD and referenced docs but it seems to work

Incidentally why do you want to put the DTD on the file? The stylesheet
will be processed by msxml in non validating mode, so the dtd will be
read but not used for validation. Even if you cache the thing locally
the main affect is that there is a noticable delay in rendering the file
for no real benefit.
 
U

UKuser

UKuser said:
David Carlisle wrote:
[...]
IE can't read that DTD (a documented non conformance of msxml,
<sigh/>
...and we had catalog resolution and federated mirroring of DTDs working
over a decade ago with Panorama as a Netscape plugin...
///Peter
I have managed to make this work where the DTD is hosted locally
(served as application/xml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
localhost/sites/dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
   <title>Simple Example </title>
  </head>
  <body style="background-color:red;">
   <p>test line of text X</p>
  </body>
</html>
I needed to download the DTD and referenced docs but it seems to work

Incidentally why do you want to put the DTD on the file? The stylesheet
will be processed by msxml in non validating mode, so the dtd will be
read but not used for validation. Even if you cache the thing locally
the main affect is that there is a noticable delay in rendering the file
for no real benefit.

--http://dpcarlisle.blogspot.com

I'm trying to make sure the code validates - hence thinking they need
a DTD.

How could I make the code valid without referencing a DTD? IE doesn't
seem
to like it although removing the whole doctype validates it still has
1 error.
 
D

David Carlisle

UKuser said:
How could I make the code valid without referencing a DTD? IE doesn't
seem
to like it although removing the whole doctype validates it still has
1 error.


most validating parsers (including the online one at w3c) can be
configured to default a dtd for certain top level elements (eg <html> in
this case) so you can validate the file before you serve it, putting the
dtd on the file and causing the client to reparse the dtd isn't so
useful, especially as you are styling with xslt so the document the
browser is rendering isn't the document you serve but the document
9including on IEs case the doctye) generated by xslt so it is the
doctype specified in xsl:eek:utput, not the <!DOCTYPE in the file that
determines whether quirks mode is used for example. (It is true that the
xhtmml spec recommends put in a doctype on the file, but in the real
world that has a high cost. (Unlike html where the browsers don't fetch
the dtd, if you serve with an xml mime type then some browsers, and in
particular IE do fetch the dtd).
 
P

Peter Flynn

UKuser wrote:
[...]
I'm trying to make sure the code validates - hence thinking they need
a DTD.

Unless you are using default values for a token list, or Notations and
other bells and whistles, only the author needs the DTD (to make sure
the document is constructed correctly). Once that's been done, it can be
processed as well-formed only, without a DTD.
How could I make the code valid without referencing a DTD? IE doesn't
seem to like it although removing the whole doctype validates it
still has 1 error.

I gave up trying to use XML in browsers a long time ago. The browser
makers are not willing to support XML, so I do it all server-side.

///Peter
 
U

UKuser

most validating parsers (including the online one at w3c) can be
configured to default a dtd for certain top level elements (eg <html> in
this case) so you can validate the file before you serve it, putting the
dtd on the file and causing the client to reparse the dtd isn't so
useful, especially as you are styling with xslt so the document the
browser is rendering isn't the document you serve but the document
9including on IEs case the doctye) generated by xslt so it is the
doctype specified in xsl:eek:utput, not the <!DOCTYPE in the file that
determines whether quirks mode is used for example. (It is true that the
xhtmml spec recommends put in a doctype on the file, but in the real
world that has a high cost. (Unlike html where the browsers don't fetch
the dtd, if you serve with an xml mime type then some browsers, and in
particular IE do fetch the dtd).
--http://dpcarlisle.blogspot.com

Hi there,

Sorry for the delay - can i just clarify something:

a) Is there somewhere I can read more about how this all works from a
technical level? The web generally tells you what to put not why its
so
b) Are you saying - put the DTD in the W3C checker but omit it from
the final code served? As I read it - because the XSLT transforms the
document, am I right in thinking the whole DOCTYPE line isn't
necessary - or just the referrer to the DTD?
i.e.
Necessary for Validator
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Necessary for Browsers
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> OR Nothing?

As a general point - has anyone done the W3 Schools XML certified
developer exam? Any thoughts on it just for semi recognition? Does it
cover these sorts of things?

Thanks again

A
 
D

David Carlisle

Necessary for Validator
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Necessary for Browsers
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> OR Nothing?


what a doctype was supposed to be for is to specify the grammar (dtd)
being used. But validating parsers (including the online w3c one)
usually have a way to default a dtd so if you don't specify one then it
is equivalent, to a validating parser, to using a default one (usually
html4 transitional these days)

Howveer browsers treat the same syntax completely differently,

in html mode they never fetch the dtd or validate the document but they
do recognise certain doctypes as fixed strings that turn on "standards"
as opposed to "quirks" mode browsing. Mainly this affects css widths in
boxes and tables, but also turns on or off any number of arbitrary
bug-compatibility behaviours, depending on teh browser. So typically if
you don't use a doctype the brousers try to act lie IE4 or NS4 or
something as regards css positioning but if you specify one of a fixed
number of magic doctypes they try harder to implement css as specified.
google for quirks mode will give lots of info on this including pages
where people keep up to date lists of which browsers recognise which
doctypes.

In xml mode the sitation is different again.

If there is no stylesheet IE doesn't render the docuemnt at all, but ff
safar opera will recognise xhtml and do similar doctype sniffing as for html

If there is an xsl stylesheet the doctype desn't affect rendering (as it
is the output from xsl that is rendered, nt the original document) FF
will basically ignre te dtd except for a very few special ones such as
the mathnl dtd of which it has a local copy in the firefox installation.

IE fetches the dtd (which is why typically you don't want to do this,
as the dtd is big and slow to download)


David
 
M

Martin Honnen

David said:
In xml mode the sitation is different again.

If there is no stylesheet IE doesn't render the docuemnt at all, but ff
safar opera will recognise xhtml and do similar doctype sniffing as for
html

Mozilla/Firefox does not do doctype sniffing when rendering
application/xml or text/xml or application/xhtml+xml to decide whether
to use quirks mode or standards compliant strict rendering mode. XML is
always rendered in standards compliant strict rendering mode.

See https://developer.mozilla.org/index.php?title=En/Mozilla's_Quirks_Mode
 
U

UKuser

Mozilla/Firefox does not do doctype sniffing when rendering
application/xml or text/xml or application/xhtml+xml to decide whether
to use quirks mode or standards compliant strict rendering mode. XML is
always rendered in standards compliant strict rendering mode.

Seehttps://developer.mozilla.org/index.php?title=En/Mozilla%27s_Quirks_Mode

So are there any sites where I can read up more about all this?
 
D

David Carlisle

Martin said:
David Carlisle wrote: [wrong]

oops, thanks for posting the correction.

Basic point I was trying to make that DOCTYPE means rather different
things to a validator and a browser stil stands, but sorry I messed up
the details.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top