title: Diazo - Conditionally add a class to a theme element
body: <p>I need to add a class to an element coming from the theme only if certain conditions are met.  I've tried <a href="https://stackoverflow.com/questions/6599993/adding-an-class-to-body-element-with-xdv">this solution</a>, adjusted for Diazo by replacing <code>prepend</code> with <code>before</code>:</p>
  
  <pre><code>&lt;before css:theme=".main" if-content="not(//*[@id='portal-column-two'])"&gt;&lt;xsl:attribute name="class"&gt;&lt;xsl:value-of select="//*[@class='main']/@class"/&gt; full&lt;/xsl:attribute&gt;&lt;/before&gt;
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <pre><code>XSLTApplyError: xsl:attribute: Cannot add attributes to an element if children have been already added to the element.
  </code></pre>
  
  <p>I get that error even when I remove all other rules such that there is only the <code>&lt;theme&gt;</code> rule and the <code>&lt;before&gt;</code> rule.</p>
  
  <p>How can I add a class to a theme element only when there is no <code>#portal-column-two</code> element in the content?</p>