Hi
I'd like to get a populated datatable, create an in memory xml document
(file shouldn't be more than a couple of meg), load an XSLT file, do a
transform and stream it to a browser. What am I Missing please?
MemoryStream strm = new MemoryStream();
XmlWriter writer = XmlWriter.Create(strm);
DataTable dataTbl = new myBLL().GetAll();
dataTbl.WriteXml(writer);
// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(Server.MapPath("~/docs/Accounts.xsl"));
// Execute the transform and output the results to a file.
xslt.Transform(?, file to sent to response stream);
Thanks
Andrew
Tim Van Wassenhove - 19 Jun 2007 16:16 GMT
J055 schreef:
> Hi
>
[quoted text clipped - 19 lines]
>
> xslt.Transform(?, file to sent to response stream);
Since you're talking about streaming to webbrowser i'll presume you have
access to an HttpContext... Output the right content-type header
(probably text/xml) and create an XmlWriter from the
Response.Outputstream... Then pass in that writer instance in the
Transform method...

Signature
Tim Van Wassenhove - Read my mind <url:http://www.timvw.be/>
Martin Honnen - 19 Jun 2007 16:40 GMT
> I'd like to get a populated datatable, create an in memory xml document
> (file shouldn't be more than a couple of meg), load an XSLT file, do a
[quoted text clipped - 17 lines]
>
> xslt.Transform(?, file to sent to response stream);
MemoryStream strm = new MemoryStream();
DataTable dataTbl = new myBLL().GetAll();
dataTbl.WriteXml(strm);
strm.Position = 0;
// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(Server.MapPath("~/docs/Accounts.xsl"));
// Execute the transform and output the results to a file.
Response.ContentType = "application/xml";
using (XmlReader xmlReader = XmlReader.Create(strm))
{
xslt.Transform(xmlReader, (XsltArgumentList)null, Response.OutputStream);
}

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
WenYuan Wang [MSFT] - 21 Jun 2007 11:01 GMT
Hello Andrew,
Thanks for Martin and Tim's suggestion.
I also agree with them.
xslt.Transform(xmlReader, (XsltArgumentList)null, Response.OutputStream)
could output the stream transformed from XSLT to web browser.
Do you meet any further issue on this?
Please feel free to update here. Thus, we could follow up.:)
Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.