Combination of XML and HTML (I)

Source: Internet
Author: User
XML restrictions currently, content data of many Web sites is stored in databases or data files. For Web application developers, if they want to extract useful information from the database, the traditional method is to write a script program on the server.

XML limitations

Currently, content data of many websites is stored in databases or data files. For Web application developers, if they want to extract useful information from the database, the traditional method is to write script programs (such as VBScript, JavaScript, CGI, ASP, Perl, etc.) on the server side, and obtain related records by performing SQL queries on the database, then, the query results are organized into HTML pages and returned to the client. you can use the browser to observe the ultimate result.

In order to improve the mobility and scalability of system services and make the scope of service objects wider, many trade websites try to regard business rules, raw data and performance situations as mutually independent services to identify the supply. The method of displaying HTML data is obviously different from this requirement. Therefore, the original data is stored in XML documents. the XML technique is suitable for e-commerce to show the content of a style sheet file. However, in essence, the XSL Technique is not for data display. it is a pattern conversion technique and is far less diverse in display methods than HTML. For programmers, a more imaginative plan is to combine the two HTML and XML skills to complement each other, so that the real original data can maintain the original meaning and structure at the same time, we can also make full use of the ever-changing HTML display skills. XML data Island is the product of this fusion of skills and its application Tags directly embed XML data into HTML pages, so that the advantages and disadvantages of the two are achieved.

Processing Method of Data Island in IE

To be able to process HTML pages embedded in XML code, Internet Explorer 4.0 (IE 4.0) introduces DSO (Data Source Objects, Data Source object) techniques and uses Java Applet.

For example:

ID = "xmldso" WIDTH = 0 HEIGHT = 0 MAYSCRIPT = TRUE>

In the preceding example, the CODE attribute specifies the DSO Java applet. the MAYSCRIPT attribute ensures that the client script can process data objects, and the PARAM tag specifies the position of the XML document.

The limitation of Java application is that the xml url address can only be clarified in the HTML document, but the XML tag cannot be directly embedded in it, which is still a certain gap with the real data Island plan. Microsoft expanded DSO skills in Internet Explorer 5.0 (IE 5.0), breaking through previous restrictions and truly integrating HTML and XML. Supporting direct applications on HTML pages Label.

For example:

Some XML ......

As long as the ID of each data Island is unique, it can be embedded in the data Island wherever necessary on the page, and these DSO are mutually independent.

In addition to the direct embedding method in the preceding example, you can also use the external referencing method to link the data Island.

For example:

In this way, Java Applet is the option that programmers should consider only when the company's customer object continuously applies IE 4.0 and understands the compatibility title of these customers.

In the DSO technique implemented by IE 5.0, if the Data is obtained by querying the database through the SQL language, they are stored in the ADO (ActiveX Data Objects) record set. The server sends this ActiveX control (usually an ADO Record Set) to the client for further processing by the client script program. In fact, IE 5.0 processes the XML data Island as a special ADO record set.

XML data binding

1. ADO record set ing

Each primary element in XML is mapped to a record in the ADO record set, and the child element is mapped to the field (also called the field) in the record set ).

For example, books. XML in xml data Island exists as follows:

Straight Talk About Computers

72-80088-005

Gourmet Microwave

72-80081-082

In this case, the mapped ADO record set is:

Title isbn

Straight Talk About Computers 72-80088-005

Gourmet Microwave 72-80081-082

2. binding to HTML elements

After the HTML document is embedded in the data Island, you can bind the XML data Island with the HTML element. Each DSO entry (data Island) has a unique ID number. First, you can set the DATASRC attribute in the HTML element to the corresponding ID to link the HTML element with the data Island. Then, the extracted XML element is determined by setting the dataworkflow attribute value.

For example, the code bound to the DIV element is as follows:

Note: not all HTML elements can be bound to the XML data Island. Currently, the elements supporting this DSO binding mechanism are as follows:

A. APPLET, BUTTON, DIV, FRAME, IFRAME, IMG, and INPUT (the types are CHECKBOX, HIDDEN, LABEL, PASSWORD, RADIO, and TEXT), LABEL, MARQUEE, SELECT, SPAN, TABLE, and TEXTAREA.

3. explicit XML data in tabular form

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.