[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: onLoad Collapsing of subtree.
Hi, Your stylesheet uses the following two lines of code to collapse a node. node.children.item(0).src = "plus.gif"; node.nextSibling.style.display = 'none'; I suppose calling them on your tree's root node should solve your problem. cheers, prakash "Brahadambal Srinivasan" To: "xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> <brahadambal@gma cc: (bcc: omprakash.v/Polaris) il.com> Subject: onLoad Collapsing of subtree. 05/02/2006 11:07 AM Please respond to xsl-list I have the folowwing sample XML and XSLT. I want all the nodes to be collapsed on load! Is it possible? Please help me out. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="XMLexample.xsl" type="text/xsl" ?> <TS> <Table1> <fld1>0</fld1> <disc1> <dfld1>7</dfld1> <loop3> <lfld2>170</lfld2> <loop4> <lfld3>40</lfld3> </loop4> </loop3> <fld3>1025</fld3> </disc1> <loop1> <lfld1>1030</lfld1> </loop1> <loop1> <lfld1>1031</lfld1> <loop2> <disc1> <dfld1>7</dfld1> <loop3> <lfld2>170</lfld2> <loop4> <lfld3>40</lfld3> </loop4> </loop3> <fld3>1025</fld3> </disc1> <disc2> <fld2>1200908</fld2> <Iterate1> <lfld4>700</lfld4> <Iterate2> <fld5>7</fld5> <Iterate3> <fld6>7</fld6> <fld7>7</fld7> </Iterate3> <fld8>7</fld8> </Iterate2> </Iterate1> <fld3>1025</fld3> </disc2> </loop2> <fld10>1024</fld10> </loop1> </Table1> </TS> XSLT is: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/TS"> <html> <head> <title>XML in Tree View</title> <meta name="generator" content="ZZEE Art HTML Listing"/> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <style type="text/css"> <!-- body { font-family: "Times New Roman"; font-size: 12pt; background-color: #ffffff; color: #000000; text-align: left; } ul.zzul {list-style-type:none; display: block;} span.zzspace {left:11px;} a, a:visited {color: #0000ff;} a:hover { color: #ff0000;} --> </style> <!-- [client side code for collapsing and unfolding branches] --> <script language="JavaScript"> function Toggle(node) { // Unfold the branch if it isn't visible if (node.nextSibling.style.display == 'none') { // Change the image (if there is an image) if (node.children.length > 0) { if (node.children.item(0).tagName == "IMG") { node.children.item(0).src = "minus.gif"; } } node.nextSibling.style.display = ''; } // Collapse the branch if it IS visible else { // Change the image (if there is an image) if (node.children.length > 0) { if (node.children.item(0).tagName == "IMG") { node.children.item(0).src = "plus.gif"; } } node.nextSibling.style.display = 'none'; } } </script> </head> <body> <ul style="list-style-type:none; margin:0; padding:0;"> <table border="0"> <tr> <td> <xsl:apply-templates select="." mode="render"/> </td> </tr> </table> </ul> </body> </html> </xsl:template> <xsl:template match="/" mode="render"> <xsl:apply-templates mode="render"/> </xsl:template> <xsl:template match="*" mode="render"> <table border="0"> <tr> <td/> <td/> <td/> <td> <a onClick="Toggle(this)"> <img src="minus.gif"/> <xsl:text> </xsl:text> <xsl:value-of select="local-name()"/> </a> <div> <xsl:apply-templates select="@*" mode="render"/> <xsl:apply-templates mode="render"/> </div> </td> </tr> </table> </xsl:template> <xsl:template match="text()" mode="render"> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="translate(.,' ',' ')"/> </xsl:call-template> </xsl:template> <xsl:template name="escape-ws"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, ' ')"> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="substring-before($text, ' ')"/> </xsl:call-template> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="substring-after($text, ' ')"/> </xsl:call-template> </xsl:when> <xsl:when test="contains($text, ' ')"> <xsl:value-of select="substring-before($text, ' ')"/> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="substring-after($text, ' ')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> TIA. Brady. POLARIS, THE LEADER IN SPECIALITY APPLICATION DEVELOPMENT : ------------------------------------------------------------- Polaris has been awarded the Leader in the category of "Speciality Application Development" among the Top 100 global Companies from Cyber Media Publications for the Year 2006. -------------------------------------------------------------- This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit Us at http://www.polaris.co.in
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|