title: How to render XSL based on conditional statement
body: <p>I need help with syntax </p>
  
  <p>From a CMS I'm getting some title information (Music, TV, Comedy) Now I need to run a check in xsl to see which one comes up and then render the appropriate content (in my case a set of checkboxes)</p>
  
  <p>Based on what Title comes up I want to render different XSL code. If Title = TV then show this XSL, else if Title = Music then render this XSL instead.</p>
  
  <p>This is my code so far, however it's <em>throwing an error</em> because I have an XSL when statement inside of an XSL if statement.</p>
  
  <pre><code>&lt;xsl:template name="PrintTitles"&gt;             
  &lt;xsl:param name="ids"/&gt;
  &lt;xsl:if test="$ids"&gt;
  
      &lt;xsl:variable name="itm_id" select="substring-before($ids, '|')"/&gt;
  
      &lt;!-- xsl:if --&gt;
      &lt;xsl:if test="$itm_id"&gt;
  
          &lt;!-- Variable item &amp; title --&gt;
          &lt;xsl:variable name="itm" select="sc:item($itm_id,.)"/&gt;
          &lt;xsl:variable name="title" select="sc:fld('Title', $itm)"/&gt;
          &lt;div class="related-genre-types-{position()}" style="display:none;"&gt;&lt;xsl:value-of select="sc:fld('Title', $itm)"/&gt;&lt;/div&gt;
  
          &lt;div class="music-choices" style="display:block;"&gt;
  
              &lt;!-- Displays title --&gt;
              &lt;div class="choices-title"&gt;&lt;xsl:value-of select="sc:fld('Title', $itm)"/&gt;&lt;/div&gt;
              &lt;div class="choices-checkboxes"&gt;
  
                  &lt;!-- where I try to use the 'when conditional' throws error because this is inside of &lt;xsl:if test="$itm_id"&gt;--&gt;
                  &lt;!-- if title = TV then render this --&gt;
                  &lt;xsl:when test="title = TV"&gt;
                      &lt;xsl:for-each select="$TVGenres/item"&gt;
                          &lt;div class="category_box"&gt;
                              &lt;input type="checkbox" id="getf{sc:fld('@id',.)}" name="getfItem" value="{sc:fld('title',.)}" /&gt;
                              &lt;label for="get{sc:fld('@id',.)}"&gt;&lt;xsl:value-of select="sc:fld('title',.)" /&gt;&lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/xsl:for-each&gt;
                  &lt;/xsl:when&gt;
  
                  &lt;!-- if title = Music then render this --&gt;
                  &lt;xsl:when test="title = Music"&gt;
                      &lt;xsl:for-each select="$MusicGenres/item"&gt;
                          &lt;div class="category_box"&gt;
                              &lt;input type="checkbox" id="getf{sc:fld('@id',.)}" name="getfItem" value="{sc:fld('title',.)}" /&gt;
                              &lt;label for="get{sc:fld('@id',.)}"&gt;&lt;xsl:value-of select="sc:fld('title',.)" /&gt;&lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/xsl:for-each&gt;
                  &lt;/xsl:when&gt;
  
                  &lt;!-- if title = Comedy then render this --&gt;
                  &lt;xsl:when test="title = Comedy"&gt;
                      &lt;xsl:for-each select="$ComedyGenres/item"&gt;
                          &lt;div class="category_box"&gt;
                              &lt;input type="checkbox" id="getf{sc:fld('@id',.)}" name="getfItem" value="{sc:fld('title',.)}" /&gt;
                              &lt;label for="get{sc:fld('@id',.)}"&gt;&lt;xsl:value-of select="sc:fld('title',.)" /&gt;&lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/xsl:for-each&gt;
                  &lt;/xsl:when&gt;
  
              &lt;/div&gt;
              &lt;div class="clearfix"&gt;&lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/xsl:if&gt;
  
      &lt;xsl:call-template name="PrintTitles"&gt;
          &lt;xsl:with-param name="ids" select="substring-after($ids, '|')"/&gt;
      &lt;/xsl:call-template&gt;
  
  &lt;/xsl:if&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks for taking a look!</p>