XHTML Doctype?

UKuser

Usenet Archive
Joined
May 31, 2005
Messages
72
Reaction score
0
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
 

Tom Wright

Usenet Archive
Joined
Oct 13, 2006
Messages
31
Reaction score
0
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.
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
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
 

Peter Flynn

Usenet Archive
Joined
Jan 2, 2000
Messages
1,813
Reaction score
0
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
 

UKuser

Usenet Archive
Joined
May 31, 2005
Messages
72
Reaction score
0
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
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
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.
 

UKuser

Usenet Archive
Joined
May 31, 2005
Messages
72
Reaction score
0
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.
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
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).
 

Peter Flynn

Usenet Archive
Joined
Jan 2, 2000
Messages
1,813
Reaction score
0
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
 

UKuser

Usenet Archive
Joined
May 31, 2005
Messages
72
Reaction score
0
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
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
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
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
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
 

UKuser

Usenet Archive
Joined
May 31, 2005
Messages
72
Reaction score
0
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?
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
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
 

C. M. Sperberg-McQueen

Usenet Archive
Joined
Jul 2, 2003
Messages
95
Reaction score
0
Peter Flynn writes:

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.

Hmm.

Oddly enough, I discovered a couple of years ago that one can in fact now use XML in browsers on the Web. I had always used XML in browsers on my local machine, but in fact nowadays IE and Firefox and other Mozilla-based browsers and Safari and Opera all do support XML in the sense that they can read it, parse it, and transform it using XSLT. Sure, there are irritating gaps in the XSLT support (not everyone supports unparsed-entity-uri and Firefox pretends the tree has no namespace nodes) -- but then, there are irritating gaps in browser support for pretty much everything they claim to support, aren't there?

One friend has said "but you just use XSLT to translate it into HTML -- that's not really serving XML, is it? You should be using CSS to render the XML directly", but I think I disagree; HTML is perfectly serviceable as a rendering language for screens, and using XSLT means I can generate tables of contents and do text mirroring for things like cross references. And it's been a long time since I generated a static HTML document in order to make a working paper I wrote available to people I was working with -- so it's been a long time since we had problems owing to someone else reading an out-of-date snapshot instead of the current XML form of the document.

Experience shows that publishing XML on the Web is pretty much just as helpful and convenient now as we expected it to be, back then.

I think, Peter, you might want to look again; the situation may be rather different from the one you despaired of a long time ago.
 

William F Hammond

Usenet Archive
Joined
Jul 2, 2002
Messages
21
Reaction score
0
(C. M. Sperberg-McQueen) writes:

. . .
One friend has said "but you just use XSLT to translate it into HTML -- that's not really serving XML, is it? You should be using CSS to render the XML directly", but I think I disagree; HTML is perfectly serviceable as a rendering language for screens, and using XSLT means I can generate tables of contents and do text mirroring for things like cross references. And it's been a long time since I generated a static HTML document in order to make a working paper I wrote available to people I was working with -- so it's been a long time since we had problems owing to someone else reading an out-of-date snapshot instead of the current XML form of the document.

I think this is sensible for serving things to a known group of collaborators, but I'm inclined to side with Peter in the case of serving finished articles to the public. The audience is unarguably broader that way. (For example, (1) some browsers on some platforms will warn me about incoming "controls" when there's an xslt sheet, and (2) on a bad network day I've been known to use w3m instead of firefox.)

-- Bill
 

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

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,244
Members
248,133
Latest member
DujonT

Latest Threads

Top