Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

I can't figure out what is wrong with my logic...


macaroni

This topic is 7860 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

&nbsp;

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

Link to comment
Share on other sites

This topic is 7860 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.