您的位置:首页 > 其它

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

2004-09-07 23:27 791 查看
使用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 #
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