[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XML Comma Delimited Info to an HTML Table


Subject: Re: [xsl] XML Comma Delimited Info to an HTML Table
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 12 Oct 2001 01:53:57 +0200

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@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
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



Current Thread
Keywords