Transformation from XML to Table Rows

Subject: Transformation from XML to Table Rows
From: Estefan27@xxxxxxx
Date: Mon, 04 Dec 2000 15:53:59 EST
Greetings;
 
I have an xml document with the following structure: 
<root>
<topic id="1">
<topic_name>topic name</topic_name>
<sub_topic id="1">subtopicname</sub_topic>
<sub_topic id="2">subtopicname</sub_topic>
<sub_topic id="3">subtopicname</sub_topic>
</topic>

<topic id="2">
<topic_name>topic name</topic_name>
<sub_topic id="4">subtopicname</sub_topic>
<sub_topic id="5">subtopicname</sub_topic>
<sub_topic id="6">subtopicname</sub_topic>
</topic>
.
.
.
</root>

Can someone please show me how to make an XSLTransformation that will: 

--Transform the topic into html rows. 3 topics to row.
(i want it flexible so that i can later change the xsl to 4 per row.
therefore i wish to use something like 
    <xsl:if test="position() mod 3 = 0">
        </tr><tr> <!--naturally this gives an error-->
    </xsl:if>
)

all the sub_topics must be presented below each corresponding topic name.
Therefore I'm thinking about something along the lines of the following. (
I could be way off. if someone could help that would be great.
 
<xsl:template match="/">
<table>
<tr>
 <xsl:for-each select="root/topic">
     <td><xsl:apply-templates select="displaytopic" />
     </td>
 <xsl:for-each>
</tr>
</table>
</xsl:template>

<xsl:template match="displaytopic">
  
    <xsl:element name="a">
    <xsl:attribute name="href"> 
    /anasppage.asp?id=<xsl:value-of select="@id"/>  
    </xsl:attribute>
    <xsl:value-of select="topic_name" /> 

    </xsl:element>
  <xsl:apply-templates select="display_related_sub_topic" />
</xsl:template>

<xsl:template match="display_related_sub_topic">
  
    <xsl:element name="a">
    <xsl:attribute name="href"> 
    /anasppage.asp?id=<xsl:value-of select="@id"/>  
    </xsl:attribute>
    <xsl:value-of select="sub_topic" /> 

    </xsl:element>
  <xsl:apply-templates select="sub_topic" />
</xsl:template>

all guidance would be greatly appreciated. 

s


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


Current Thread