473,385 Members | 1,615 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,385 software developers and data experts.

How to write an xsl trasform to stream?

4
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 1603
pax82
4
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
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...
16
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...
0
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...
0
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...
3
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...
3
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...
63
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...
5
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.