473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

XSLT Transform problems..embed -vs- file access

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.GetManifestResourceStrea m("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.
Nov 15 '05 #1
2 2132
Greg Merideth wrote:
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.


Looks like some pieces are loaded related to "current URL".

You do unfair comparation between file and resource approach.
Try change file read like this and see if it still works:

FileStream fs = new FileStream(fileName);
StreamReader sr3 = new StreamReader(fs);
transForm.Load(sr3.ReadToEnd());

Vadim Chekan.

Nov 15 '05 #2
Solved my own problem.

I saw what you meant by the transform.load was looking for a filename
not a string a of XML data so I worked it to

transForm.Load(new XmlTextReader(new StringReader(sr.ReadToEnd())));

passing in the xml as a new filestream and now it works fine. So I can
use an embedded XSL file and perform XSLT transforms without external files.
Vadim Chekan wrote:
Greg Merideth wrote:
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.

Looks like some pieces are loaded related to "current URL".

You do unfair comparation between file and resource approach.
Try change file read like this and see if it still works:

FileStream fs = new FileStream(fileName);
StreamReader sr3 = new StreamReader(fs);
transForm.Load(sr3.ReadToEnd());

Vadim Chekan.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ola Natvig | last post by:
Anybody out there who knows if the 4suite implementation of XSLT are a threadsafe one? -- -------------------------------------- Ola Natvig <ola.natvig@infosense.no> infoSense AS / development
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
3
by: Alex | last post by:
I stumbled upon this while developing a custom XPathNavigator. It appears that copy action for attributes is broken in the .net framework XSLT processor. The intent was to just copy the entities...
4
by: schneider | last post by:
Anyone know if there is a way to dynamicly create a Xslt template/s and use them as an xml transform with-out use files for the Xslt? All the methods I see use files. I want to create a Xslt...
7
by: One Handed Man \( OHM - Terry Burns \) | last post by:
I've been battling with this stupid problem for hours now. WebApp: Trying to do a simple transformation using XSLT to a Web Page, but it just failes without an error message ( In other words,...
3
by: Sekhar | last post by:
Hi all I am trying to embed a user control into an XSLT.. Can something like be done?? If not, any other better alternative? Thanks Sekhar
6
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a...
8
by: Hercules Dev. | last post by:
Hi all, I'm new in xslt and xpath, so my question might be simple but i'm learning. I have an XML document and need to transform it into another XML, I use xslt and it works, but there is a...
21
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
It is common knowledge that XHTML is better HTML and you can serve XHTML content as HTML. However, the second statement is incorrect, for various reasons; it is enough to say that the HTML...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.