|
|
|
|
|
|
| |
XSLT Tutorial
XSLT: Putting it all together, server side code
To enable our code to run on all browsers we need to output HTML,
instead of using client-side code. Therefore we need to use ASP
server-side code.
The following code demonstrates how to do this VBScript ASP code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<P>
<%
set xmlDoc=server.createObject("Msxml2.FreeThreadedDOMDocument.3.0")
set xslDoc=server.createObject("Msxml2.FreeThreadedDOMDocument.3.0")
xmldoc.async = false
xslDoc.async = false
xmlDoc.load server.mapPath("/includes/myxml.xml")
if (xmlDoc.parseError.errorCode <> 0) then
Response.Write "XML error - " & "<br>"
Response.Write "Error Reason: " & xmlDoc.parseError.reason & "<br>"
Response.Write "Source: " & xmlDoc.parseError.srcText & "<br>"
Response.Write "Error Line: " & xmlDoc.parseError.line & "<br>"
Response.Write "Error Position: " & xmlDoc.parseError.linepos & "<br>"
end if
xslDoc.load server.mapPath("allitems.xsl")
if (xslDoc.parseError.errorCode <> 0) then
Response.Write "XSL error - " & "<br>"
Response.Write "Error Reason: " & xslDoc.parseError.reason & "<br>"
Response.Write "Source: " & xslDoc.parseError.srcText & "<br>"
Response.Write "Error Line: " & xslDoc.parseError.line & "<br>"
Response.Write "Error Position: " & xslDoc.parseError.linepos & "<br>"
end if
response.write xmlDoc.transformNode(xslDoc)
set xmlDoc = nothing
set xslDoc = nothing
%>
</P>
<P> </P>
</BODY>
</HTML>
|
|
|
|
|
|
|
|
|