Hi Everyone,
I'm fairly new to DNN and XML programming. I am in urgent need to resolve an issue with XML/XSL module. I have created a new page in DNN and added XML module to the page. I configured the module to reference the external source XML file and XSLT file in the module settings. After I configured the setting, the page would display the desired format with the following XSLT source code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts">
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
function ExpanderClicked()
{
//Get the element that was clicked
var ctlExpander = event.srcElement;
var ctlSelectedEntry = ctlExpander.parentElement;
//Get all the DIV elements that are direct descendants
var colChild = ctlSelectedEntry.children.tags("DIV");
if(colChild.length > 0)
{
var strCSS;
//Get the hidden element that indicates whether or not entry is expanded
var ctlHidden = ctlSelectedEntry.all("hidIsExpanded");
if(ctlHidden.value == "1")
{
//Entry was expanded and is being contracted
ctlExpander.innerHTML = "+ ";
ctlHidden.value = "0";
strCSS = "NotVisible";
}
else
{
//Entry is being expanded
ctlExpander.innerHTML = "- ";
ctlHidden.value = "1";
strCSS = "IsVisible";
}
//Show all the DIV elements that are direct children
for(var intCounter = 0; intCounter < colChild.length; intCounter++)
{
colChild[intCounter].className = strCSS;
}
}
}
]]>
</msxsl:script>
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<title>Policies</title>
<script type="text/javascript" src="TreeFromXMLUsingXSLT.js"></script>
<style>
body { font-family: Verdana; font-size: x-small; }
.IsVisible { display: block; }
.NotVisible { display: none; }
.Expander { cursor: hand; font-family: Courier; }
.Parent DIV { margin-Left: 15px !important; }
</style>
</head>
<body>
<xsl:for-each select="//TreeNode/TreeNode">
<xsl:call-template name="SubMenu">
<xsl:with-param name="strCSS">Parent IsVisible</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template name="SubMenu">
<xsl:param name="strCSS" />
<xsl:variable name="strURL" select="@Href" />
<div class="{$strCSS}">
<xsl:choose>
<xsl:when test="count(TreeNode) > 0">
<!-- Element has children, it can be expanded -->
<input type="hidden" id="hidIsExpanded" value="0" onclick=" ExpanderClicked();" />
<label id="lblExpand" class="Expander" onClick="user:ExpanderClicked()">+ </label>
</xsl:when>
<xsl:otherwise>
<label class="Expander">  </label>
</xsl:otherwise>
</xsl:choose>
<a href="{$strURL}"><xsl:value-of select="@Title" /></a>
<xsl:for-each select="TreeNode">
<xsl:call-template name="SubMenu">
<xsl:with-param name="strCSS">NotVisible</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>
The page displayed would be something like a tree view structure:
+ Parent Node 1
Child Node 1
Child Node 2
+ Parent Node 2
+ Child Node 3
Child Node 4
Child Node 5
+ Parent Node 3
Child Node 6
Parent Node 4
When I clicked on the + sign, the Node suppose to expand out and display the child nodes underneath. However, I encountered an client browser error message stating:
Line: 130
Char: 6
Error: Object expected
Code: 0
URL: http://etcmc2/Default.aspx?alias=etcmc2/library
I suspect the javascript is not working in DNN environment. Is there a way to find out the what is the cause of this?
My system is running under:
Windows Web Server 2008
MS SQL 2005
DNN v4.08.00
XML/XSL v04.03.04
Any help is very appreciated. Thanks in advance
Ken