Re: [xsl] Self-closing elements upset some browsers

Subject: Re: [xsl] Self-closing elements upset some browsers
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 14 Mar 2008 14:46:57 +0100
Marroc wrote:

I am importing legacy into a 3rd party tool and I find my self in the
situation where I need valid XHTML _and_ end-tags - this is not my decision.
I tried using the <xsl:output method="html"> but it inserts <meta> without a
closing tag and the file becomes invalid xml and subsequently fails to
import.

Well xsl:output method="html" is for HTML 4, not for XHTML.
As said, for XHTML to be served as text/html you would need xsl:output method="xhtml" but that is only supported by XSLT 2.0 processors.



Incidentally David, the problem with empty script elements, that is <script
href="" /> style, was exhibited by Firefox. It basically missed the end-tag
and assumed everything was script until the closing tag of an actual
non-empty script further down the file. It (very usefully) also showed this
behaviour in the syntax highlighting of it's source viewer.

The proper MIME type for XHTML is application/xhtml+xml, if you serve your XHTML with that Content-Type then Firefox uses its XML parser and I am sure it will not have any problem with <script/>.
The problem is that you serve your XHTML as text/html and then the browser uses its HTML parser and parses according to SGML rules and not XML rules. Therefore to serve XHTML as text/html the W3C recommends the following rules <URL:http://www.w3.org/TR/xhtml1/#guidelines> and xsl:output method="xhtml" enforces these rules.



--


	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread