Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XSLT Transformation, invalid class string XSLT Transformation, invalid class stringTo: NULL Date: 11/3/2007 12:16:00 PM
Hi Guys,
In order to sort an RSS feed i've been trying to get a date sort
function to work. I'm calling a piece of vb script to do that and when
debugging the xslt in vs2005 the output is as i expected.
However, i cant get this to work in javascript. It keeps throwing an
"invalid class string" exception when i load the stylesheet. Without
the vb script in the xslt all works fine too, so something must be
going wrong in there i recon.
I hope u guys can help me out on this. Here´s some code:
** RSS.xml **
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet title="XSL_formatting" type="text/xsl"
href="stylesheet.xsl"?>
<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
<channel>
....
<item>
<title>Air France strike chaos continues</title>
<description>More travel chaos is expected at ...</description>
<link>http://news.bbc.co.uk/go/rss/-/2/hi/europe/7065944.stm</link>
<guid isPermaLink="false">...</guid>
<pubDate>Sun, 28 Oct 2007 14:37:45 GMT</pubDate>
<category>Europe</category>
<media:thumbnail width="66" height="49".... />
</item>
...
</channel>
</rss>
** SORT.xslt **
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:util="urn:myScripts"
xmlns:xhtml='http://www.w3.org/1999/xhtml'
xmlns:media="http://search.yahoo.com/mrss/"
exclude-result-prefixes="xsl xhtml msxsl utility">
<msxsl:script language="vb" implements-prefix="util">
function GetDate(pubDate As String)
Try
Dim myDate as Date = CDate(pubDate)
Return myDate.ToString("yyyyMMddHHmmss")
Catch
End Try
end function
</msxsl:script>
<xsl:output method="xml" version="1.0" encoding="UTF-8" />
<xsl:template match="/rss/channel">
<xsl:for-each select="item">
<xsl:sort order="ascending" select="util:GetDate(./pubDate)" />
<p class="text">
<xsl:apply-templates select="description" />
</p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
** JAVASCRIPT **
...
var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
xslDoc.async = false;
xslDoc.load("sort.xslt");
xslt.stylesheet = xslDoc;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.load(g_rssFeed);
...
The code breaks at:
xslt.stylesheet = xslDoc;
Throwing an "invalid class string" exception.
Anyone? :)
Regards,
Robbert.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
