1 / 15

Embedding XML in HTML: Using Data Islands

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

sibley
Download Presentation

Embedding XML in HTML: Using Data Islands

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Embedding XML in HTML: Using Data Islands Eugenia Fernandez IUPUI

  2. 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

  3. Defining a Data Island • A data island is defined within the <XML> and </XML> HTML tags. • explicitly, by embedding XML data directly • implicitly, by reference to external XML file <XML ID=“xmldso”> <?xml version=“1.0”?>some XML</XML> <XML ID=“xmldso” SRC=“products.xml”></XML>

  4. 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.

  5. ADO Mapping Example <booklist> <book> <title>The Autobiography of Benjamin Franklin</title> <author>Benjamin Franklin</author> <price>8.99</price> </book> <book> <title>The Confidence Man</title> <author>Herman Melville</author> <price>11.99</price> </book></booklist>

  6. 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. <DIV DATASRC=“#xmldso” DATAFLD=“title”></DIV>

  7. A APPLET BUTTON DIV FRAME IFRAME INPUT (where TYPE = CHECKBOX, HIDDEN, LABEL, PASSWORD, RADIO, TEXT) IMG LABEL MARQUEE SELECT SPAN TABLE TEXTAREA HTML Elements That Support DSO Binding

  8. 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. <TABLE DATASRC=“#xmldso”> <TR> <TD><DIV DATAFLD=“title”></DIV></TD> </TR></TABLE>

  9. 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. <TABLE DATASRC=“#xmldso” DATAPAGESIZE=10>

  10. Accessing Repeating XML Elements • Use a nested table to access repeating XML elements <book> <title>Gourmet Microwave Cooking</title> <price>18.99</price> <author>Charlotte Waves</author> <author>Regina Cooker</author> <author>Mario Gourd</author> </book> <TD> <TABLE DATASRC=“#xmldso” DATAFLD=“author”> <TR><TD><SPAN DATAFLD=“$Text”></SPAN></TD></TR> </TABLE></TD>

  11. Accessing XML Attributes <book genre=“Autobiography”> <title>The Autobiography of Benjamin Franklin</title> <author>Benjamin Franklin</author> <price>8.99</price> </book> <book genre=“Literature”> <title>The Confidence Man</title> <author>Herman Melville</author> <price>11.99</price> </book> • XML attributes are treated as child elements <TD><SPAN DATAFLD=“genre”></SPAN></TD><TD><SPAN DATAFLD =“title”></SPAN></TD>

  12. 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

  13. Adding Navigation • Add a field to display the data • Add a button to invoke the desired move method. <XML ID=“xmldso” SRC=“books.xml”></XML><FORM> <!-- create field to display the data --> Title: <INPUT TYPE=‘text’ DATASRC=“#xmldso” DATAFLD=“title”> <!-- add a button to step through the XML data --><INPUT TYPE=“button” ID=“btnNext” Value=“Next”></FORM>

  14. Adding Navigation, cont. • Set an onclick event procedure for the button that calls the move command. <HEAD> <script language=“VBScript”>Sub btnNext_onclick() xmldso.recordset.MoveNextEnd Sub</script> </HEAD>

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

More Related