title: Simple XSLT nested IF statement
body: <p>Here is a snippet of my code.  The input is now supposed to include 2 optional fields.  So I thought to create 4 if statements, as the URL has to be different if the fields exist or not.  The choose/when works, and the first IF statement works.  But the last 3 if one or both of the fields are not in the input, blows up.  The URL variable(DVURL) does not get populated at all.  I'm sure this is easy answer...i hope.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:func="http://exslt.org/functions" xmlns:date="http://exslt.org/dates-and-times" xmlns:string="http://symphony-cms.com/functions" xmlns:dpfunc="http://www.datapower.com/extensions/functions"&gt;
      &lt;xsl:output method="xml"/&gt;
      &lt;xsl:template match="/"&gt;
          &lt;xsl:variable name="datavalueagg" select="test1"/&gt;
          &lt;xsl:variable name="valueagg" select="test2"/&gt;
          &lt;xsl:variable name="variable1" select="Y"/&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="($variable1 = 'Y' or $variable1 = 'N')"&gt;
                  &lt;xsl:if test="(($datavalueagg != '') and ($valueagg != ''))"&gt;
                      &lt;xsl:variable name="DVURL" select="concat('http://server.com/$valueagg/$datavalueagg')"/&gt;
                  &lt;/xsl:if&gt;
                  &lt;xsl:if test="(($datavalueagg != '') and ($valueagg = ''))"&gt;
                      &lt;xsl:variable name="DVURL" select="concat('http://server.com/$datavalueagg')"/&gt;
                  &lt;/xsl:if&gt;
                  &lt;xsl:if test="$datavalueagg = '' and $valueagg != ''"&gt;
                      &lt;xsl:variable name="DVURL" select="concat('http://server.com/$valueagg')"/&gt;
                  &lt;/xsl:if&gt;
                  &lt;xsl:if test="$datavalueagg = '' and $valueagg = ''"&gt;
                      &lt;xsl:variable name="DVURL" select="concat('http://server.com/none')"/&gt;
                  &lt;/xsl:if&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:variable name="DVURL" select="concat('http://server.com/all')"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>