title: XSLT multiple templates but only gets from last result
body: <p>I am newbie to XML and XSLT and have two different templates but the output I get is from last templates.</p>
  
  <p>The first template output the create html text where data-video-single is false i.e. the value of 0 and second template output the html text where the it two divs i.e. one on the left and second on the right.</p>
  
  <p>I need both text joined together as a single html output.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
      &lt;xsl:output method="html"/&gt;
  
      &lt;xsl:key name="groups" match="/videos/video" use="data-video-group"/&gt;
  
      &lt;xsl:template match="/videos"&gt;
              &lt;xsl:apply-templates mode="single" select="video[generate-id() = generate-id(key('groups', data-video-group)[1]) and data-video-single=0]" /&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="video" mode="single"&gt;
  
                  &lt;h2&gt;
                      &lt;xsl:value-of select="data-video-group"/&gt;
                  &lt;/h2&gt;
  
                  &lt;xsl:for-each select="key('groups', data-video-group)"&gt;
                      &lt;xsl:if test="data-video-single = '0'"&gt;
                          &lt;div class="feature"&gt;
                              &lt;p class="featurePic"&gt;
                                  &lt;img data-video-id="{data-video-id}" data-video-url="{data-video-url}" alt=""&gt;&lt;/img&gt;
                              &lt;/p&gt;
                              &lt;h3&gt;
                                  &lt;xsl:value-of select="data-video-heading"/&gt;
                              &lt;/h3&gt;
                              &lt;p&gt;
                                  &lt;xsl:value-of select="data-video-content"/&gt;
                              &lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/xsl:if&gt;
                  &lt;/xsl:for-each&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="/videos"&gt;
          &lt;xsl:apply-templates mode="nonSingle" select="video[generate-id() = generate-id(key('groups', data-video-group)[1]) and data-video-single=1]" /&gt;                
      &lt;/xsl:template&gt; 
  
      &lt;xsl:template match="video" mode="nonSingle"&gt;
  
          &lt;xsl:if test="position() mod 2 != 0"&gt;
              &lt;div class="featureLeft"&gt;
                  &lt;h2&gt;
                      &lt;xsl:value-of select="data-video-group"/&gt;
                  &lt;/h2&gt;
  
                  &lt;xsl:for-each select="key('groups', data-video-group)"&gt;
                      &lt;xsl:if test="data-video-single = '1'"&gt;
                          &lt;div class="feature"&gt;
                              &lt;p class="featurePic"&gt;
                                  &lt;img data-video-id="{data-video-id}" data-video-url="{data-video-url}" alt=""&gt;&lt;/img&gt;
                              &lt;/p&gt;
                              &lt;h3&gt;
                                  &lt;xsl:value-of select="data-video-heading"/&gt;
                              &lt;/h3&gt;
                              &lt;p&gt;
                                  &lt;xsl:value-of select="data-video-content"/&gt;
                              &lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/xsl:if&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/div&gt;            
          &lt;/xsl:if&gt;
  
          &lt;xsl:if test="position() mod 2 = 0"&gt;
              &lt;div class="featureRight"&gt;
                  &lt;h2&gt;
                      &lt;xsl:value-of select="data-video-group"/&gt;
                  &lt;/h2&gt;
  
                  &lt;xsl:for-each select="key('groups', data-video-group)"&gt;
                      &lt;xsl:if test="data-video-single = '1'"&gt;
                          &lt;div class="feature"&gt;
                              &lt;p class="featurePic"&gt;
                                  &lt;img data-video-id="{data-video-id}" data-video-url="{data-video-url}" alt=""&gt;&lt;/img&gt;
                              &lt;/p&gt;
                              &lt;h3&gt;
                                  &lt;xsl:value-of select="data-video-heading"/&gt;
                              &lt;/h3&gt;
                              &lt;p&gt;
                                  &lt;xsl:value-of select="data-video-content"/&gt;
                              &lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/xsl:if&gt;
  
                  &lt;/xsl:for-each&gt;
              &lt;/div&gt;                        
          &lt;/xsl:if&gt;
  
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Here is the source xml data.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
  &lt;?xml-stylesheet type="text/xsl" href="/UserControls/IRISNewRelease/Data/newrelease.xslt"?&gt;
  &lt;videos&gt;
      &lt;video&gt;
          &lt;data-video-id&gt;1&lt;/data-video-id&gt;
          &lt;data-video-single&gt;0&lt;/data-video-single&gt;
          &lt;data-video-group&gt;ABC GROUP&lt;/data-video-group&gt;
          &lt;data-video-groupNote&gt;&lt;/data-video-groupNote&gt;
          &lt;data-video-url&gt;VIMEO&lt;/data-video-url&gt;
          &lt;data-video-heading&gt;Video Heading 1&lt;/data-video-heading&gt;
          &lt;data-video-content&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae lacus fermentum vehicula.&lt;/data-video-content&gt;
      &lt;/video&gt;
      &lt;video&gt;
          &lt;data-video-id&gt;2&lt;/data-video-id&gt;
          &lt;data-video-single&gt;0&lt;/data-video-single&gt;
          &lt;data-video-group&gt;ABC GROUP&lt;/data-video-group&gt;
          &lt;data-video-url&gt;VIMEO&lt;/data-video-url&gt;
          &lt;data-video-heading&gt;Video Heading 2&lt;/data-video-heading&gt;
          &lt;data-video-content&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae lacus fermentum vehicula.&lt;/data-video-content&gt;
      &lt;/video&gt;
      &lt;video&gt;
          &lt;data-video-id&gt;3&lt;/data-video-id&gt;
          &lt;data-video-single&gt;0&lt;/data-video-single&gt;
          &lt;data-video-group&gt;Company Secretarial&lt;/data-video-group&gt;
          &lt;data-video-url&gt;VIMEO&lt;/data-video-url&gt;
          &lt;data-video-heading&gt;Video Heading 3&lt;/data-video-heading&gt;
          &lt;data-video-content&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae lacus fermentum vehicula.&lt;/data-video-content&gt;
      &lt;/video&gt;
      &lt;video&gt;
          &lt;data-video-id&gt;4&lt;/data-video-id&gt;
          &lt;data-video-single&gt;0&lt;/data-video-single&gt;
          &lt;data-video-group&gt;Business Tax&lt;/data-video-group&gt;
          &lt;data-video-url&gt;VIMEO&lt;/data-video-url&gt;
          &lt;data-video-heading&gt;Video Heading 4&lt;/data-video-heading&gt;
          &lt;data-video-content&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae lacus fermentum vehicula.&lt;/data-video-content&gt;
      &lt;/video&gt;
      &lt;video&gt;
          &lt;data-video-id&gt;5&lt;/data-video-id&gt;
          &lt;data-video-single&gt;0&lt;/data-video-single&gt;
          &lt;data-video-group&gt;Personal Tax&lt;/data-video-group&gt;
          &lt;data-video-url&gt;VIMEO&lt;/data-video-url&gt;
          &lt;data-video-heading&gt;Video Heading 5&lt;/data-video-heading&gt;
          &lt;data-video-content&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae lacus fermentum vehicula.&lt;/data-video-content&gt;
      &lt;/video&gt;
      &lt;video&gt;
          &lt;data-video-id&gt;6&lt;/data-video-id&gt;
          &lt;data-video-single&gt;1&lt;/data-video-single&gt;
          &lt;data-video-group&gt;Personal Tax&lt;/data-video-group&gt;
          &lt;data-video-groupNote&gt;Integration with IRIS Personal Tax&lt;/data-video-groupNote&gt;
          &lt;data-video-url&gt;VIMEO&lt;/data-video-url&gt;
          &lt;data-video-heading&gt;Video Heading 6&lt;/data-video-heading&gt;
          &lt;data-video-content&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae lacus fermentum vehicula.&lt;/data-video-content&gt;
      &lt;/video&gt;
  &lt;/videos&gt;
  </code></pre>
  
  <p>The expected result as below ...</p>
  
  <p>The below result is from the first template i.e. mode = single, if you comment the second template and run it will work fine.</p>
  
  <pre><code>&lt;h2&gt;
      Personal Tax&lt;/h2&gt;
  &lt;div class="feature"&gt;
      &lt;p class="featurePic"&gt;
          &lt;img data-video-id="50214413" data-video-url="VIMEO" alt=""&gt;&lt;/p&gt;
      &lt;h3&gt;
          Simplified Client Data Entry&lt;/h3&gt;
      &lt;p&gt;
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae
          lacus fermentum vehicula.&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="feature"&gt;
      &lt;p class="featurePic"&gt;
          &lt;img data-video-id="50214135" data-video-url="VIMEO" alt=""&gt;&lt;/p&gt;
      &lt;h3&gt;
          IRIS Personal Tax and Payroll Integration&lt;/h3&gt;
      &lt;p&gt;
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae
          lacus fermentum vehicula.&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the result from second template i.e. mode = nonSingle, if you comment the first template and run this result will work fine.</p>
  
  <pre><code>&lt;div class="featureLeft"&gt;
      &lt;h2&gt;
          Accounts Production&lt;/h2&gt;
      &lt;div class="feature"&gt;
          &lt;p class="featurePic"&gt;
              &lt;img data-video-id="50220365" data-video-url="VIMEO" alt=""&gt;&lt;/p&gt;
          &lt;h3&gt;
              Companies House iXBRL e-filing&lt;/h3&gt;
          &lt;p&gt;
              Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae
              lacus fermentum vehicula.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="feature"&gt;
          &lt;p class="featurePic"&gt;
              &lt;img data-video-id="50220516" data-video-url="VIMEO" alt=""&gt;&lt;/p&gt;
          &lt;h3&gt;
              IRIS Accounts Production supports companies limited by guarantee&lt;/h3&gt;
          &lt;p&gt;
              Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae
              lacus fermentum vehicula.&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="featureRight"&gt;
      &lt;h2&gt;
          Company Secretarial&lt;/h2&gt;
      &lt;div class="feature"&gt;
          &lt;p class="featurePic"&gt;
              &lt;img data-video-id="50220436" data-video-url="VIMEO" alt=""&gt;&lt;/p&gt;
          &lt;h3&gt;
              Company name change for Companies House&lt;/h3&gt;
          &lt;p&gt;
              Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae
              lacus fermentum vehicula.&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="featureLeft"&gt;
      &lt;h2&gt;
          Business Tax&lt;/h2&gt;
      &lt;div class="feature"&gt;
          &lt;p class="featurePic"&gt;
              &lt;img data-video-id="50214325" data-video-url="VIMEO" alt=""&gt;&lt;/p&gt;
          &lt;h3&gt;
              IRIS Business Tax Client Account Overview&lt;/h3&gt;
          &lt;p&gt;
              Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo tellus vitae
              lacus fermentum vehicula.&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Currently I have both on the file it will only show last template result instead of the both templates.</p>
  
  <p>Any help will be highly appreciated.</p>
  
  <p>Thanks</p>