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

首頁 > 開發 > XML > 正文

建立MS XML 測試環境

2024-09-05 20:56:17
字體:
來源:轉載
供稿:網友
一般的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方式安裝.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 时尚| 乐陵市| 东台市| 扶风县| 京山县| 宣威市| 莱阳市| 呈贡县| 凭祥市| 民乐县| 杭锦后旗| 西昌市| 尼勒克县| 萨迦县| 新田县| 伊春市| 错那县| 即墨市| 定襄县| 准格尔旗| 陕西省| 武山县| 嵩明县| 承德县| 东明县| 陆良县| 雷山县| 廊坊市| 泽州县| 武义县| 双桥区| 衢州市| 门头沟区| 鸡东县| 宜章县| 南汇区| 昌黎县| 峨眉山市| 张北县| 乌兰县| 青河县|