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

Hi,


RDayal@hmsy.com wrote:

>Hello:
>
>I have an XML document of the format:
>
><records>
>        <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"/>
></records>
>
>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.
>
>
>-Ruchi
>
>
>  
>
Try this code.  It might give you good start

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:variable name="unique_letters"
        select="/records
                /record[not(@letter=preceding-sibling::record/@letter)]
                /@letter"
        />
    <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 />   
            </xsl:for-each>   
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

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

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

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:12 GMT