|
Subject: How to Drill down wth XML/XSL From: Jia Ming Li <jmingli@xxxxxxxx> Date: Tue, 14 Dec 1999 16:28:38 -0800 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: for-each and variables, Kay Michael | Thread | Problems with FOP and/or XT, Richard Lander |
| RE: for-each and variables, Mike Brown | Date | Problems with FOP and/or XT, Richard Lander |
| Month |