W3C home > Mailing lists > Public > www-xsl-fo@w3.org > April 2004

Re: going to the next record!

From: Karthikeyan <karthikeyan.balasubramanian@aspiresys.com>
Date: Fri, 23 Apr 2004 01:22:40 +0530
Message-ID: <40882287.2030803@aspiresys.com>
To: RDayal@hmsy.com, www-xsl-fo@w3.org


RDayal@hmsy.com wrote:

>I have an XML document of the format:
>        <record num="1" letter="A" color="blue"/>
>        <record num="1" letter="A" color="red"/>
>        <record num="1" letter="B" color="green"/>
>        <record num="1" letter="B" color="yellow"/>
>what i need to do is output in the following format:
>Letter = A
>color = blue
>color = red
><---next page-->
>Letter = B
>color = green
>color = yellow
>I can only get the first record (for A and its colors) with the XSL that I
>have written.
>Could somebody please show me a sample XSL to get the desired output? I
>would be very thankful.
Try this code.  It might give you good start

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    <xsl:variable name="unique_letters"
    <xsl:template match="record">
        <xsl:for-each select="$unique_letters">
            Letter = <xsl:value-of select="." /><br />                   
            <xsl:for-each select="//record[@letter=current()]">
            color = <xsl:value-of select="@color" /><br />   

It does grouping but I couldnt prevent duplication.  Need little more work.

Karthikeyan B
Received on Thursday, 22 April 2004 15:58:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:10:00 UTC