Step 1 Data System Technology (2.xml+ XSLT page generation mechanism)

Source: Internet
Author: User
Tags xslt
In this system, the main page of a website does not return data in the normal aspx return mode, but is generated in XML + XSLT format. This is my personal favorite method, this method has a better advantage in this system. I will list several advantages:
1. Complete separation of data and representation. The data is fully implemented in XML files, while the form of page representation is fully implemented using XSLT. Program The structure is clear, simple, and easy to maintain;
2. You can select to output the result to a file or response at will;
3. XSLT can automatically compress html Code Generate compact, not easy to read, without affecting the code parsed by the browser. Your comments in the XSLT file will not be displayed on the client, unless you specifically specify;
4. XSLT allows mutual calls so that an architecture that is easier to update and maintain can be implemented;
5. it is very easy for XSLT to completely skin over the website. It is easy for you to think that their design of XSLT is to skin over the website. It can turn the website into a website with completely different styles, instead of ordinary CSS skin replacement, you just need to change the color subject.
Disadvantages: there may not be too many people using XSLT and it is difficult to learn. This is the biggest obstacle.
It is clear to use XML + XSLT to construct a website. First, create an xmldocument object, then fill in data into XML in a standard format, and then open the XSLT file, you can use this XSLT file to convert XML and directly output the result to response. The following is the code output by XSLT: 1 Protected void SaveFile (xmldocument XML, string effectfile)
2 {
3 Transform transform XSLT = new transform ();
4 XSLT. Load (server. mappath (xsltfilepath) + xsltfile );
5 XSLT. Transform (XML, null, response. outputstream, null );
6 Writer. Close ();
7 }

This article is not about how to fill the data into XML data. However, I can provide an idea to use the for XML statement in SQL statements, the method is to add the for XML auto statement segment after your query statement, so that the data returned by SQL Server will be in the XML node format, then you use the following function to import the returned results to your xml node: 1 Protected   Void Getxmlbysql (xmlnode, String SQL, sqlconnection conn)
2 {
3 Sqlcommand = New Sqlcommand (SQL, Conn );
4 Xmltextreader = (Xmltextreader) sqlcommand. executexmlreader ();
5 Xmltextreader. Normalization = True ;
6 Try
7 {
8 While ( ! Xmltextreader. EOF)
9 {
10 Xmlnode tempxmlnode = Xmlnode. ownerdocument. readnode (xmltextreader );
11 If (Tempxmlnode ! = Null )
12 Xmlnode. appendchild (tempxmlnode );
13 }
14 }
15 Catch (Exception E) {}
16 Xmltextreader. Close ();
17 Sqlcommand. Dispose ();
18 }

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.