如何在XSLT1.0中使用Jquery
我一直试图在XSLT1.0中使用jquery,但无法使其正常工作。 我是xslt新手,不知道如何使用它 我试过附上的代码:如何在XSLT1.0中使用Jquery,jquery,xml,rss,xslt-1.0,Jquery,Xml,Rss,Xslt 1.0,我一直试图在XSLT1.0中使用jquery,但无法使其正常工作。 我是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.micros
<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>
5.
假的
1033
RSS_查看器_网页部件
左边
假的
高度)
{
content=content.replace(/\s+\s*$/,“”);
$(this.html(content++…);
}
});
]]>
任何帮助都将不胜感激!!
提前谢谢
<script type="text/javascript">
//<xsl:comment><![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 + " " + "...");
}
});
//]]></xsl:comment>
</script>
//高度)
{
content=content.replace(/\s+\s*$/,“”);
$(this.html(content++…);
}
});
//]]>
我个人的建议:不要使用XSLT。由于它被认为是一种过时的技术,所以不同浏览器实现中的bug没有得到修复。相反,使用AJAX并将所需数据从XML解析到您自己的HTML文档中。@NewGirlInCalgary它到底是如何失败的?@Louis它什么都不做。它甚至不向我显示警报框。如果我删除所有内容并只写alert();它甚至不起作用。我不确定我做错了什么。@Blazemonger我正在sharepoint 2007中使用RSS Web部件。此XSLT来自该Web部件。我需要编辑XSLT并进行一些修改。因此,我无法编写自己的ajax代码来解析RSS源。@NewGirlInCalgary“它什么都不做”对我来说意味着转换的结果是一个空字符串。如果是这样的话,那么您的问题就比如何使用XSLT生成jQuery代码要广泛得多。