Establish MS XML test environment

Source: Internet
Author: User
Tags object version xsl xslt
Xml

The general Windows environment (more than Windows version SE) has a MSXML environment, the following ASP code can run, but not necessarily work, not work may be due to the style alone http://www.w3.org/1999/XSL/ Transform , and the initial environment only supports http://www.w3.org/TR/WD-xsl, so it may not come out.
<%@ LANGUAGE = JScript%>
<%
Set the source and style sheet locations here
var sourcefile = Server.MapPath ("Test.xml");
var stylefile = Server.MapPath ("test.xsl");


Load the XML
var Source = Server.CreateObject ("Microsoft.XMLDOM");
Source.async = false;
Source.load (sourcefile);
Load the XSL
var style = Server.CreateObject ("Microsoft.XMLDOM");
Style.async = false;
Style.load (Stylefile);
Response.Write (Source.transformnode (style));
%>


A new parser, such as MSXML 3 or MSXML 4 Technology Preview, is created for the development environment of MSXML.
After MSXML 3 has been installed in Replace mode, we can use the following code


<%@ LANGUAGE = JScript%>
<%
Set the source and style sheet locations here
var sourcefile = Server.MapPath ("Test.xml");
var stylefile = Server.MapPath ("test.xsl");


Load the XML
var Source = Server.CreateObject ("msxml2.domdocument");
Source.async = false;
Source.load (sourcefile);
Load the XSL
var style = Server.CreateObject ("msxml2.domdocument");
Style.async = false;
Style.load (Stylefile);
Response.Write (Source.transformnode (style));
%>
This gives us the development environment for MSXML 3, but if we don't want to break the original environment, we'll test our example based on MSXML 3, although the Replace-mode installation provides backwards compatibility to support XSL elements, functions, and XSL namespaces.
In fact, the use of version-independent ProgIDs (Version-dependent ProgIDs) To create object instances can be better to complete the work, we do not need to replace the installation, with the Side-by-side way, we look at the following code:


<%@ LANGUAGE = JScript%>
<%
Set the source and style sheet locations here
var sourcefile = Server.MapPath ("Test.xml");
var stylefile = Server.MapPath ("test.xsl");


Load the XML
var Source = Server.CreateObject ("msxml2.domdocument.3.0");
Source.async = false;
Source.load (sourcefile);
Load the XSL
var style = Server.CreateObject ("msxml2.domdocument.3.0");
Style.async = false;
Style.load (Stylefile);
Response.Write (Source.transformnode (style));
%>
You just need to add version number 3.0 to the msxml2.domdocument and then use MSXML 3, MSXML 4, and so on.
In the client environment is the same, using JS to create a DOM object is the same.
function Test () {
var xmldoc = new ActiveXObject ("msxml2.domdocument.3.0");
var Currnode;
Xmldoc.async = false;
Xmldoc.load ("Test.xml");
Currnode = XmlDoc.documentElement.firstChild;
alert (currnode.xml);
}
Finally, XSLT style side-by-side mode is not supported in Internet Explorer 5.0 and later versions. If you want to open an XSLT style sheet using IE 5来, you need to install it in replace mode.



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.