Re: [xsl] XHTML html validation

Subject: Re: [xsl] XHTML html validation
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 16 Feb 2007 12:21:08 +0100
Hi John,

If you go XHTML, you don't want to use the method HTML, as it will not produce legal XHTML, which Andrew already pointed out.

I did some tests with Saxon 8, and found that when the doctype is output, the case is "html", not "HTML" for the root element declaration. You may want to switch to a more conformant processor (i.e., Saxon):

XSLT version 1.0:
method="xml" does not output the doctype-public if you do not also supply a doctype-system
method="html" correctly outputs the doctype public, but will render your document as HTML and not as XHTML.


XSLT version 2.0:
method="xml" does not output the doctype-public if you do not also supply a doctype-system
method="xhtml" does not output the doctype-public if you do not also supply a doctype-system
method="html" correctly outputs the doctype public, but will render your document as HTML and not as XHTML.


I am not sure if this is according to the W3 specs of xsl:output, I'll have to check. It strucks me as a bit odd that the doctype-public is ignored for xml and xhtml, unless there's also a doctype-system. But I thought that these are not needed together, but my doctype knowledge is a bit rusty.

Of course, XHTML does not require a doctype. You can output without one, and add the correct namespace to the root element. However, this may (or may not) trigger the browser's infamous quirks mode, which you definitely don't want when you pursue XHTML.

One more thing: if you want to force a certain string on the beginning of your file, you can use a trick with character-maps in XSLT 2 to get it there. I've put a workaround on this or saxon's list a while ago, but it is easy enough to implement.

Cheers!
-- Abel Braaksma
  http://www.nuntia.nl

John Steel wrote:

<xsl:output method="html"
doctype-public='-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'/>

Current Thread