[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: any ideas?

Subject: RE: any ideas?
From: Ben Robb <Ben@xxxxxxxxxx>
Date: Thu, 4 Nov 1999 12:56:20 -0000
hide on the fly xml
You could use a code like this (NB. Not tested, or even checked for
well-formed XML/XSL *grin*):

+++ XML +++

<SITE>
	<SECTION ID="1" LEVEL="1" TITLE="Section 1" LINK=""/>
	<SECTION ID="2" LEVEL="1" TITLE="Section 2" LINK="">
		<SECTION ID="3" LEVEL="2" TITLE="Section 2.1" LINK=""/>
		<SECTION ID="4" LEVEL="2" TITLE="Section 2.2" LINK=""/>
	</SECTION>
...
</SITE>

+++ XSL +++

<xsl:for-each select="//SITE/SECTION">
	<div onclick="JavaScript:displayChild()">
		<xsl:attribute name="id">parent<xsl:value-of
select="@ID"/></xsl:attribute>
		<img src="plus.gif"/><xsl:value-of select="@TITLE"/>
	</div>
	<div style="display:none">
		<xsl:attribute name="id">child<xsl:value-of
select="@ID"/></xsl:attribute>
		
		<xsl:for-each select="SECTION">
			<xsl:value-of select="@TITLE"/><BR/>
		</xsl:for each>
	</div>
</xsl:for-each>

The JavaScript function "displayChild()" basically sets the style of display
for the second div tag to be "" (ie. makes the child visible). I've left it
to you to add things like positioning to get the div tags to appear in the
right place.

There are a couple of problems with this method

1) This will only work if there are two levels. Does anyone know of a way to
do recursive for loops? Like "Carry on going down the tree doing the same
sort of thing as long as there are more SECTION elements beneath it" without
hard coding? I'm sure there is a way...

2) I toyed with the idea of making it a flat structure, which would mean
that the order becomes very important, but gets rid of the problem in (1).
ie:

<SITE>
	<SECTION ID="1" LEVEL="1" TITLE="Section 1" LINK=""/>
	<SECTION ID="2" LEVEL="1" TITLE="Section 2" LINK=""/>
	<SECTION ID="3" LEVEL="2" TITLE="Section 2.1" LINK=""/>
	<SECTION ID="4" LEVEL="2" TITLE="Section 2.2" LINK=""/>
	
...
</SITE>


The problem with that, though, is that it is difficult to target the correct
div tags to show and hide on the fly (since you don't know the "parent" of
the item in the index.

Anyone else have any thoughts?

Ben Robb


> -----Original Message-----
> From: TaNiA [mailto:tania@xxxxxxxxxxxxxx]
> Sent: 04 November 1999 04:00
> To: xsl
> Subject: any ideas?
> 
> 
> Hi all,
> 
> was wondering if anyone could give me any pointers in 
> building a table of
> contents like what Microsoft has using  XML and XSL .
> http://msdn.microsoft.com/workshop/xml/toc.htm
> thanks in advance,
> tania
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

**********************************************************************


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • any ideas?
    • TaNiA - Thu, 4 Nov 1999 12:00:04 +0800
      • <Possible follow-ups>
      • Ben Robb - Thu, 4 Nov 1999 12:56:20 -0000 <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.