title: Tricking XSL into interpreting XML element with a particular attribute as being null or empty
body: <p>Java 8 here, but I don't think that makes any difference as I believe this is a pure XSL question at heart.</p>
  
  <p>I have some code that is producing the following XML (as an example):</p>
  
  <pre><code>&lt;fizz&gt;
    &lt;account&gt;10016&lt;/account&gt;
    &lt;accountId&gt;2000001347&lt;/accountId&gt;
    &lt;buzz class="null"/&gt;
  &lt;/fizz&gt;
  </code></pre>
  
  <p>There are 3 potential scenarios for the <code>buzz</code> element's value at runtime:</p>
  
  <ul>
  <li>"Null Class Buzz" -> <code>&lt;buzz class="null"/&gt;</code>; or</li>
  <li>"Non-Null Class Buzz" -> <code>&lt;buzz class="anythingOtherThanNull"/&gt;</code>; or</li>
  <li>"Normal Buzz" -> <code>&lt;buzz&gt;&lt;complicatedXmlStructureInsideOfHere&lt;/buzz&gt;</code></li>
  </ul>
  
  <p>So at runtime we might have "Null Class Buzz", "Non-Null Class Buzz" or "Normal Buzz". <strong>I do not want to transform the <code>buzz</code> element in the case of "Null Class Buzz".</strong> (But I <em>do</em> want to transform Non-Null Class Buzz and Normal Buzz variations.)</p>
  
  <p>Here is my XSL transform:</p>
  
  <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
      &lt;xsl:strip-space elements="*"/&gt;
  
      &lt;xsl:template match="/fizz"&gt;
        &lt;foobar&gt;
          &lt;xsl:copy-of select="account"/&gt;
          &lt;logId&gt;&lt;xsl:value-of select="accountId"/&gt;&lt;/logId&gt;
          &lt;xsl:if test="buzz"&gt;
            &lt;FLIMFLAM SEGMENT="1"&gt;
              &lt;HAPP&gt;003&lt;/HAPP&gt;
              &lt;SADD&gt;&lt;xsl:value-of select="buzz"/&gt;&lt;/SADD&gt;
            &lt;/FLIMFLAM&gt;
          &lt;/xsl:if&gt;
        &lt;foobar&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The problem is that this transforms Null Class Buzz variations and produces:</p>
  
  <pre><code>&lt;foobar&gt;
    &lt;account&gt;10016&lt;/account&gt;
    &lt;logId&gt;2000001347&lt;/logId&gt;
    &lt;FLIMFLAM SEGMENT="1"&gt;
      &lt;HAPP&gt;003&lt;/HAPP&gt;
      &lt;SADD/&gt;
    &lt;/FLIMFLAM&gt;
  &lt;/foobar&gt;
  </code></pre>
  
  <p>Whereas, in the case of Null Class Buzz, I want <code>buzz</code> ignored entirely:</p>
  
  <pre><code>&lt;foobar&gt;
    &lt;account&gt;10016&lt;/account&gt;
    &lt;logId&gt;2000001347&lt;/logId&gt;
  &lt;/foobar&gt;
  </code></pre>
  
  <p>Any ideas how I can do this? Thanks in advance!</p>