April 1, 200322 yr I'm trying to display a article summaries and each summary has a category. I want to display the category only when it is different . i.e. If the category for next following summaries is different from the previous then display it otherwise display a blank line. Below is a snippet of my xsl file: <table border="0" cellpadding="3" cellspacing="3"> <xsl:variable name="prev_category"><xsl:value-of select="fmp:RESULTSET/fmp:ROW[1]/fmp:COL[4]"/></xsl:variable> <tr><td><xsl:value-of select="fmp:RESULTSET/fmp:ROW[1]/fmp:COL[4]"/></td></tr> <xsl:for-each select="fmp:RESULTSET/fmp:ROW"> <xsl:variable name="related_url"><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></xsl:variable> <xsl:variable name="curr_category"><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></xsl:variable> <xsl:if test="$curr_category = $prev_category"> <tr><td>NBSP</td></tr> <xsl:variable name="curr_category"><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></xsl:variable> </xsl:if> <xsl:if test="$prev_category != $curr_category"> <tr><td><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></td></tr> <xsl:variable name="prev_category"><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></xsl:variable> </xsl:if> <tr> <td> <p><xsl:value-of select="fmp:COL[1]/fmp:DATA"/></p> <p> <xsl:value-of select="fmp:COL[3]/fmp:DATA"/></p> <p>Related URL: <a href="http://{$related_url}"><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></a></p> </td> </tr> </xsl:for-each> </table> Here is an output of the snippet of code: As you will read, the second "Category 2" should not be printed but rather a non-breaking space should be printed but it sill prints out "Category 2" I printed out the values of curr_category and prev_category and prev_category always seems to remain as "Category1" which was initially set in the beginning.... Any ideas? Category1 Title One test test test test summary url 1 Title Two test test test test summary 2 url 2 Category2 Title Threee test test test test summary 3 url3 Category2 Title Four test test test test summary 4 url4
Create an account or sign in to comment