2016-08-17 62 views
0

我有一个Sharepoint列表,其中一列是一个查找列,它返回多个值,用分号分隔。我想在输出中将这些项目显示为单独的行,而不是与分隔符一起显示为单行。对于所讨论的场在xsl如下:如何格式化Sharepoint查找列XSL值

<xsl:template match="FieldRef[(@Encoded) and @Name='Project_x0020_Tasks']" ddwrt:dvt_mode="body" mode="Lookup_body" ddwrt:ghost="show"> 

      <xsl:param name="thisNode" select="."/> 

<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" /> 


</xsl:template> 

当前视图中显示一个表格单元格内的数据为:

Task 1; Task 2; Task 3; 

我想它显示为

Task 1 
Task 2 
Task 3 

我花了大量的时间在网上搜索,但还没有找到任何解决方案,可以帮助我到目前为止。

回答

0

你可以做的是有一个分号转换为<br />标签,像这样递归模板:

<xsl:template name="CharToLineBreak"> 
    <xsl:param name="text" /> 
    <xsl:param name="char" /> 
    <xsl:choose> 
     <xsl:when test="contains($text, $char)"> 
      <xsl:value-of select="substring-before($text, $char)" /> 
      <br /> 
      <xsl:call-template name="CharToLineBreak"> 
       <xsl:with-param name="text" select="substring-after($text, $char)" /> 
       <xsl:with-param name="char" select="$char" /> 
      </xsl:call-template> 
     </xsl:when> 
     <xsl:otherwise> 
      <xsl:value-of select="$text" /> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 

然后,而不是如你的问题做xsl:value-of,做xsl:call-template像这样.. 。

<xsl:call-template name="CharToLineBreak"> 
     <xsl:with-param name="text" select="$thisNode/@*[name()=current()/@Name]" /> 
     <xsl:with-param name="char" select="';'" /> 
    </xsl:call-template> 

我不知道为什么你获得属性值的过程非常复杂。它可以被简化为

<xsl:call-template name="CharToLineBreak"> 
     <xsl:with-param name="text" select="@Project_x0020_Tasks" /> 
     <xsl:with-param name="char" select="';'" /> 
    </xsl:call-template> 
+0

这种复杂性是由SharePoint自动生成的。我使用调用模板而不是调用的值尝试了模板,但SharePoint不会显示它。我想我将不得不使用JavaScript解决方案。 –