473,769 Members | 4,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(f ileName+".xml") ;
XslTransform transForm = new XslTransform();

// here's where i load the .xsl in from the assembly if you do a
// System.Windows. Forms.MessageBo x.Show(sr2.Read ToEnd(),""); you will
// see all of the .xsl data properly loaded
Stream s =
typeof(_xmlData ).Assembly.GetM anifestResource Stream("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("XSL TData.html",Fil eMode.Create);
XPathNavigator nav = doc.CreateNavig ator();
transForm.Trans form(nav,null,f s);

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 2152
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(file Name);
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(n ew 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(file Name);
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
1917
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
2933
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 this, and came across a problem that I haven't been able to solve elegantly. The problem is to find "linker" vertexes that a pair of verteces from a pre-defined set. For example, if the graph verteces represent cities and edges represent flights...
4
3170
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 particular tag, and was also pretty sure that they wanted the following <ul><li>two</li><li>items</li></ul> to appear as a list. To make matters worse <sarcastic>how could this be worse?</sarcastic>, the XHTML can be mixed with our own tags.</note>
3
1760
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 and attributes from the source XML into the output using simple "identity" like XSLT: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/>
4
4823
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 transform via code? Any examples would be great.
7
1281
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, it bums out with a general exeption with no message ). It creates the Ouput.html, but errors and does not fill it with HTML.
3
1399
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
2656
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 "database frontend" type of intranet application. The existing table-display code consists of a mountain of very clever but extremely brittle spaghetti-javascript, which I'm planning to replace with XSLT transformations. At present I'm still...
8
15902
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 case that i don't know how to solve, I need to concat a string from multiple childs into a standard way, the following is an example of the source and the target XML.
21
4609
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 validator does not tolerate XML-style empty tags. It seems serving XHTML to the browser is of no advantage and can cause serious problems if the browser does not understand the difference. This raises the question of downgrading XHTML to HTML. I could...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.