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

How to Drill down wth XML/XSL

Subject: How to Drill down wth XML/XSL
From: Jia Ming Li <jmingli@xxxxxxxx>
Date: Tue, 14 Dec 1999 16:28:38 -0800
xml drill down
How can I select columns depense onClick?
The initial output of my xml page is like below.

	------------------------------
	| File  	| Hit | ByteSent	|
	------------------------------
	| abc.html	| 50 	| 1200 	|
	------------------------------
	| xyz.html	| 100 | 1900	|
	-------------------------------
what I want to do is when a mouse click on 50, it display the elements
inside Hit 50 <Detail>*</Detail>. likewise the click on 100 would display
the <Detail> under 100.


XML data
=================
<?xml:stylesheet type="text/xsl" href="Top.xsl"?>
<ILUXREPORT xmlns="x-schema:Top-schema.xml">
<ILUXREPORT>
  	<ITEMS>
  	  <Item>
		<File>abc.html</File>
		<ByteSent>12200</ByteSent>
		<Hit>50</Hit>
	   	<Detail>
	   		<a>a</a>
			<b>b</b>
	   	</Detail>
  	  </Item>

  	  <Item>
		<File>xyz.html</File>
		<ByteSent>1900</ByteSent>
		<Hit>100</Hit>
		<Detail>
	   		<a>a1</a>
			<b>b1</b>
		</Detail>
  	  </Item>
  	</ITEMS>
</ILUXREPORT>
========================

XSL sheet
+++++++++++++++
  <xsl:template match="/">
    <HTML>						   
      <HEAD>
      </HEAD>
  	<SCRIPT language="JavaScript"><xsl:comment><![CDATA[
    	var counter=0;
    	function drillDown(field)
    		{
			if ((counter++ % 2) == 0 )
   //			drillDownField.value = field;
				detail.style.display="block";
			else
				detail.style.display="none";

         	}
 	]]></xsl:comment></SCRIPT>


  	<SCRIPT for="window" event="onload"><xsl:comment><![CDATA[
  	  stylesheet = document.XSLDocument;
  	  source = document.XMLDocument;
  	  sortField = document.XSLDocument.selectSingleNode("//@order-by");
   //	  drillDownField = document.XSLDocument.selectSingleNode("@Hit");   
  
  	]]></xsl:comment></SCRIPT>
 <BODY>
	<TABLE ALIGN="CENTER">
	<TR><TD><DIV id="listing"><xsl:apply-templates
select="ILUXREPORT"/></DIV></TD></TR>
	<TR><TD><DIV id="detail" STYLE="display:none"><xsl:apply-templates
select="ILUXREPORT/ITEMS"/></DIV></TD></TR>
	</TABLE>
	</BODY>
	</HTML>
  </xsl:template>

  <xsl:template match="ILUXREPORT">
    <TABLE ALIGN="center" BORDER="2">
      <TR>
        <TD><DIV class="header" onClick="sort('File')">File</DIV></TD>
        <TD><DIV class="header" onClick="sort('Hit')">Hit</DIV></TD>
        <TD><DIV class="header" onClick="sort('ByteSent')">Byte
Sent</DIV></TD>
      </TR>
      <xsl:for-each select="ITEMS/Item" order-by="File">
        <TR>
          <TD><DIV class="row"><xsl:value-of select="File"/></DIV></TD>
          <TD><DIV class="row" onClick='drillDown("50")'><xsl:value-of
select="Hit"/></DIV></TD>
          <TD><DIV class="row"><xsl:value-of select="ByteSent"/></DIV></TD>
        </TR>
      </xsl:for-each>
  </TABLE>
  </xsl:template>

  <xsl:template match="ILUXREPORT/ITEMS">
    <TABLE ALIGN="center" BORDER="2">
    	<TR>
		<TD><DIV class="header">a</DIV></TD>
		<TD><DIV class="header">b</DIV></TD>
		</TR>
    	<xsl:for-each select="Item/Detail/row">
		<TR>
		<TD><DIV class="row"><xsl:value-of select="a" /></DIV></TD>
		<TD><DIV class="row"><xsl:value-of select="b" /></DIV></TD>
		</TR>
   		</xsl:for-each>
    </TABLE>
  </xsl:template>
</xsl:stylesheet>

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++


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


Current Thread

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.