[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Display more than one table in generic xslt - reg
Subject: Re: Display more than one table in generic xslt - reg
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 26 Mar 2010 16:38:43 +0100
|
Ramesh Kumar wrote:
Is this technique called as Muenchian Grouping technique ?
Yes, the stylesheet below uses Muenchian grouping to identify second
level elements of the same name and group them into a "tr" element
containing a single "td" element with a single "table" element.
See also http://www.jenitennison.com/xslt/grouping/index.xml
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="by-name"
match="/*/*"
use="concat('{', namespace-uri(), '}', local-name())"/>
<xsl:template match="/">
<html>
<body>
<table>
<tbody>
<xsl:apply-templates select="*/*[generate-id() =
generate-id(key('by-name', concat('{', namespace-uri(), '}',
local-name()))[1])]" mode="table"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="/*/*" mode="table">
<tr>
<td>
<table border="1">
<thead>
<tr>
<xsl:apply-templates mode="th"/>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="key('by-name', concat('{',
namespace-uri(), '}', local-name()))"/>
</tbody>
</table>
</td>
</tr>
<xsl:if test="position() != last()">
<tr>
<td> </td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template match="/*/*/*" mode="th">
<th>
<xsl:value-of select="local-name()"/>
</th>
</xsl:template>
<xsl:template match="/*/*">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="/*/*/*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|