Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 07:10 AM
Gilles Kuhn
Guest
 
Posts: n/a
Default grouping items among a list according to items subtag value

Hello all, here is my problem:
Let's assume I have a movie list containing movies from different
countries. The xml looks like:
<root>
<movie>
<title>matrix</title>
<country>USA</country>
</movie>
<movie>
<title>T3</title>
<country>USA</country>
</movie>
<movie>
<title>tomorrow never dies</title>
<country>GB</country>
</movie>
<movie>
<title>la dolce vita</title>
<country>italy</country>
</movie>
<movie>
<title>la vita e bella</title>
<country>italy</country>
</movie>
</root>

I would like to display a table (in HTML) with:
in the first cell, the movies made in US, in the second, the ones
coming from GB... I assume the list is already sorted. Of course, in
general, I have no idea about the country possible values and the
number of movies.
It should look like that:

<table>
<!-- iteration on the _different_ values of country, which I don't
know a priori -->
<xsl:for-each select="??????????????????????">
<tr>
<td>
<xsl:for-each select="movie[country=XXXXXXXXXXXXXXX]">
<!-- here I put my movie layout -->
<xsl:for-each>
</td>
</tr>
<xsl:for-each>
<table>

Does anyone knows what I should put instead of ??????????????????, and
XXXXXXX?
Or any other method solving the problem (I have tried too, to use
<xsl:if test="not(country=preceding::country)">) to put or not the
<td> and <tr> html tags, but it leads to incorrect tags imbrication
between xsl:if and tr/td...).

Thanks a lot for your help.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles