|
-
How to format data in a table
I have few items in xml. The number of items can change. I want to display
these items in a table format, how can I do using XSLT?
Ex:
<subroutine>
<script id="1">
<name>test</name>
</script>
<script id="2">
<name>test2</name>
</script>
<script id="3">
<name>test3</name>
</script>
<script id="4">
<name>test4</name>
</script>
<script id="5">
<name>test5</name>
</script>
</subroutine>
I want to display above as
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td></td>
</tr>
</table>
Any suggestions how to do it.
My thought process on how to do is below but I am stuck and don't have any
clue what to do next
<xsl:template match="subroutine">
<div id="Subroutines">
<H2 align="center">Avenue Scripts</H2>
<table border="1">
<xsl:for-each select="script">
<xsl:if test="position() mod 4 = 1">
<tr>
<xsl:call-template name="srtd"/>
</tr>
</xsl:if>
</xsl:for-each>
</table>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template name="srtd">
<td>
<xsl:value-of select="@id"/>
</td>
<td>
<xsl:value-of select="@id"/>
</td>
<td>
<xsl:value-of select="@id"/>
</td>
<td>
<xsl:value-of select="@id"/>
</td>
</xsl:template>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks