我使用xslt 1.0转换Sharepoint 2013数据视图。 数据源包含3个连接列表:
我在ISOList中循环播放项目,并希望显示与此特定项目相关的所有风险。逻辑是:首先找到与ISOList中的特定项相关的威胁,然后找到与其中一个威胁相关的风险。
所以我用ISOList的项目ID(ISORef)作为参数调用模板 - 就像这样:
<xsl:template name="Risks">
<xsl:param name="ISORef" />
<!-- add extra info to string, so it only selects relevant items -->
<xsl:variable name="ISORefString" select="concat('&ID=',$ISORef,'&RootFolder')"/>
<!-- get relevant threats -->
<xsl:variable name="SelectedThreats" select="/dsQueryResponse/Threat_Catalogue/Rows/Row[contains(@ISO_x0020_Reference, $ISORefString)]"/>
<!-- Create variable, that contains all ID's in Threat_Catalogue that are relevant -->
<xsl:variable name="ListThreats"><xsl:for-each select="$SelectedThreats">=<xsl:value-of select="@ID"/>&</xsl:for-each></xsl:variable>
<!-- Variable - just to illustrate problem -->
<xsl:variable name="ListThreatsAlternative" select="$ListThreats" />
<!-- this is where I'm trying to use variable to get relevant risks, but fails -->
<!-- Old: Didn't Work, has been replaced -->
<!--
<xsl:variable name="SelectedRisks" select="/dsQueryResponse/Risks/Rows/Row[contains($ListThreats, substring-before(substring-after(@Threat, 'ID'), 'RootFolder'))]"/>
-->
<!-- New: Works as intended -->
<xsl:variable name="SelectedRisks" select="/dsQueryResponse/Risks/Rows/Row[contains($ListThreats, substring-before(substring-after(@Threat, 'ID'), 'RootFolder')) and $ListThreats != '' and @Threat != '']"/>
<!-- Example output: -->
Original: <xsl:value-of select="$ListThreats" /> <!-- contains: '=118&' --> <br/>
Alternative: <xsl:value-of select="$ListThreatsAlternative" /> <!-- empty -->
</xsl:template>
问题是变量ListThreats在用作SelectedRisks或ListThreatsAlternative选择的条件时显示为空字符串。
*编辑:
源XML由Sharepoint生成。我不知道如何获取特定数据源的XML,但在下面我已经从Risks列表中添加了XML。我已经大大缩短了XML源代码,但希望它足够了。 此外 - 源XML和Sharepoint在列表中显示的内容存在一些显着差异。特别是在查找字段时。
示例:
当Sharepoint显示内容时: https://xxx.xxx.xxx.com/sites/xxx_xxx/ISMS/_layouts/15/listform.aspx?PageType=4&ListId={4ab4bbff-588b-4c06-9685-c814cdefd59f}&ID=56&RootFolder = *&#39;,RefreshPage);返回false;&#34; HREF =&#34; HTTPS:?//xxx.xxx.xxx.com/sites/xxx_xxx/ISMS/_layouts/15/listform.aspx PAGETYPE = 4和; ListId = {4ab4bbff-588B-4c06-9685-c814cdefd59f}&安培; ID = 56&amp; RootFolder = *&#34;&gt;黑客:14。密码破解
当源XML中显示类似内容时:
55; #Hackers:13。恶意软件
这是XML源(缩写):
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30">
<s:AttributeType name="ows_ID" rs:name="ID" rs:number="1">
<s:datatype dt:type="i4" dt:maxLength="4"/>
</s:AttributeType>
<s:AttributeType name="ows_LinkTitle" rs:name="Risk Title" rs:number="2">
<s:datatype dt:type="string" dt:maxLength="512"/>
</s:AttributeType>
<s:AttributeType name="ows_Threat" rs:name="Threat" rs:number="15">
<s:datatype dt:type="variant" dt:lookup="true" dt:maxLength="8009"/>
</s:AttributeType>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ows_ID="72" ows_LinkTitle="Test risk" ows_Threat="55;#Hackers: 13. Malware" />
</rs:data>
</xml>
答案 0 :(得分:0)
在选择中找到答案,愚蠢的错误。在OP中编辑。