0

预期格式 实际格式

我如何通过 xslt 实现这一目标?我从你上面给出的 cde 中得到一个错误(sharepoint 2010 xslt dataview:修改表结构以显示列表项

错误是:变量或参数“行”未定义或超出范围。请帮助我为什么会收到此错误:(添加您的代码后,我的完整代码将如下所示:

<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>

错误是:变量或参数“行”未定义或超出范围。请帮忙

4

1 回答 1

0

你能试试这个吗?

<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>
于 2013-03-12T10:32:32.580 回答