title: XSL Dropdown Selected Attribute
body: <p>I've seen similar questions and solutions on here but nothing I've tried has worked out. I'm trying to generate a drop-down list of month names with /result/startMonthName as the default selected option.</p>
  
  <pre><code>&lt;select id="queryMonth"&gt;
  &lt;xsl:for-each select="/result/monthOptions/entry"&gt;
      &lt;option value="{key + 1}"&gt;
          &lt;xsl:value-of select="value"/&gt;
          &lt;xsl:if test="/result/startMonthName"&gt;
              &lt;xsl:attribute name="selected"&gt;selected&lt;/xsl:attribute&gt;
          &lt;/xsl:if&gt;
      &lt;/option&gt;
  &lt;/xsl:for-each&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>However, the first month is always the initial selected.
  The monthOptions result is a node of Values (month names) and keys (month integers from 0 to 11). I have tried with both xsl:if test="/result/startMonthName" and xsl:if test="/result/startMonth".</p>
  
  <p>I have found that if the</p>
  
  <pre><code>&lt;xsl:value-of select="value"/&gt; 
  </code></pre>
  
  <p>line is after the </p>
  
  <pre><code>&lt;xsl:if test="/result/startMonthName"&gt;
      &lt;xsl:attribute name="selected"&gt;selected&lt;/xsl:attribute&gt;
  &lt;/xsl:if&gt;
  </code></pre>
  
  <p>then the last month is always the initial selected, but never the startMonth.</p>