0
我一直試圖在xslt 1.0中使用jquery,但是我無法讓它工作。 我是xslt的新手,不確定如何使用它。如何在XSLT 1.0中使用jquery
我試圖封閉代碼:
<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">False</xsl:param>
<xsl:output method="html"/>
<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" >
<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>
<script type="text/javascript">
<![CDATA[
$('.RssNewContent1').each(function()
{
//alert("test");
var height = parseInt($(this).css("height"));
var content = $(this).html();
while (this.scrollHeight > height)
{
content = content.replace(/\s+\S*$/, "");
$(this).html(content + " " + "...");
}
});
]]>
</script>
</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:if test="($CurPosition <= $rss_FeedLimit)">
<div class="RssNewContent1" >
<a href = "{link}" target="_blank">
<xsl:value-of select="title" />
</a>
<xsl:value-of disable-output-escaping="yes" select="string(description)" />
</div>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
任何幫助將不勝感激! 在此先感謝!
我個人的建議:不要使用XSLT。不同瀏覽器的實現中的錯誤沒有被修復,因爲它被認爲是一種死亡技術。相反,使用AJAX並將所需的數據從XML解析到您自己的HTML文檔中。 – Blazemonger
@NewGirlInCalgary它是如何失敗的? – Louis
@Louis它沒有做任何事情。它甚至不顯示警告框。如果我刪除所有內容並只寫alert();它甚至不起作用。我不確定我做錯了什麼。 – NewGirlInCalgary