[xsl] creating a table with xslt

Subject: [xsl] creating a table with xslt
From: "Kimberly Begley" <kimberly.lewis@xxxxxxxxx>
Date: Mon, 17 Mar 2008 14:02:49 +1000
This is my first post on  your forum - I was searching around for how
to implement a counter in xslt and this brought me to your user group.
I'm looking to do make a very simple table from an xml file that is
output from a servlet.
 There is no text in the table.
Imagine a test that has 500 questions and each cell in the table
represents a question - they are red/green/grey square jpeg's depeding
on if you got the question correct/incorrect or n/a (you didn't answer
 Ideally you'd end up with alot of green squares and a few red squares
- then you could click on any square and the page would update with a
box at the bottom showing you all the details of that question.
I have pasted some simple xslt code below (it doesn't include all the
elements or features - it is just for testing purposes)  that goes
through each element in the xml file and makes a row for it in the
table. I'm having problems figuring out how to automatically make
multiple rows and columns with data like this - obviously a simple
foreach loop won't work. All the data is the same - it is just in a
table to structure it for ease of viewing so columns and rows don't
actually map to anything - it's all the same. The other problem is
that a user may not answer all the questions and can only answer some
of them - meaning there is not guarranteed to be 500 elements in the
xml file.
 Maybe a table isn't the best structure to use in this case?
Any advice?

<xsl:template match="/">




    <xsl:for-each select="testresults/test">

        <xsl:when test="result &gt; 0">
        <a href="{plot_path}" target="_blank">
         <IMG SRC="red.jpg"/>

        <xsl:when test="result = 0">
        <a href="{plot_path}" target="_blank">
         <IMG SRC="green.jpg"/>
        <a href="{plot_path}" target="_blank">
         <IMG SRC="grey.jpg"/>

Current Thread