semi-sentient
10-10-2006, 10:07 AM
OK, using JavaScript I can typically assign an event handler and continue processing when readyState == 4. In ASP, I'm not sure how exactly to do that, as I don't have any of my reference books and searching Google hasn't been all that helpful. The problem that I'm having is that sometimes the XML document isn't loaded when I try to apply the XSL, so I get a "document not ready" type message. I'm using class ASP and I'm attempting to do the following:
1) load an XML document from a URL
2) apply XSL so that I can format it in HTML
3) send an e-mail
Here is the code for loading the XML document and stylesheet:
' Declare variables to be used
Dim objMessage, objConn, objRS, strSQL, strMessages, strOut
' Handle errors...
On Error Resume Next
' First we must get the relevant job messages so we put them in the body of the e-mail message (format XML -> HTML)...
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
Set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = false
xslDoc.async = false
' Load our XML document and XSL document
xmlDoc.load("http://servername/getXML.asp?job=" & Request.QueryString("jobID"))
xslDoc.load("\\servername\path\style.xsl")
' Format the messages (preserve < and > since we're sending an HTML e-mail anyway)
strMessages = xmlDoc.transformNode(xslDoc) (PROBLEM OCCURS HERE)
strMessages = Replace(strMessages, ">", ">")
strMessages = Replace(strMessages, "<", "<")
strMessages = Replace(strMessages, "<br>", "")
' Clean up
Set xmlDoc = Nothing
Set xslDoc = Nothing
.... code to query database and send e-mail follows ...
I need a way to halt execution until the XML document is successfully loaded, at which time I can then apply the XSL. Any suggestions would be greatly appreciated. It's been several years since I've worked with ASP, so hopefully I've explained the problem and required solution well enough.
Thanks in advance.
1) load an XML document from a URL
2) apply XSL so that I can format it in HTML
3) send an e-mail
Here is the code for loading the XML document and stylesheet:
' Declare variables to be used
Dim objMessage, objConn, objRS, strSQL, strMessages, strOut
' Handle errors...
On Error Resume Next
' First we must get the relevant job messages so we put them in the body of the e-mail message (format XML -> HTML)...
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
Set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = false
xslDoc.async = false
' Load our XML document and XSL document
xmlDoc.load("http://servername/getXML.asp?job=" & Request.QueryString("jobID"))
xslDoc.load("\\servername\path\style.xsl")
' Format the messages (preserve < and > since we're sending an HTML e-mail anyway)
strMessages = xmlDoc.transformNode(xslDoc) (PROBLEM OCCURS HERE)
strMessages = Replace(strMessages, ">", ">")
strMessages = Replace(strMessages, "<", "<")
strMessages = Replace(strMessages, "<br>", "")
' Clean up
Set xmlDoc = Nothing
Set xslDoc = Nothing
.... code to query database and send e-mail follows ...
I need a way to halt execution until the XML document is successfully loaded, at which time I can then apply the XSL. Any suggestions would be greatly appreciated. It's been several years since I've worked with ASP, so hopefully I've explained the problem and required solution well enough.
Thanks in advance.