Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Loading Embedded Resources/Files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rasheed - 09 Oct 2007 20:31 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.