Hi
In console application when we are trying to transform XSLT , its taking lots of times to translate.<o:p></o:p>
transform.Transform(xmlReader,outputXmlWriter);
Code given below:::
protected string GetTransformedXml(string inputFileNameXSLT, object viewModelPart)
{
StringBuilder sb = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings { ConformanceLevel = ConformanceLevel.Fragment, OmitXmlDeclaration = true };
XmlWriter outputXmlWriter = XmlWriter.Create(sb, settings);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(inputFileNameXSLT);
using (MemoryStream ms = SerializeToStream(viewModelPart))
{
ms.Seek(0, SeekOrigin.Begin);
XmlReader xmlReader = XmlReader.Create(ms);
transform.Transform(xmlReader, outputXmlWriter);
}
return sb.ToString();
}
private MemoryStream SerializeToStream(object obj)
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
MemoryStream ms = new MemoryStream();
serializer.Serialize(ms, obj);
return ms;
}
inputFileNameXSLT(XSLT):::Size 3736KB