This comes up on this list every so often. I've gone through this,
too. The secret is to get all the encoding to match. You have the
least amount of control over the browsers, so target their default
settings. Here's what works for me:
For outputting (X)HTML (note the encoding) -
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:cvs="http://www.cvshome.org/docs/manual/"
cvs:id="$Id: index.xsl,v 1.1 2003/06/24 18:32:00 dbibbens Exp $">
<xsl:output
method="xml"
media-type="text/html"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="DTD/xhtml1-strict.dtd"
cdata-section-elements="script style"
encoding="ISO-8859-1"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml"
cvs:id="$Id: index.xsl,v 1.1 2003/06/24 18:32:00 dbibbens Exp $">
<head>
<link rel="stylesheet" type="text/css" href="/css/xo.css"/>
...
</head>
<body>
...
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The above produces the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:cvs="http://www.cvshome.org/docs/manual/"
cvs:id="$Id: index.xsl,v 1.1 2003/06/24 18:32:00 dbibbens Exp $">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
...
</head>
<body>
...
</body>
</html>
For outputting XML (again note the ecoding):
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:cvs="http://www.cvshome.org/docs/manual/cvs_12.html"
cvs:id="$Id: catalog-item.xsl,v 1.2 2003/06/24 19:15:20 dbibbens Exp $">
<xsl:import href="http://xobjex.com/model/share/instance-id.xsl?print=src"/>
<xsl:output method="xml" encoding="utf-8"/>
<xsl:template match="/">
<xsl:call-template name="catalog-item"/>
</xsl:template>
<xsl:template name="catalog-item">
<xsl:element name="catalog-item">
<xsl:attribute name="instance-id">
<xsl:call-template name="instance-id"/>
</xsl:attribute>
<xsl:attribute name="cvs:id">
<xsl:text>$Id: catalog-item.xsl,v 1.2 2003/06/24 19:15:20
dbibbens Exp $</xsl:text>
</xsl:attribute>
<xsl:element name="name">
<xsl:value-of select="//@name"/>
</xsl:element>
<xsl:element name="description">
<xsl:value-of select="//@description"/>
</xsl:element>
<xsl:element name="attributes">
<xsl:for-each select="//@attribute">
<xsl:element name="attribute">
<xsl:attribute name="name">
<xsl:value-of select="substring-before(.,',')"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="substring-after(.,',')"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
<xsl:element name="graphics">
<xsl:for-each select="//@graphic">
<xsl:element name="graphic">
<xsl:attribute name="uri">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Which produces:
<?xml version="1.0" encoding="utf-8"?>
<catalog-item
xmlns:cvs="http://www.cvshome.org/docs/manual/cvs_12.html"
instance-id="Pw9szxiUGC0AAV1ke(_at_)8" cvs:id="$Id: catalog-item.xsl,v 1.2
2003/06/24 19:15:20 dbibbens Exp$">
<name></name>
<description></description>
<attributes>
<attribute name="color" value="blue"/>
<attribute name="color" value="red"/>
</attributes>
<graphics/>
</catalog-item>
"[Tech]" <tech(_at_)oznogco(_dot_)com> writes:
Hi,
I create a valid UTF-8 encoding XML file with "Microsoft.XMLDOM".
It's OK when a parse my XML/XSL with ASP.
But not if I open the file directly with Mozilla or IE
1. My XML file are OK
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sauve.xsl"?>
2. My XSL file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="no"/>
3. And I force the "Content-Type"!
<xsl:template match="/">
...
=>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
...
Mozilla say (File info tab) that is "ISO" file but say about "Content-Type"
== >text/html; charset=UTF-8
Gorgeous!
Tx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list