XML Data Islands - Engineering and Technology IUPUI

Download Report

Transcript XML Data Islands - Engineering and Technology IUPUI

Embedding XML in HTML: Using Data Islands

Eugenia Fernandez IUPUI

Internet Explorer 5 Approach

• Treats XML as a Data Source Object or DSO, also referred to as a data island • Handles symmetric data best, i.e. data that resembles a relational table • Can use multiple data islands in same HTML file • Each data island requires unique ID

Defining a Data Island

• A data island is defined within the and HTML tags.

– explicitly, by embedding XML data directly

some XML

– implicitly, by reference to external XML file

Mapping XML Data to an ADO Recordset

XML data within an XML data island is treated as an ADO recordset. Each main element maps to a record in the ADO recordset, and each child element maps to a field in the record.

ADO Mapping Example

The Autobiography of Benjamin Franklin Benjamin Franklin 8.99 The Confidence Man Herman Melville 11.99

Title

The Autobiography of Benjamin Franklin The Confidence Man

Author

Benjamin Franklin Herman Melville

Price

8.99

11.99

Binding Data Islands to HMTL Elements

• Individual fields can be bound to HTML tags using the DATASRC and DATAFLD attributes – DATASRC specifies the ID of the XML data island. The ID must be preceded with #.

– DATAFLD specifies the XML field from which data is taken.

HTML Elements That Support DSO Binding

• A • APPLET • BUTTON • DIV • FRAME • IFRAME • INPUT (where TYPE = CHECKBOX, HIDDEN, LABEL, PASSWORD, RADIO, TEXT) • IMG • LABEL • MARQUEE • SELECT • SPAN • TABLE • TEXTAREA

Displaying Data in HTML Tables

• Use a TABLE to display multiple rows of data.

• Set the DATASRC in the TABLE tag.

• For each TD, include an HTML element and set its DATAFLD attribute • The data binding agent automatically populates multiple rows, for each record in the XML dataset.

Paging the DSO Data

• For large XML data islands, DSO allows the data to be displayed in pages. • The size of the page is set through the DATAPAGESIZE attribute in the TABLE tag.

Accessing Repeating XML Elements • Use a nested table to access repeating XML elements Gourmet Microwave Cooking 18.99 Charlotte Waves Regina Cooker Mario Gourd

Accessing XML Attributes

• XML attributes are treated as child elements The Autobiography of Benjamin Franklin Benjamin Franklin 8.99 The Confidence Man Herman Melville 11.99

Navigating the DSO Recordset

• You can navigate through your DSO Recordset by adding script to call the ADO move methods: – Move, MoveFirst, MoveLast, MoveNext, MovePrevious • Example

xmldso.recordset.MoveNext

Adding Navigation

• Add a field to display the data • Add a button to invoke the desired move method.

Title:

Adding Navigation, cont.

• Set an onclick event procedure for the button that calls the move command.

Sources

• “Building XML-Based Web Applications” a Microsoft Certified Course.