You would have to first load the XSLT document into an XmlDocument object.
XmlDocument xsltDoc = new XmlDocument();
xsltDoc.LoadXml(xsltString);
Then, create an XslTransform and, now, load the XSLT document into the
transform by creating an XPathNavigator from the document:
XslTransform transform = new XslTransform();
transform.Load(xsltDoc.CreateNavigator(), null, null);
Assuming you have the XML document loaded into a XmlDocument as well,
you are now ready to perform the transformation.
Let's use a System.IO.MemoryStream as the output channel.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlString);
XsltArgumentList args = new XsltArgumentList();
MemoryStream output = new MemoryStream(100000);
// Put any XSLT transform parameters into 'args' here.
transform.Transform
(xmlDoc.CreateNavigator(), args, output, null);
All this can be done in RAM without a single read/write to the hard drive.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <0
...@0000.SPAM> wrote in message
news:eFYDvpu4EHA.3236@TK2MSFTNGP15.phx.gbl...
> So you are saying to create a xslt with a XmlDocument object?
> I still don't see any way to create a XslTransform from a XmlDocument?
> Have any sample code?
> Thanks,
> Schneider
> "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
> news:OfrMnap4EHA.1564@TK2MSFTNGP09.phx.gbl...
>> schneider wrote:
>> > Anyone know if there is a way to dynamicly create a Xslt template/s and
> use
>> > them as an
>> > xml transform with-out use files for the Xslt?
>> > All the methods I see use files.
>> > I want to create a Xslt transform via code?
>> Basically any XSLT stylesheet is just XML document, so of course you can
>> build it in-memory using XmlDocument. Another common approach is to
>> generate XSLT stylesheets on the fly using XSLT (again - as XSLT is XML,
>> the best way to generate/transform it is XSLT itself).
>> --
>> Oleg Tkachenko [XML MVP]
>> http://blog.tkachenko.com