The MakeMenuXML function begins by adding the name of the Web server as an attribute to the <topmenu> node of the *menu.xml file. The code loads the <topmenu> element into the currNode variable and, after obtaining the URL from the Request.ServerVariables collection, calls the setAttribute method to dynamically set a rooturl attribute. The nested Left and InStr functions find the name of the application's virtual root.
This change happens only in the in-memory representation of the *menu.xml file; the change does not persist in the file itself. Processing done by the XSL file appends the attribute further so that the resulting HTML stream sent to the browser correctly calls Build.asp, which handles the ONCLICK events for all menu items on the Build menu.
Sub makeMenuXML()
Dim currNode,strNode,toRemoveNode,newNode,childNode
Dim menuArray,oLoadMenu,srcPath,item, sURL
'Adds the servername as an attribute to topmenu node
Set currNode = oXML.selectSingleNode("//topmenu")
sURL = Request.ServerVariables("URL")
currNode.setAttribute "rooturl","http://" & _
Request.ServerVariables("HTTP_HOST") & _
Left(sURL,InStr(2,sURL,"/")-1)
See Adding Menu Items to a Popup Object for a discussion of the code that adds menu items and their event handlers to the HTML stream.
Next, the code returns to the application's root with a call to the server.MapPath method. Then the code sets a reference to the Litware.Lingo component. The following code fragment illustrates this process:
srcPath = server.MapPath("..")
Set oLoadMenu = Server.CreateObject("Litware.Lingo")
If IsEmpty(oLoadMenu) or oLoadMenu Is Nothing Then
Response.Write "Object failed:"
Response.End
The PT application uses Litware.Lingo to prepare for the XSL transformation. The *menu.xml file stores the data necessary to perform the XSL transformation for all menus except one. The Build menu, however, contains no information, because it presents the languages each application arena supports, which change when administrators add or remove languages.
To create the Build menu with the correct list of languages, the PT application dynamically adds child elements and attributes to the XML document object into which the *menu.xml file is loaded.