title: XSLT define a variable and check if it exists after
body: <p>I am attempting to transform an XML document. First, I am defining a global variable:</p>
  
  <pre><code> &lt;xsl:variable name="foo"&gt;&lt;xsl:value-of select="bar"/&gt;&lt;/xsl:variable&gt;
  </code></pre>
  
  <p>Now there is a chance that the XML I'm transforming has <code>&lt;bar&gt;some data&lt;/bar&gt;</code> defined. There is also a chance that it is not defined.</p>
  
  <p>Once I declare the global variable below, I'm trying to output the following if it is defined:</p>
  
  <pre><code>&lt;foo&gt;DEFINED&lt;/foo&gt;
  </code></pre>
  
  <p>and if it's not defined:</p>
  
  <pre><code>&lt;foo&gt;NOT DEFINED&lt;/foo&gt;
  </code></pre>
  
  <p>I am using <code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;</code></p>
  
  <p>What's the best way of going about this?</p>