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

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

** 1. xsl文件 : **

 1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 2<xsl:template match="/">
 3<html>
 4<head>
 5
 6//这里虽然指明了显示编码,但是xmlspy生成的xsl解释文件会另在此行之前加上utf-16的编码方式而另此处的指示无效,解决办法如下:   
 7<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> </head>
 8
 9** 2\. xsl解释xml文件后输出文件的源代码  ** : 
10
11<html>
12<head>
13<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
14<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
15</head>
16<body bgcolor="#0099ff">
17
18** 3\. 解决办法:把xsl文件改写成如下形式  **
19
20<?xml version="1.0" encoding="gb2312"?>
21<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
22<xsl:template match="/">
23<html>   
24** <meta content="text/html; charset=utf-8" http-equiv="Content-Type">   
25** <head>
26<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
27</meta></head>
28<body bgcolor="#0099ff">
29
30在<head></head>之前加上 ** <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>, ** 这样xsl解释xml文件生成的文件的源代码就会是如下形式  : 
31
32<html>
33<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
34<head>
35<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
36<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
37</head>
38<body bgcolor="#0099ff">
39
40这样编码方式就在utf-16之前给改过来了,客户端也可以正常显示gb2312的中文了  。 
41
42[email protected] #</body></html></body></meta></html></xsl:template></xsl:stylesheet></body></html></html></xsl:template></xsl:stylesheet>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus