Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsXMLXMLJavascript ErrorJavascript Error
Previous
 
Next
New Post
2/3/2009 1:12 PM
 

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 = "+&nbsp;";
       ctlHidden.value = "0";
       strCSS = "NotVisible";
      }
      else
      {
       //Entry is being expanded
       ctlExpander.innerHTML = "-&nbsp;";
       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) &gt; 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()">+&#160;</label>
   
     </xsl:when>
     <xsl:otherwise>
   <label class="Expander">&#160;&#160;</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

 
New Post
2/8/2009 1:18 PM
 

Ken,

you are running into several issues. The XML module renders its output as part of a DotNetNuke site, which already contains an html, head or body section.

Second you are  mixing client side and server side code. If security was setup to allow server side scripts (which is not for the xml module), the javascript would be callable within the xsl code, it would extend the xsl language. That script would be totally invisible on the client side, and therefore it can'tt be used for client side events.  

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsXMLXMLJavascript ErrorJavascript Error


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out