|
Subject: [xsl] XSLT in IE (MSXML3) From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx> Date: Mon, 25 Jun 2007 17:08:13 +0200 |
I've written a summary what problems may arise when using client side XSLT with IE. Tested with IE6 and MSXML3 on Win2000, it has the form of a stylesheet, to make it ease to test on different platforms, browser levels and versions of MSXMLx. Any comments or additions are most welcome!
XML: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="Test_IE_view.xsl" type="text/xsl"?> <doc xmlns="http://www.w3.org/1999/xhtml"> <p><span>**no*</span><span>*blank**</span></p> <p>text1<br/>text2</p> <div style="display: none"/> </doc>
XSLT: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/>
<xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*"/> </xsl:copy> </xsl:template>
<xsl:template match="xhtml:doc">
<html>
<xsl:comment>in IE-6 below is the same for xsl:output method="xml" or
"html"</xsl:comment>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Testing XSLT in IE (MSXML3)</title>
<style type="text/css">
#div11, #div12 {background: red; width: 200px; height: 6px; border:
4px solid black; overflow:hidden;}
#div11 {border-width: 6px 40px;}
#div12 {border-width: 6px 0px;}
</style>
</head>
<body>
<h2>Testing XSLT in IE (MSXML3)</h2>
<p>As IE strips whitespace before the XSLT processing starts, it may be worth
to consider <xsl:strip-space elements="*"/> for a cross-browser
stylesheet.</p>
<p>IE seems to ignore xsl:output encoding="UTF-8" and produces
<?xml version="1.0" encoding="UTF-16"?> for the xml header (maybe
without negative consequences).</p>
<div id="div11"></div>
<p>same length for quirks-mode (for xsl:output method="xml" and
omit-xml-declaration
ommited or ="no")</p>
<div id="div12"></div>
<p>Using xsl:output method="html" or "xml" seems to make no difference for the
following tests. First, the elements come from the <b>input document</b>:
<ul>
<li>with xsl:output indent="yes" CRLF (hex 0D0A) may be inserted
between elements, even in places where
no whitespace was in the
source. Strongly recommended:
xsl:output indent="no"</li>
<li>the <br/> element becomes <br>CRLF</br>, giving you an extra
newline. To eliminate the extra newline you might use <xsl:template
match="xhtml:br"> <br/> </xsl:template></li>
<li>the <div style="display: none"/> becomes <div style="display:
none">CRLF</div></li>
</ul>
</p>
<xsl:apply-templates/>
<p>Second, the elements come from the <b>stylesheet</b>:
<ul>
<li>no CRLF (hex 0D0A) will be inserted</li>
<li><br/> correctly becomes <br /></li>
<li><div style="display: none"/> becomes <div style="display: none" />,
causing IE to skip all content which comes after it (here
<p>text6</p>). To avoid this,
simply code <div style="display:
none"></div>.</li>
</ul>
</p>
<p><span>**no*</span><span>*blank**</span></p>
<p>text1<br/>text2</p>
<div style="display: none"></div>
<p>text5</p>
<div style="display: none"/>
<p>text6</p>
</body>
</html>
</xsl:template><xsl:template match="/"> <xsl:apply-templates select="xhtml:doc"/> </xsl:template>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSL Syntax in XML File? /, Yves Forkl | Thread | [xsl] searching a group of xml docu, Vaduvoiu Tiberiu |
| Re: [xsl] XSL Syntax in XML File? /, Yves Forkl | Date | [xsl] searching a group of xml docu, Vaduvoiu Tiberiu |
| Month |