国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > XML > 正文

建立MS XML 測試環境

2024-09-05 20:54:21
字體:
來源:轉載
供稿:網友

一般的Windows環境(Windows 98 SE以上版本)都有一個MSXML環境,以下的asp代碼可以運行,但不一定工作,不工作可能是由于樣式單是http://www.w3.org/1999/XSL/Transform的,而最初環境只支持http://www.w3.org/TR/WD-xsl,所以可能什么也不出來。

以下為引用的內容:

<%@ 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));
%>

一般以MSXML為開發環境的都要建立安裝新的解析器,如MSXML 3或者MSXML 4 Technology Preview,在以replace方式裝了MSXML 3后,我們可以使用以下的代碼

以下為引用的內容:

<%@ 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));
%>

這樣我們獲得了MSXML 3的開發環境,但如果我們不想破壞原來的環境,又要測試我們基于MSXML 3的例子呢,雖然用replace方式安裝提供了向后兼容方式來支持XSL元素,函數和XSL命名空間。

其實使用版本無關progIDs(version-dependent progIDs)來創建對象實例可以更好的完成工作,我們不需要用replace方式安裝,用side-by-side方式即可,我們看下面的代碼:

以下為引用的內容:

<%@ 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));
%>

只需要在Msxml2.DOMDocument后面加上版本號3.0,即可使用MSXML 3的東東了,MSXML 4呢,依次類推。

在客戶端的環境也是一樣的,用js創建DOM對象是一樣的。

以下為引用的內容:
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);
}

最后,XSLT樣式單side-by-side方式下在Internet Explorer 5.0及以后版本不支持。如果你要使用IE 5來打開XSLT樣式單,需要用replace方式安裝.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 石景山区| 铜梁县| 大悟县| 青川县| 荃湾区| 施甸县| 东宁县| 舟山市| 普兰店市| 和平区| 西昌市| 维西| 明水县| 望奎县| 类乌齐县| 合江县| 宜春市| 奇台县| 荥经县| 长丰县| 清水县| 依兰县| 类乌齐县| 白河县| 高邮市| 师宗县| 昆山市| 海阳市| 鹤山市| 古丈县| 从化市| 禹城市| 安仁县| 新乡县| 呼玛县| 华容县| 昌图县| 北流市| 塘沽区| 和顺县| 亚东县|