[Home] [By Thread] [By Date] [Recent Entries]
Richard Dyce wrote:
Nothing too dramatic really - This stylesheet achieves the described result, additionally adding thead and tbody: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="/">
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<xsl:apply-templates select="view"/>
</body>
</html>
</xsl:template> <xsl:template match="view">
<xsl:apply-templates select="record_list"/>
</xsl:template><xsl:template match="record_list"> <h2><xsl:value-of select="@type"/> Listing</h2> <p>Showing <xsl:value-of select="@begin_record"/> to <xsl:value-of select="@end_record" /> of <xsl:value-of select="@total_found" /> records</p> <table> <thead> <xsl:apply-templates select="structure"/> </thead> <tbody> <xsl:apply-templates select="record"/> </tbody> </table> </xsl:template> <xsl:template match="structure">
<tr>
<xsl:apply-templates select="field"/>
</tr>
</xsl:template> <xsl:template match="field">
<th>
<xsl:value-of select="@label"/>
</th>
</xsl:template> <xsl:template match="record">
<tr>
<xsl:apply-templates select="*"/>
</tr>
</xsl:template> <xsl:template match="record/*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template></xsl:stylesheet> It processes all child elements of record elements (match="record/*") so in that regard it is dynamic, it does however simply process those elements in the order they appear and does not look at the field elements, those are just used to create the thead. As at least in your sample the field and record/* elements are in the same order the above might suffice. If not then post back. -- Martin Honnen http://JavaScript.FAQTs.com/
|

Cart



