title: XSLT setting a variable to either foo or @foo depending on presence of attribute
body: <p>I'm trying to set parttext to @head if <code>use_head="true"</code> is not present and to the contents of <code>&lt;head&gt;</code> <code>&lt;/head&gt;</code> if <code>use_head="true"</code> is present</p>
  
  <pre><code>&lt;xsl:template match="toc_part"&gt;
  
      &lt;xsl:variable name="artnum"&gt;
          &lt;xsl:value-of select="../@num" /&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="partnum"&gt;
          &lt;xsl:value-of select="@num" /&gt;
      &lt;/xsl:variable&gt;
  
          &lt;xsl:variable name="parttext"&gt;
              &lt;xsl:if test="@use_head"&gt;
                  &lt;xsl:value-of select="head"/&gt;
              &lt;/xsl:if&gt;
              &lt;xsl:if test="not[@use_head]"&gt;
                  &lt;xsl:value-of select="@head"/&gt;
              &lt;/xsl:if&gt;
          &lt;/xsl:variable&gt; 
  
  
      &lt;tr&gt;
          &lt;td&gt;
               
          &lt;/td&gt;
          &lt;td&gt;
              &lt;a class="int" href="{$GBLfilePre}{$artnum}.html#{$artnum}{$partnum}"&gt;&lt;xsl:text&gt;Part &lt;/xsl:text&gt;&lt;xsl:value-of select="$partnum" /&gt;&lt;/a&gt;
  
          &lt;/td&gt;
          &lt;td&gt;
              &lt;xsl:value-of select="$parttext" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>I've also tried:  </p>
  
  <pre><code>&lt;xsl:if test="@use_head"&gt;&lt;xsl:variable name="parttext"&gt;&lt;xsl:value-of select="head"&gt;&lt;/xsl:variable&gt;
  &lt;xsl:if test="not[@use_head"]&gt;&lt;xsl:variable name="parttext"&gt;&lt;xsl:value-of select="@head"&gt;&lt;/xsl:variable&gt;     
  </code></pre>
  
  <p>which give parttext undefined when referenced.</p>