C
Christoph
I'm trying to come up with a stylesheet where, when the rows are displayed,
duplicate game names are not shown on subsequent rows. It works but doesn't
work properly. If I sort the data using <xsl:sort> prior to processing,
it's not checking against the previous row after the sort but instead the
previous row from the original data set. Here is the XML and XSL I'm using:
<GameSets>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>10th Anniversary</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Anarchs</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Ancient Hearts</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Bloodlines</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Camarilla</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Netrunner</gamename>
<setname>Classic</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Dark Sovereigns</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Final Nights</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Gehenna</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Jyhad</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Kindred Most Wanted</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Legacies of Blood</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Netrunner</gamename>
<setname>Netrunner</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Nights of Reckoning</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Promotional</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Netrunner</gamename>
<setname>Proteus</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Sabbat</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Sabbat War</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>The Black Hand</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>V:TES</setname>
</GameSetsRow>
</GameSets>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xslutput method="html"/>
<xsl:template match="GameSets">
<html>
<head>
<title>Game Sets</title>
</head>
<body>
<h1>Game Sets</h1>
<table border="1">
<tr>
<th>Position</th>
<th>Game</th>
<th>Set</th>
<th>Previous Game</th>
</tr>
<xsl:for-each select="GameSetsRow">
<xsl:sort select="gamename"/>
<xsl:variable name="pos" select="position()"/>
<tr>
<td><xsl:copy-of select="$pos"/></td>
<td>
<xsl:if test="$pos = 1 or gamename !=
preceding-sibling::GameSetsRow[1]/gamename">
<xsl:copy-of select="gamename"/>
</xsl:if>
</td>
<td><xsl:copy-of select="setname"/></td>
<td><xsl:copy-of
select="preceding-sibling::GameSetsRow[1]/gamename"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What am I missing? Why isn't the test using the sorted set?
thnx,
Christoph
duplicate game names are not shown on subsequent rows. It works but doesn't
work properly. If I sort the data using <xsl:sort> prior to processing,
it's not checking against the previous row after the sort but instead the
previous row from the original data set. Here is the XML and XSL I'm using:
<GameSets>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>10th Anniversary</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Anarchs</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Ancient Hearts</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Bloodlines</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Camarilla</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Netrunner</gamename>
<setname>Classic</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Dark Sovereigns</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Final Nights</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Gehenna</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Jyhad</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Kindred Most Wanted</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Legacies of Blood</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Netrunner</gamename>
<setname>Netrunner</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Nights of Reckoning</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Promotional</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Netrunner</gamename>
<setname>Proteus</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Sabbat</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>Sabbat War</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>The Black Hand</setname>
</GameSetsRow>
<GameSetsRow>
<gamename>Vampire: The Eternal Struggle</gamename>
<setname>V:TES</setname>
</GameSetsRow>
</GameSets>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xslutput method="html"/>
<xsl:template match="GameSets">
<html>
<head>
<title>Game Sets</title>
</head>
<body>
<h1>Game Sets</h1>
<table border="1">
<tr>
<th>Position</th>
<th>Game</th>
<th>Set</th>
<th>Previous Game</th>
</tr>
<xsl:for-each select="GameSetsRow">
<xsl:sort select="gamename"/>
<xsl:variable name="pos" select="position()"/>
<tr>
<td><xsl:copy-of select="$pos"/></td>
<td>
<xsl:if test="$pos = 1 or gamename !=
preceding-sibling::GameSetsRow[1]/gamename">
<xsl:copy-of select="gamename"/>
</xsl:if>
</td>
<td><xsl:copy-of select="setname"/></td>
<td><xsl:copy-of
select="preceding-sibling::GameSetsRow[1]/gamename"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What am I missing? Why isn't the test using the sorted set?
thnx,
Christoph