This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]