|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 ? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Close all folders , tree view -please help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|