G
Greg Merideth
I have an XSL file that I am using to transform some XML data using this
method below. The problem is that if I use an embedded .XSL file in
the .NET assembly, I get an error indicating that the URI is invalid,
however if I open the file from the harddrive in the current directory,
it works.
Here's the method, notice that after s is loaded with the .xsl file from
the resource stream that if you do a messagebox.show with s.readtoend
you get a messagebox with all of the correct .xsl data in it, the same
data you get from the regular .load command. in the embedded version it
simply fails.
// load in the XML data file
XPathDocument doc = new XPathDocument(fileName+".xml");
XslTransform transForm = new XslTransform();
// here's where i load the .xsl in from the assembly if you do a
// System.Windows.Forms.MessageBox.Show(sr2.ReadToEnd(),""); you will
// see all of the .xsl data properly loaded
Stream s =
typeof(_xmlData).Assembly.GetManifestResourceStream("xmlData.XSLTData.xsl");
// make a stream reader
StreamReader sr2 = new StreamReader(s);
// bingo...fails here with invalid URI
transForm.Load(sr2.ReadToEnd());
// however if you do this instead it works
transForm.Load("XSLTData.xsl");
FileStream fs = new FileStream("XSLTData.html",FileMode.Create);
XPathNavigator nav = doc.CreateNavigator();
transForm.Transform(nav,null,fs);
Any idea why I can't use an embedded version?
I can whip up a quick .zip file with the source files in it if needed.
method below. The problem is that if I use an embedded .XSL file in
the .NET assembly, I get an error indicating that the URI is invalid,
however if I open the file from the harddrive in the current directory,
it works.
Here's the method, notice that after s is loaded with the .xsl file from
the resource stream that if you do a messagebox.show with s.readtoend
you get a messagebox with all of the correct .xsl data in it, the same
data you get from the regular .load command. in the embedded version it
simply fails.
// load in the XML data file
XPathDocument doc = new XPathDocument(fileName+".xml");
XslTransform transForm = new XslTransform();
// here's where i load the .xsl in from the assembly if you do a
// System.Windows.Forms.MessageBox.Show(sr2.ReadToEnd(),""); you will
// see all of the .xsl data properly loaded
Stream s =
typeof(_xmlData).Assembly.GetManifestResourceStream("xmlData.XSLTData.xsl");
// make a stream reader
StreamReader sr2 = new StreamReader(s);
// bingo...fails here with invalid URI
transForm.Load(sr2.ReadToEnd());
// however if you do this instead it works
transForm.Load("XSLTData.xsl");
FileStream fs = new FileStream("XSLTData.html",FileMode.Create);
XPathNavigator nav = doc.CreateNavigator();
transForm.Transform(nav,null,fs);
Any idea why I can't use an embedded version?
I can whip up a quick .zip file with the source files in it if needed.