Re: if-questioning between two nodes inside an for-each-loop

Subject: Re: if-questioning between two nodes inside an for-each-loop
From: Nick Browne <NickBrowne@xxxxxxxxxxxxxxx>
Date: Fri, 15 Sep 2000 15:23:53 +0100
Try the following variation of your original :

  <xsl:template match="/">
  <xsl:variable name="CHOOSE">
   <xsl:value-of select="cars/choose"/>
  </xsl:variable>
  <html>
   :  etc.
           <xsl:for-each select="cars/single">
            <option>
             <xsl:attribute name="value"><xsl:value-of
select="."/></xsl:attribute>
             <xsl:if test=". = $CHOOSE">
              <xsl:attribute name="selected">Yes</xsl:attribute>
             </xsl:if>
             <xsl:value-of select="."/>
            </option>

        </xsl:for-each>
:  etc.

Main changes are :
1. Moving variable assignment to after template.
2. Adding a $ to CHOOSE on if test.
3. Moving attributes so that they are generated before any content is created
for the option element.

Regards
Nick Browne
Slipstone Ltd


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


Current Thread