Re: [xsl] [xsl-list] MSXML 3.0/4.0 XSLT rendering bug

Subject: Re: [xsl] [xsl-list] MSXML 3.0/4.0 XSLT rendering bug
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 13 Jul 2005 16:18:25 +0100
You need to decide if you are generating html or xhtml (IE doesn't
support xhtml, and just treats it as html, so it sometimnes works and
sometimes doesn;t depending on how far xhtml syntax differs from html)

Your stylesheet appears confused, parts are aimed at html and parts
xhtml...

<xsl:output method="html"

the method would default to html if the top levelresult
element was html in no-namespace (which it isn't)
You force html method here but that only has an effect on
elements in no-namespace (and many of your elements are in
xhtml namespace). The output method has no affect in firefox as
mozilla's xslt does not serialise the output it passes the result as an
in memory tree straight to the browser.

 encoding="ISO-8859-1" indent="yes"

doctype-public="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

this isn't the PUBLIC ID of either HTML or XHTML, it is the SYSTEM ID of
one version of XHTML. XML does not allow the specification of  Just a
PUBLIC ID you have to give a SYSTEM ID as well so if you use
doctype-public without doctype-system then XSLT will ignore the
doctype-public. When working client side, the browser will not load the
DTd anyway so this not really doing anything.

  <xsl:template match="*">
  <html xmlns="http://www.w3.org/1999/xhtml";>

this generates html in the xhtml namespace (apparently for every input
element, although actually you never call xsl:apply-templates so this
only happens once.

<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />

If you were generating html (ie elements in no-namespace using the html
output method) it would be best to not add such an element, as XSLKT
will generate one specifying the encoding that it uses (which may notbe
the encoding that you ask for)

<xsl:element name="link">
<xsl:attribute name="type">text/css</xsl:attribute>
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$hostName"
/>/css/common.css</xsl:attribute>
</xsl:element>

That could have been more easily written

<link type="text/css" rel="stylesheet" href="{$hostName}/css/common.css"/>

This would be output in the result as using > or /> depending on whether
the html method is used if it was in no-namespace ratehr than xhtml.
Again this matters to IE which does not understand XHTML syntax.

<xsl:element name="script">
same comments as for link.
In thsi case though I think IE gets even more confused if the XML 
empty element syntax is used. (Which it will be if yougenerate xhtml
elements) Also the actualy javascript code would need to access an xml
or html dom, depending.

It would probably best to generate elements in no-namespace so that the
html output method can be used to generate html syntax if you need to
target IE.


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread