Recently, and Apple peel in the discussion optimization Weather for the Google earth use XSLT to transform the XML data problem, then must use the conversion engine, presumably the process is to the XML file and XSLT files are reproduced into memory with the DOM engine to convert to the we want to HTML (in my case, to generate the KML file). This conversion process is divided between the client and the server side, because the client's browser needs the user's browsers to fully support XML, but not all of the user's browser is now supported (IE5, IE4, etc.), so the conversion of the service side is ideal.
XML file Form:
I started the conversion code, with the ASP+JAVASCIRPT:
======== output type and stream encoding ==========================
Response.ContentType = "Application/vnd.google-earth.kml+xml";
Response.Charset = "UTF-8";
===== gets and loads the remote XML file ==========================
var oxhy = Server.CreateObject ("MSXML2.") XMLHTTP ");
var url = http://www.dnxh.cn/ge/CHXX0101.xml;
Oxhy.open ("Get", url,false);
Oxhy.send ();
var oxd = Server.CreateObject ("MSXML2.") DOMDocument ");
Oxd.loadxml (Oxhy.responsetext);
= = = Load xsl file =========================
var xsl = Server.CreateObject ("Microsoft.XMLDOM");
Xsl.async = false;
Xsl.load (Server.MapPath ("gew.xsl"));
Conversion of File = = = ====================
Response.Write (Oxd.transformnode (XSL));
Logically this should not be the problem of coding, because the declaration of the location of the code is declared. But there was a problem. The initial declaration of the output KML file is always
<?xml version= "1.0" encoding= "UTF-16"?>
The test found no problem with XML and XSLT two source files, and the problem was in the conversion engine in the ASP code, and later in the RE: [XSL] Problem with Chinese (Solution) This article probably found the cause, which says the engine transform Node is generated a string, and on the Win32 platform always UTF-16 to handle the string, and then we use this string to generate KML file, the result can only be UTF-16.
the solution is to use the transformNodeToObject engine. The File Conversion section is replaced with oxd.transformnodetoobject ( xsl , response). The difference between the two methods is that the previous one was to generate a string variable, and the latter is to directly save the converted XML data to the specified node.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.