public static string Transform(string xmlPath, XsltArgumentList argList) { XmlWriterSettings xSettings = new XmlWriterSettings(); xSettings.ConformanceLevel = ConformanceLevel.Fragment; xSettings.Encoding = InstanceReport.Encoding; xSettings.Indent = true; xSettings.OmitXmlDeclaration = true; //we REALLY need to set this to HTML xSettings.GetType().GetProperty("OutputMethod").SetValue(xSettings, XmlOutputMethod.Html, null); return(Transform(xmlPath, xSettings, argList)); }
public static string Transform(string xmlPath, XsltArgumentList argList) { string html = null; try { string transformFile = RulesEngineUtils.GetResourcePath(RulesEngineUtils.ReportBuilderFolder.Resources, "InstanceReport.xslt"); XslCompiledTransform transform = new XslCompiledTransform(); transform.Load(transformFile); using (MemoryStream ms = new MemoryStream()) { XmlWriterSettings xSettings = new XmlWriterSettings(); xSettings.ConformanceLevel = ConformanceLevel.Fragment; xSettings.Encoding = Encoding.ASCII; xSettings.Indent = true; xSettings.OmitXmlDeclaration = true; //we REALLY need to set this to HTML xSettings.GetType().GetProperty("OutputMethod").SetValue(xSettings, XmlOutputMethod.Html, null); using (XmlWriter xWriter = XmlWriter.Create(ms, xSettings)) { transform.Transform(xmlPath, argList, xWriter); } ms.Flush(); html = Encoding.ASCII.GetString(ms.ToArray()); } } catch (Exception ex) { html = "<h2>Error <small>generating preview</small></h2>" + "<pre>" + ex.Message + "</pre>"; } return(html); }