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

Subject: RE: [xsl] Self-closing elements upset some browsers
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Fri, 14 Mar 2008 10:16:04 -0400
(although this doesn't seem to be on topic...) You can create XHTML in
XSL version 1 that will display correctly in browsers using standards
compliant mode (not tag soup/quirks mode). You can send it as text/html
and browsers will still treat it in standards compliant mode given you
have the doctype correct. Just keep correcting your output till you get
valid XHTML.

use xsl:output method xml and omit-xml-declaration set to yes (this is
for IE to use standards compliant mode)

For your script element just insert a comment:

<script src="blah">//</script>

For your anchor element, insert a comment. 

best,
-Rob


On Fri, 2008-03-14 at 13:31 +0000, Marroc wrote:
> Thanks David, Martin and Ken,
> 
> 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.
> 
> So, for this import stage, I'll be going with Ken's suggestion that I insert
> a <xsl:comment />.
> 
> However, we're also having problems with the output from the system creating
> empty <a> tags for bookmarks. I can switch to method="html" there and give
> it a try. Those pages would only be exhibited in browsers anyway and so it
> doesn't need to be valid xhtml.
> 
> 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.
> 
> Thanks again,
> Richard

Current Thread