<% option explicit dim xmlFile, defaultDocument xmlFile = "data.xml" defaultDocument = "default.htm" sub alerter(byRef strMsg) response.write "
" + strMsg + "
" end sub dim xmlDoc set xmlDoc = server.createObject("msxml2.DomDocument.6.0") 'call xmlDoc.setProperty("ProhibitDTD", false) 'call xmlDoc.setProperty("ResolveExternals", false) dim oFs, oFsFile, dataFile, sDataInFile, oTextStream dataFile = server.mapPath(xmlFile) set oFs = server.CreateObject("scripting.filesystemobject") If oFS.FileExists(dataFile) Then Set oTextStream = oFS.OpenTextFile(dataFile,1) sDataInFile = oTextStream.ReadAll oTextStream.Close Set oTextStream = nothing End if 'repair stupid XML sDataInFile = replace(sDataInFile, " xmlns = ""http://docbook.org/ns/docbook""", " xmlns:db = ""http://docbook.org/ns/docbook""") sDataInFile = replace(sDataInFile, "", "") sDataInFile = replace(sDataInFile, "", "") sDataInFile = replace(sDataInFile, " ", "") 'response.Write sDataInFile 'response.end if not xmlDoc.loadXml(sDataInFile) then alerter("Error on XML: " + xmlDoc.parseError.reason) end if dim query, arrQry, qi, sPath, chapterParam qi = 0 spath = "" query = replace(replace(request.queryString,"#",""), "force=true","") arrQry = split(query, "-") do while(qi <= ubound(arrQry)) dim curr curr = int(arrQry(qi)) '- 1 if(qi=0) then chapterParam = curr sPath = "chapter[position()=" & curr else sPath = sPath & "]/section[position()=" & curr end if qi = qi + 1 loop if sPath <> "" then sPath = sPath & "]" dim siteTitle, siteLogo, imageURL, nodesSiteTitle, nodesSiteLogo imageURL = "" set nodesSiteTitle = xmlDoc.documentElement.selectNodes("title") set nodesSiteLogo = xmlDoc.documentElement.selectNodes("subtitle") if nodesSiteTitle.length > 0 then siteTitle = nodesSiteTitle(0).text end if if nodesSiteLogo.length > 0 then siteLogo = nodesSiteLogo(0).text end if response.Write "" response.Write "" + siteTitle + "" response.Write "" response.Write "
" response.Write "

" + siteTitle + "

" response.Write "
" if siteLogo <> "" then response.write "" + siteTitle + "" response.Write "
" response.Write "
" dim chapterList, chapter, chapterIx chapterIx = 1 set chapterList = xmlDoc.documentElement.selectNodes("chapter") for each chapter in chapterList dim style style = "" if chapterIx = chapterParam then style = "style='background-color:#dedede;'" response.Write "
  • " + chapter.selectSingleNode("title").text + "" chapterIx = chapterIx + 1 next response.Write "
  • " dim nodeList, node, nodeIx nodeIx = 1 if sPath <> "" then set nodeList = xmlDoc.documentElement.selectSingleNode(sPath) else set nodeList = xmlDoc.documentElement end if for each node in nodeList.childNodes dim currNode currNode = node.tagName if currNode <> "section" then select case (currNode) case "title" response.Write "

    " + node.text + "

    " case "para" response.Write "
    " + node.text + "
    " case "screen" response.write "
    " + node.text + "
    " case "graphic" dim imgSRC imgSRC = node.attributes.getNamedItem("fileref").value response.Write "
    " + imgSRC + "
    " end select else response.Write "
  • " + node.selectSingleNode("title").text + "" nodeIx = nodeIx + 1 end if next response.Write "
  • " if request("force") <> "true" then response.write "" response.write "" set xmlDoc = nothing %>