创建 XLS 变量以显示与 SharePoint 2010 列表中特定条件匹配的所有字段值

create an XLS variable to show all field values that match certain condition in a SharePoint 2010 list

给定以下 SharePoint 列表:

Name    Age
Lisa    15
Joe     20
Nick    15

我可以设法创建一个 XSL 变量来计算年龄等于 15 的行

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
<xsl:variable name="KidsCount" select="count($Rows[@Age = 15])"/>

现在,我想用年龄等于 15 岁的所有名字(串联)创建变量 KidsNames。

我应该在下面的 select 部分填写什么?

<xsl:variable name="KidsNames" select="  ???   "/>

可以在每个名字的末尾添加一个新行或 return 个字符,所以在打印变量 #kidsNames 时我会得到一种名字列表?

在 XSLT 2.0 或更高版本中,您可以使用 string-join() :

<xsl:variable name="KidsNames" select="string-join($Rows[@Age = 15]/@Name, ',')"/>

但我相信 Sharepoint 2010 只支持 XSLT 1.0,所以这里有可能使用 xsl:for-each 循环的 XSLT 1.0 解决方案:

<xsl:variable name="KidsNames">
    <xsl:for-each select="$Rows[@Age = 15]">
        <xsl:if test="position() > 1">
            <xsl:text>,</xsl:text>
        </xsl:if>
        <xsl:value-of select="@Name"/>
    </xsl:for-each>
</xsl:variable>