I used to use XSLT to transform XML that I get from a database and write the output to a file:
//Transforms Xml with Xslt and write to file
After some testing we started to experience problems with this approach as there is a a memory leak in MS XML 4.0 core services while using transform.Transform() function.
There are two options
I decided to rather transform the XML and return a XmlDocument as the output… the solution is to use a MemoryStream for the output and then load that into your XmlDocument. Or create a string or whatever you want to return:
//Transforms Xml with Xslt and returns the transformed XmlDocument
XmlDocument transformedDoc = new XmlDocument();