Convert XSL and XML to HTML files

Source: Internet
Author: User
Tags xsl xslt
1 ///   <Summary>
2 /// Convert XSL and XML to HTML files
3 ///   </Summary>
4 ///   <Param name = "strpolictext"> XSL Template File </Param>
5 ///   <Param name = "strxml"> XML template file </Param>
6 ///   <Returns> Tring of HTML </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 (strpolictext) |   String . Isnullorempty (strxml ))
12 {
13 Err. seterrorno (smcerr. err_email_paramnull );
14 Return Err;
15 }
16 // Load the style sheet.
17 Xslcompiledtransform XSLT =   New Extends compiledtransform ();
18 // Instance the stringbuilder to return value
19 Stringbuilder sb =   New Stringbuilder ();
20 // Execute the xmlwriter. Create and output the xmlwriter
21 Xmlwriter =   Null ;
22 Xmlreader Reader =   Null ;
23 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 Xslreader = 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 Xslreader =   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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.