sharepoint - XSL/XSLT - 添加一个值作为 DIV 的样式属性

标签 sharepoint xslt sharepoint-2010 content-query-web-part

我正在使用 SharePoint 2010 和内容查询 Web 部件从 SharePoint 列表中输出日期列表。此列表的显示由名为 ItemStyle.xsl 的 XSL 样式表控制

我在总体外观方面取得了进展,但现在想添加它检索到的字段之一作为背景/样式属性。

我相信我遇到的问题与 xsl value-of select 有关,在标签末尾有一个右括号,因此无意中关闭了我的 DIV。有人可以查看下面的代码并建议在打开的 DIV 中打印 CategoryColour 的替代方法。

我也会偶尔将“xmlns:ddwrt”插入到我希望至少看到“style:background....”的 html 中

非常感谢

<xsl:stylesheet                                                                                                                                                                                         
  version="1.0"                                                                                                                                                                                         
  exclude-result-prefixes="x d xsl msxsl cmswrt"                                                                                                                                                        
  xmlns:x="http://www.w3.org/2001/XMLSchema"                                                                                                                                                            
  xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"                                                                                                                                                 
  xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"                                                                                                                            
  xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"                                                                                                                               
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                                                                                                                                                      
  xmlns:msxsl="urn:schemas-microsoft-com:xslt">                                                                                                                                                         

<!-- PrettyCal Template -->                                                                                                                                                                             
<xsl:template name="PrettyCal" match="Row[@Style='PrettyCal']" mode="itemstyle">                                                                                                                        
    <xsl:variable name="Start"><xsl:value-of select="@EventDate" /></xsl:variable>                                                                                                                      
    <xsl:variable name="End"><xsl:value-of select="@EndDate" /></xsl:variable>                                                                                                                          
    <xsl:variable name="AllDay"><xsl:value-of select="@AllDayEvent" /></xsl:variable>                                                                                                                   
    <xsl:variable name="Location"><xsl:value-of select="@EventLocation" /></xsl:variable>                                                                                                               
    <xsl:variable name="CategoryColour"><xsl:value-of select="@EventCategoryColour" /></xsl:variable>                                                                                                   

    <div class="upcoming-events" style="background: {CategoryColour}" ><xsl:value-of select="$CategoryColour"/>                                                                                         

        <h2 class="event-title">                                                                                                                                                                        
        <a>                                                                                                                                                                                             
        <xsl:attribute name="onClick">                                                                                                                                                                  
            javascript:SP.UI.ModalDialog.showModalDialog({ url: '/services/marketing/Lists/College%20Calendar/DispForm.aspx?ID=<xsl:value-of select="@ID" />', title: 'Event Details' }); return false; 
        </xsl:attribute>                                                                                                                                                                                
        <xsl:value-of select="@Title" /></a></h2>                                                                                                                                                       

    </div>                                                                                                                                                                                              
</xsl:template>                                                                                                                                                                                         
</xsl:stylesheet>                                                                                                                                                                                       

最佳答案

你有:

  <div class="upcoming-events" style="background: {CategoryColour}" ><xsl:value-of select="$CategoryColour"/>                                                                           

你真的想要:

  <div class="upcoming-events" style="background: {$CategoryColour}" ><xsl:value-of select="$CategoryColour"/>                                                                           

关于sharepoint - XSL/XSLT - 添加一个值作为 DIV 的样式属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14126400/

相关文章:

asp.net - ASP 按钮不起作用

google-chrome - SSRS 报告滚动问题

sharepoint - 如何使用声明身份验证保护 SharePoint 2013 中的应用程序页面

java - 使用 sardine 从 java 应用程序访问 sharepoint 网站

javascript - 通过javascript将多个附件从列表复制到文档库

visual-studio-2010 - 如何使用命令行构建 SharePoint 2010 包?

xml - xslt 应用具有相同父节点的模板

xslt - 在xslt中选择一个并行节点

javascript - 根据条件将 XSL 属性保存到 JavaScript 数组

sharepoint - 部署步骤 'Retract Solution' : Feature 'GUID' is not activated at this scope 出错