是否有可能在ASP经典的远程服务器上加载一个XSL样式表(Is it possible to loa

2019-11-02 12:49发布

我没有在服务器上的磁盘访问,所以我需要从远程位置加载XSL样式表。

取而代之的是...

set xsl = Server.CreateObject("MSXML2.DOMDocument")
xsl.async = false
xsl.load(Server.MapPath("xsl.xsl"))

是这样的,可载入XSL样式表?

xsl.Open "get", "http://www.example.com/xsl.xsl" , False
xsl.Send

如果以上是不可能的可以在样式表可以在ASP文件内部放。 如果是这样,怎么是,实现的呢?

UPDATE - 全码

Dim xml, xsl, url, url2

url = "https://www.example.xml"
url2 = "http://www.example.com/xsl/xsl.xsl"
Set xml =  Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "get", url, False
xml.Send
Response.ContentType = "text/xml"

set xsl = Server.CreateObject("MSXML2.DOMDocument")
xsl.async = false

xsl.load(Server.MapPath("xsl.xsl"))

'xsl.Open "get", url2, False
'xsl.Send

Response.AddHeader "Content-Type", "text/xml;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8"
Response.Write xml.responseXML.transformNode(xsl)

Answer 1:

尝试

Dim req, sheet
Set req = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
req.open "GET", "http://example.com/sheet.xsl", False
req.send
If req.status = 200 Then
  Set sheet = req.responseXML
  ...
Else
  '  handle HTTP problems here
End If


文章来源: Is it possible to load a XSL stylesheet from a remote server in ASP classic