Chapter 1 data island of XML basic tutorial and experiment Guide

Source: Internet
Author: User

Chapter 4 data island

Data island allows us to integrate XML into HTML pages and write scripts for XML without reading XML through scripts or <Object> tags. Almost anything that can exist in a fully structured XML document can exist in a data island. Through data island, we can display XML data island data in any form of HTML webpage, such as tables, forms, or paging display.

Key points of this chapter:
Understanding data island Definitions
Familiar with data island binding and forms
Understanding how data island elements are bound
Familiar with DSO concepts
Understanding DSO operations on XML data island data
Proficient in DSO data traversing Data Islands
Proficient in displaying data island data by PAGE
Master the front and back display styles through DSO and XSL

8.1 Data island Overview

When we use XML tags in HTML documents to embed XML data, an XML data island is formed in HTML documents. Data island refers to the XML data that exists in the HTML page. XML data can be contained in HTML files or an external file. Using XML data island can save us the trouble of writing complex scripts.

8.1.1 data island Definition

XML data island (Data Islands) is the XML data referenced or contained by HTML pages, that is, the XML data stored in HTML pages.CodeIs a technology introduced from ie5. You can easily insert Data Islands into HTML documents using XML tags. So how to access the data in the XML data island is very simple, through the xml id. The data island on the page is the same as other XML data and can be accessed through the standard DOM method.

8.1.2 data island binding

Data Binding means that XML Data Islands can be bound to HTML elements (such as tables ). In the following example, an XML data island is loaded from an external XML document. An HTML table is bound to this data island. The span elements in an HTML table are bound to each other using the dataworks attribute and the XML elements corresponding to the XML document.

8.2 data island applications

The data in XML documents can be displayed in multiple forms, including CSS style forms, XSL style forms, and data island technologies. Data island technology is easier than the first two technologies.

8.2.1 data island usage form

Data Island has two definitions: one is to directly embed the preceding XML data into the HTML page, and the other is to see that the XML data is saved in a separate XML file, introduce the data in the XML file to the HTML page. You can use the datasrc and dataworks attributes to bind an XML data island to an HTML control.

8.2.2 data island access XML Element Content

After embedding the data island in the HTML document, you can bind the XML data island with the HTML element. Each data island has a unique ID number. The process is to first set the datasrc attribute in the HTML element to the corresponding ID so that the HTML element can be associated with the data island. Then, the extracted XML element is determined by setting the dataworkflow attribute value.

8.2.3 data island access xml tag attributes

If the attribute name is the same as the sub-element name, add "!" before the element name. But in actual use, pay attention to the data structure of the XML file. Now we create a case to demonstrate how to use the XML data island access tag attribute.

8.3 DSO data source object

We can not only obtain data in the XML document through the data island, but also add, modify, and delete data through the DSO data source object.

8.3.1 DSO Concept

To handle HTML pages embedded with XML code, Internet Explorer 4.0 (IE 4.0) and later versions introduce the DSO (Data Source objects, data source object) technology. Xml dso is a Microsoft ActiveX Control embedded in Microsoft Internet Explorer. Using the embedded control, DSO helps format data and display the data on the HTML page, DSO can be used to extract data from the following files: external XML documents or XML data embedded in HTML documents. DSO can be used to operate the XML data of documents embedded in HTML. To use DSO, the root XML element must not have any attributes.

8.3.2 operate XML data island data

In IE, when you create an identifier ID for the XML data island, you actually create a data source object DSO that operates the XML data island. Here, the DSO object can be viewed as the root node of a DOM tree model, that is, the XML data island is processed as a tree loaded into the memory. The DSO object can add, delete, and modify nodes to the XML data island based on the DOM tree model structure. The execution result is displayed on the data on the current HTML page, but it does not affect the data changes in the XML data islands.

8.3.3 traverse XML data island data

The data source object DSO can display, query, modify, delete, and add data island nodes. These operations are based on the tree model. In addition, DSO can process the XML data island as an ADO record set. The advantage of this is that it can use various methods provided by ADO to access the data source, especially when you bind a data island to HTML elements such as span, Div, and input. These elements usually display the first record of the record set. to traverse and browse the record set, one is to bind the table object we mentioned earlier, in addition, you can use the ADO method in combination with the script.ProgramComplete the data browsing function. For example, if you create a button response function, you can click "Next" to view corresponding records one by one.

8.3.4 display XML data island data by PAGE

Generally, when the retrieval result set is too large (usually very large), the paging data display policy is adopted, that is, a small part of data in each returned result set, you can view more results through operations similar to "previous" and "Next. The user expects that the submitted search can quickly get a response, and the operations on the "Previous Page" and "next page" can also quickly get a response. Therefore, the key to the problem is to obtain the result data required for each record based on the start position and the number of records required.

8.4 DSO and XSL switching styles

The XML file can be used to store data. The style form file XSL or CSS can be used to specify the data display style. The two can be combined to specify the data display style. However, only one style is displayed, because an XML file corresponds to a style form file. Using the DSO data source object, we can specify multiple style form files for the XML file. We select the method we like to view the data. For example, anyone who browses information on the client can select their preferred colors and images to display data. They do not need to send their hobbies to the server and directly complete the information on the client, this reduces the workload on the server. To implement this function, you can combine the DSO data source object with the XSL style form.

Download source code

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.