title: How to display 2 records per row in XSLT
body: <p>I want to display 2 records per row from a list in my SharePoint site.</p>
  
  <p>I am using XSLT. This is how I want to display records:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;Record1&lt;/td&gt;
      &lt;td&gt;Record2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;Record3&lt;/td&gt;
      &lt;td&gt;Record4&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>I have written the following code to do this job but getting error on line where  is written. Basically XSLT is not allowing me to write  without closing . But I want it that way otherwise my logic won't work. So is there a way to achieve this?</p>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>&lt;xsl:choose&gt;
      &lt;xsl:when test="position() mod 2 = 1"&gt;
          &lt;tr&gt; (this is my error line)
      &lt;/xsl:when&gt;
  &lt;/xsl:choose&gt;
  
  &lt;td&gt;rest of my code will come here&lt;/td&gt;
  
  &lt;xsl:choose&gt;
      &lt;xsl:when test="position() mod 2 = 0"&gt;
          &lt;/tr&gt;
      &lt;/xsl:when&gt;
  &lt;/xsl:choose&gt;  
  </code></pre>
  
  <p><strong>EDIT</strong><br>
  This is how my complete SharePoint code looks like.</p>
  
  <pre><code>&lt;xsl:template match="/" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal"&gt;
  &lt;table width="327" border="0" cellspacing="0" cellpadding="0"&gt;
      &lt;tr&gt;
          &lt;td&gt;Links&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;table width="327" border="0" cellspacing="0" cellpadding="0"&gt;
                  &lt;xsl:apply-templates /&gt;
              &lt;/table&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="Row" name="items"&gt;
  &lt;xsl:choose&gt;
      &lt;xsl:when test="position() mod 2 = 1"&gt;
          &lt;tr&gt; (this is my error line)
      &lt;/xsl:when&gt;
  &lt;/xsl:choose&gt;
  
  &lt;td&gt;rest of my code will come here&lt;/td&gt;
  
  &lt;xsl:choose&gt;
      &lt;xsl:when test="position() mod 2 = 0"&gt;
          &lt;/tr&gt;
      &lt;/xsl:when&gt;
  &lt;/xsl:choose&gt;  
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>So basically the code where it says <code>&lt;xsl:apply-templates /&gt;</code>, this is where complete block of code starting from <code>&lt;xsl:template match="Row" name="items"&gt;</code> is repeated and filled with rows so there is no for loop here.</p>
  
  <p><strong>EDIT - Complete XSL Code</strong>  </p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl" xmlns:ddwrt2="urn:frontpage:internal"&gt;
  &lt;xsl:output method="html" indent="yes"/&gt;
  &lt;xsl:param name="ViewAll" /&gt;
  
  &lt;!-- This template is the "wrapper" or "container" for the custom view. --&gt;
  &lt;xsl:template match="/" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal"&gt;
  
  &lt;!-- This is the actual wrapper element that will be emitted --&gt;
  &lt;table width="327" border="0" cellspacing="0" cellpadding="0"&gt;
      &lt;tr&gt;
          &lt;td colspan="3"&gt;
              &lt;table width="327" border="0" cellspacing="0" cellpadding="0"&gt;
                  &lt;tr&gt;
                  &lt;td width="10" height="30" class="webpart_img1"&gt;&lt;/td&gt;
                  &lt;td width="307" height="30" class="webpart_img2"&gt;Links&lt;/td&gt;
                      &lt;td width="10" height="30" class="webpart_img3"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td height="1" colspan="3"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td width="10" height="105" class="quicklink_img1"&gt;&lt;/td&gt;
          &lt;td width="307" height="105" class="quicklink_img1"&gt;
              &lt;table width="307" border="0" cellspacing="0" cellpadding="0"&gt;
                  &lt;xsl:apply-templates /&gt;
              &lt;/table&gt;
          &lt;/td&gt;
          &lt;td width="10" height="105" class="quicklink_img1"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td width="10" height="6" class="quicklink_img2"&gt;&lt;/td&gt;
          &lt;td width="307" height="6" class="quicklink_img1"&gt;&lt;/td&gt;
          &lt;td width="10" height="6" class="quicklink_img3"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;!-- end wrapper --&gt;
  &lt;/xsl:template&gt;
  
  &lt;!-- This template is for the repeating content --&gt;
  &lt;xsl:template match="Row" name="repeat"&gt;
      &lt;tr&gt;
          &lt;td width="16" height="21"&gt;&lt;img src="images/mybullet.png"/&gt;&lt;/td&gt;
          &lt;td width="142" height="21"&gt;&lt;a href="URL" class="quicklink"&gt;Title of URL&lt;/a&gt;&lt;/td&gt;
          &lt;td width="11"&gt;&lt;/td&gt;
          &lt;td width="16" height="21"&gt;&lt;img src="images/mybullet.png"/&gt;&lt;/td&gt;
          &lt;td width="142" height="21"&gt;&lt;a href="URL" class="quicklink"&gt;Title of URL&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I am trying to display links which are coming from a List in SharePoint. The list has two columns:</p>
  
  <p>Title<br>
  URL  </p>
  
  <p>So I want to display 2 titles per row with their URL as hyper link.</p>