Title: New Perspectives on XML
1 - Tutorial 2.1
- XML Fields and Records
2Using XML as a Data Source
- Data binding is a technique where the Web pages
content is drawn from a data source. Data binding
frees the data from the format in which it is
displayed so the same data source can be combined
with several different Web pages. - In this tutorial, the data source is an XML
document containing information about the
employees at Freezing Point. - The Web pages uses placeholders which we will
later populate with data from two XML documents.
3Opening the Web Page
- Open the file FP1text and save as FP1.htm.
- Open and view FR1.htm using Internet Explorer.
hyperlink to the pages author
subtitle text
information about an employee
employee photograph
employee name
buttons to display different employees
4Using Data Binding to Create a Final Web Page
- This figure shows how data binding will be used
to create a final Web page
5Fields, Records, and Recordsets
- Data in a data source is organized by fields,
records, and recordsets. - A field is an element that contains a single item
of information such as an employees last name. - A record is a collection of those fields.
- A recordset is a collection of records.
6Fields, Records, and Recordsets
This figure shows fields, records, and a
recordset of an XML document
7Data Islands
- The first step in data binding is to attach the
Web page to a recordset. The attached data is
called a data island. They can be either external
files or code entered into the HTML file. - The syntax to create a data island from an
external file is - ltxml idid srcURLgtlt/xmlgt
- Here, id is the id name assigned to the data
island - URL is the filename and location of the external
XML file
8Data Islands
- For example
- ltxml idCompany srcCompany.xmlgtlt/xmlgt
- This creates a data island named Company attached
to Company.xml.
9Data Islands
- To insert a data island directly into the HTML
file, use this syntax - ltxml ididgt
- xml code
- lt/xmlgt
- While this technique can be used, it is not
recommended. After all, the philosophy of XML is
to separate data content from data formatting.
10Data Islands
- Data islands are stored by the XML parser as a
Data Source Object (DSO). - The DSO takes care of the interaction between the
Web page and the data island. Also, program code
can be written to control the actions of the DSO
such as specifying which records will be
displayed in the Web page at any one time.
11Creating a Data Island
This figure shows how to create the data island
12Binding XML Elements to HTML Tags
- After the data island has been created, the
elements in the XML document need to be bound to
the HTML file. - The syntax is
- lttag datasrcid datafldfieldgt
- Here, tag is the name of the HTML tag, id is the
name of the data island, and field is the name of
the field in the data source.
13HTML Tags that Support Data Binding in Internet
Explorer
This figure shows HTML tags that support data
binding in Internet Explorer
14Binding XML Elements to HTML Tags
This figure shows how to bind XML elements to
HTML tags
15Binding XML Elements to HTML Tags Continued
This figure shows how to bind the rest of the
FPINFO.XML elements