Re: [xsl] How to tell if no data returned

Subject: Re: [xsl] How to tell if no data returned
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 2 Oct 2006 09:35:02 +0100
On 10/2/06, Garry <garry@xxxxxxxxxxxxxxxxxx> wrote:
Hi all

I have a problem which I would normally fix using a variable. I have a
routine similar to that below. What I want to know is if it doesnt get into
the for-each loop. If it doesnt it means no rows are written and I would
like to add a note to the page if this is the case.

<xsl:for-each
select="/stages/competition/leg/stage/classification/competitor[../../@no=$s
Num]">
<xsl:if test="../@type = 'STAGE'">
<xsl:if test="../../../../@cno=$paramVal1">

... row detail written here

</xsl:if>
</xsl:if>
</xsl:for-each>

Well a exact conversion would be:


<xsl:variable name="competitors"
select="/stages/competition/leg/stage/classification/competitor[../../@no=$sNum]"/>

<xsl:choose>
 <xsl:when test="$competitors">
   <xsl:for-each select="$competitors">
      ....
  </
 <xsl:otherwise>
   note....


But if those xsl:if's are the only children of the xsl:for-each then the variable should really be:

select="/stages[@cno=$paramVal1]/competition/leg/stage[@no=$sNum]/classification[@type
= 'STAGE']/competitor"

cheers
andrew

Current Thread