Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Grouping by two or any number [Thread Next] RE: Grouping by two or any numberTo: NULL Date: 12/1/2004 8:17:00 PM Hi Kiran,
Please try this XSL -
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" />
<xsl:template match="/Parent">
<xsl:for-each select="node">
<xsl:if test="(position() mod 2) = 0">
group <xsl:value-of select="position() div 2" /> - <xsl:value-of
select="preceding-sibling::node[1]" />,<xsl:value-of select="." />
</xsl:if>
<xsl:if test="((position() mod 2) != 0) and (position() = last())">
group <xsl:value-of select="floor((position() div 2) + 1)" /> -
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
"Kiran" wrote:
> i have the following xml
>
> <Parent>
> <node>a</node>
> <node>s</node>
> <node>d</node>
> <node>f</node>
> <node>g</node>
> <node>h</node>
> <node>j</node>
> <node>k</node>
> <node>l</node>
> </Parent>
>
>
> Need to print in following format (into groups of two)
>
> group 1 - a,s
> group 2 - d,f
> group 3 - g,h
> group 4 - j,k
> group 5 - l
>
> Thanks in advance
>
> Kiran
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
