SharePoint XSLT Demo

<xsl:template name="TemplateNmae" match="Row[@Style=TemplateNmae']" mode="itemstyle">
  <xsl:param name="CurPos" />
  <xsl:param name="AOI"/>
  <xsl:variable name ="MaxRows" select ="count(//Row[contains(@Canonical,concat($AOI,';'))])"></xsl:variable>
 
  
  
   <xsl:variable name="SafeLinkUrl">
     <xsl:call-template name="OuterTemplate.GetSafeLink">
      <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
     </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="DisplayTitle">
     <xsl:call-template name="OuterTemplate.GetTitle">
      <xsl:with-param name="Title" select="@Article_Title"/>
      <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
     </xsl:call-template>
    </xsl:variable>
 
    <xsl:variable name="LinkTarget">
     <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
    </xsl:variable>
    
    
    <xsl:variable name="DisplayDate">
          <xsl:call-template name="Test.GetDate">
            <xsl:with-param name="Date" select="@Date"/>
    
          </xsl:call-template>
       </xsl:variable>

    
  

   
   <xsl:if test="contains(@Canonical,concat($AOI,';'))">
   
      
   <div class="elsevier_headlines">
            <ul class="medical">
              <li>
               
               

     <!--
     <a  href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">
                   <xsl:value-of select="$DisplayTitle"/>
                 </a>
                 -->
                
                 <!-- Section to display Article Title --> 
                 <xsl:choose>
     
            <xsl:when test ="string-length(normalize-space(string($DisplayTitle)))&gt;=20">
            
            
            <a  href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">
            <xsl:value-of select="concat(substring($DisplayTitle,1,20),'...')"/>
            </a>
            
             </xsl:when>
             
            <xsl:otherwise>
            
            <a  href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">
            <xsl:value-of select="$DisplayTitle"/>
            </a>

            
            </xsl:otherwise>
     </xsl:choose>

                
                <!-- Section to display new icon per Publication date  -->
                <xsl:if test="(normalize-space(string(@Publication_Date))='') or ((number(ddwrt:FormatDateTime(string(@Publication_Date),2052,'yyyyMMdd'))&lt;=number(ddwrt:FormatDateTime(string(ddwrt:TodayIso()),2052,'yyyyMMdd'))) and (number(ddwrt:FormatDateTime(string(@Publication_Date),2052,'yyyyMMdd'))&gt;=(number(ddwrt:FormatDateTime(string(ddwrt:TodayIso()),2052,'yyyyMMdd'))-7)))">
      
      
      <img src="/News/News/Documents/new_icon.jpg"/>
                  

     </xsl:if>
               
     <!-- Section to display Publication date  -->
                 <span style="color:#808080;padding-left:45px">
                  <xsl:value-of select="$DisplayDate"></xsl:value-of>
        </span>
         


         
              </li>           
            </ul>
          </div>
         
         
          <!-- Section to display List All link  -->
  <xsl:if test ="$CurPos=10 or $MaxRows=$CurPos">

        <div class="tab_head_pad weather_padding3">
          <a  href="/News/News/Pages/News.aspx" target="{$LinkTarget}" title="{@LinkToolTip}">
            显示全部
          </a>
        </div>

  </xsl:if>
         
        </xsl:if>
 
   
  
 </xsl:template>

原文地址:https://www.cnblogs.com/dexter2003/p/2050917.html