需要隐藏从其他来源自动生成的标签

发布于 2024-10-24 03:00:26 字数 24927 浏览 1 评论 0原文

我需要放置显示摩根大通股票行情的 RSS 查看器 Web 部件。

我找到的 RSS 提要是:http://www.quoterss.com/quote.php?symbol=JPM&format=0&uid=1280868448 但他的提要还检索不必要的链接,例如Facebook作弊代码、Iphone作弊代码...我想隐藏那些不必要的作弊代码链接。

下面提供了具有上述提要的 RSS 查看器 Web 部件的 XSLT。

<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" >            
            <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>
            </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="item link-item" >
                            <a href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >
                                <xsl:value-of select="title"/>
                            </a>
                            <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>                            
                </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(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="no"/> 
                </xsl:if>
             <div class="description"> 
                <a href="{ddwrt:EnsureAllowedProtocol(string(link))}">More...</a> 
             </div> 
        </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" >
            <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>
            </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" >
                        <a 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(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" >
            <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>
            </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="item link-item" >
                                <a href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >
                                    <xsl:value-of select="atom:title"/>
                                </a>
                            <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>
                            <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>
        </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(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" >
            <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>
            </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="item link-item" >
                                <a href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >
                                    <xsl:value-of select="atom2:title"/>
                                </a>
                            <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>
                            <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>
        </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(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>

从上面的 XSLT 我可以看出 HTML 是自动生成的,这是通过

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

如果我朝着正确的方向前进,如果 HTML 是自动生成的,我将无法使用 XSL 隐藏那些不必要的链接。所以我尝试使用 JQuery 来做到这一点。

自动生成的HTML如下。

<table border=0 cellspacing=0 cellpadding=1 width=150><tr><td bgcolor="#000000"> <table border=0 cellspacing=0 cellpadding=0 width="100%" class="pq_all"> <tr bgcolor="#DDDDDD"><td width="100%" align=CENTER colspan=3 nowrap> </td></tr> <tr bgcolor="#EEEEEE"><td width="100%" nowrap>&nbsp;Last </td> <td width="40%" nowrap align=right>45.74</td></tr> <tr bgcolor="#DDDDDD"><td width="100%" nowrap>&nbsp;Change </td> <td width="40%" nowrap align=right><font color="#409940">+1.18</font>&nbsp;</td></tr> <tr bgcolor="#EEEEEE"><td width="100%" nowrap>&nbsp;% Change </td> <td width="40%" nowrap align=right><font color="#409940">2.65%</font>&nbsp;</td></tr> <tr bgcolor="#DDDDDD"><td width="100%" nowrap>&nbsp;Volume </td> <td width="40%" nowrap align=right>77445704&nbsp;</td></tr> <tr bgcolor="#EEEEEE"><td width="100%" nowrap>&nbsp;Last </td> <td width="40%" nowrap align=right>4:02pm&nbsp;</td></tr> </table> </td></tr></table> _<div><a href="http://cheatcodes.com/iphone/">iPhone Cheat Codes</a></div>_

我想隐藏包含对 http://cheatcodes.com/iphone/ 的引用的链接,该链接以斜体显示为“iPhone 作弊代码”。 通过使用 JQuery 我尝试过

$('a[href*=http://cheatcodes.com]').hide() 

……但这不起作用。我还尝试深入研究它,当我尝试使用 JQuery 获取 href 标记的值时,

alert($('a[href*=http://cheatcodes.com]')).attr(href)

结果显示未定义。此外,作弊代码的链接也会每天更新...我唯一发现的是 URL 的这一部分保持不变是:http://cheatcodes.com/... 根据我对 HTML 的理解自动生成 JQuery 无法隐藏该 Anchor 标记。

我有点陷入这个困境。如果有人告诉我该行为的确切原因和解决方案,我真的很感激。另外,如果有人知道其他 RSS 源,我可以在其中获取摩根大通的股票报价,这将有助于解决这一问题。

谢谢, 达瓦尔

I need to put RSS viewer web part that shows Stock Quotes for JPMorgan Chase.

RSS feed that I found for that is : http://www.quoterss.com/quote.php?symbol=JPM&format=0&uid=1280868448 but his feed also retrives unnecessary links such as FaceBook cheat codes, Iphone cheat codes ... I want to hide those unnecessary links for the cheat codes.

XSLT for RSS viewer web part having above mentioned feed is provided below.

<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" >            
            <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>
            </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 <= $rss_FeedLimit)">
                    <div class="item link-item" >
                            <a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
                                <xsl:value-of select="title"/>
                            </a>
                            <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>                            
                </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) > 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(dc:date,number($rss_LCID),3)"/>
                    </xsl:otherwise>
                </xsl:choose>

                <xsl:if test="string-length(description) > 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="no"/> 
                </xsl:if>
             <div class="description"> 
                <a href="{ddwrt:EnsureAllowedProtocol(string(link))}">More...</a> 
             </div> 
        </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" >
            <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>
            </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 <= $rss_FeedLimit)">
                    <div class="item link-item" >
                        <a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
                            <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(dc:date,number($rss_LCID),3)"/>
                <xsl:if test="string-length(rss1:description) > 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" >
            <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>
            </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 <= $rss_FeedLimit)">
                            <div class="item link-item" >
                                <a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
                                    <xsl:value-of select="atom:title"/>
                                </a>
                            <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>
                            <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>
        </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(atom:updated,number($rss_LCID),3)"/>
                <xsl:choose>
                    <xsl:when test="string-length(atom:summary) > 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) > 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" >
            <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>
            </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 <= $rss_FeedLimit)">
                     <div class="item link-item" >
                                <a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
                                    <xsl:value-of select="atom2:title"/>
                                </a>
                            <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>
                            <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>
        </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(atom2:updated,number($rss_LCID),3)"/>
                 <xsl:choose>
                    <xsl:when test="string-length(atom2:summary) > 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) > 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>

