title: Test if nodes are empty or contain NULL using template match
body: <p>Edit to the XML</p>
  
  <p>I am trying to figure out how test if nodes do not exist or contain the word NULL using template matching.  Currently I am using a &lt;xsl:choose> test in my matched template.  Is there a more efficient way to do this test?</p>
  
  <p>In the XML if the  or  nodes do not eixt, or contain the word NULL then I want to skip that  node completely and print out a statement saying why that node is incorrect (i.e. "The TITLE does not exist" or "The CONTENT is NULL").</p>
  
  <p>In the XML I have the third and fourth  node should not display any content and instead print a statement saying why content was not displayed.</p>
  
  <p>Here is an example of the XML I am using to test:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FIGURES&gt;
    &lt;FIGURE&gt;
      &lt;TITLE&gt;Title 1&lt;/TITLE&gt;
      &lt;DESC&gt;Description 1&lt;/DESC&gt;
      &lt;CONTENT&gt;Content 1&lt;/CONTENT&gt;
    &lt;/FIGURE&gt;
    &lt;FIGURE&gt;
      &lt;TITLE&gt;Title 2&lt;/TITLE&gt;
      &lt;DESC&gt;Description 2&lt;/DESC&gt;
      &lt;CONTENT&gt;Content 2&lt;/CONTENT&gt;
    &lt;/FIGURE&gt;
    &lt;FIGURE&gt;
      &lt;DESC&gt;Description 3&lt;/DESC&gt;
      &lt;CONTENT&gt;Content 3&lt;/CONTENT&gt;
    &lt;/FIGURE&gt;
    &lt;FIGURE&gt;
      &lt;TITLE&gt;Title 4&lt;/TITLE&gt;
      &lt;DESC&gt;Description 4&lt;/DESC&gt;
      &lt;CONTENT&gt;NULL&lt;/CONTENT&gt;
    &lt;/FIGURE&gt;     
    &lt;FIGURE&gt;
      &lt;TITLE&gt;Title 5&lt;/TITLE&gt;
      &lt;DESC&gt;Description 5&lt;/DESC&gt;
      &lt;CONTENT&gt;Content 5&lt;/CONTENT&gt;
    &lt;/FIGURE&gt;
  &lt;/FIGURES&gt;
  </code></pre>
  
  <p>Here is the XSLT I am using:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="html" encoding="utf-8"/&gt;
  
  &lt;xsl:template match="/"&gt;
    &lt;div class="container"&gt;
     &lt;xsl:apply-templates /&gt;
   &lt;/div&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="FIGURES"&gt;
    &lt;ul class="list"&gt;
      &lt;xsl:apply-templates select="FIGURE" mode="titles" /&gt;
    &lt;/ul&gt;  
    &lt;div class="content"&gt;
      &lt;xsl:apply-templates select="FIGURE" mode="content" /&gt;
    &lt;/div&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="FIGURE" mode="titles"&gt;
    &lt;xsl:choose&gt;
      &lt;!-- Check to see if the TITLE field is empty --&gt;
      &lt;xsl:when test="translate(./TITLE,' ', '') = ''"&gt;The TITLE node is empty&lt;/xsl:when&gt;                      
      &lt;!-- Check to see if the TITLE field is NULL --&gt;
      &lt;xsl:when test="normalize-space(./TITLE) = 'NULL'"&gt;The TITLE node is NULL&lt;/xsl:when&gt; 
      &lt;!-- Check to see if the CONTENT field is empty --&gt;
      &lt;xsl:when test="translate(./CONTENT,' ', '') = ''"&gt;The CONTENT node is empty&lt;/xsl:when&gt;
      &lt;!-- Check to see if the CONTENT field is NULL --&gt;
      &lt;xsl:when test="normalize-space(./CONTENT) = 'NULL'"&gt;The CONTENT node is NULL&lt;/xsl:when&gt;                                            
      &lt;xsl:otherwise&gt;
        &lt;li&gt;
          &lt;a href="#section-{position()}"&gt;
            &lt;h3&gt;&lt;xsl:value-of select="TITLE" /&gt;&lt;/h3&gt;
          &lt;/a&gt;
          &lt;p&gt;&lt;xsl:value-of select="DESC" /&gt;&lt;/p&gt;
        &lt;/li&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="FIGURE" mode="content"&gt;
    &lt;xsl:choose&gt;
      &lt;!-- Check to see if the TITLE field is empty --&gt;
      &lt;xsl:when test="translate(./TITLE,' ', '') = ''"&gt;The TITLE node is empty&lt;/xsl:when&gt;                      
      &lt;!-- Check to see if the TITLE field is NULL --&gt;
      &lt;xsl:when test="normalize-space(./TITLE) = 'NULL'"&gt;The TITLE node is NULL&lt;/xsl:when&gt; 
      &lt;!-- Check to see if the CONTENT field is empty --&gt;
      &lt;xsl:when test="translate(./CONTENT,' ', '') = ''"&gt;The CONTENT node is empty&lt;/xsl:when&gt;
      &lt;!-- Check to see if the CONTENT field is NULL --&gt;
      &lt;xsl:when test="normalize-space(./CONTENT) = 'NULL'"&gt;The CONTENT node is NULL&lt;/xsl:when&gt;                                            
      &lt;xsl:otherwise&gt;
        &lt;div id="section-{position()}"&gt;
          &lt;p&gt;&lt;xsl:value-of select="CONTENT" /&gt;&lt;/p&gt;
        &lt;/div&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Thank you.</p>