473,804 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write an xsl trasform to stream?

4 New Member
hi, sorry for my english but i don't speak good english.

in this web service i send 2 data stream(xml and xsl file) and i would like to return a xslt trasform-file byte array (now i return string because i'm in testing)
when the transResult file is been created, it's source is all NULL char.
why? where i'm wrong?


Expand|Select|Wrap|Line Numbers
  1.     public string getData(byte[] xmlData, byte[] xslData)
  2.     {
  3.  
  4.         string workDir = "D:\\provaWebService\\";
  5.  
  6.  
  7.         int xmlFileSize = xmlData.Length;
  8.         int xslFileSize = xslData.Length;
  9.  
  10.  
  11.         Stream xmlStreamData = new MemoryStream(xmlData);
  12.         Stream xslStreamData = new MemoryStream(xslData);
  13.         Stream output = new MemoryStream();
  14.  
  15.         XPathDocument XPathDoc = new XPathDocument(xmlStreamData);
  16.         XslCompiledTransform xslTrans = new XslCompiledTransform();
  17.  
  18.         XmlReader reader = XmlReader.Create(xslStreamData);
  19.  
  20.         xslTrans.Load(reader);
  21.  
  22.  
  23.         output.Position = 0;
  24.         XmlTextWriter writer = new XmlTextWriter(output,Encoding.UTF8);
  25.         writer.Formatting = Formatting.Indented;
  26.  
  27.         xslTrans.Transform(XPathDoc.CreateNavigator(), null, writer);
  28.  
  29.  
  30.         FileStream outFile = new FileStream(workDir + "result.html", FileMode.Create);
  31.         byte[] byteArray = new byte[output.Length];
  32.         int numBytesToRead = (int)output.Length;
  33.         int n = output.Read(byteArray, 0, numBytesToRead);
  34.  
  35.         outFile.Write(byteArray, 0, byteArray.Length);
  36.         outFile.Close();
  37.  
Thanks,
P.
Jan 11 '07 #1
1 1640
pax82
4 New Member
it's source is all NULL char
his source is all NULL char
:-)
Jan 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4626
by: radnoraj | last post by:
Hi, I am sucessfull in redirecting console output to a file. but in this case nothing is displayed on the console, cout output is written to file without display. how do write the output to console as well as to file, my code is as below, ======================================================================= #include <iostream.h> #include<ostream> #include<sstream>
16
3501
by: ben beroukhim | last post by:
I have huge number of legacy code which use standard files functions. I would like to pass a memory pointer rather than a FILE pointer. I am trying to use FILEs in the code to refer to memory buffers. Basically, I want to be able to use all the standard read and write functions, but I want them to refer to memory locations, rather than disk files. I do not want to touch the legacy code. Does any one know of a library
0
1066
by: Ireney Berezniak | last post by:
Hi, I am trying to send an UTF-8 XML string to remote resource via HttpWebRequest using POST method, which means that I need to get the request stream and write my XML string to it. No problems here. The problem that I'm running into is that the "+" sign that one of the XML elements contains is lost somehow in the transaction. I verified that the "+" is actually in the XML string prior to getting bytes, and writing to stream: ...
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14063
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
3411
by: Dinsdale | last post by:
I must be totally missing something. I am trying to use DirectX to play an AVI file that is stored as a Manifest Resource. Apperently the Video class only takes a string path as a parameter, so I wanted to write the avi to a file from the manifest. I thought I would just be able to read it in as a Stream and then write it out to a FileStream but this does not seem to be the case. To complicate things, I just found out about the...
63
3271
by: Bill Cunningham | last post by:
I don't think I can do this without some help or hints. Here is the code I have. #include <stdio.h> #include <stdlib.h> double input(double input) { int count=0,div=0; double mean=0,linput=0; FILE *fpr, *fpw;
5
2368
by: =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?= | last post by:
I'm sorry, but I've read your code a couple of times and just don't see where the Form1 is initialized. Form1 also sounds like a class name, and this would be how you could do some form operations in vb6, but not in .Net. This would explain why the messagebox works, as it is not instantiated, but called statically as you did in your code. I think you need this where your MsgBox is called: dim ui as New Form1() ui.txt_rec.Text =...
4
11959
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the dialog box has as the default file name the name of this ashx file. I'd like to make that name more meaningfull but don't know how it gets set. I'm looking for a Response.Write but don't find one. Maybe that why the
0
9716
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
9595
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
10354
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
10359
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
10101
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...
0
9177
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...
0
6870
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
5536
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...
3
3005
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.