This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XML Comma Delimited Info to an HTML Table
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] XML Comma Delimited Info to an HTML Table
- From: Jörg Heinicke <joerg dot heinicke at gmx dot de>
- Date: Fri, 12 Oct 2001 01:53:57 +0200
- References: <OFACDC5A0B.F12993D4-ON4C256AE2.00722C7C@uk.cgeyc.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
I only want to point out the "technique". You can use recursive
call-templates like the following one:
<xsl:template match="Record">
<tr>
<xsl:call-template name="divide">
<xsl:with-param name="to-be-divided" select="."/>
<xsl:with-param name="delimiter" select="';'"/>
</xsl:call-template>
</tr>
</xsl:template>
<xsl:template name="divide">
<xsl:param name="to-be-divided"/>
<xsl:param name="delimiter"/>
<xsl:choose>
<xsl:when test="contains($to-be-divided,$delimiter)">
<td><xsl:value-of
select="substring-before($to-be-divided,$delimiter)"/></td>
<xsl:call-template name="divide">
<xsl:with-param name="to-be-divided"
select="substring-after($to-be-divided,$delimiter)"/>
<xsl:with-param name="delimiter" select="';'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="$to-be-divided"/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
It's not tested, but similar to this it should work.
Joerg
----- Original Message -----
From: <Surangi.Sharma@NZ.CGEYC.COM>
To: <xsl-list@lists.mulberrytech.com>
Sent: Thursday, October 11, 2001 11:42 PM
Subject: [xsl] XML Comma Delimited Info to an HTML Table
> This email is to be read subject to the disclaimer below.
>
> [xsl] Comma Delimited Output to an HTML Table
>
> Hi,
> I have an XML file containing data corresponding to a table (see below).
> The first <Record> contains the column headings and the subsequent Records
> contain the row data (comma delimited). I am working on an XSLT to
> transform this XML message into an HTML format for a nice crisp display.
> Without re-inventing the wheel, is there any known solution in producing
an
> HTML table out of this?
>
> <Data>
> <Record>Full Name, Address1, Address2, Address3, Phone Number, Age,
> Hobby</Record>
> <Record>Anne Brown, 25A Symonds St, , Auckland, 09373535, 29,
> Reading</Record>
> <Record>Mark Smith, 30 Whiteney St, Blockhouse Bay, Auckland, 09
> 6232653, 31, Swimming</Record>
> <Record>Dane Anderson ,1 Crescent Dr, Newton, Auckland, 09373995, 20,
> </Record>
> ...
> </Data>
>
> Your help is much appreciated...
>
> cheers!!
> SS
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list