[xsl] xsl key related

Subject: [xsl] xsl key related
From: Mark Ivs <markivs2003@xxxxxxxxx>
Date: Fri, 19 Nov 2004 05:06:52 -0800 (PST)
Hello,
I would like to get a list of all unique
country_groups which has a year=2004 and num=2 and
display them in multiple table columns. So, if my
result has 10 items, then for a 2 column layout, my
table will be 2 column and 5 rows. For 3 column
layout, my table will be 3 column and 4 rows(last
column will have 2 rows filled). The number of columns
is declared in a variable. With Jarno's help, I was
able to get the unique country_groups, but I am not
sure how to display them in multiple columns. The xsl
currently displays all the items in one column.

If the xsl:key contains only the unique contry_groups
it will be earlier to accomplish what I want. But I am
not if I that's possible.

Can someone help please ? Thank you very much in
advance.

Mark

-----------------------------------
XML - stripped down version of the original
-----------------------------------
<?xml version="1.0"?>
<myroot>

<country year="2004" num="1">
<country_group>WWW</course_group>
<num>001</num>
</country>

<country year="2004" num="1">
<country_group>ZZZ</course_group>
<num>001</num>
</country>

<country year="2004" num="2">
<country_group>AAA</course_group>
<num>221</num>
</country>

<country year="2004" num="2">
<country_group>BBB</course_group>
<num>002</num>
</country>

<country year="2004" num="2">
<country_group>CCC</course_group>
<num>022</num>
</country>


<country year="2004" num="2">
<country_group>AAA</course_group>
<num>011</num>
</country>

</myroot>


-----------------------
   XSL
-----------------------
<xsl:key name="groups" match="country"
use="concat(country_group, @year, @num)"/>
<xsl:variable name="numberOfColumns" select="2"/>

<xsl:template match="myroot">
  <xsl:apply-templates select="country">
    <xsl:sort select="country_group" />
  </xsl:apply-templates>
</xsl:template>
  
<xsl:template match="country">
<xsl:if test="generate-id() =
generate-id(key('groups', concat(country_group,
'2004', '2')))">
  <tr><td><xsl:value-of
select="country_group"/></td></tr>
</xsl:if>
</xsl:template> 


		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 

Current Thread