none
XSL in LVWP - What should I change in this XSL so it takes items from a SharePoint Calendar instead of an RSS feed? RRS feed

  • Question

  • Hi there

    XSL -  What should I change in this XSL so it takes items from a SharePoint Calendar instead of an RSS feed?
    My aim is that AFTER changing the XSL - the calendar web part will show dates on left like this screenshot:
    (As of now the RSS web part looks like this)

    Thanks so much.

    The XSL that does this 

    <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
                   version="1.0" exclude-result-prefixes="xsl ddwrt msxsl rssaggwrt" 
                   xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
                   xmlns:rssaggwrt="http://schemas.microsoft.com/WebParts/v3/rssagg/runtime"
                   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                   xmlns:rssFeed="urn:schemas-microsoft-com:sharepoint:RSSAggregatorWebPart"
                   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"
                   xmlns:rss1="http://purl.org/rss/1.0/" xmlns:atom="http://www.w3.org/2005/Atom"
                   xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
                   xmlns:atom2="http://purl.org/atom/ns#">
    
        <xsl:param name="rss_FeedLimit">5</xsl:param>
        <xsl:param name="rss_ExpandFeed">false</xsl:param>
        <xsl:param name="rss_LCID">1033</xsl:param>
        <xsl:param name="rss_WebPartID">RSS_Viewer_WebPart</xsl:param>
        <xsl:param name="rss_alignValue">left</xsl:param>
        <xsl:param name="rss_IsDesignMode">True</xsl:param>
    
            <xsl:template match="rss">
                <xsl:call-template name="RSSMainTemplate"/>
            </xsl:template>
    
            <xsl:template match="rdf:RDF">
                <xsl:call-template name="RDFMainTemplate"/>
            </xsl:template>
    
            <xsl:template match="atom:feed">
                <xsl:call-template name="ATOMMainTemplate"/>
            </xsl:template>
    
            <xsl:template match="atom2:feed">
                <xsl:call-template name="ATOM2MainTemplate"/>
            </xsl:template>
    
            <xsl:template name="RSSMainTemplate" 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">
                <xsl:variable name="Rows" select="channel/item"/>
                <xsl:variable name="RowCount" select="count($Rows)"/>
                <div class="slm-layout-main box box-ipr" >            
              <!--  <div class="groupheader item medium">
                            <a href="{ddwrt:EnsureAllowedProtocol(string(channel/link))}">
                                <xsl:value-of select="channel/title"/>
                            </a>
    						
                </div>    -->        
                <xsl:call-template name="RSSMainTemplate.body">
                    <xsl:with-param name="Rows" select="$Rows"/>
                    <xsl:with-param name="RowCount" select="count($Rows)"/>
                </xsl:call-template>
    			
    			<a class="block-link" href="http://investors.contoso.com/Media-Center/Press-Releases/default.aspx">PRESS RELEASE ARCHIVE</a>
                </div>
    			
    			
            </xsl:template>
    
            <xsl:template name="RSSMainTemplate.body" 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">
                <xsl:param name="Rows"/>
                <xsl:param name="RowCount"/>
                <xsl:for-each select="$Rows">
                    <xsl:variable name="CurPosition" select="position()" />
                    <xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
                    <xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
                    <xsl:if test="($CurPosition &lt;= $rss_FeedLimit)">
                        
    					<div class="custom-link-item">
    					<div class="arrow_box dateIcon">
                                <!-- display date -->
    							<xsl:variable name="publisdate" select="pubDate"></xsl:variable>
    							<!--<xsl:value-of select= "$publisdate"/> -->
    							<xsl:variable name="date" select= "substring($publisdate,6,6)" />
    						   <div>
    						   <xsl:value-of select ="substring($date,1,3)"/>
    						   </div>
    						   <div>
    						   <xsl:value-of select ="substring($date,4,6)"/>
    						   </div>
    							
    							<!-- End  -->
                                <xsl:if test="$rss_ExpandFeed = true()">
                                    <xsl:call-template name="RSSMainTemplate.description">
                                        <xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
                                        <xsl:with-param name="CurrentElement" select="$CurrentElement"/>
                                    </xsl:call-template>
                                </xsl:if>
                                <xsl:if test="$rss_ExpandFeed = false()">
                                    <xsl:call-template name="RSSMainTemplate.description">
                                        <xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
                                        <xsl:with-param name="CurrentElement" select="$CurrentElement"/>
                                    </xsl:call-template>
                                </xsl:if>
    						</div>	
    							<div class="custom-link-item-content">
    							<a target="_blank" href="{ddwrt:EnsureAllowedProtocol(string(link))}" >
                                    <xsl:value-of select="title"/>
                                </a>
    							</div>
                        </div>  
    					
                    </xsl:if>
                </xsl:for-each>
            </xsl:template>
    		
    	<xsl:template name="RSSMainTemplate.description" 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">
                <xsl:param name="DescriptionStyle"/>
                <xsl:param name="CurrentElement"/>
    	    <div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
                    <xsl:choose>
                        <!-- some RSS2.0 contain pubDate tag, some others dc:date -->
                        <xsl:when test="string-length(pubDate) &gt; 0">
                            <xsl:variable name="pubDateLength" select="string-length(pubDate) - 3" />
    		        <xsl:value-of select="ddwrt:FormatDate(substring(pubDate,0,$pubDateLength),number($rss_LCID),3)"/>
                        </xsl:when>
                        <xsl:otherwise>
                        	<xsl:value-of select="ddwrt:FormatDate(string(dc:date),number($rss_LCID),3)"/>
                        </xsl:otherwise>
                    </xsl:choose>
    
                    <xsl:if test="string-length(description) &gt; 0">
                        <xsl:variable name="SafeHtml">
                            <xsl:call-template name="GetSafeHtml">
                                <xsl:with-param name="Html" select="description"/>
                            </xsl:call-template>
                        </xsl:variable>
                         - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
                    </xsl:if>
            </div>
            </xsl:template>
    
    
            <xsl:template name="RDFMainTemplate" 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">
                <xsl:variable name="Rows" select="rss1:item"/>
                <xsl:variable name="RowCount" select="count($Rows)"/>
                <div class="slm-layout-main box box-ipr" >
                <div class="groupheader item medium">
                    <a href="{ddwrt:EnsureAllowedProtocol(string(rss1:channel/rss1:link))}">
                        <xsl:value-of select="rss1:channel/rss1:title"/>
                    </a>
                </div>            
                <xsl:call-template name="RDFMainTemplate.body">
                    <xsl:with-param name="Rows" select="$Rows"/>
                    <xsl:with-param name="RowCount" select="count($Rows)"/>
                </xsl:call-template>
    			
    			<a class="block-link" href="http://investors.contoso.com/Media-Center/Press-Releases/default.aspx">PRESS RELEASE ARCHIVE</a>
                </div>
            </xsl:template>
    
            <xsl:template name="RDFMainTemplate.body" 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">
                <xsl:param name="Rows"/>
                <xsl:param name="RowCount"/>
                <xsl:for-each select="$Rows">
                    <xsl:variable name="CurPosition" select="position()" />
                    <xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
                    <xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
                    <xsl:if test="($CurPosition &lt;= $rss_FeedLimit)">
    				
                        <div class="item link-item" style="border-bottom: 1px solid #e2e2e2;">
    					
                            <a style="font-size:17px;color:#4d4d4d;" href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >
                                <xsl:value-of select="rss1:title"/>
                            </a>
                            <xsl:if test="$rss_ExpandFeed = true()">
                                    <xsl:call-template name="RDFMainTemplate.description">
                                        <xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
                                        <xsl:with-param name="CurrentElement" select="$CurrentElement"/>
                                    </xsl:call-template>
                            </xsl:if>
                            <xsl:if test="$rss_ExpandFeed = false()">
                                    <xsl:call-template name="RDFMainTemplate.description">
                                        <xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
                                        <xsl:with-param name="CurrentElement" select="$CurrentElement"/>
                                    </xsl:call-template>
                            </xsl:if>
                        </div>
    					
    		</xsl:if>
                </xsl:for-each>
            </xsl:template>
    
    	<xsl:template name="RDFMainTemplate.description" 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">
                <xsl:param name="DescriptionStyle"/>
                <xsl:param name="CurrentElement"/>
    	    <div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
    		    <xsl:value-of select="ddwrt:FormatDate(string(dc:date),number($rss_LCID),3)"/>
                    <xsl:if test="string-length(rss1:description) &gt; 0">
                        <xsl:variable name="SafeHtml">
                            <xsl:call-template name="GetSafeHtml">
                                <xsl:with-param name="Html" select="rss1:description"/>
                            </xsl:call-template>
                        </xsl:variable>
                         - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
                    </xsl:if>
    		    <div class="description">
    		        <a href="{ddwrt:EnsureAllowedProtocol(string(rss1:link))}">More...</a>
    	        </div>
            </div>
            </xsl:template>
    
    
            <xsl:template name="ATOMMainTemplate" 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">
                <xsl:variable name="Rows" select="atom:entry"/>
                <xsl:variable name="RowCount" select="count($Rows)"/>
                <div class="slm-layout-main box box-ipr" >
                <div class="groupheader item medium">
                    <a href="{ddwrt:EnsureAllowedProtocol(string(atom:link/@href))}">
                        <xsl:value-of select="atom:title"/>
                    </a>
                </div>            
                <xsl:call-template name="ATOMMainTemplate.body">
                    <xsl:with-param name="Rows" select="$Rows"/>
                    <xsl:with-param name="RowCount" select="count($Rows)"/>
                </xsl:call-template>
    			
    			<a class="block-link" href="http://investors.contoso.com/Media-Center/Press-Releases/default.aspx">PRESS RELEASE ARCHIVE</a>
                </div>
            </xsl:template>
    
            <xsl:template name="ATOMMainTemplate.body" 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">
                <xsl:param name="Rows"/>
                <xsl:param name="RowCount"/>
                <xsl:for-each select="$Rows">
                    <xsl:variable name="CurPosition" select="position()" />
                    <xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
                    <xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
                    <xsl:if test="($CurPosition &lt;= $rss_FeedLimit)">
    				
                                <div class="custom-link-item">
    								<div class="arrow_box dateIcon">
    									<div>
    										<xsl:if test="$rss_ExpandFeed = true()">
    											<xsl:call-template name="ATOMMainTemplate.description">
    												<xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
    												<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
    											</xsl:call-template>
    										</xsl:if>
    									</div>
    									<div>
    										<xsl:if test="$rss_ExpandFeed = false()">
    											<xsl:call-template name="ATOMMainTemplate.description">
    												<xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
    												<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
    											</xsl:call-template>
    										</xsl:if>
    									</div>
    								</div>
    								<a href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >
                                        <xsl:value-of select="atom:title"/>
                                    </a>
    								
                                </div>
    		</xsl:if>
                </xsl:for-each>
            </xsl:template>
    
    	<xsl:template name="ATOMMainTemplate.description" 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">
                <xsl:param name="DescriptionStyle"/>
                <xsl:param name="CurrentElement"/>
    	    <div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
    		<xsl:value-of select="ddwrt:FormatDate(string(atom:updated),number($rss_LCID),3)"/>
                    <xsl:choose>
                        <xsl:when test="string-length(atom:summary) &gt; 0">
                            <xsl:variable name="SafeHtml">
                                <xsl:call-template name="GetSafeHtml">
                                    <xsl:with-param name="Html" select="atom:summary"/>
                                </xsl:call-template>
                            </xsl:variable>
                             - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
                        </xsl:when>
                        <xsl:when test="string-length(atom:content) &gt; 0">
                            <xsl:variable name="SafeHtml">
                                <xsl:call-template name="GetSafeHtml">
                                    <xsl:with-param name="Html" select="atom:content"/>
                                </xsl:call-template>
                            </xsl:variable>
                             - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
                        </xsl:when>
                    </xsl:choose>
    		    <div class="description">
    		        <a href="{ddwrt:EnsureAllowedProtocol(string(atom:link/@href))}">More...</a>
    	        </div>
            </div>
            </xsl:template>
    
            <xsl:template name="ATOM2MainTemplate" 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">
                <xsl:variable name="Rows" select="atom2:entry"/>
                <xsl:variable name="RowCount" select="count($Rows)"/>
                <div class="slm-layout-main box box-ipr" >
                <div class="groupheader item medium">                
                    <a href="{ddwrt:EnsureAllowedProtocol(string(atom2:link/@href))}">
                        <xsl:value-of select="atom2:title"/>
                    </a>
    				
                </div>
                <xsl:call-template name="ATOM2MainTemplate.body">
                    <xsl:with-param name="Rows" select="$Rows"/>
                    <xsl:with-param name="RowCount" select="count($Rows)"/>
                </xsl:call-template>
    			
    			<a class="block-link" href="http://investors.contoso.com/Media-Center/Press-Releases/default.aspx">PRESS RELEASE ARCHIVE</a>
                </div>
    			
            </xsl:template>
    
            <xsl:template name="ATOM2MainTemplate.body" 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">
                <xsl:param name="Rows"/>
                <xsl:param name="RowCount"/>
                <xsl:for-each select="$Rows">
                    <xsl:variable name="CurPosition" select="position()" />
                    <xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
                    <xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
                    <xsl:if test="($CurPosition &lt;= $rss_FeedLimit)">
    				
                         <div class="custom-link-item">
                            <div class="arrow_box dateIcon">
    							<div>
    								<xsl:if test="$rss_ExpandFeed = true()">
    									<xsl:call-template name="ATOM2MainTemplate.description">
    										<xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
    										<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
    									</xsl:call-template>
    								</xsl:if>
    							</div>
    							<div>
    								<xsl:if test="$rss_ExpandFeed = false()">
    									<xsl:call-template name="ATOM2MainTemplate.description">
    										<xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
    										<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
    									</xsl:call-template>
    								</xsl:if>
    							</div>
    						</div>	
    						<div class="custom-link-item-content">        
    							<a style="font-size:17px;color:#4d4d4d;" href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >
    								<xsl:value-of select="atom2:title"/>
    							</a>
    						</div>
                        </div>
    					
    		</xsl:if>
                </xsl:for-each>
            </xsl:template>
    
    	<xsl:template name="ATOM2MainTemplate.description" 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">
                <xsl:param name="DescriptionStyle"/>
                <xsl:param name="CurrentElement"/>
    	    <div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
    		    <xsl:value-of select="ddwrt:FormatDate(string(atom2:updated),number($rss_LCID),3)"/>
                    <xsl:choose>
                        <xsl:when test="string-length(atom2:summary) &gt; 0">
                            <xsl:variable name="SafeHtml">
                                <xsl:call-template name="GetSafeHtml">
                                    <xsl:with-param name="Html" select="atom2:summary"/>
                                </xsl:call-template>
                            </xsl:variable>
                             - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
                        </xsl:when>
                        <xsl:when test="string-length(atom2:content) &gt; 0">
                            <xsl:variable name="SafeHtml">
                                <xsl:call-template name="GetSafeHtml">
                                    <xsl:with-param name="Html" select="atom2:content"/>
                                </xsl:call-template>
                            </xsl:variable>
                             - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
                        </xsl:when>
                    </xsl:choose>
    		    <div class="description">
        		    <a href="{ddwrt:EnsureAllowedProtocol(string(atom2:link/@href))}">More...</a>
    	        </div>
            </div>
            </xsl:template>
    
            <xsl:template name="GetSafeHtml">
                <xsl:param name="Html"/>
                <xsl:choose>
                    <xsl:when test="$rss_IsDesignMode = 'True'">
                         <xsl:value-of select="$Html"/>
                    </xsl:when>
                    <xsl:otherwise>
                         <xsl:value-of select="rssaggwrt:MakeSafe($Html)"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:template>
    
    </xsl:stylesheet>


    • Edited by ran009 Friday, March 24, 2017 8:13 PM
    Wednesday, March 22, 2017 10:35 PM

