1 /// <summary>
2 // convert XSL and XML into HTML files
3 /// </summary>
4 /// <param name = "strpolictext"> XSL template file </param>
5 // <param name = "strXML"> XML template file </param>
6 /// <returns> HTML tring </returns>
7 private static SmcErr GetEmailBodyContent (string strXSLText, string strXML, out string strHTML)
8 {
9 SmcErr err = new SmcErr (SmcErr. SMC_ERR_SUCCESS );
10 strHTML = null;
11 if (string. IsNullOrEmpty (strw.text) | string. IsNullOrEmpty (strXML ))
12 {
13 err. SetErrorNo (SmcErr. ERR_EMAIL_PARAMNULL );
14 return err;
15}
16 // Load the style sheet.
17 bytes compiledtransform xslt = new bytes compiledtransform ();
18 // Instance the StringBuilder to return value
19 StringBuilder sb = new StringBuilder ();
20 // Execute the XmlWriter. Create and output the xmlWriter
21 XmlWriter xmlWriter = null;
22 XmlReader reader = null;
23 XmlReader xmlReader = null;
24 try
25 {
26 xmlWriter = XmlWriter. Create (sb );
27 // Execute the Encoding and output the byte []
28 byte [] bXSL = System. Text. Encoding. UTF8.GetBytes (strXSLText );
29 // Execute the XmlReader. Create and output the specified Reader
30 bytes reader = XmlReader. Create (new MemoryStream (bXSL ));
31
32 // Execute the Encoding and output the byte []
33 byte [] bXML = System. Text. Encoding. UTF8.GetBytes (strXML );
34 // Execute the XmlReader. Create and output the specified Reader
35 xmlReader = XmlReader. Create (new MemoryStream (bXML ));
36
37 // Load the style sheet.
38 xslt. Load (xslReader );
39 // Execute the transform and output the results to xmlWriter.
40 xslt. Transform (xmlReader, null, xmlWriter );
41
42 strHTML = sb. ToString ();
43}
44 catch (Exception ex)
45 {
46 err. SetErrorNo (SmcErr. ERR_EMAIL_PARAMNULL );
47 return err;
48}
49 finally
50 {
51 bytes reader = null;
52 xmlReader = null;
53}
54
55 if (strHTML = null)
56 {
57 err. SetErrorNo (SmcErr. ERR_EMAIL_PARAMNULL );
58}
59
60 return err;
61
62}
63
64 # endregion