XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 15th, 2004, 03:03 PM
kipaaduma kipaaduma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 kipaaduma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Close all folders , tree view -please help

I have this xml :

<?xml-stylesheet type="text/xsl" href="xml_tree.xsl"?>
<menu icon1="images/home.gif" caption="Books & Publications">
<menuItem caption="Science Fiction">
<menuItem action="17" title="Worst Case Scenario" caption="Tanwani Anyangwe"></menuItem>
<menuItem action="4" title="Jurasic Park" caption="Micheal Crichton"></menuItem>
<menuItem action="3" title="Star Wars" caption="George Lucas"></menuItem>
</menuItem>
<menuItem caption="Cold War" opened="false" icon1="images/refresh.png">
<menuItem action="10" caption="The Forth Protocol"></menuItem>
<menuItem action="3" caption="Fire Fox"></menuItem>
<menuItem action="31" caption="United Artists">
<menuItem action="310" caption="Dr. No" />
<menuItem action="311" caption="From Russia with Love" />
<menuItem action="1" caption="Live & Let Die" />
<menuItem action="31" caption="Diamonds are Foreever" />
<menuItem action="31" caption="Never Say Never Again" />
<menuItem action="31" caption="For you eyes only" />
<menuItem caption="Eastern Block Fictions" icon1="images/closed.gif" icon2="images/open.gif">
<menuItem action="10" caption="The Forth Protocol"></menuItem>
<menuItem action="3" caption="Fire Fox"></menuItem>
<menuItem action="31" caption="James Bond (007)">
<menuItem action="310" caption="Dr. No" />
<menuItem action="311" caption="From Russia with Love" />
<menuItem action="1" caption="Live & Let Die" />
<menuItem action="31" caption="Diamonds are Foreever" />
<menuItem action="31" caption="Never Say Never Again" />
<menuItem action="31" caption="For you eyes only" />
</menuItem>
<menuItem action="13" caption="Maya Durashka"></menuItem>
</menuItem>
</menuItem>
<menuItem action="13" caption="Maya Durashka"></menuItem>
</menuItem>
<menuItem icon1="images/copy.small.png" caption="Western Herritage">
<menuItem action="10" title="Tom Sawyer" caption="Mark Twain"></menuItem>
<menuItem action="70" title="Roots" caption="Alex Harley"></menuItem>
</menuItem>
<menuItem icon1="images/notepad.png" caption="African American Herritage">
<menuItem action="70" title="Roots" caption="Alex Harley"></menuItem>
</menuItem>

</menu>

and i use this xsl :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Author: Tanwani Anyangwe (tanwani@aspwebsolution.com) -->
<!-- Web Site: http://www.aspwebsolution.com -->
<!-- This template and many more are available free online at http://www.aspwebsolution.com -->
<xsl:output method="html" version="4.0" />
<xsl:template match="/">
<html>
<head>
<title>XML Tree</title>
<script language="javascript">
<![CDATA[
function toggle(id,closed,opened,pre){
var myChild = document.getElementById(id);
var myPIcon = document.getElementById("picon" + id);
var myIcon = document.getElementById("icon" + id);
if(myChild.style.display=="none"){
myChild.style.display="block";
myIcon.src=opened;
myPIcon.src="images/"+ pre + "minus.png";
}else{
myChild.style.display="none";
myIcon.src=closed;
myPIcon.src="images/"+ pre +"plus.png";
}
}

]]>
</script>
<style>
a:link{color:black;text-decoration:none;font-size:8pt;font-family:verdana;}
a:visited{color:black;text-decoration:none;font-size:8pt;font-family:verdana;}
a:hover{color:blue;text-decoration:underline;font-size:8pt;font-family:verdana;}
</style>
</head>
</html>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="menu">
<div>
<img src="images/home.gif" border="0" />
<xsl:text>*</xsl:text>
<a href="#">
<xsl:value-of select="@caption" />
</a>
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="menuItem">
<xsl:variable name="hasChild">
<xsl:if test="menuItem">true</xsl:if>
</xsl:variable>
<xsl:variable name="prefix">
<xsl:choose>
<xsl:when test="position()=last()">
<xsl:text>L</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>T</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<xsl:choose>
<xsl:when test="$hasChild='true'">
<xsl:variable name="myId" select="generate-id()" />
<xsl:variable name="icon1">
<xsl:value-of select="'images/folder-closed.gif'" />
</xsl:variable>
<xsl:variable name="icon2">
<xsl:value-of select="'images/folder-open.gif'" />
</xsl:variable>
<xsl:variable name="style">
<xsl:if test="position() < last()">
<xsl:text>border-left:1px dotted gainsboro;</xsl:text>
</xsl:if>
</xsl:variable>
<div onclick="toggle('{$myId}','{$icon1}','{$icon2}','{$prefix}')">
<img src="images/{$prefix}plus.png" border="0" align="absMiddle" id="picon{$myId}" />
<img src="{$icon1}" border="0" align="absMiddle" id="icon{$myId}" />
<xsl:text>*</xsl:text>
<a href="#">
<xsl:value-of select="@caption" />
</a>
</div>
<div style="padding-left:8px;">
<table border="0" style="{$style}" cellspacing="0" cellpadding="0">
<tr>
<td>
<span id="{$myId}" style="display:none;padding-left:10px;">
<xsl:apply-templates />
</span>
</td>
</tr>
</table>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="doc">
<xsl:choose>
<xsl:when test="position()=last()">
<xsl:text>images/l.png</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>images/t.png</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div >
<img src="images/{$prefix}.png" border="0" align="absMiddle" />
<img src="images/file.gif" border="0" align="absMiddle" />
<xsl:text>*</xsl:text>
<a href="#">
<xsl:value-of select="@caption" />
</a>
</div>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

I wish i culd give my icons but we dont need them to understand, the icons are folders (open/close folders icons).
And i want to add in the beginning a new button that will close /open all folders in one click ! and not just one by one !
can anyone help ?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Close all folders , tree view -please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT