Is it possible to load a XSL stylesheet from a remote server in ASP classic

妖精的绣舞 提交于 2019-12-25 01:49:49

问题


I do not have disk access on the server so I need to load a XSL stylesheet from a remote location.

Instead of this...

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

Is something like this possible to load a XSL stylesheet?

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

If above is not possible can the stylesheet be put internally in the ASP file. If so, how is that accomplished?

UPDATE - Full code

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)

回答1:


Try

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


来源:https://stackoverflow.com/questions/18954843/is-it-possible-to-load-a-xsl-stylesheet-from-a-remote-server-in-asp-classic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!