home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / mstools / MSNScreenSaverSetup_1_00_0831_0.exe / MSNScreenSaver.msi / rss.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-08-10  |  6.8 KB  |  162 lines

  1. <?xml version='1.0'?>
  2. <!-- Style RSS so that it is readable. -->
  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  4. xmlns:MSFT="http://www.microsoft.com"
  5. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  6. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  7. xmlns:rss1="http://purl.org/rss/1.0/"
  8. xmlns:rss09="http://my.netscape.com/rdf/simple/0.9/"
  9. xmlns:dc="http://purl.org/dc/elements/1.1/"
  10. exclude-result-prefixes="MSFT msxsl rdf rss1 rss09 dc">
  11.  
  12. <xsl:param name="locked" select="'no'" />
  13.  
  14. <msxsl:script language="VBScript" implements-prefix="MSFT">
  15. <![CDATA[
  16. Function stripChars(xml, textlength)
  17.     fullString = xml.nextNode.text
  18.     fullString=Replace(fullString, Chr(10), "")
  19.     fullString=Replace(fullString, """", "")
  20.     fullString=Replace(fullString, "'", "")
  21.  
  22.     Set RegularExpressionObject = New RegExp
  23.     With RegularExpressionObject
  24.         .IgnoreCase = True
  25.         .Global = True
  26.     End With
  27.  
  28.     '' Need to delete the SCRIPT tags first
  29.     RegularExpressionObject.Pattern = "<\s*script(?:.*?)/script\s*>"
  30.     Set expressionMatch = RegularExpressionObject.Execute(fullString)
  31.     If Not (expressionMatch.Count = 0) Then
  32.         maxMatch = expressionMatch.Count
  33.         For matchLoop = maxMatch-1 to 0 Step-1
  34.             Set expressionMatched = expressionMatch(matchLoop)
  35.             fullString = Left(fullString, expressionMatched.FirstIndex) & " " & Mid(fullString, expressionMatched.FirstIndex + expressionMatched.Length + 1)
  36.         Next
  37.     End If
  38.  
  39.     '' Now everything else.
  40.     RegularExpressionObject.Pattern = "(</?([^!][a-zA-Z0-9]*)\s*(?:.*?)>)"
  41.     Set expressionMatch = RegularExpressionObject.Execute(fullString)
  42.     If Not (expressionMatch.Count = 0) Then
  43.         maxMatch = expressionMatch.Count
  44.         For matchLoop = maxMatch-1 to 0 Step-1
  45.             Set expressionMatched = expressionMatch(matchLoop)
  46.             thisTag = expressionMatched.SubMatches(1)
  47.             fullString = Left(fullString, expressionMatched.FirstIndex) & " " & Mid(fullString, expressionMatched.FirstIndex + expressionMatched.Length + 1)
  48.         Next
  49.     End If
  50.  
  51.     Set RegularExpressionObject = nothing
  52.  
  53.     If Len(fullString) > textLength Then
  54.         fullString=Left(fullString, textlength) & "..."
  55.     End If
  56.  
  57.     If Trim(fullString) = "" Then
  58.         fullString = "There is no further information."
  59.     End If
  60.  
  61.     stripChars = fullString
  62. End Function
  63.  
  64. Function safeUrl(link)
  65.  
  66.     url = link.nextNode.text
  67.     
  68.     url = Replace(url, "<", "")
  69.     url = Replace(url, ">", "")
  70.     url = Replace(url, """", "")
  71.     url = Replace(url, "'", "")
  72.     url = Replace(url, ";", "")
  73.     url = Replace(url, "(", "")
  74.     url = Replace(url, ")", "")
  75.     
  76.     safeUrl = url
  77. End Function
  78. ]]>
  79. </msxsl:script>
  80.  
  81. <xsl:template match="/">
  82.     <xsl:apply-templates select="/rss | /rdf:RDF" />
  83. </xsl:template>
  84.  
  85. <xsl:template match='rss | rdf:RDF'>
  86.     <xsl:variable name="rssversion" select="@version" />
  87.     <div class="rssContainer">
  88.         <span class="rssImage" id="rssImage"><img id="rssDummyImage" align="absmiddle" src="GIF/BLANK_GIF" onload="setRssTransparency()" /></span>
  89.         <div class="rssUpdatedContainer"><xsl:if test="channel/pubDate != ''">Updated: <xsl:value-of select="channel/pubDate" /></xsl:if> </div>
  90.         <xsl:if test="rss1:channel/dc:rights != ''">
  91.             <div onmouseout="hideCopyright();" class="rssCopyrightContainer">
  92.                 <xsl:attribute name="onmouseover">doCopyright(event, '<xsl:value-of select="rss1:channel/dc:rights" />');</xsl:attribute>
  93.                 <xsl:value-of select="rss1:channel/dc:rights" />
  94.             </div>
  95.         </xsl:if>
  96.         <xsl:if test="channel/copyright != ''">
  97.             <div onmouseout="hideCopyright();" class="rssCopyrightContainer">
  98.                 <xsl:attribute name="onmouseover">doCopyright(event, '<xsl:value-of select="channel/copyright" />');</xsl:attribute>
  99.                 <xsl:value-of select="channel/copyright" />
  100.             </div>
  101.         </xsl:if> 
  102.         <div>
  103.             <xsl:attribute name="class">
  104.             <xsl:choose>
  105.                 <xsl:when test="(channel/copyright='' or not(channel/copyright)) and (rss1:channel/dc:rights='' or not(rss1:channel/dc:rights))">rssHeader</xsl:when>
  106.                 <xsl:otherwise>rssHeaderC</xsl:otherwise>
  107.             </xsl:choose>
  108.             </xsl:attribute>
  109.             <xsl:value-of select="channel/title" /><xsl:value-of select="rss1:channel/rss1:title" /><xsl:value-of select="rss09:channel/rss09:title" /></div>
  110.             <div class="rssLinkContainer">
  111.                 <ul class="rssLinkList">
  112.                     <xsl:apply-templates select="channel/item[position() < 11] | rss1:item[position() < 11] | rss09:item[position() < 11]" mode="decide" />
  113.                 </ul>
  114.             <div id="tooltip" style="display:none;"></div>
  115.         </div>
  116.         <div id="copyrighttooltip" style="display:none;"></div>
  117.     </div>
  118. </xsl:template>
  119.  
  120. <xsl:template match="item | rss1:item | rss09:item" mode="decide">
  121.     <xsl:variable name="link"><xsl:value-of select="link" /><xsl:value-of select="rss1:link" /><xsl:value-of select="rss09:link" /></xsl:variable>
  122.     <xsl:variable name="description"><xsl:value-of select="description" /><xsl:value-of select="rss1:description" /><xsl:value-of select="rss09:description" /></xsl:variable>
  123.     <xsl:variable name="title"><xsl:value-of select="title" /><xsl:value-of select="rss1:title" /><xsl:value-of select="rss09:title" /></xsl:variable>
  124.     <li class="rssLinkList">
  125.     <xsl:choose>
  126.             <xsl:when test="$locked='yes' or $link=''">
  127.                 <span onmouseout="hideTooltip();" class="rssLinkList">
  128.                 <xsl:apply-templates select="." mode="details">
  129.                     <xsl:with-param name="link" select="$link" />
  130.                     <xsl:with-param name="description" select="$description" />
  131.                     <xsl:with-param name="title" select="$title" />
  132.                 </xsl:apply-templates>
  133.                 </span>
  134.             </xsl:when>
  135.             <xsl:otherwise>
  136.                 <a onmouseout="hideTooltip();" class="rssLinkList">
  137.                 <xsl:attribute name="href">javascript:LaunchUrl('<xsl:value-of select="MSFT:safeUrl($link)" />');</xsl:attribute>
  138.                 <xsl:apply-templates select="." mode="details">
  139.                     <xsl:with-param name="link" select="$link" />
  140.                     <xsl:with-param name="description" select="$description" />
  141.                     <xsl:with-param name="title" select="$title" />
  142.                 </xsl:apply-templates>
  143.                 </a>
  144.             </xsl:otherwise>
  145.     </xsl:choose>
  146.    </li>
  147. </xsl:template>
  148.  
  149. <xsl:template match="item | rss1:item | rss09:item" mode="details">
  150.     <xsl:param name="link" />
  151.     <xsl:param name="description" />
  152.     <xsl:param name="title" />
  153.     <xsl:if test="$description">
  154.         <xsl:attribute name="onmouseover">doTooltip(event, '<xsl:value-of select="MSFT:stripChars($description, 500)" />');</xsl:attribute>
  155.     </xsl:if>
  156.     <xsl:choose>
  157.         <xsl:when test="$title='' or not($title)"><xsl:value-of select="MSFT:stripChars($description, 50)" /></xsl:when>
  158.         <xsl:otherwise><xsl:value-of select='$title'/></xsl:otherwise>
  159.     </xsl:choose>
  160. </xsl:template>
  161.  
  162. </xsl:stylesheet>