473,671 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How? Writing the results of a XSL transformation to a string rather than to File

I am a bit of a newbie to C# and would like help with the following.

I am bringing in a dataset and transforming that dataset using an XSL style sheet to generate text. This text does in fact contains SQL statements (DBCC commands etc) which I want to capture and run on a SQL Server instance. At the moment I can do this by writing the result of the transformation to file and re-loading it, but would like to skip out the file and write directly into a string. How do I acheive this?

Currently my code looks like this;

{load DataSet xmltestDS with relational data}

XmlDataDocument xmlDoc = new XmlDataDocument (xmltestDS);
XslTransform xslTran = new XslTransform();
xslTran.Load("C :\\XSLTTest.xsl ");
XmlTextWriter writer = new XmlTextWriter(" C:\\XSLTTest.tx t", System.Text.Enc oding.UTF8);
xslTran.Transfo rm(xmlDoc, null, writer, null);

Thanks

Stuart
Nov 12 '05 #1
2 2015
You could try using the overload that uses the TextWriter and pass in a
StringWriter instance.

"Stuart" <Dr*******@yahX X.cXm (Replace Y with a, X with o)> wrote in message
news:AB******** *************** ***********@mic rosoft.com...
I am a bit of a newbie to C# and would like help with the following.

I am bringing in a dataset and transforming that dataset using an XSL style sheet to generate text. This text does in fact contains SQL statements
(DBCC commands etc) which I want to capture and run on a SQL Server
instance. At the moment I can do this by writing the result of the
transformation to file and re-loading it, but would like to skip out the
file and write directly into a string. How do I acheive this?
Currently my code looks like this;

{load DataSet xmltestDS with relational data}

XmlDataDocument xmlDoc = new XmlDataDocument (xmltestDS);
XslTransform xslTran = new XslTransform();
xslTran.Load("C :\\XSLTTest.xsl ");
XmlTextWriter writer = new XmlTextWriter(" C:\\XSLTTest.tx t", System.Text.Enc oding.UTF8); xslTran.Transfo rm(xmlDoc, null, writer, null);

Thanks

Stuart

Nov 12 '05 #2
You could try using the overload that uses the TextWriter and pass in a
StringWriter instance.

"Stuart" <Dr*******@yahX X.cXm (Replace Y with a, X with o)> wrote in message
news:AB******** *************** ***********@mic rosoft.com...
I am a bit of a newbie to C# and would like help with the following.

I am bringing in a dataset and transforming that dataset using an XSL style sheet to generate text. This text does in fact contains SQL statements
(DBCC commands etc) which I want to capture and run on a SQL Server
instance. At the moment I can do this by writing the result of the
transformation to file and re-loading it, but would like to skip out the
file and write directly into a string. How do I acheive this?
Currently my code looks like this;

{load DataSet xmltestDS with relational data}

XmlDataDocument xmlDoc = new XmlDataDocument (xmltestDS);
XslTransform xslTran = new XslTransform();
xslTran.Load("C :\\XSLTTest.xsl ");
XmlTextWriter writer = new XmlTextWriter(" C:\\XSLTTest.tx t", System.Text.Enc oding.UTF8); xslTran.Transfo rm(xmlDoc, null, writer, null);

Thanks

Stuart

Nov 12 '05 #3

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

Similar topics

2
1552
by: Stuart | last post by:
I am a bit of a newbie to C# and would like help with the following I am bringing in a dataset and transforming that dataset using an XSL style sheet to generate text. This text does in fact contains SQL DDL statements (DBCC commands etc) which I want to capture and run on a SQL Server instance. At the moment I can do this by writing the result of the transformation to file and re-loading it, but would like to skip out the file and write...
3
1168
by: Mark Goldin | last post by:
I need to show results of transformation on the server. Thansformation returns an attribute based xml string. Can I bind DataRepeater to the xml string? Thanks
6
4979
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory exceptions with large XML files. I tried a simple punt of -Xmx512MB but that didn't work. In the future, the input XML file may become considerably bigger than 96 MB, so even if it did work, it probably would be putting off the inevitable to some later...
1
3888
by: Billy | last post by:
Hi All, I'm attempting to use the MapNetworkDrive <snippedbelow from entire code below with very poor performance results. Basically, I have very small 73kb text files that are rewritten daily to a network share using the MapNetworkDrive command to connect to the valid \\servername\share path. After successfully connecting the drive in the ASP code, the text file
0
8390
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
8819
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
8596
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,...
1
6222
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
5690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4221
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
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2806
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
2048
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.