From the above XSLT I was able to figure out that HTML is generated automatically, that is done by

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

If I am going in the right direction, if HTML is generated automatically, I will not be able to hide those unnecessary links using XSL. So I tried to do that using JQuery.

HTML that is generated automatically is as follows.

<table border=0 cellspacing=0 cellpadding=1 width=150><tr><td bgcolor="#000000"> <table border=0 cellspacing=0 cellpadding=0 width="100%" class="pq_all"> <tr bgcolor="#DDDDDD"><td width="100%" align=CENTER colspan=3 nowrap> </td></tr> <tr bgcolor="#EEEEEE"><td width="100%" nowrap> Last </td> <td width="40%" nowrap align=right>45.74</td></tr> <tr bgcolor="#DDDDDD"><td width="100%" nowrap> Change </td> <td width="40%" nowrap align=right><font color="#409940">+1.18</font> </td></tr> <tr bgcolor="#EEEEEE"><td width="100%" nowrap> % Change </td> <td width="40%" nowrap align=right><font color="#409940">2.65%</font> </td></tr> <tr bgcolor="#DDDDDD"><td width="100%" nowrap> Volume </td> <td width="40%" nowrap align=right>77445704 </td></tr> <tr bgcolor="#EEEEEE"><td width="100%" nowrap> Last </td> <td width="40%" nowrap align=right>4:02pm </td></tr> </table> </td></tr></table> _<div><a href="http://cheatcodes.com/iphone/">iPhone Cheat Codes</a></div>_

I want to hide the link containing reference to the http:.//cheatcodes.com/iphone/ which is rendered as "iPhone Cheat Codes" in ITALIC.
By using JQuery I tried

$('a[href*=http://cheatcodes.com]').hide() 

...... but this doesnt work. I also tried to dig into it and when I tried to fetch the value of href tag using

alert($('a[href*=http://cheatcodes.com]')).attr(href)

JQuery shows me undefined as a result. Also the links for the cheat codes also get updated on daily basis ... only thing that I found is this portion of the URL remains same is: http:.//cheatcodes.com/... As per my understanding as the HTML is generated automatically JQuery is not able to hide that Anchor tag.

I am kind of stucked into this. If some one gives me light on the exact cause of the behaviour and the solution, I really would appreciate it. Also if some one knows about other RSS feed where I can get the stock quote for the JPMorgan Chase would be helpfull to overcome this issue.

Thanks,
Dhaval

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟燃烟灭 2024-10-31 03:00:26

您是否尝试过 alert($('a[href*="http://cheatcodes.com"]')).attr(href)

Did you try alert($('a[href*="http://cheatcodes.com"]')).attr(href)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文