[xsl] Setting flags ?

Subject: [xsl] Setting flags ?
From: john.gough@xxxxxxxxxxxx
Date: Mon, 29 Jul 2002 12:46:13 +0100
I am a beginner with XSLT and have found this list a great source of help
and advice and i have a built a search  page which works just fine and uses
.asp to get the $searchValue1 string from the user, but i can not work out
how to display a value at the end of the search if NONE of the nodes in the
first for-each contained a match to the string.

Have cut some of the code out to make it clearer what i am trying to do. 

I can not seem to set the $flag in the for-each, If i use a variable $Flag
i get a out of scope error and if i use a parameter, i get Keyword
xsl:param may not be used here.  I think i am trying to do this the wrong
way and wonder if somebody can point me in the right direction.

Thanks

<?xml version='1.0' ?>
<xsl:stylesheet version ="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:param name="searchValue1"/>
 
<xsl:template match="/">

<xsl:for-each select="index/indexitem">
<xsl:choose>

    <!--Same Case-->
    <xsl:when test = "contains(@text,$searchValue1)">
 <option>
     <!--Match - do stuff here-->
 </option>
      </xsl:when>

   <!--All Upper Case-->
        <xsl:when test =
"contains(@text,translate($searchValue1,'abcdefghijklmnopqrstuvwxyz',
             'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))">
 <option>
     <!--Match - do stuff here-->
 
 </option>
 
      </xsl:when>

    <!--All Lower Case-->
        <xsl:when test =
"contains(@text,translate($searchValue1,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
             'abcdefghijklmnopqrstuvwxyz'))">
 <option>
     <!--Match  - do stuff here-->
 </option>
 
      </xsl:when>

    <!--1st Upper Case-->

        <xsl:when test =
"contains(@text,concat(translate(substring($searchValue1,1,1),'abcdefghijklmnopqrstuvwxyz',
             'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),substring($searchValue1,2)))">
 <option>
     <!--Match - do stuff here-->

 </option>
 
      </xsl:when>
</xsl:choose>

</xsl:for-each>
   
 
<xsl:choose>
  <xsl:when test="$Flag"></xsl:when>
     <!-- Flag exists so do nothing -->
   <xsl:otherwise>
        <option>
     <!-- Display the 'Nothing Found Sorry' Message -->
 </option>
</xsl:otherwise>
</xsl:choose>

</select>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread