Hi ,
Requirement is, I have to load my Xslt file into Exe/DLL.
I have created one .Xslt file and C# code for the same to produce
on .Xml file, like this:
System.Xml.XPath.XPathDocument Xmlpath = new
System.Xml.XPath.XPathDocument(filename);
XslTransform xsl = new XslTransform();
Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
("SolutionNameSpaceName.FormatConvertion.xslt");
System.Xml.XmlReader xmlReader = new System.Xml.XmlTextReader(xmlStrea
m );
xsl.Load(xmlReader);
XmlTextWriter textWriter = new XmlTextWriter(OutputPath +
"OutputFile.xml ", UTF8Encoding .Defaul t);
xsl.Transform(Xmlpath, list, textWriter);
My problem is with this statement:
Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
("SolutionNameSpaceName.FormatConvertion.xslt");
I have given my Application nameSpace "." Xslt filename but it returns
null into xmlStream.
For more informaton: I have read some information regarding
http://www.aisto.com/roeder/dotnet/ assembly Reflector, but still I
am unable to do this.
By using Reflector I am unable to see the Xslt file information after
loading the my solution DLL.
thanks in advance,
regards
Rs
harborsparrow - 12 Oct 2007 04:15 GMT
Something like this code should work, where xsltURL is a filepath like
"c:/rss.xsl":
public static string runTransform(string sourceURL, string
xsltURL)
{
//source
XmlTextReader reader = new XmlTextReader(sourceURL);
XmlDataDocument document = new XmlDataDocument();
document.Load(reader);
//target
StringWriter stw = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stw);
xmlTextWriter.Formatting = Formatting.Indented;
//transformation
XslCompiledTransform xslt1 = new XslCompiledTransform();
xslt1.Load(xsltURL);
// execute the transform and output the results to a file.
xslt1.Transform(sourceURL, xmlTextWriter);
//return HTML file
return stw.GetStringBuilder().ToString();
}
> Hi ,
>
[quoted text clipped - 31 lines]
> regards
> R s
Mark Dykun - 17 Oct 2007 20:24 GMT
Rasheed,
Is it possible that you did not make the file an embedded resource. I am
guessing that this is the reason that you could not see the xslt file in the
assembly manifest.
Mark Dykun
VP Mobile and Integration Services, Castle CRM
> Hi ,
>
[quoted text clipped - 32 lines]
> regards
> Rs