I am trying to do XSL transforms that are being returned in ADO DataSets. No real problems performing the transform, however I feel that I am not being efficient in the process. The code is as follows:
// put xml into memory stream msInput
Stream msInput,msOutput;
msInput = new MemoryStream();
ds.WriteXml(msInput);
msInput.Position = 0;
// create Xpath document
XPathDocument doc = new XPathDocument(msInput);
// load xsl transform doc
XslTransform xslt = new XslTransform();
xslt.Load(sXslFile);
// transform msInput via xsl into msOutput
msOutput = new MemoryStream();
xslt.Transform(doc,null,msOutput);
msOutput.Flush();
msOutput.Position = 0;
// load dataset
ds = new DataSet();
ds.ReadXml(msOutput);
It currently takes about 0.051 sec on a 1000 MHz processor with the majority (circa 97%)of the time going to ReadXml, WriteXml, and Load XSL methods.
Is it possible to pass the XML directly to XPathDocument without the WriteXml and use of two Memory Streams? Likewise for the ReadXml getting it back into the DataSet?
|