簡體   English   中英

XSL / XSLT - 為DIV添加value-of作為樣式屬性

[英]XSL / XSLT - Adding a value-of as a style attribute for a DIV

我正在使用SharePoint 2010和內容查詢Web部件從SharePoint列表中輸出日期列表。 此列表的顯示由名為ItemStyle.xsl的XSL樣式表控制

我已經在一般外觀方面取得了進展,但現在想要將其檢索的一個字段添加為背景/樣式屬性。

我相信我遇到的問題與xsl值有關 - 選擇在標簽的末尾有一個右括號,因此無意中關閉了我的DIV。 有人可以查看下面的代碼,並建議在開放DIV中打印CategoryColour的替代方法。

我偶爾也會在html中插入“xmlns:ddwrt”,我希望至少看到“style:background ....”

非常感謝

<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"/>                                                                           

你在變量CategoryColour前面缺少一個$

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM