The menu.asp file includes code that dynamically adds XML elements and attributes to the XML document object that contains the *menu.xml file. This feature enables the PT application to support additional arenas and languages by creating new lingo.xml files.
Before the XSL transformation on the *menu.xml file begins, menu.asp determines the languages the application supports and builds these languages into the in-memory representation of *menu.xml that is stored in an XML document object. The LoadMenuOptions method, which is available in Litware.Lingo, searches through the file structure of the PT application to locate folders in which there is a file named lingo.xml. LoadMenuOptions returns the names of these folders and stores them in menuArray, a Visual Basic Collection object. (You obtain specific members of the Collection object using the Item method; you iterate through the entire collection using the For.Each. . .Next statement.) The names of these folders, en-us, de, and ja, are the codes for the languages the PT application supports.
Next, the code uses the selectSingleNode method of the XML DOM to perform a pattern match and retrieve the <Build> element from *menu.xml. The code then iterates through the items in menuArray—the codes for the languages—and adds <menuitem> child elements to the <Build> element. The code then creates two attributes for <menuitem> elements: itemname, which is retrieved using the Item method and is the name of one of the language folders, and url, which receives the string "/menu/build.asp". The XSL file uses these attributes during the XSL transformation to build the ONCLICK event handlers for the HTML files that result.
After these elements and attributes are added to the in-memory representation of *menu.xml (oXML), the code calls the transformNode method and passes it the XSL file. The following code fragment illustrates this process:
End If
Set menuArray = oLoadMenu.LoadMenuOptions(srcPath,"lingo.xml")
strNode = "//menu[@name='Build']"
Set currNode = oXML.selectSingleNode(strNode)
For each item in menuArray
Set newNode = oXML.createElement("menuitem")
Set childNode = currNode.appendChild(newNode)
childNode.setAttribute "itemname",item
childNode.setAttribute "url","/menu/build.asp"
Next
Response.Write oXML.transformNode(oXSL)
Set oLoadMenu = Nothing
End Sub
For a discussion of the code that generates HTML during the XSL transformation, see Performing the XSL Transformation on menu.xml.