hello.asp

<%@ Language="VBScript"  %>
<% Response.Buffer = true %>
<% 
 If StrComp("POST",Request.ServerVariables("REQUEST_METHOD"),1) = 0 then
 
   Dim xmlArena,xmlARoot,xmlLingo,xmlLRoot,xmlResult,xmlRoot,oFS,passedValue

   passedValue = Request.Form("BTN")
   If Not passedValue = "" then 
   
      Select Case UCASE(passedValue)
      Case "ENGLISH"  passedValue="en" 
      Case "GERMAN" passedValue="de"   
      Case "JAPANESE" passedValue="ja"    
      End Select
   Else
      Response.Write "Wrong Button pressed or value of button not passed "
      Response.End 
   End If
   
   
   Set xmlArena = Server.CreateObject("Microsoft.XMLDOM")
   Set xmlLingo = Server.CreateObject("Microsoft.XMLDOM")
   Set xmlResult = Server.CreateObject("Microsoft.XMLDOM")
   Set xslResult = Server.CreateObject("Microsoft.XMLDOM")
 
   Set oFS = Server.CreateObject("Scripting.FileSystemObject")

   xmlArena.async = false
   xmlLingo.async = false
    xmlResult.preserveWhiteSpace = true
           
    URL = Server.MapPath("arena.xml")
    xmlArena.load(URL)
         
    URL = Server.MapPath(passedValue & "_lingo.xml")
    xmlLingo.load(URL)
         
    URL = Server.MapPath("result.xsl")
    xslResult.load(URL)
         
    Call parseError(xmlArena)
    Call parseError(xmlLingo)
    Call parseError(xslResult)

    Set xmlARoot = xmlArena.documentElement
    Set xmlLRoot = xmlLingo.documentElement
         
   URL = Server.MapPath(passedValue & "_result.xml")
 
   If Not oFS.FileExists(URL) Then
     Set tStrm = oFS.CreateTextFile(URL,True,True)
     Set xmlResult.documentElement = xmlARoot
     Set xmlRoot = xmlARoot

     Call getXML(xmlRoot)
          
     tStrm.WriteLine(xmlResult.xml)
     tStrm.Close()
   Else
     xmlResult.load(URL)
     Call parseError(xmlResult)
   End If
   
   ' Flipping the code page depending upon the language choosen
   strNode = "//UIElement[@CODEPAGE]"
   Set Element = xmlResult.selectSingleNode(strNode)
   Session.CodePage = CInt(Element.getAttribute("CODEPAGE"))
   Response.write xmlResult.transformNode(xslResult) 'display resulting htm
%>

<SCRIPT LANGUAGE="VbScript" RUNAT="SERVER" DEFER>
Sub getXML(root)
   Set oElement= xmlLRoot
       
   'Combines Lingo attributes with arena attributes
   ' to produce resulting xml file
        
   'For 1st element
   For each attrib in xmlLRoot.attributes
      root.setAttribute attrib.nodeName,Decode(attrib.nodeValue)
   Next
        
   'For all other elements
   For Each element in root.childNodes
      strNode = "//" & element.nodeName & "[@ID='"  & element.getAttribute("ID")  & "']"
      Set oElement =  xmlLingo.selectSingleNode(strNode)
      For Count = 1 to  oElement.attributes.length -1 
         Set attrib = oElement.attributes(Count)
         element.setAttribute attrib.nodeName,Decode(attrib.nodeValue)
      Next
   Next
   
End Sub  
 
Sub parseError(xmlDoc)
   If xmlDoc.parseError.errorCode <> 0 Then
      reportError xmlDoc.url, xmlDoc.parseError
   End If
End Sub
 
Sub reportError(where, error)
   Response.Write("<B>Error loading " & where & "</B> Reason: " + error.reason)
   Response.Write "<br> Line No : " & error.line
End Sub
   
