Join 如何在SharePoint Designer 2007中在联接的数据源上创建筛选的数据视图

Join 如何在SharePoint Designer 2007中在联接的数据源上创建筛选的数据视图,join,filter,sharepoint-designer,dataview,Join,Filter,Sharepoint Designer,Dataview,我正在尝试使用SharePoint Designer 2007为MOSS 2007创建筛选数据视图。下面的简化示例演示了我试图实现的目标 假设我有两个列表:颜色和人。人员列表有一个名为Favorite Color的查找列,允许用户从颜色列表中进行选择 我想创建一个DataView,它将只显示没有人选择作为其喜爱颜色的颜色 我已经成功创建了一个DataView,通过插入以下XSL代码显示每种颜色以及选择该颜色的人数: <xsl:value-of select="count(/dsQueryR

我正在尝试使用SharePoint Designer 2007为MOSS 2007创建筛选数据视图。下面的简化示例演示了我试图实现的目标

假设我有两个列表:颜色和人。人员列表有一个名为Favorite Color的查找列,允许用户从颜色列表中进行选择

我想创建一个DataView,它将只显示没有人选择作为其喜爱颜色的颜色

我已经成功创建了一个DataView,通过插入以下XSL代码显示每种颜色以及选择该颜色的人数:

<xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title])" />

我尝试对DataView查询应用相同的逻辑,如下所示,但仍然返回所有行:

<xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title]) = 0]"/>

我认为上面的问题是,在查询发生时,current()函数不起作用,因为没有当前行。因此,我还尝试使用一个完整的参考,得到了相同的结果:

<xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = dsQueryResponse/Colors/Rows/Row/@Title]) = 0]"/>

是否可以使用XSL执行我想要的查询类型?如果是这样,我哪里出了问题?完整的XSL如下所示:

<XSL><xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">
    <xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
    <xsl:variable name="dvt_StyleName">Table</xsl:variable>
    <xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row[count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = dsQueryResponse/Colors/Rows/Row/@Title]) = 0]"/>
    <table border="0" width="100%" cellpadding="2" cellspacing="0">
    <tr valign="top">
    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <th class="ms-vh" width="1%" nowrap="nowrap"></th>
    </xsl:if>
        <th class="ms-vh" nowrap="nowrap">Color</th>
        <th class="ms-vh" nowrap="nowrap">Number of People</th>
    </tr>
    <xsl:call-template name="dvt_1.body">
        <xsl:with-param name="Rows" select="$Rows"/>
    </xsl:call-template>
    </table>
</xsl:template>
<xsl:template name="dvt_1.body">
    <xsl:param name="Rows"/>
    <xsl:for-each select="$Rows">
        <xsl:call-template name="dvt_1.rowview"/>
    </xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
    <tr>
        <xsl:if test="position() mod 2 = 1">
            <xsl:attribute name="class">ms-alternating</xsl:attribute>
        </xsl:if>
        <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
            <td class="ms-vb" width="1%" nowrap="nowrap">
                <span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
            </td>
        </xsl:if>
        <td class="ms-vb">
            <xsl:value-of select="@Title"/>
        </td>
        <td class="ms-vb">
            <xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = current()/@Title])" />
        </td>
    </tr>
</xsl:template>

'
0
桌子
颜色
人数
ms交替

我实际上还没有试过,但如果你基本上按照安德鲁的建议,先循环浏览颜色列表,会怎么样。如果不符合条件,就不要显示行

   <xsl:variable name="Rows" select="/dsQueryResponse/Colors/Rows/Row"/>

然后

<xsl:template name="dvt_1.rowview">
<xsl:variable name="title" select="@Title" />
<xsl:if test="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = $title]) &gt; 0">
<tr>
    <xsl:if test="position() mod 2 = 1">
        <xsl:attribute name="class">ms-alternating</xsl:attribute>
    </xsl:if>
    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <td class="ms-vb" width="1%" nowrap="nowrap">
            <span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
        </td>
    </xsl:if>
    <td class="ms-vb">
        <xsl:value-of select="@Title"/>
    </td>
    <td class="ms-vb">
        <xsl:value-of select="count(/dsQueryResponse/People/Rows/Row[@Favorite_x0020_Color = $title])" />
    </td>
</tr>
</xsl:if>
</xsl:template>

ms交替

另一种策略可能是首先查询颜色列表中的所有行,然后删除循环中的行。有人知道如何从查询中删除单个行吗?