| the complete webmaster | ||||
| tutorials | reviews | reference | ||
|
Adding XML support to your FrontPage webDuring 1998 there was considerable noise expressed about XML. You can be sure that 1999 will continue that trend... Currently XML is only really of interest to developers, but that will quickly change. There are now XML tools available for all the popular programming language (Perl, Java etc.) as well as several XML editing applications. Microsoft are going to push XML support as one of the major new features of Internet Explorer 5, and it is likely that it will be supported in future versions of Netscape and other browsers. This tutorial gives you a simple example of how to use XML within your FrontPage web, and display the data in Internet Explorer 4 or 5. It will be of interest to you if you want to keep up to date with modern web developments. Interfacing of XML to HTML documents is likely to be of huge importance to the web of tomorrow, so it is a good idea to become familiar with it now. Creating a simple XML documentIn real world scenarios, most XML documents will be created from other data sources (e.g. databases, spreadsheets or other files). But for testing purposes, it is useful to be able to create small sample XML documents. Like HTML, XML documents are simply plain text files with embedded tags describing the data. As such they can be created in any text editor (e.g. notepad). Alternatively, why not try one of the XML editors available, such as XML Notepad, which is a free download from the Microsoft website. Once you have installed an XML editor, you might like to alter the FrontPage Explorer to automatically load XML documents into the XML editor. To do this for XML Notepad, use the Options menu command accessible from the FrontPage Explorer Tools menu. When the Options window appears, click on the Configure Editors click-tab. Click on the Add button to display the Modify Editor Association window. For File Type, enter xml. Under Editor Name, enter XML Notepad. Finally, in the Command field, add the path to the XML Notepad program (e.g. C:\Program Files\XML Notepad\XMLPAD.EXE). In this example, you will need a small XML file. This example contains information about four different fruit: bananas, oranges, strawberries and tomatoes. Each fruit has three elements: name (FRUIT_NAME), description (FRUIT_DESCRIPTION), and name of associated image file (FRUIT_IMGSRC). The fruit can therefore be represented in XML as shown below: <ITEM> The complete sample XML document with the data for all four fruit is available. Displaying the XML document in the browserXML support in web browsers is still fairly primitive. Netscape Communicator 4.5 (and earlier versions) have no integrated XML support. Microsoft was early to grasp the usefulness of XML - as you may have been aware, the "Channels" feature of Internet Explorer 4 uses XML in its Channel Definition Format (.cdf) files. Internet Explorer 4 and Internet Explorer 5 are supplied with a number of Data Source Objects that can be used to bind data to a web page (in a process known as databinding). It so happens that one of these Data Source Objects is a Java Applet that can be used to display XML within the browser. This Applet will be demonstrated here, primarily because it is easy to use. If you want to find out more about this Java Applet, try the Site Builder Network. To insert this Applet into a web page being edited using FrontPage, use the Java Applet menu command accessible from the Advanced option of the FrontPage Editor Insert menu. When the Java Applet Properties window appears, type: com.ms.xml.dso.XMLDSO.class in the Applet Source field. Add an Applet Parameter with a name of url and a corresponding value of the name of your XML file (e.g. test.xml). Once you have done this, set both the Width and the Height of the Applet to zero (although if you make the Applet larger, say 200 wide and 100 high, the applet will display a status message in the Internet Explorer browser window). Finally, click on the Style button to display the Style window. In this window, enter an ID for this Java Applet (e.g. xmlApplet). Once you have inserted the Java Applet into your web page, you need to write some HTML in order to display the data. The usual method is to create a table. In this example, the three properties of each fruit will be displayed in columns, with a new row for each fruit. The HTML required to achieve this is shown below: < table border="2" width="100%" datasrc="#xmlApplet" cellpadding="5"><thead> <tr> <th>Name</th> <th>Description</th> <th>Picture</th> </tr> </thead> <tr> <td valign="top"><span datafld="FRUIT_NAME" dataformatas="HTML"></span></td> <td valign="top"><span datafld="FRUIT_DESCRIPTION" dataformatas="HTML"></span></td> <td valign="top"><img datafld="FRUIT_IMGSRC" dataformatas="TEXT"></td> </tr> </table> This is a standard table, with some important additions. Firstly, the opening TABLE tag has a DATASRC element which associates the table with the Java Applet Data Source Object (which was given an ID of xmlApplet). Next, the table header has column names for each of the three properties of the XML data. Finally, the main part of the table inserts rows for each of the fruit. Note that each cell in the row has a SPAN tag containing a DATAFLD element, which is associated with the appropriate element in the XML document. The DATAFORMATAS element is used by the Java Applet to determine whether the data should be converted to HTML, or inserted as plain text. The FRUIT_IMGSRC contains the URL of the image associated with the fruit, so unlike the FRUIT_NAME and FRUIT_DESCRIPTION has to be formatted as text. Once you have done all of this, you should have a web page that looks similar to this sample page. Needless to say, this page will only work in Internet Explorer 4.01 or Internet Explorer 5. Other sources of information about XML
Author: Brett
Burridge More articles about FrontPage |
| write for us | about us | advertise |
Copyright 1997, 1998 A Big Lime. All rights reserved.