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

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
transform xml to table
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

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.