[xsl] problem with xsl:if test statement

Subject: [xsl] problem with xsl:if test statement
From: Amy Huang <h.amy88@xxxxxxxxx>
Date: Mon, 17 Dec 2007 20:51:15 -0800 (PST)

I'm new to xml and xsl. I need to generate one link if my query finds 
one or more records in my XML document. But I if I use "for each 
statement", the link will repeat again and again depending on how many 
records satisfy my query. E.g., if 2 records satisfy my query, the link will repeat twice like this: 

For apples, click here 
For apples, click here 

How can I generate only one link if my query finds more than one records? 

<?xml version="1.0" encoding="iso-8859-1"?> 
<xsl:stylesheet version="1.0" 

<xsl:param name="Country" select="Mexico" ></xsl:param> 
<xsl:template match="/"> 
<h2>Types of Fruits</h2> 
<xsl:for-each select="Products/Fruits"> 
<xsl:if test="Country = $Country and Type = 'Apples'"> 
<xsl:attribute name="href"> 
fruits.aspx?moi=<xsl:value-of select="$Country"/> 
For apples, click here 
<br /> 


Any help would be greatly appreciated! 

Amy Huang

Never miss a thing.  Make Yahoo your home page. 

Current Thread