title: get last item in content query web part using xslt (SharePoint 2010)
body: <p>This is my first time that I am using Content Query Web part and xslt. I have to display the <code>last 5 posts</code> from a blog in the following fashion (please look at the image below):</p>
  
  <p>The table contains two columns. In the left column I would like to display the last post and in the right column I would like to display the rest of the posts from a particual blog.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>The source is just an OOTB Blog Site and I have added a few posts in it. I would like to display these posts in an html table which contains two columns. In the left column I would like to display the last post entered in the blog and in the right column I would like to loop through other posts. The user must specify how many posts he/she would like to see in the CQWP.</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>This is the xslt that I have created so far. The only think is that the table is being repeated multiple times, which I don't want that. There should be only one table. If you look in the xslt code I have manually entered some text, like Test1, test 2... In their place I would like to display the rest of the blog posts.</p>
  
  <pre><code>&lt;xsl:template name="Post" match="Row[@Style='Post']" mode="itemstyle"&gt;
      &lt;xsl:variable name="SafeLinkUrl"&gt;
          &lt;xsl:call-template name="OuterTemplate.GetSafeLink"&gt;
              &lt;xsl:with-param name="UrlColumnName" select="'LinkUrl'"/&gt;
          &lt;/xsl:call-template&gt;
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="DisplayTitle"&gt;
          &lt;xsl:call-template name="OuterTemplate.GetTitle"&gt;
              &lt;xsl:with-param name="Title" select="@Title"/&gt;
              &lt;xsl:with-param name="UrlColumnName" select="'LinkUrl'"/&gt;
          &lt;/xsl:call-template&gt;
      &lt;/xsl:variable&gt;
      &lt;div&gt;        
          &lt;table width="100%" cellpadding="2" cellspacing="2" border="1"&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" valign="top"&gt;
                     &lt;xsl:value-of select="@Author"/&gt;&lt;/td&gt;
                  &lt;td rowspan="2" valign="top" width="30%"&gt;
                      &lt;div&gt;
                          &lt;b&gt;Previous blog posts:&lt;/b&gt;
                      &lt;/div&gt;
                      &lt;div&gt;
                          &lt;ul style="margin-left:-2px;"&gt;
                          &lt;li&gt;Test 1&lt;/li&gt;
                          &lt;li&gt;Test 2&lt;/li&gt;
                          &lt;li&gt;Test 3&lt;/li&gt;
                          &lt;li&gt;Test 4&lt;/li&gt;
                          &lt;/ul&gt;
                      &lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td width="15%" valign="top"&gt;
                      image&lt;/td&gt;
                  &lt;td  valign="top"&gt;
                       &lt;div&gt;
                          &lt;xsl:value-of select="@Title"/&gt;
                       &lt;/div&gt;  
                       &lt;div class="custom_description"&gt; 
                          &lt;xsl:value-of select="@Body" disable-output-escaping="yes" /&gt; 
                      &lt;/div&gt;                  
                      &lt;p&gt;
                      &lt;xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/&gt;
                      &lt;a href="{$SafeLinkUrl}"&gt;
                        &lt;xsl:if test="$ItemsHaveStreams = 'True'"&gt;
                          &lt;xsl:attribute name="onclick"&gt;
                            &lt;xsl:value-of select="@OnClickForWebRendering"/&gt;
                          &lt;/xsl:attribute&gt;
                        &lt;/xsl:if&gt;
                        &lt;xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'"&gt;
                          &lt;xsl:attribute name="onclick"&gt;
                            &lt;xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/&gt;
                          &lt;/xsl:attribute&gt;
                        &lt;/xsl:if&gt;
                        &lt;br /&gt;
                        &lt;b&gt;Read More &amp;gt;&lt;/b&gt;
                      &lt;/a&gt;
                      &lt;/p&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;                   
      &lt;/div&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p><strong>Edit 3</strong></p>
  
  <pre><code>&lt;root&gt;
     &lt;Posts&gt;
          &lt;Post ID="1"&gt;
           &lt;Title&gt;this post 1&lt;/Title&gt;
           &lt;Body&gt;The comment comes here&lt;/Body&gt;
      &lt;/Post&gt;
  &lt;Post ID="2"&gt;
           &lt;Title&gt;this post 2&lt;/Title&gt;
           &lt;Body&gt;The comment comes here&lt;/Body&gt;
      &lt;/Post&gt;
  &lt;Post ID="3"&gt;
           &lt;Title&gt;this post 3&lt;/Title&gt;
           &lt;Body&gt;The comment comes here&lt;/Body&gt;
      &lt;/Post&gt;
  &lt;Post ID="4"&gt;
           &lt;Title&gt;this post 4&lt;/Title&gt;
           &lt;Body&gt;The comment comes here&lt;/Body&gt;
      &lt;/Post&gt;
  &lt;Post ID="5"&gt;
           &lt;Title&gt;this post 5&lt;/Title&gt;
           &lt;Body&gt;The comment comes here&lt;/Body&gt;
      &lt;/Post&gt;
  
     &lt;/Posts&gt;
  
  &lt;/root&gt;
  </code></pre>
  
  <p>Thank you</p>
  
  <p><img src="https://i.stack.imgur.com/w6bCE.png" alt="enter image description here"></p>