Welcome to WebmasterWorld Guest from 107.22.55.73

Forum Moderators: httpwebwitch

Message Too Old, No Replies

muenchian grouping

can not extract elements from document

     
10:39 pm on Nov 27, 2006 (gmt 0)

New User

5+ Year Member

joined:Nov 27, 2006
posts:1
votes: 0


I'm student of XML and need some help.
I'm trying to use the muenchian grouping to extract the first occurance of each movie title. There are no duplicate titles in a ballot, but the title can be repeated in each ballot. My code only extracts the first move from the first ballot.

Thanks
Desmond

XML document format
<poll> root element
<ballot id="b1">
<movie>A FISH CALLED WANDA (1988)</movie>
<movie>ADAM'S RIB (1949)</movie>
<movie>ANNIE HALL (1977)</movie>
.
.
.
</ballot>
<ballot id="b2">
<movie>A DAY AT THE RACES (1937)</movie>
<movie>A SHOT IN THE DARK (1964)</movie>
<movie>AMERICAN GRAFFITI (1973)</movie>
.
.
.
</ballot>
<ballot id="b3">
.
.
.
</poll>

XSL document
<?xml version="1.0"?>
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="movies" match="//ballot" use="movie" /><xsl:template match="/">
<html>
<head><title>Top American Comedies</title>
<link href="comedy.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>The Top American Comedy Films</h2>
<h4> Number of Ballots: total </h4>
<table width="550">
<tr>
<th>Rank</th>
<th>Movie</th>
<th>Votes</th>
<th>%</th>
</tr>
<!-- ************** start of my code *************** -->
<xsl:for-each select="//ballot[generate-id()=generate-id(key('movies', movie)[1])]">
<xsl:sort select="movie"/>
<tr>
<td><xsl:value-of select="movie" /></td>
</tr>
</xsl:for-each>
<!-- ************** end of my code *************** -->
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>

2:30 pm on Nov 29, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 17, 2001
posts:1262
votes: 0


Your code works exactly right for me. What is the problem you're experiencing?