xsl-list
[Top] [All Lists]

Re: Getiing Confused in Encoding Plz Help

2003-03-05 13:50:09
Hi Mike
    u r rigth, i changed the encoding tags of my XML and XSL file (both r
available below)
now the html i m getting on the client shows me no japanese characters, but
only questions marks "?"
what could be the reason

the XSL file (saved as UTF-8 with signature)
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output method="html" version="4.0" encoding="utf-8"/>
<xsl:template match="/address">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" Content="text-html" charset="utf-8"></meta>
</head>
<body>
<page>
    <xsl:apply-templates/>
</page>
</body>
</html>
</xsl:template>
<xsl:template match="*">
<xsl:value-of select="name()"/> :
<xsl:value-of select="current()"/>
</xsl:template>
</xsl:stylesheet>

the XML file (saved as UTF-8 with signature)
<?xml version="1.0" encoding="utf-8"?>
<address>
<city>東京</city>
<section>千代田区</section>
<street>紀尾井町4-1</street>
<zip>102-0094</zip>
</address>


The ASP code for  HTML generation

 Set Source = server.CreateObject("MSXML2.DomDocument")
 Set stylesheet = server.CreateObject("MSXML2.DomDocument")

  ' Load data.
  Source.async = False
  Source.Load xmlfile.xml

  stylesheet.async = False
  stylesheet.Load xslfile.xsl

  HTMLText = source.transformNode(stylesheet)

  Response.Write HTMLText

QAZI ASIM

----- Original Message -----
From: "Mike Brown" <mike(_at_)skew(_dot_)org>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Tuesday, March 04, 2003 11:09 PM
Subject: Re: [xsl] Getiing Confused in Encoding Plz Help


asim wrote:
    when i give this encoding tag
    <?xml version="1.0" encoding="iso-8859-1"?>
on the top of my xsl files

...you are making the assertion that the bytes of the file can be
converted
to Unicode characters according to the iso-8859-1 character map.

and then save them using visual studio.net save
as encoding and i choose UTF-8(without signature)

...so it is a utf-8 file and you have mislabeled it as iso-8859-1. This is
the
wrong thing to do. You are required by XML 1.0 to provide an accurate
encoding
declaration. Change the declaration to encoding="utf-8" so that the XML
parser
reading the file will be able to properly decode the file's bytes.

This is true for any XML, not just XSL.

Mike

--
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>