<%@ Language=VBScript %>
<%
Option Explicit
Dim objWML, objXSL, objCards
Dim sCardName, sURL, Temp, i
sCardName = Request.QueryString("wml_url").Item
sURL = Request.QueryString("url").Item
'For local files
If Len(sURL) > 0 And InStr(sURL, "http://") = 0 _
And InStr(sURL, ":\") = 0 Then
sURL = Server.MapPath(sURL)
End If
'Picks out the Url/Card.
If InStr(sURL, "#") Then
sCardName = Mid(sUrl, InStr(sURL, "#") + 1)
sUrl = Mid(sUrl, 1, InStr(sURL, "#") - 1)
End If
If Len(sURL) = 0 Then
%>
WAP Emulator
<%
Else
Set objWML = Server.CreateObject("Microsoft.XMLDOM")
Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
objWML.Async = False
objWML.Load(sURL) 'Loads the WML document
objXSL.Async = False
objXSL.ValidateonParse = False
objXSL.Load(Server.MapPath("./wml.xsl")) 'Loads the WML XSL.
'Goes through the cards in the WML deck and picks out the
'first (default) card if none has been specified.
Set objCards = objWML.documentElement.childNodes
For i = 0 To objCards.Length - 1
If (Len(sCardName) = 0 And i = 0) Or LCase(sCardName) = _
LCase(objCards.item(i).attributes.item(0).Text) Then
Temp = objCards.Item(i).transformNode(objXSL.documentElement)
%>
<%=objCards.item(i).attributes.item(1).Text%>
<%
Response.Write(Tweak(Temp))
End If
Next
'Clean up XMLDOM objects.
Set objCards = Nothing
Set objXSL = Nothing
Set objWML = Nothing
End If
'===================================================================
Private Function Tweak(sRaw)
'Normalizes the links.
sRaw = Replace(sRaw, "HREF=""?wml_url=#", "HREF=""./default.asp?url=" & sURL & "&wml_url=")
'Replaces .wbmp extensons with .gif
sRaw = Replace(sRaw, ".wbmp", ".gif")
Tweak = sRaw
End Function
%>
Select a WAP URL