Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
|
An XML Primer, 5 of 9
Like HTML, XML is a subset of SGML (Structured Generalized Markup Language), optimized for delivery over the web.
Unlike HTML, which tags elements in web pages for presentation by a browser, e.g. <bold>Oracle</bold>, XML tags elements as data, e.g. <company>Oracle</company>. For example, you can use XML to give context to words and values in web pages, identifying them as data instead of simple textual or numeric elements.
The following example is in HTML code. This is followed by the corresponding XML example. The examples show employee data:
<table> <tr><td>EMPNO</td><td>ENAME</td><td>JOB</td><td>SAL</td></tr> <tr><td>7654</td><td>MARTIN</td><td>SALESMAN</td><td>1250</td></tr> <tr><td>7788</td><td>SCOTT</td><td>ANALYST</td><td>3000</td></tr> </table>
In the XML code, note the addition of XML data tags and the nested structure of the elements.
<?xml version="1.0"?> <EMPLIST> <EMP> <EMPNO>7654</EMPNO> <ENAME>MARTIN</ENAME> <JOB>SALESMAN</JOB> <SAL>1250</SAL> </EMP> <EMP> <EMPNO>7788</EMPNO> <ENAME>SCOTT</ENAME> <JOB>ANALYST</JOB> <SAL>3000</SAL> </EMP> </EMPLIST>
Consider the following HTML that uses tags to present data in a row of a table. Is "Java Programming" the name of a book? A university course? A job skill? You cannot be sure by looking at the data and tags on the page. Imagine a computer program trying to figure this out!
<HTML> <BODY> <TABLE> <TR> <TD>Java Programming</TD> <TD>EECS</TD> <TD>Paul Thompson</TD> <TD>Ron<BR>Uma<BR>Lindsay</TD> </TR> </TABLE> </BODY> </HTML>
The analogous XML example has the same data, but the tags indicate what information the data represents, not how it should be displayed. It's clear that "Java Programming" is the Name of a Course, but it says nothing about how it should be displayed.
<?xml version="1.0"?> <Course> <Name>Java Programming</Name> <Department>EECS</Department> <Teacher> <Name>Paul Thompson</Name> </Teacher> <Student> <Name>Ron</Name> </Student> <Student> <Name>Uma</Name> </Student> <Student> <Name>Lindsay</Name> </Student> </Course>
XML and HTML both represent information:
Figure 24-2 summarizes, how XML differs from HTML.
|
Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|