We have dealt with some basic XML concepts already, so now we are prepared to leap forward and take a closer look at this powerful language. The X in XML stands for eXtensible- in other words, the language can be extended to meet the requirements of a specific situation.
Now let us see an Example of XML Document to illustrate all that we are learnt so far in Part I and II emphasizing on Syntax Element (just numbered each line for easy explanation).
1.<?xml version = “1.0” encoding = “UTF-8”>
2.<!DOCTYPE addresslist SYSTEM
3.<!ENTITY oldlist System “oldaddresslist.xml>
7. <name> Adam Hall </name>
8. <address> 123 Green Street
9. <city> Pompano Beach </city>
10. <state> FL </state>
<zipcode> 12345 </zipcode>
Mary Joseph </name>
15. <address> 63 Belle Street </address>
Delray Beach </city>
17. <state> FL </state>
18. <zipcode> 12210 </zipcode>
Example 2.2: The file oldaddresslist.xml that is referenced as an external entity
on line 3 of example 2.1.
<?xml version = “1.0” encoding = “UTF-8”>
<address> 344 Main Street </address>
<city> Boca Raton
<state> FL </state>
<zipcode> 33445 </zipcode>
<address> 2345 Lake Street </address>
<state> FL </state>
The functions of tags in Example 2.1 are as follows:
Line 1: This is the processing instruction that informs XML processor that the file adheres to XML version 1.0 and that the file uses the character encoding known as UTF-8.
Line 2: This is the start of a multi line DOCTYPE. This type of tag is used for various purposes and often contains other tags. On this line tag specifies that the document is of type “addresslist” and that it follows the data model that is define in the DTD located in the file addresslist.dtd. In this case the name of the document type and the name of DTD are the same, but they need not be so. Note that the DTD file addresslist.dtd is not presented here, its name is used only to demonstrate the DOCTYPE tag.
Line 3: This is an ENTITY tag, which is contained within the DOCTYPE tag. It declares reference to an external file. Specifically, it defines the term “oldlist” to refer to the file oldaddresslist.xml.
Line 4: This marks the end of the DOCTYPE tag.
Line 5: This tags marks the beginning of the content portion of the document, of type “addresslist”. Note the name of this tag must be the same as the name specified in the DOCTYPE tag (line 2). This is the document’s root element.
Line 6: This tag marks the beginning of a unit of data called “employee”.
Line 7 through 11: These lines contains tags and datas that define the information belonging to the this “employee” unit.
Line 12: This tag marks the end of the “employee” unit of data.
Line 13 through 19: The data and data on these lines define a second “employee” unit of data.
Line 20: This line references the “oldlist” entity that was declared in line 3. It is marked as an entity referenced by the leading (&) and the ending semicolon (;). The effect of this line will be pretty much the same as if the content of the file oldaddresslist.xml were cut and pasted into the document at this location.
Line 21: This final tag marks the end of the “addresslist” document.
Hope this part of the tutorial had provided an overview of the “XML World”. XML is deceptively simple in principle, but it is this very simplicity that is the root of its tremendous power and flexibility for representing structured data. In the next part we will deal elaborately on Data Modeling in DTDs and later move up to Data Modeling in XDR Schemas.