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