grouping items among a list according to items subtag value

Discussion in 'XML' started by Gilles Kuhn, Sep 15, 2003.

  1. Gilles Kuhn

    Gilles Kuhn Guest

    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.
    Gilles Kuhn, Sep 15, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    512
  2. fzl2007
    Replies:
    7
    Views:
    564
    Mark Space
    Apr 12, 2009
  3. maury

    Grouping items in checkboxlist

    maury, Apr 17, 2011, in forum: ASP .Net
    Replies:
    0
    Views:
    770
    maury
    Apr 17, 2011
  4. fishfry

    Choosing grouping of split items

    fishfry, Feb 15, 2004, in forum: Perl Misc
    Replies:
    8
    Views:
    145
    John W. Krahn
    Feb 16, 2004
  5. AcCeSsDeNiEd

    Grouping like items together

    AcCeSsDeNiEd, Nov 15, 2005, in forum: Perl Misc
    Replies:
    9
    Views:
    176
    AcCeSsDeNiEd
    Nov 17, 2005
Loading...

Share This Page