All replies

  • Hello! Any thoughts please?

    Thanks.

    Thursday, March 23, 2017 7:04 PM
  • Hi,

    Instead of using XSL(which is troublesome to develop and maintain) to customize a list view, I would suggest you insert the corresponding Calendar list view part into the page and then do your customization on the view.

    If you may have specific requirement on the list view design, you can also build a custom view page with the help of JavaScript, which is more recommended in the modern web design.

    Please let me know if there is any doubt about my suggestions, or you can talk more about your requirement here, let’s see if there would be any better and handy solution for you.

    Best regards,

    Patrick Liang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, March 24, 2017 6:00 AM
    Moderator
  • Hi Patrick

    I am not sure if JavaScript can do that, (regardless I do not know JavaScript).

    I just updated my question with an image to clarify what I need.

    Any thoughts?

    Thanks.

    Friday, March 24, 2017 8:15 PM
  • Hi,

    Yes, this can be achieved using JavaScript with JavaScript Client Object Model.

    With JavaScript Client Object Model, we can get the data we need from SharePoint lists/libraries.

    JavaScript makes it easier to modify HTML source code to implement the style you want.

    Best regards,

    Patrick Liang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, March 29, 2017 9:53 AM
    Moderator
  • Hi Patrick

    As am not a JS programmer myself, so cannot come up with the code.
    I was hoping that if someone can suggest an edit in the XSL code I pasted above, that can be great!

    Any help will be appreciated.

    Thanks.

    Wednesday, March 29, 2017 10:30 PM