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

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

使用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 #

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航