Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET Xsl script transform results in 'System.Object' is not defined or imported
    primarykey
    data
    text
    <p>XSL noobie but uttery stuck!</p> <p>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.</p> <p>However , when i try to run this using code I get the error</p> <blockquote> <p>Predefined type 'System.Object' is not defined or imported</p> </blockquote> <p>To function to call the transform looks like this , it's pretty basic and worked before I started to use scripting</p> <blockquote> <pre><code>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,&gt; System.Text.Encoding.UTF8); transform.Transform(xmlTextReader, xmlWriter); stream.Position = 0; XmlDocument XmlDoc = new XmlDocument(); XmlDoc.Load(stream); return XmlDoc.OuterXml; } </code></pre> </blockquote> <p>The XSL transform is this.. </p> <blockquote> <pre><code>&lt;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"&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;msxsl:script implements-prefix="nlbExtension" language="C#"&gt; &lt;![CDATA[ public string FormatDateTime(string xsdDateTime, string format) { DateTime date = DateTime.Parse(xsdDateTime); return date.ToString(format); } ]]&gt; &lt;/msxsl:script&gt; &lt;xsl:template match="/"&gt; &lt;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" &lt;xsl:for-each select="./Collection/Content" &gt; &lt;url&gt; &lt;loc&gt;http://www.nlb.org&lt;xsl:value-of select="./QuickLink/text()"/&gt;&lt;/loc&gt; &lt;lastmod&gt;&lt;xsl:value-of select="./DateModified/text()" /&gt;&lt;/lastmod&gt; &lt;/url&gt; &lt;/xsl:for-each&gt; &lt;/urlset&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload