Hi
XSL noobie but uttery stuck!
I have a transform that formats a date using c# scripting function , this works fine when I am in VS 2008 and run "show xml output", the output is exactly what I want.
However , when i try to run this using code I get the error
Predefined type 'System.Object' is not defined or imported
To function to call the transform looks like this , it's pretty basic and worked before I started to use scripting
public static string RunXSLT(string xsltFile, string inputXML) { XslCompiledTransform transform = new XslCompiledTransform(); XsltSettings settings = new XsltSettings(); settings.EnableScript = true; transform.Load(xsltFile, settings, null); StringReader sReader = new StringReader(inputXML); XmlTextReader xmlTextReader = new XmlTextReader(sReader); //Create an XmlTextWriter which outputs to memory stream Stream stream = new MemoryStream(); XmlWriter xmlWriter = new XmlTextWriter(stream,> System.Text.Encoding.UTF8); transform.Transform(xmlTextReader, xmlWriter); stream.Position = 0; XmlDocument XmlDoc = new XmlDocument(); XmlDoc.Load(stream); return XmlDoc.OuterXml; }
The XSL transform is this..
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:nlbExtension="urn:nlbExtension" exclude-result-prefixes="msxsl nlbExtension"> <xsl:output method="xml" indent="yes"/> <msxsl:script implements-prefix="nlbExtension" language="C#"> <![CDATA[ public string FormatDateTime(string xsdDateTime, string format) { DateTime date = DateTime.Parse(xsdDateTime); return date.ToString(format); } ]]> </msxsl:script> <xsl:template match="/"> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" <xsl:for-each select="./Collection/Content" > <url> <loc>http://www.nlb.org<xsl:value-of select="./QuickLink/text()"/></loc> <lastmod><xsl:value-of select="./DateModified/text()" /></lastmod> </url> </xsl:for-each> </urlset> </xsl:template> </xsl:stylesheet>