您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200510
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

关于“使用xmlspy编写xsl文件时候,在xsl解释xml文件的时候总是使用utf-16编码”的解决办法

yangbc

使用xmlspy编写xsl文件时候,当使用如下编码时,在xsl解释xml文件的时候总是使用UTF-16编码方式

1.   xsl文件

<?xml version="1.0" encoding="gb2312"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>

//这里虽然指明了显示编码,但是xmlspy生成的xsl解释文件会另在此行之前加上utf-16的编码方式而另此处的指示无效,解决办法如下:
<META http-equiv="Content-Type" content="text/html; charset=gb2312"/> </head>

2.    xsl解释xml文件后输出文件的源代码

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#0099ff">

3.   解决办法:把xsl文件改写成如下形式

<?xml version="1.0" encoding="gb2312"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<META http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<head>
<META http-equiv="Content-Type" content="text/html; charset=gb2312"/>
</head>
<body bgcolor="#0099ff">

在<head></head>之前加上<META http-equiv="Content-Type" content="text/html; charset=gb2312"/>,这样xsl解释xml文件生成的文件的源代码就会是如下形式

<html>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#0099ff">

这样编码方式就在utf-16之前给改过来了,客户端也可以正常显示gb2312的中文了

                                                                                                          benchunyang8@hotmail.com  #