Public Function Decode(str)
   x = InStr(str,"%")
   Do While x > 0
      Decode = Decode & Mid(str,1,x-1)
      If LCase(Mid(str,x+1,1)) = "u" Then
         'Response.Write "CHRW: " & "&H" & Mid(str,x+2,4) & "<br>"
         Decode = Decode & ChrW(CLng("&H" & Mid(str,x+2,4)))
         str = Mid(str,x+6)
      Else
         'Response.Write "CHR: " & "&H" & Mid(str,x+1,2) & "<br>"
         Decode = Decode & Chr(CLng("&H" & Mid(str,x+1,2)))
         str = Mid(str,x+3)
      End If
      x = InStr(str,"%")
   Loop
   Decode = Decode & str
End Function
</SCRIPT>

<% End If %>

<HTML>
<HEAD>
<TITLE>Hello World XML Sample</TITLE>
<LINK REL="stylesheet"  TYPE="text/css" HREF="Result.css" >

<SCRIPT LANGUAGE="VbScript">

Function Decode(str)
   x = InStr(str,"%")
   Do While x > 0
      Decode = Decode & Mid(str,1,x-1)
      If LCase(Mid(str,x+1,1)) = "u" Then
         'Response.Write "CHRW: " & "&H" & Mid(str,x+2,4) & "<br>"
         Decode = Decode & ChrW(CLng("&H" & Mid(str,x+2,4)))
         str = Mid(str,x+6)
      Else
         'Response.Write "CHR: " & "&H" & Mid(str,x+1,2) & "<br>"
         Decode = Decode & Chr(CLng("&H" & Mid(str,x+1,2)))
         str = Mid(str,x+3)
      End If
      x = InStr(str,"%")
   Loop
   Decode = Decode & str
End Function

sub showTitle(str)
   Mousetitle.innertext = Cstr(Decode(str))
   Mousetitle.style.posLeft = Clng(window.event.clientX )
   Mousetitle.style.posTop = Clng(window.event.clientY )
   Mousetitle.style.display= ""
end sub

sub hideTitle()
   Mousetitle.innertext = "" 
   Mousetitle.style.display ="none"
end sub

</SCRIPT>


</HEAD>

<BODY>
<DIV   ID="Mousetitle" style="display:none;position:absolute;background:fafad2;width:260px;zorder:40;">
</DIV>
<FORM NAME="frmLingo" METHOD="POST" ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>">
<TABLE  WIDTH=100%>
<TR HEIGHT=10%></TR>
<TR><TD WIDTH=30%></TD><TD>
<FIELDSET STYLE="WIDTH:40%">
<LEGEND>Choose language</LEGEND>
  <TABLE WIDTH=100%>
   <TR><TD><INPUT  TYPE="SUBMIT" NAME="BTN"   VALUE="ENGLISH"  TITLE="Click here for 'Hello World' in English." > </TD>
   <TD><INPUT TYPE="SUBMIT"  NAME="BTN"       VALUE="GERMAN"  onmouseover="showTitle('%u004b%u006c%u0069%u0063%u006b%u0065%u006e%u0020%u0053%u0069%u0065%u0020%u0068%u0069%u0065%u0072%u0020%u0066%u00fc%u0072%u0020%u0027%u0048%u0065%u006c%u006c%u006f%u0020%u0057%u006f%u0072%u006c%u0064%u0027%u0020%u0061%u0075%u0066%u0020%u0044%u0065%u0075%u0074%u0073%u0063%u0068%u002e')" onmouseout="hideTitle()"></TD>
   <TD><INPUT TYPE="SUBMIT" NAME="BTN"       VALUE="JAPANESE" onmouseover="showTitle('%u30af%u30ea%u30c3%u30af%u3059%u308b%u3068%u65e5%u672c%u8a9e%u3067%U0020%U300c%U0048%U0065%U006c%U006c%U006f%U0020%U0057%U006f%U0072%U006c%U0064%U300d%U0020%u3092%u8868%u793a%u3057%u307e%u3059')" onmouseout="hideTitle()"></TD>
   </TR>
  </TABLE>
</FIELDSET>
</TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>