Welcome to WebmasterWorld Guest from

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)

5+ Year Member

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.


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 id="b2">
<movie>A DAY AT THE RACES (1937)</movie>
<movie>A SHOT IN THE DARK (1964)</movie>
<movie>AMERICAN GRAFFITI (1973)</movie>
<ballot id="b3">

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="/">
<head><title>Top American Comedies</title>
<link href="comedy.css" rel="stylesheet" type="text/css" />
<h2>The Top American Comedy Films</h2>
<h4> Number of Ballots: total </h4>
<table width="550">
<!-- ************** start of my code *************** -->
<xsl:for-each select="//ballot[generate-id()=generate-id(key('movies', movie)[1])]">
<xsl:sort select="movie"/>
<td><xsl:value-of select="movie" /></td>
<!-- ************** end of my code *************** -->


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

WebmasterWorld Senior Member 10+ Year Member

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

Featured Threads

Hot Threads This Week

Hot Threads This Month