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.