xsltsharepoint-2010

The variable or parameter 'Rows' is either not defined or it is out of scope


Expected Format Actual Format

How do i achieve this through xslt? I am getting an error from the cde above given by you ( sharepoint 2010 xslt dataview : modify table structure to display list item )

The error is: The variable or parameter 'Rows' is either not defined or it is out of scope. Please help why am i getting this error:( My full code would go like this after the code by you has been added:

<xsl:template match='dsQueryResponse'>
  <table cellpadding="10" cellspacing="0" border="1" style="padding:25px;">
    <!--table for head-->
    <tr>
      <!--table row-->
      <td colspan='2'>
        <!--table definition-->
        <b style="font-size:25px;">ELearning List</b>
        <!-- heading-->
      </td>
    </tr>
    <xsl:apply-templates select='Rows/Row'/>
  </table>
</xsl:template>
<xsl:template match='Row'>
  <!-- template is defined above -->
  <xsl:for-each select="$Rows[position() mod 3 = 1]">
    <!-- 3 recods in one row should be displayed -->
    <tr>
      <xsl:variable name="i" select="position() - 1" />
      <xsl:for-each select="$Rows[(position() &gt; ($i * 3)) and (position() &lt;= (($i + 1) * 3))]">
        <td>
          <img src="../PublishingImages/FLDRNEW.GIF" width="50px" height="50px" style="padding-right:20px;"></img>
          <!-- image is to display folder below which the hyperlinked text has been populated -->
          <br/>
          <a href="{@FileRef}" style="font-weight:bold;">
            <!-- it is the anchor tag which drives to the corresponding documents -->
            <xsl:value-of select="substring-after(string(@FileRef),'/Docs/')"/>
            <!-- fetches the value of Name column -->
          </a>
        </td>
      </xsl:for-each>
    </tr>
  </xsl:for-each>
</xsl:template>

The error is: The variable or parameter 'Rows' is either not defined or it is out of scope. Please help


Solution

  • Could you give this a try?

    <xsl:template match='dsQueryResponse'>
      <table cellpadding="10" cellspacing="0" border="1" style="padding:25px;">
        <!--table for head-->
        <tr>
          <!--table row-->
          <td colspan='2'>
            <!--table definition-->
            <b style="font-size:25px;">ELearning List</b>
            <!-- heading-->
          </td>
        </tr>
        <xsl:apply-templates 
                select='Rows/Row[position() mod 3 = 1]' mode="group" />
      </table>
    </xsl:template>
    
    <xsl:template match='Row' mode="group">
      <tr>
        <xsl:apply-templates 
                select=". | following-sibling::Row[position() &lt; 3]" />
      </tr>
    </xsl:template>
    
    <xsl:template match="Row">
      <td>
        <!-- image is to display folder below which the hyperlinked text has 
                been populated -->
        <img src="../PublishingImages/FLDRNEW.GIF" width="50px" height="50px" 
             style="padding-right:20px;" />
        <br/>
        <!-- the anchor tag which drives to the corresponding documents -->
        <a href="{@FileRef}" style="font-weight:bold;">
          <!-- fetches the value of Name column -->
          <xsl:value-of select="substring-after(string(@FileRef),'/Docs/')"/>
        </a>
      </td>
    </xsl:template>