Example of some of the ASP code (written in VBScript) used to process the XML and XSL files.
<%
'================================================================================================='
'FUNCTION''XSLTransform(xmlfile,xslfile,errstring)
'Returns a string - the xslfile transformation of the xmlfile
'Optionally returns errstring if there's an error
'================================================================================================='
Function XSLTransform(xmlfile,xslfile,errstring)
dim objXMLDoc, objXSLDoc
const PROG_ID = "Microsoft.XMLDOM"
set objXMLDoc = Server.CreateObject(PROG_ID)
objXMLDoc.async = false
objXMLDoc.load(xmlfile)
if objXMLDoc.parseError.errorCode = 0 then
set objXSLDoc = Server.CreateObject(PROG_ID)
objXSLDoc.async = false
objXSLDoc.load(xslfile)
if objXSLDoc.parseError.errorCode = 0 then
XSLTransform = objXMLDoc.transformNode(objXSLDoc)
else
if errstring <> "" then
XSLTransform = errstring
end if
end if
else
if errstring <> "" then
XSLTransform = errstring
end if
end if
set objXSLDoc = nothing
set objXMLDoc = nothing
End Function
...
if xslfile <> "" then
Set XSLDoc = Server.CreateObject("Microsoft.XMLDOM")
XSLDoc.async = false
XSLDoc.load(Server.MapPath(xslfile))
if XSLDoc.parseError.errorCode <> 0 then
Response.Write("<font face=""arial""><br>ERROR<br>" & XSLDoc.parseError.URL & "<br>LINE " & XSLDoc.parseError.line & ": CHAR " & XSLDoc.parseError.linepos & "<br><br><b>" & XSLDoc.parseError.reason & "</b><br><br><XMP style=""background-color:CCCCCC"">" & XSLDoc.parseError.srcText & "</XMP><br></font>")
Response.End
end if
Response.Write(XMLDoc.transformNode(XSLDoc.documentElement))
end if
%>