My favorite way to do this involves an xslt 2.0 stylesheet and the data in an xml format.
Assuming you data looks something like this.
---------------------------------------
<data>
 <record>
  <category>cat 1</category>
  <subject>sub a</subject>
 </record>
 <record>
  <category>cat 2</category>
  <subject>sub b</subject>
 </record>
  <record>
  <category>cat 2</category>
  <subject>sub c</subject>
 </record>
</data>
---------------------------------------
your xsl would incorporate this snippet (common xslt code removed for clarity)
---------------------------------------
<ul>
<xsl:for-each-group select="/data/record" group-by="category">
<li><xsl:value-of select="category"/>
<ul>
<xsl:for-each select="current-group()">
 <li><xsl:value-of select="subject"/></li>
</xsl:for-each>
</ul>
</li>
</xsl:for-each-group>
</ul>
---------------------------------------
notice the "for-each-group" xsl element.  It's wicked powerful, and only available in 2.0.  You could do some stuff with xsl 1.0, but this is by far an easier way to look at it.

there's just one caveat...

XSL 2.0 is not supported by the xsl libraries included with witango and it's @XSLT tag

we wrote our own bean to call from witango and executed the SAXON Transform method from that bean.

/John


Robert Garcia wrote:
There are many ways to skin this, this is how I do these kinds of things. Feels cleaner to me, but doesn't make it better.

<@assign local$myarray <@array value="cat 2, sub 4;cat 1,sub 1;cat 1,sub 2;cat 3,sub 9;cat 1,sub 3;cat 2,sub 5;cat 2,sub 6;cat 3,sub 7;cat 3, sub 8;">>
<@assign local$myarray[0,1] "cats">
<@assign local$myarray[0,2] "subs">
<@assign local$justcats <@distinct local$myarray cols="1 DICT">>
<@sort local$justcats cols=1>
<@comment>now display it</@comment>
<ul>
<@rows array=local$justcats>
<li><@col 1>
<@assign local$thissubs <@filter local$myarray "'#cats' = '<@col 1>'">>
<@sort local$thissubs cols=2>
<ul>
<@rows array=local$thissubs>
<li><@col 2></li>
</@rows>
</ul>
</li>
</@rows>
</ul>


-- 

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040

On Oct 11, 2006, at 11:56 AM, WebDude wrote:

 
Sorry if this seems so elementary...
 
I have a table that lists categories and subjects - ie...
 
category1    subject1
category1    subject2   
category1    subject3
category2    subject4
category2    subject5   
category2    subject6
category3    subject7
category3    subject8   
category3    subject9
 
How do I display...
 
category1   
    subject1
    subject2   
    subject3
 
category2   
    subject4
    subject5   
    subject6
 
category3   
    subject7
    subject8   
    subject9
 
 
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
    

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
  

-- 


John McGowan
[EMAIL PROTECTED]
P 847.608.6900 x 110
F 847.608.9501
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to