%@ Language=VBScript %>
<%
' from http://www.siteexperts.com/tips/xml/ts03/page3.asp
' If you want to store the XML component in the application or session state, you need to use the free-threaded version of the XML control (Microsoft.FreeThreadedXMLDOM). If you are only using the XML comoponent on the page itself, you should use the single-threaded version as you will get better performance (Microsoft.XMLDOM). Since you can't share objects between the two versions, you should not intermix both versions on the same page.
' Parse error formatting function
function reportParseError(error)
Dim s, i, r
s = ""
for i=1 to error.linepos-1
s = s & " "
next
r = "XML Error loading '" &_
error.url & "'" &_
"" & error.reason &_
"
"
if (error.line > 0) then
r = r & "" &_
"at line " & error.line & ", character " & error.linepos &_
"\n" & error.srcText &_
"\n" & s & "^" &_
""
end if
reportParseError = r
end function
function TransformDocument(sPath, srcXML, srcXSL, sDir)
Dim sourceFile, styleFile, source, sCache
Dim objFSO, objFile
sCache = sPath + sDir + "\" + srcXML + ".inc"
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(sCache) Then
' Check if cached
Set objFile = objFSO.OpenTextFile(sCache)
TransformDocument = objFile.readAll
objFile.close
else
sourceFile = sPath + srcXML + ".xml"
styleFile = sPath + srcXSL
' Load the XML - Use Free Threaded control
set source = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
source.async = false
source.load sourceFile
' Load the XSL
' Cache parsed XSL sheet
if isempty(application(styleFile)) then
set style = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
style.async = false
style.load styleFile
application.lock()
set application(styleFile)=style
application.unlock()
else
set style = application(styleFile)
end if
if (source.parseError.errorCode <> 0) then
result = reportParseError(source.parseError)
elseif (style.parseError.errorCode <> 0) then
result = reportParseError(style.parseError)
else
on error resume next
result = source.transformNode(style)
if (err.number<>0) then
result = reportRuntimeError(exception)
else
' dropping body and html tag
result = left(result,len(result)-18)
' add top menu code
result = result & "var TOP_MENU_ARRAY = new Array("
Set xmlMenu = server.CreateObject("Microsoft.XMLDOM")
blnFileExist = xmlMenu.load(server.MapPath("menu.xml"))
set NodeList = xmlMenu.documentElement.selectNodes("XML/menus/menu/@name")
x = 0
For Each Node In NodeList
if x <> 0 then result = result & ","
x = 1
result = result & "'" & Node.text & "'"
Next
result = result & ");" & chr(13)
' add dropdown menu code
result = result & "function menu_createDropDown(menutext,menuicons,menulinks){" & chr(13)
y = 0
For Each Node In NodeList
result = result & "menutext[" & y & "]=new Array("
set SubNodeList = xmlMenu.documentElement.selectNodes("XML/menus/menu[@name = '" & Node.text & "']/menu/@name")
x = 0
For Each SubNode In SubNodeList
if x <> 0 then result = result & ","
x = 1
result = result & "'" & SubNode.text & "'"
Next
result = result & ");" & chr(13)
result = result & "menuicons[" & y & "]=new Array("
set SubNodeList = xmlMenu.documentElement.selectNodes("XML/menus/menu[@name = '" & Node.text & "']/menu/@icon")
x = 0
For Each SubNode In SubNodeList
if x <> 0 then result = result & ","
x = 1
result = result & "'" & SubNode.text & "'"
Next
result = result & ");" & chr(13)
result = result & "menulinks[" & y & "]=new Array("
set SubNodeList = xmlMenu.documentElement.selectNodes("XML/menus/menu[@name = '" & Node.text & "']/menu/@link")
x = 0
For Each SubNode In SubNodeList
if x <> 0 then result = result & ","
x = 1
result = result & "'" & SubNode.text & "'"
Next
result = result & ");" & chr(13)
y = y + 1
Next
result = result & "}" & chr(13)
Set objFile = objFSO.OpenTextFile( server.mapPath("menuheader.asp"))
result = result & objFile.readAll ' & "