473,785 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my case i have everything in string

in C# how do i transform an xml document with an xsl document when my xml
document is a string and my xsl document is a string? the msdn examples only
show how to do it with steams and files. in my case i have everything in
string
Nov 17 '05 #1
3 1807
Seems like your whole posting is on subject line. Is that what subject text
box is used for?
"Daniel" <so************ *******@yahoo.c om> wrote in message
news:um******** ******@TK2MSFTN GP10.phx.gbl...
in C# how do i transform an xml document with an xsl document when my xml
document is a string and my xsl document is a string? the msdn examples
only
show how to do it with steams and files. in my case i have everything in
string

Nov 17 '05 #2
You can create an XmlReader from a TextReader, then use that for both
the document and the transform:

System.IO.TextR eader docTextReader = new
System.IO.Strin gReader(xmlStri ng);
System.Xml.XmlR eader docReader = new
System.Xml.XmlR eader(docTextRe ader);
System.Xml.XPat hDocument doc = new System.Xml.XPat hDocument(docRe ader);
System.IO.TextR eader xslTextReader = new
System.IO.Strin gReader(xslStri ng);
System.Xml.XmlR eader xslReader = new
System.Xml.XmlR eader(xslTextRe ader);
System.Xml.Xsl. XslTransform transform = new
System.Xml.Xsl. XslTransform();
transform.Load( xslReader);
XmlReader transformedXmlR eader = transform.Trans form(doc, new
System.Xml.Xsl. XsltArgumentLis t(), new XmlUrlResolver( ));

I've used fully-qualified names everywhere so that you can see where
the classes are defined. Of course, you would use "using" directives
and simple class names instead.

Nov 17 '05 #3
You can create an XmlReader from a TextReader, then use that for both
the document and the transform:

System.IO.TextR eader docTextReader = new
System.IO.Strin gReader(xmlStri ng);
System.Xml.XmlR eader docReader = new
System.Xml.XmlR eader(docTextRe ader);
System.Xml.XPat hDocument doc = new System.Xml.XPat hDocument(docRe ader);
System.IO.TextR eader xslTextReader = new
System.IO.Strin gReader(xslStri ng);
System.Xml.XmlR eader xslReader = new
System.Xml.XmlR eader(xslTextRe ader);
System.Xml.Xsl. XslTransform transform = new
System.Xml.Xsl. XslTransform();
transform.Load( xslReader);
XmlReader transformedXmlR eader = transform.Trans form(doc, new
System.Xml.Xsl. XsltArgumentLis t(), new XmlUrlResolver( ));

I've used fully-qualified names everywhere so that you can see where
the classes are defined. Of course, you would use "using" directives
and simple class names instead.

Nov 17 '05 #4

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

Similar topics

6
5564
by: Richard Koch | last post by:
Hi folks! I want to transform a XML document using a XLS stylesheet (transformNodeToObject()). I did my code as the MSDN examples suggest, the transformation succeeds S_OK. Unfortunately, the XML result doc is not valid, e.g. get_xml() fails, the string is empty. Does that sound familiar to anyone? If yes, thanks for your help! Richard
13
9651
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
1
1654
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my case i have everything in string
5
3610
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an instruction document (not data based) - same as using an xml web control. The resulting html is on the client? but what about the server side of things? Trying to figure out how to change and save the xmlDocument. It I put a button OUTSIDE of the...
6
2491
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process I've hit a snag. How do I resolve multiple external references? The transform method on a stylesheet only takes one resolver, not an array Stephen
6
1656
by: Bill Cohagan | last post by:
I've got a c# app that does some transforms using XSL files that are stored as Embedded Resources in the app. That turns out to be significant; i.e., the problem I've encountered goes away if I reference the XSL files from the file system. The problem is that within the XSL file I have a reference to document(''), intending to "self reference" the stylesheet. As I mentioned above, this works fine as long as the stylesheet is file based;...
1
1384
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my case i have everything in string
3
2134
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty string. I expected the xml to be transformed into a plain text document. Everything works fine when i transform using XmlPad. Here's the code (which does generate the Xml properly): Sample XML:
9
1585
by: Doug Stiers | last post by:
I have this vb.net (framework 1.1) code: Dim x As Xml.Xsl.XslTransform = New Xml.Xsl.XslTransform Dim xr As XmlResolver MessageBox.Show("before load") x.Load(<xsl file name>) -- THIS IS WHERE IT ERRORS -- MessageBox.Show("after load") 'do the transform x.Transform(gsXpensePath, < XML file_name>, xr)
3
302
by: Peter Row | last post by:
Hi, I have 2 XML files and 1 XSLT file. The second XML file has the following declarative 1st line: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ....the 1st one (the one to be transformed) doesn't. In the transform file I load the 2nd XML file which contains
0
9643
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7496
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
5380
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...
1
4046
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.