I am using ASP. I created a asp page that parse and display the xml content (i call it the main xml file). This xml page contains <item-id> tags. The tags refers/points to another xml file (sample1 and sample2 etc). When user click on a link on the main page. a popup window opens (getItem.asp is call see below). The user needs to be redirect if the content of the xml file contais the <item-content> tag with web address (sample1) or display content if <item-content> tags contains the <html> tag (sample2). My problem is on the getItem.asp
Any suggestion will be great.
Again need a lot of help...I hope you understand what I am trying to do. thanks
----- main.asp ------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/dbConn.asp" -->
<%
Dim aspPage
Dim xmlFile
Dim xslFile
aspPage= "main.asp"
xmlFile = "main.xml"
xslFile = "getXSL.xsl"
%>
<script language="JavaScript" type="text/JavaScript">
<!--
function openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<%
function showxmldata(strMXLFile, strXSLFile, strParam)
dim blnXMLOK
dim blnXSLOK
dim strFilesErr
Set xmlDoc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
Set xslDoc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
xmlDoc.preserveWhiteSpace = true
blnXMLOK = xmlDoc.load(Server.MapPath(strMXLFile))
blnXSLOK = xslDoc.load(Server.MapPath(strXSLFile))
if blnXMLOK and blnXSLOK then
'check for parameter
if strParam <> "" then
set xslt = Server.CreateObject("MSXML2.XSLTemplate")
set xslt.stylesheet = xslDoc
Set xslProc = xslt.createProcessor()
xslProc.input = xmlDoc
xslProc.addParameter "strCategory", cstr(strParam)
xslProc.transform
sOutput = xslProc.output
response.Write(sOutput)
set xslProc = nothing
set xslt = nothing
else
response.Write(xmlDoc.transformNode(xslDoc))
end if
else
if not blnXMLOK then
strFileErr = strFileErr & "strXMLFile: " & strMXLFile
end if
if not blnXSLOK then
strFileErr = "<br>" & strFileErr & "strXSLFile: " & strXSLFile
end if
response.write(strFileErr)
End if
set xmlDoc = nothing
set xslDoc = nothing
End Function
%>
<html>
<head>
</head>
<Body>
<%
Dim objXMLDoc
Set objXMLDoc=Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.load(Server.MapPath(xmlFile))
if objXMLDoc.parseError.errorcode<>0 then
'error handling code
Response.write "Error code: " & objXMLDoc.parseError.errorCode & "<BR>"
Response.write "Position in file: " & objXMLDoc.parseError.filepos & "<BR>"
Response.write "Error text: " & objXMLDoc.parseError.reason & "<BR>"
else
Dim vMXLFile, vXSLFile, vParam
vMXLFile = xmlFile
vXSLFile = xslFile
if request.QueryString("strMenu")="" then
vParam = "Addictions Articles"
else
vParam = request.QueryString("strMenu")
end if
showxmldata vMXLFile, vXSLFile, vParam
end if
%>
</body>
</html>
----- main.xml ------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<LIFE>
<DATAAREA>
<folder>
<folder-name>Addictions</folder-name>
<category>
<category-name>Addictions Articles</category-name>
<category-items>
<item-name>Stages of Recovery</item-name>
<item-description>In this article you will learn about the stages people go through to recover from drug or alcohol abuse and some resources that can help you learn more.</item-description>
<item-id>sample1</item-id>
</category-items>
<category-items>
<item-name>Lapse without Relapse</item-name>
<item-description>In this article you will learn about the basics of relapse prevention, situations that can contribute to relapse, and where to begin to get help.</item-description>
<item-id>sample2</item-id>
</category-items>
<category-items>
<item-name>The Effects of Alcohol on You and Your Workplace</item-name>
<item-description>In this article you will learn about the effects of alcohol on the workplace and what you can do about it.</item-description>
<item-id>11972</item-id>
</category-items>
</category>
<category>
<category-name>Addictions Frequently Asked Questions</category-name>
<category-items>
<item-name>When do most smokers relapse when they try to stop?</item-name>
<item-description>null</item-description>
<item-id>11989</item-id>
</category-items>
<category-items>
<item-name>Is a slip involving just one cigarette serious?</item-name>
<item-description>null</item-description>
<item-id>11997</item-id>
</category-items>
</category>
<category>
<category-name>Addictions Announcements</category-name>
</category>
</folder>
</DATAAREA>
</LIFE>
------ getXSL.xsl ---------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl

utput method="xml" indent="yes" doctype-system="../dtds/docbookx.dtd" doctype-public="-//OASIS//DTD DocBook XML//EN"/>
<xsl

aram name="strCategory"/>
<xsl:template match="LIFE/DATAAREA/folder/category">
<xsl:value-of select="child::folder-name"/>
<xsl:if test="category-name = $strCategory">
<div class="tbl-heading"><p style="width:80%;font-weight:bold"><xsl:value-of select="child::category-name"/></p></div>
<xsl:for-each select="category-items">
<xsl:variable name="itemid">
<xsl:apply-templates select="child::item-id"/>
</xsl:variable>
<xsl:variable name="itemName">
<xsl:apply-templates select="child::item-name"/>
</xsl:variable>
<br/>
<div><a class="body_Link" title="{$itemName}" href="javascript:;" onclick="openBrWindow('getItem.asp?item={$itemid}.xml','xx','width=700,height=600 scrollbars=yes location=yes');"><b><xsl:apply-templates select="child::item-name"/> </b></a></div>
<div>
<xsl:variable name="include_description" select="boolean(child::item-description[.!='null'])"/>
<xsl:if test="child::item-description=$include_description">
<xsl:value-of select="child::item-description"/>
</xsl:if><br/></div>
<div> </div>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
---------- getItem.asp ----------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim vItem
vItem = request.QueryString("item")
Dim objXMLDoc, xmlFile
xmlFile = vItem
Dim objSvrHTTP
Dim PostData
Set objSvrHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
objSvrHTTP.open "GET", xmlFile, false
objSvrHTTP.send
Response.Write objSvrHTTP.responseText
response.end
Set objXMLDoc=Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.load(Server.MapPath(xmlFile))
if objXMLDoc.parseError.errorcode<>0 then
'error handling code
Response.write "Error code: " & objXMLDoc.parseError.errorCode & "<BR>"
Response.write "Position in file: " & objXMLDoc.parseError.filepos & "<BR>"
Response.write "Error text: " & objXMLDoc.parseError.reason & "<BR>"
else
' proceed
Dim tempMenu
tempMenu = ""
set oRoot = objXMLDoc.documentElement
Set NodeList = oRoot.getElementsByTagName("item-content")
'Set NodeListn = oRoot.nodeName
For Each Elem In NodeList
'If (Elem.firstChild.nodeValue = "Addictions articles") then
isNode = Elem.nodeName
xElment =Elem.text
response.redirect(xElment)
If isNode = "html" then
response.Redirect("testxmlhttp.asp?item=" & vItem)
Else
'xElment =Elem.text
'response.Write(xElment)
End if
Next
End if
%>